tests: various for loop variants
This commit is contained in:
Родитель
72d6c6c301
Коммит
85e2c1bc25
|
@ -0,0 +1,74 @@
|
|||
float4 unity_LightColor[4];
|
||||
float4 unity_LightPosition[4];
|
||||
float4 unity_LightAtten[4];
|
||||
|
||||
float4x4 UNITY_MATRIX_MVP;
|
||||
float4x4 UNITY_MATRIX_MV;
|
||||
float4x4 UNITY_MATRIX_IT_MV;
|
||||
|
||||
struct appdata {
|
||||
float4 vertex : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
};
|
||||
|
||||
struct v2f {
|
||||
half4 pos : POSITION;
|
||||
half4 color : TEXCOORD0;
|
||||
};
|
||||
|
||||
float3 ShadeMyVertexLights (float4 vertex, float3 normal)
|
||||
{
|
||||
float3 viewpos = mul(UNITY_MATRIX_MV, vertex).xyz;
|
||||
float3 viewN = mul((float3x3) UNITY_MATRIX_IT_MV, normal);
|
||||
float3 lightColor = float3(0.0,0.0,0.0);
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
float3 toLight = unity_LightPosition[i].xyz - viewpos.xyz;
|
||||
float lengthSq = dot(toLight, toLight);
|
||||
float atten = 1.0 / (1.0 + lengthSq * unity_LightAtten[i].z);
|
||||
float diff = max (0, dot (viewN, normalize(toLight)));
|
||||
lightColor += unity_LightColor[i].rgb * (diff * atten);
|
||||
}
|
||||
return (lightColor * 2.0);
|
||||
}
|
||||
|
||||
v2f main (appdata v)
|
||||
{
|
||||
v2f o;
|
||||
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
|
||||
o.color = 0;
|
||||
|
||||
for (int i = 0; i < 2; ++i)
|
||||
o.color += unity_LightColor[i];
|
||||
|
||||
// same variable
|
||||
for (int i = 0; i < 4; ++i)
|
||||
o.color += unity_LightColor[i];
|
||||
|
||||
// different start/end conditions
|
||||
for (int j = 3; j >= 0; j = j-1)
|
||||
o.color += unity_LightColor[j];
|
||||
|
||||
// scope variables
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
float4 l = unity_LightColor[i] * unity_LightAtten[i].x;
|
||||
o.color += l;
|
||||
}
|
||||
|
||||
// scope variables again
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
float4 l = unity_LightColor[i] * unity_LightAtten[i].z;
|
||||
o.color += l;
|
||||
}
|
||||
|
||||
// weird loop construct
|
||||
int k = 1;
|
||||
for (; k < 3; )
|
||||
{
|
||||
o.color += unity_LightColor[k].x;
|
||||
int z = k + 1;
|
||||
k = z;
|
||||
}
|
||||
|
||||
return o;
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
|
||||
#line 14
|
||||
struct v2f {
|
||||
vec4 pos;
|
||||
vec4 color;
|
||||
};
|
||||
#line 9
|
||||
struct appdata {
|
||||
vec4 vertex;
|
||||
vec3 normal;
|
||||
};
|
||||
uniform mat4 UNITY_MATRIX_MVP;
|
||||
uniform vec4 unity_LightAtten[4];
|
||||
uniform vec4 unity_LightColor[4];
|
||||
v2f xlat_main( in appdata v );
|
||||
#line 35
|
||||
v2f xlat_main( in appdata v ) {
|
||||
v2f o;
|
||||
int i = 0;
|
||||
int i_1 = 0;
|
||||
int j = 3;
|
||||
int i_2 = 0;
|
||||
vec4 l;
|
||||
int i_3 = 0;
|
||||
vec4 l_1;
|
||||
int k = 1;
|
||||
int z;
|
||||
#line 38
|
||||
o.pos = (UNITY_MATRIX_MVP * v.vertex);
|
||||
o.color = vec4( 0.00000);
|
||||
for ( ; (i < 2); (++i)) {
|
||||
o.color += unity_LightColor[i];
|
||||
}
|
||||
#line 45
|
||||
for ( ; (i_1 < 4); (++i_1)) {
|
||||
o.color += unity_LightColor[i_1];
|
||||
}
|
||||
#line 49
|
||||
for ( ; (j >= 0); j = (j - 1)) {
|
||||
o.color += unity_LightColor[j];
|
||||
}
|
||||
#line 53
|
||||
for ( ; (i_2 < 2); (++i_2)) {
|
||||
l = (unity_LightColor[i_2] * unity_LightAtten[i_2].x);
|
||||
o.color += l;
|
||||
}
|
||||
#line 59
|
||||
for ( ; (i_3 < 2); (++i_3)) {
|
||||
l_1 = (unity_LightColor[i_3] * unity_LightAtten[i_3].z);
|
||||
o.color += l_1;
|
||||
}
|
||||
#line 65
|
||||
while ( (k < 3) ) {
|
||||
o.color += unity_LightColor[k].x;
|
||||
#line 69
|
||||
z = (k + 1);
|
||||
k = z;
|
||||
}
|
||||
#line 73
|
||||
return o;
|
||||
}
|
||||
varying vec4 xlv_TEXCOORD0;
|
||||
void main() {
|
||||
v2f xl_retval;
|
||||
appdata xlt_v;
|
||||
xlt_v.vertex = vec4( gl_Vertex);
|
||||
xlt_v.normal = vec3( gl_Normal);
|
||||
xl_retval = xlat_main( xlt_v);
|
||||
gl_Position = vec4( xl_retval.pos);
|
||||
xlv_TEXCOORD0 = vec4( xl_retval.color);
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
|
||||
#line 14
|
||||
struct v2f {
|
||||
mediump vec4 pos;
|
||||
mediump vec4 color;
|
||||
};
|
||||
#line 9
|
||||
struct appdata {
|
||||
highp vec4 vertex;
|
||||
highp vec3 normal;
|
||||
};
|
||||
uniform highp mat4 UNITY_MATRIX_MVP;
|
||||
uniform highp vec4 unity_LightAtten[4];
|
||||
uniform highp vec4 unity_LightColor[4];
|
||||
v2f xlat_main( in appdata v );
|
||||
#line 35
|
||||
v2f xlat_main( in appdata v ) {
|
||||
v2f o;
|
||||
highp int i = 0;
|
||||
highp int i_1 = 0;
|
||||
highp int j = 3;
|
||||
highp int i_2 = 0;
|
||||
highp vec4 l;
|
||||
highp int i_3 = 0;
|
||||
highp vec4 l_1;
|
||||
highp int k = 1;
|
||||
highp int z;
|
||||
#line 38
|
||||
o.pos = (UNITY_MATRIX_MVP * v.vertex);
|
||||
o.color = vec4( 0.00000);
|
||||
for ( ; (i < 2); (++i)) {
|
||||
o.color += unity_LightColor[i];
|
||||
}
|
||||
#line 45
|
||||
for ( ; (i_1 < 4); (++i_1)) {
|
||||
o.color += unity_LightColor[i_1];
|
||||
}
|
||||
#line 49
|
||||
for ( ; (j >= 0); j = (j - 1)) {
|
||||
o.color += unity_LightColor[j];
|
||||
}
|
||||
#line 53
|
||||
for ( ; (i_2 < 2); (++i_2)) {
|
||||
l = (unity_LightColor[i_2] * unity_LightAtten[i_2].x);
|
||||
o.color += l;
|
||||
}
|
||||
#line 59
|
||||
for ( ; (i_3 < 2); (++i_3)) {
|
||||
l_1 = (unity_LightColor[i_3] * unity_LightAtten[i_3].z);
|
||||
o.color += l_1;
|
||||
}
|
||||
#line 65
|
||||
while ( (k < 3) ) {
|
||||
o.color += unity_LightColor[k].x;
|
||||
#line 69
|
||||
z = (k + 1);
|
||||
k = z;
|
||||
}
|
||||
#line 73
|
||||
return o;
|
||||
}
|
||||
varying mediump vec4 xlv_TEXCOORD0;
|
||||
void main() {
|
||||
v2f xl_retval;
|
||||
appdata xlt_v;
|
||||
xlt_v.vertex = vec4( gl_Vertex);
|
||||
xlt_v.normal = vec3( gl_Normal);
|
||||
xl_retval = xlat_main( xlt_v);
|
||||
gl_Position = vec4( xl_retval.pos);
|
||||
xlv_TEXCOORD0 = vec4( xl_retval.color);
|
||||
}
|
Загрузка…
Ссылка в новой задаче