bgfx/3rdparty/glsl-optimizer/tests/fragment/complex-prepasslight-irES.txt
Branimir Karadzic dee3fe5266 Initial commit.
2012-04-03 20:30:07 -07:00

529 lines
11 KiB
Text

struct v2f {
highp vec4 pos;
highp vec4 uv;
highp vec3 ray;
};
varying highp vec3 xlv_TEXCOORD1;
varying highp vec4 xlv_TEXCOORD0;
uniform highp vec4 unity_LightmapFade;
uniform highp vec4 _ZBufferParams;
uniform highp vec3 _WorldSpaceCameraPos;
uniform samplerCube _ShadowMapTexture;
uniform highp vec4 _ProjectionParams;
uniform sampler2D _LightTextureB0;
uniform samplerCube _LightTexture0;
uniform highp vec4 _LightShadowData;
uniform highp vec4 _LightPositionRange;
uniform highp vec4 _LightPos;
uniform highp mat4 _LightMatrix0;
uniform highp vec4 _LightColor;
uniform highp mat4 _CameraToWorld;
uniform sampler2D _CameraNormalsTexture;
uniform sampler2D _CameraDepthTexture;
float xll_saturate (
in float x
)
{
float tmpvar_1;
tmpvar_1 = clamp (x, 0.0, 1.0);
return tmpvar_1;
}
vec2 xll_saturate (
in vec2 x
)
{
vec2 tmpvar_1;
tmpvar_1 = clamp (x, 0.0, 1.0);
return tmpvar_1;
}
vec3 xll_saturate (
in vec3 x
)
{
vec3 tmpvar_1;
tmpvar_1 = clamp (x, 0.0, 1.0);
return tmpvar_1;
}
vec4 xll_saturate (
in vec4 x
)
{
vec4 tmpvar_1;
tmpvar_1 = clamp (x, 0.0, 1.0);
return tmpvar_1;
}
mat2 xll_saturate (
in mat2 m
)
{
vec2 tmpvar_1;
tmpvar_1 = clamp (m[0], 0.0, 1.0);
vec2 tmpvar_2;
tmpvar_2 = clamp (m[1], 0.0, 1.0);
mat2 tmpvar_3;
vec2 tmpvar_4;
tmpvar_4 = tmpvar_1;
tmpvar_3[0] = tmpvar_4;
vec2 tmpvar_5;
tmpvar_5 = tmpvar_2;
tmpvar_3[1] = tmpvar_5;
return tmpvar_3;
}
mat3 xll_saturate (
in mat3 m
)
{
vec3 tmpvar_1;
tmpvar_1 = clamp (m[0], 0.0, 1.0);
vec3 tmpvar_2;
tmpvar_2 = clamp (m[1], 0.0, 1.0);
vec3 tmpvar_3;
tmpvar_3 = clamp (m[2], 0.0, 1.0);
mat3 tmpvar_4;
vec3 tmpvar_5;
tmpvar_5 = tmpvar_1;
tmpvar_4[0] = tmpvar_5;
vec3 tmpvar_6;
tmpvar_6 = tmpvar_2;
tmpvar_4[1] = tmpvar_6;
vec3 tmpvar_7;
tmpvar_7 = tmpvar_3;
tmpvar_4[2] = tmpvar_7;
return tmpvar_4;
}
mat4 xll_saturate (
in mat4 m
)
{
vec4 tmpvar_1;
tmpvar_1 = clamp (m[0], 0.0, 1.0);
vec4 tmpvar_2;
tmpvar_2 = clamp (m[1], 0.0, 1.0);
vec4 tmpvar_3;
tmpvar_3 = clamp (m[2], 0.0, 1.0);
vec4 tmpvar_4;
tmpvar_4 = clamp (m[3], 0.0, 1.0);
mat4 tmpvar_5;
vec4 tmpvar_6;
tmpvar_6 = tmpvar_1;
tmpvar_5[0] = tmpvar_6;
vec4 tmpvar_7;
tmpvar_7 = tmpvar_2;
tmpvar_5[1] = tmpvar_7;
vec4 tmpvar_8;
tmpvar_8 = tmpvar_3;
tmpvar_5[2] = tmpvar_8;
vec4 tmpvar_9;
tmpvar_9 = tmpvar_4;
tmpvar_5[3] = tmpvar_9;
return tmpvar_5;
}
vec2 xll_vecTSel (
in bvec2 a,
in vec2 b,
in vec2 c
)
{
float tmpvar_1;
if (a.x) {
tmpvar_1 = b.x;
} else {
tmpvar_1 = c.x;
};
float tmpvar_2;
if (a.y) {
tmpvar_2 = b.y;
} else {
tmpvar_2 = c.y;
};
vec2 tmpvar_3;
tmpvar_3.x = tmpvar_1;
tmpvar_3.y = tmpvar_2;
return tmpvar_3;
}
vec3 xll_vecTSel (
in bvec3 a,
in vec3 b,
in vec3 c
)
{
float tmpvar_1;
if (a.x) {
tmpvar_1 = b.x;
} else {
tmpvar_1 = c.x;
};
float tmpvar_2;
if (a.y) {
tmpvar_2 = b.y;
} else {
tmpvar_2 = c.y;
};
float tmpvar_3;
if (a.z) {
tmpvar_3 = b.z;
} else {
tmpvar_3 = c.z;
};
vec3 tmpvar_4;
tmpvar_4.x = tmpvar_1;
tmpvar_4.y = tmpvar_2;
tmpvar_4.z = tmpvar_3;
return tmpvar_4;
}
vec4 xll_vecTSel (
in bvec4 a,
in vec4 b,
in vec4 c
)
{
float tmpvar_1;
if (a.x) {
tmpvar_1 = b.x;
} else {
tmpvar_1 = c.x;
};
float tmpvar_2;
if (a.y) {
tmpvar_2 = b.y;
} else {
tmpvar_2 = c.y;
};
float tmpvar_3;
if (a.z) {
tmpvar_3 = b.z;
} else {
tmpvar_3 = c.z;
};
float tmpvar_4;
if (a.w) {
tmpvar_4 = b.w;
} else {
tmpvar_4 = c.w;
};
vec4 tmpvar_5;
tmpvar_5.x = tmpvar_1;
tmpvar_5.y = tmpvar_2;
tmpvar_5.z = tmpvar_3;
tmpvar_5.w = tmpvar_4;
return tmpvar_5;
}
mediump float Luminance (
in mediump vec3 c
)
{
mediump float tmpvar_1;
tmpvar_1 = dot (c, vec3(0.22, 0.707, 0.071));
return tmpvar_1;
}
float Linear01Depth (
in highp float z
)
{
return (1.0 / ((_ZBufferParams.x * z) + _ZBufferParams.y));
}
float DecodeFloatRGBA (
in highp vec4 enc
)
{
highp vec4 kDecodeDot;
vec4 tmpvar_1;
tmpvar_1 = vec4(1.0, 0.00392157, 1.53787e-05, 0.0);
kDecodeDot = tmpvar_1;
highp float tmpvar_2;
tmpvar_2 = dot (enc, kDecodeDot);
return tmpvar_2;
}
float SampleCubeDistance (
in highp vec3 vec
)
{
highp vec4 packDist;
lowp vec4 tmpvar_1;
tmpvar_1 = textureCube (_ShadowMapTexture, vec);
lowp vec4 tmpvar_2;
tmpvar_2 = tmpvar_1;
packDist = tmpvar_2;
highp float tmpvar_3;
tmpvar_3 = DecodeFloatRGBA (packDist);
return tmpvar_3;
}
mediump float unitySampleShadow (
in highp vec3 vec,
in highp float mydist
)
{
mediump vec4 shadows;
highp vec4 shadowVals;
highp float z;
float tmpvar_1;
tmpvar_1 = 0.0078125;
z = tmpvar_1;
highp vec3 tmpvar_2;
tmpvar_2.x = z;
tmpvar_2.y = z;
tmpvar_2.z = z;
highp float tmpvar_3;
tmpvar_3 = SampleCubeDistance ((vec + tmpvar_2));
highp float tmpvar_4;
tmpvar_4 = tmpvar_3;
shadowVals.x = tmpvar_4;
highp vec3 tmpvar_5;
tmpvar_5.x = -(z);
tmpvar_5.y = -(z);
tmpvar_5.z = z;
highp float tmpvar_6;
tmpvar_6 = SampleCubeDistance ((vec + tmpvar_5));
highp float tmpvar_7;
tmpvar_7 = tmpvar_6;
shadowVals.y = vec2(tmpvar_7).y;
highp vec3 tmpvar_8;
tmpvar_8.x = -(z);
tmpvar_8.y = z;
tmpvar_8.z = -(z);
highp float tmpvar_9;
tmpvar_9 = SampleCubeDistance ((vec + tmpvar_8));
highp float tmpvar_10;
tmpvar_10 = tmpvar_9;
shadowVals.z = vec3(tmpvar_10).z;
highp vec3 tmpvar_11;
tmpvar_11.x = z;
tmpvar_11.y = -(z);
tmpvar_11.z = -(z);
highp float tmpvar_12;
tmpvar_12 = SampleCubeDistance ((vec + tmpvar_11));
highp float tmpvar_13;
tmpvar_13 = tmpvar_12;
shadowVals.w = vec4(tmpvar_13).w;
highp vec4 tmpvar_14;
tmpvar_14 = vec4(mydist);
highp vec4 tmpvar_15;
tmpvar_15 = tmpvar_14.xyzw;
bvec4 tmpvar_16;
tmpvar_16 = lessThan (shadowVals, tmpvar_15);
highp vec4 tmpvar_17;
tmpvar_17 = _LightShadowData.xxxx.xyzw;
vec4 tmpvar_18;
tmpvar_18 = xll_vecTSel (tmpvar_16, tmpvar_17, vec4(1.0, 1.0, 1.0, 1.0));
vec4 tmpvar_19;
tmpvar_19 = tmpvar_18;
shadows = tmpvar_19;
mediump float tmpvar_20;
tmpvar_20 = dot (shadows, vec4(0.25, 0.25, 0.25, 0.25));
return tmpvar_20;
}
mediump float ComputeShadow (
in highp vec3 vec,
in highp float z,
in highp vec2 uv
)
{
highp float mydist;
highp float fade;
highp float tmpvar_1;
tmpvar_1 = ((z * _LightShadowData.z) + _LightShadowData.w);
fade = tmpvar_1;
float tmpvar_2;
tmpvar_2 = xll_saturate (fade);
float tmpvar_3;
tmpvar_3 = tmpvar_2;
fade = tmpvar_3;
highp float tmpvar_4;
tmpvar_4 = length (vec);
highp float tmpvar_5;
tmpvar_5 = (tmpvar_4 * _LightPositionRange.w);
mydist = tmpvar_5;
highp float tmpvar_6;
tmpvar_6 = (mydist * 0.97);
mydist = tmpvar_6;
mediump float tmpvar_7;
tmpvar_7 = unitySampleShadow (vec, mydist);
return tmpvar_7;
return 1.0;
}
mediump vec4 xlat_main (
in v2f i
)
{
highp float fade;
mediump vec4 res;
highp float spec;
mediump vec3 h;
mediump float diff;
highp float atten;
highp float att;
mediump vec3 lightDir;
highp vec3 tolight;
highp vec3 wpos;
highp vec4 vpos;
highp float depth;
mediump vec3 normal;
mediump vec4 nspec;
highp vec2 uv;
highp vec3 tmpvar_1;
tmpvar_1 = (i.ray * (_ProjectionParams.z / i.ray.z));
i.ray = tmpvar_1;
highp vec2 tmpvar_2;
tmpvar_2 = (i.uv.xy / i.uv.w);
uv = tmpvar_2;
lowp vec4 tmpvar_3;
tmpvar_3 = texture2D (_CameraNormalsTexture, uv);
lowp vec4 tmpvar_4;
tmpvar_4 = tmpvar_3;
nspec = tmpvar_4;
mediump vec3 tmpvar_5;
tmpvar_5 = ((nspec.xyz * 2.0) - 1.0);
normal = tmpvar_5;
mediump vec3 tmpvar_6;
tmpvar_6 = normalize (normal);
mediump vec3 tmpvar_7;
tmpvar_7 = tmpvar_6;
normal = tmpvar_7;
lowp vec4 tmpvar_8;
tmpvar_8 = texture2D (_CameraDepthTexture, uv);
lowp float tmpvar_9;
tmpvar_9 = tmpvar_8.x;
depth = tmpvar_9;
highp float tmpvar_10;
tmpvar_10 = Linear01Depth (depth);
highp float tmpvar_11;
tmpvar_11 = tmpvar_10;
depth = tmpvar_11;
highp vec4 tmpvar_12;
tmpvar_12.w = 1.0;
tmpvar_12.xyz = (i.ray * depth).xyz;
highp vec4 tmpvar_13;
tmpvar_13 = tmpvar_12;
vpos = tmpvar_13;
highp vec3 tmpvar_14;
tmpvar_14 = (_CameraToWorld * vpos).xyz;
wpos = tmpvar_14;
highp vec3 tmpvar_15;
tmpvar_15 = (wpos - _LightPos.xyz);
tolight = tmpvar_15;
highp vec3 tmpvar_16;
tmpvar_16 = normalize (tolight);
highp vec3 tmpvar_17;
tmpvar_17 = -(tmpvar_16);
lightDir = tmpvar_17;
highp float tmpvar_18;
tmpvar_18 = dot (tolight, tolight);
highp float tmpvar_19;
tmpvar_19 = (tmpvar_18 * _LightPos.w);
att = tmpvar_19;
highp vec2 tmpvar_20;
tmpvar_20 = vec2(att);
highp vec2 tmpvar_21;
tmpvar_21 = tmpvar_20.xy;
lowp vec4 tmpvar_22;
tmpvar_22 = texture2D (_LightTextureB0, tmpvar_21);
lowp float tmpvar_23;
tmpvar_23 = tmpvar_22.w;
atten = tmpvar_23;
mediump float tmpvar_24;
tmpvar_24 = ComputeShadow (tolight, vpos.z, uv);
highp float tmpvar_25;
tmpvar_25 = (atten * tmpvar_24);
atten = tmpvar_25;
highp vec4 tmpvar_26;
tmpvar_26.w = 1.0;
tmpvar_26.xyz = wpos.xyz;
lowp vec4 tmpvar_27;
tmpvar_27 = textureCube (_LightTexture0, (_LightMatrix0 * tmpvar_26).xyz);
highp float tmpvar_28;
tmpvar_28 = (atten * tmpvar_27.w);
atten = tmpvar_28;
mediump float tmpvar_29;
tmpvar_29 = dot (lightDir, normal);
mediump float tmpvar_30;
tmpvar_30 = max (0.0, tmpvar_29);
mediump float tmpvar_31;
tmpvar_31 = tmpvar_30;
diff = tmpvar_31;
highp vec3 tmpvar_32;
tmpvar_32 = normalize ((wpos - _WorldSpaceCameraPos));
highp vec3 tmpvar_33;
tmpvar_33 = normalize ((lightDir - tmpvar_32));
highp vec3 tmpvar_34;
tmpvar_34 = tmpvar_33;
h = tmpvar_34;
mediump float tmpvar_35;
tmpvar_35 = dot (h, normal);
mediump float tmpvar_36;
tmpvar_36 = max (0.0, tmpvar_35);
mediump float tmpvar_37;
tmpvar_37 = pow (tmpvar_36, (nspec.w * 128.0));
mediump float tmpvar_38;
tmpvar_38 = tmpvar_37;
spec = tmpvar_38;
float tmpvar_39;
tmpvar_39 = xll_saturate (atten);
highp float tmpvar_40;
tmpvar_40 = (spec * tmpvar_39);
spec = tmpvar_40;
highp vec3 tmpvar_41;
tmpvar_41 = (_LightColor.xyz * (diff * atten));
res.xyz = tmpvar_41.xyz.xyz;
mediump float tmpvar_42;
tmpvar_42 = Luminance (_LightColor.xyz);
highp float tmpvar_43;
tmpvar_43 = (spec * tmpvar_42);
res.w = vec4(tmpvar_43).w;
highp float tmpvar_44;
tmpvar_44 = ((vpos.z * unity_LightmapFade.z) + unity_LightmapFade.w);
fade = tmpvar_44;
float tmpvar_45;
tmpvar_45 = xll_saturate ((1.0 - fade));
mediump vec4 tmpvar_46;
tmpvar_46 = (res * tmpvar_45);
res = tmpvar_46;
mediump vec4 tmpvar_47;
tmpvar_47 = exp2 (-(res));
return tmpvar_47;
}
void main ()
{
v2f xlt_i;
mediump vec4 xl_retval;
vec4 tmpvar_1;
tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0);
xlt_i.pos = tmpvar_1;
highp vec4 tmpvar_2;
tmpvar_2 = xlv_TEXCOORD0.xyzw;
highp vec4 tmpvar_3;
tmpvar_3 = tmpvar_2;
xlt_i.uv = tmpvar_3;
highp vec3 tmpvar_4;
tmpvar_4 = xlv_TEXCOORD1.xyz;
highp vec3 tmpvar_5;
tmpvar_5 = tmpvar_4;
xlt_i.ray = tmpvar_5;
mediump vec4 tmpvar_6;
tmpvar_6 = xlat_main (xlt_i);
mediump vec4 tmpvar_7;
tmpvar_7 = tmpvar_6;
xl_retval = tmpvar_7;
mediump vec4 tmpvar_8;
tmpvar_8 = xl_retval.xyzw;
mediump vec4 tmpvar_9;
tmpvar_9 = tmpvar_8;
gl_FragData[0] = tmpvar_9;
}