bgfx/3rdparty/glsl-optimizer/tests/fragment/zun-Hidden_Internal-PrePassLighting-ir.txt
2014-02-10 23:06:13 -08:00

408 lines
8.8 KiB
Text

struct v2f {
vec4 pos;
vec4 uv;
vec3 ray;
};
uniform sampler2D _CameraDepthTexture;
uniform sampler2D _CameraNormalsTexture;
uniform vec4 _LightColor;
uniform vec4 _LightPos;
uniform vec4 _LightPositionRange;
uniform vec4 _LightShadowData;
uniform samplerCube _LightTexture0;
uniform sampler2D _LightTextureB0;
uniform vec4 _ProjectionParams;
uniform samplerCube _ShadowMapTexture;
uniform mat4 _View2Shadow;
uniform mat4 _ViewToCookie;
uniform vec4 _ZBufferParams;
uniform vec4 unity_LightmapFade;
float xll_saturate (
in float x_1
)
{
float tmpvar_2;
tmpvar_2 = clamp (x_1, 0.0, 1.0);
return tmpvar_2;
}
vec2 xll_saturate (
in vec2 x_3
)
{
vec2 tmpvar_4;
tmpvar_4 = clamp (x_3, 0.0, 1.0);
return tmpvar_4;
}
vec3 xll_saturate (
in vec3 x_5
)
{
vec3 tmpvar_6;
tmpvar_6 = clamp (x_5, 0.0, 1.0);
return tmpvar_6;
}
vec4 xll_saturate (
in vec4 x_7
)
{
vec4 tmpvar_8;
tmpvar_8 = clamp (x_7, 0.0, 1.0);
return tmpvar_8;
}
mat2 xll_saturate (
in mat2 m_9
)
{
vec2 tmpvar_10;
tmpvar_10 = clamp (m_9[0], 0.0, 1.0);
vec2 tmpvar_11;
tmpvar_11 = clamp (m_9[1], 0.0, 1.0);
mat2 tmpvar_12;
vec2 tmpvar_13;
tmpvar_13 = tmpvar_10;
tmpvar_12[0] = tmpvar_13;
vec2 tmpvar_14;
tmpvar_14 = tmpvar_11;
tmpvar_12[1] = tmpvar_14;
return tmpvar_12;
}
mat3 xll_saturate (
in mat3 m_15
)
{
vec3 tmpvar_16;
tmpvar_16 = clamp (m_15[0], 0.0, 1.0);
vec3 tmpvar_17;
tmpvar_17 = clamp (m_15[1], 0.0, 1.0);
vec3 tmpvar_18;
tmpvar_18 = clamp (m_15[2], 0.0, 1.0);
mat3 tmpvar_19;
vec3 tmpvar_20;
tmpvar_20 = tmpvar_16;
tmpvar_19[0] = tmpvar_20;
vec3 tmpvar_21;
tmpvar_21 = tmpvar_17;
tmpvar_19[1] = tmpvar_21;
vec3 tmpvar_22;
tmpvar_22 = tmpvar_18;
tmpvar_19[2] = tmpvar_22;
return tmpvar_19;
}
mat4 xll_saturate (
in mat4 m_23
)
{
vec4 tmpvar_24;
tmpvar_24 = clamp (m_23[0], 0.0, 1.0);
vec4 tmpvar_25;
tmpvar_25 = clamp (m_23[1], 0.0, 1.0);
vec4 tmpvar_26;
tmpvar_26 = clamp (m_23[2], 0.0, 1.0);
vec4 tmpvar_27;
tmpvar_27 = clamp (m_23[3], 0.0, 1.0);
mat4 tmpvar_28;
vec4 tmpvar_29;
tmpvar_29 = tmpvar_24;
tmpvar_28[0] = tmpvar_29;
vec4 tmpvar_30;
tmpvar_30 = tmpvar_25;
tmpvar_28[1] = tmpvar_30;
vec4 tmpvar_31;
tmpvar_31 = tmpvar_26;
tmpvar_28[2] = tmpvar_31;
vec4 tmpvar_32;
tmpvar_32 = tmpvar_27;
tmpvar_28[3] = tmpvar_32;
return tmpvar_28;
}
mat3 xll_constructMat3 (
in mat4 m_33
)
{
vec3 tmpvar_34;
tmpvar_34 = m_33[0].xyz;
vec3 tmpvar_35;
tmpvar_35 = m_33[1].xyz;
vec3 tmpvar_36;
tmpvar_36 = m_33[2].xyz;
mat3 tmpvar_37;
vec3 tmpvar_38;
tmpvar_38 = tmpvar_34;
tmpvar_37[0] = tmpvar_38;
vec3 tmpvar_39;
tmpvar_39 = tmpvar_35;
tmpvar_37[1] = tmpvar_39;
vec3 tmpvar_40;
tmpvar_40 = tmpvar_36;
tmpvar_37[2] = tmpvar_40;
return tmpvar_37;
}
float Luminance (
in vec3 c_41
)
{
float tmpvar_42;
tmpvar_42 = dot (c_41, vec3(0.22, 0.707, 0.071));
return tmpvar_42;
}
float Linear01Depth (
in float z_43
)
{
return (1.0 / ((_ZBufferParams.x * z_43) + _ZBufferParams.y));
}
float DecodeFloatRGBA (
in vec4 enc_44
)
{
vec4 kDecodeDot_45;
vec4 tmpvar_46;
tmpvar_46 = vec4(1.0, 0.00392157, 1.53787e-05, 6.22737e-09);
kDecodeDot_45 = tmpvar_46;
float tmpvar_47;
tmpvar_47 = dot (enc_44, kDecodeDot_45);
return tmpvar_47;
}
float SampleCubeDistance (
in vec3 vec_48
)
{
vec4 packDist_49;
vec4 tmpvar_50;
tmpvar_50 = textureCube (_ShadowMapTexture, vec_48);
vec4 tmpvar_51;
tmpvar_51 = tmpvar_50;
packDist_49 = tmpvar_51;
float tmpvar_52;
tmpvar_52 = DecodeFloatRGBA (packDist_49);
return tmpvar_52;
}
float unitySampleShadow (
in vec3 vec_53,
in float mydist_54
)
{
float dist_55;
float tmpvar_56;
tmpvar_56 = SampleCubeDistance (vec_53);
float tmpvar_57;
tmpvar_57 = tmpvar_56;
dist_55 = tmpvar_57;
float tmpvar_58;
if ((dist_55 < mydist_54)) {
tmpvar_58 = _LightShadowData.x;
} else {
tmpvar_58 = 1.0;
};
return tmpvar_58;
}
float ComputeShadow (
in vec3 vec_59,
in vec2 uv_60
)
{
float mydist_61;
float fade_62;
float tmpvar_63;
tmpvar_63 = ((vec_59.z * _LightShadowData.z) + _LightShadowData.w);
fade_62 = tmpvar_63;
float tmpvar_64;
tmpvar_64 = xll_saturate (fade_62);
float tmpvar_65;
tmpvar_65 = tmpvar_64;
fade_62 = tmpvar_65;
mat3 tmpvar_66;
tmpvar_66 = xll_constructMat3 (_View2Shadow);
vec3 tmpvar_67;
tmpvar_67 = (tmpvar_66 * vec_59);
vec_59 = tmpvar_67;
float tmpvar_68;
tmpvar_68 = length (vec_59);
float tmpvar_69;
tmpvar_69 = (tmpvar_68 * _LightPositionRange.w);
mydist_61 = tmpvar_69;
float tmpvar_70;
tmpvar_70 = (mydist_61 * 0.97);
mydist_61 = tmpvar_70;
float tmpvar_71;
tmpvar_71 = unitySampleShadow (vec_59, mydist_61);
return tmpvar_71;
return 1.0;
}
vec4 frag (
in v2f i_72
)
{
float fade_73;
vec4 res_74;
float spec_75;
vec3 h_76;
float diff_77;
float atten_78;
float att_79;
vec3 lightDir_80;
vec3 tolight_81;
vec3 vpos_82;
float depth_83;
vec3 normal_84;
vec4 nspec_85;
vec2 uv_86;
vec3 tmpvar_87;
tmpvar_87 = (i_72.ray * (_ProjectionParams.z / i_72.ray.z));
i_72.ray = tmpvar_87;
vec2 tmpvar_88;
tmpvar_88 = (i_72.uv.xy / i_72.uv.w);
uv_86 = tmpvar_88;
vec4 tmpvar_89;
tmpvar_89 = texture2D (_CameraNormalsTexture, uv_86);
vec4 tmpvar_90;
tmpvar_90 = tmpvar_89;
nspec_85 = tmpvar_90;
vec3 tmpvar_91;
tmpvar_91 = ((nspec_85.xyz * 2.0) - 1.0);
normal_84 = tmpvar_91;
vec3 tmpvar_92;
tmpvar_92 = normalize (normal_84);
vec3 tmpvar_93;
tmpvar_93 = tmpvar_92;
normal_84 = tmpvar_93;
vec4 tmpvar_94;
tmpvar_94 = texture2D (_CameraDepthTexture, uv_86);
float tmpvar_95;
tmpvar_95 = tmpvar_94.x;
depth_83 = tmpvar_95;
float tmpvar_96;
tmpvar_96 = Linear01Depth (depth_83);
float tmpvar_97;
tmpvar_97 = tmpvar_96;
depth_83 = tmpvar_97;
vec3 tmpvar_98;
tmpvar_98 = (i_72.ray * depth_83);
vpos_82 = tmpvar_98;
vec3 tmpvar_99;
tmpvar_99 = (_LightPos.xyz - vpos_82);
tolight_81 = tmpvar_99;
vec3 tmpvar_100;
tmpvar_100 = normalize (tolight_81);
vec3 tmpvar_101;
tmpvar_101 = tmpvar_100;
lightDir_80 = tmpvar_101;
float tmpvar_102;
tmpvar_102 = dot (tolight_81, tolight_81);
float tmpvar_103;
tmpvar_103 = (tmpvar_102 * _LightPos.w);
att_79 = tmpvar_103;
vec2 tmpvar_104;
tmpvar_104 = vec2(att_79);
vec2 tmpvar_105;
tmpvar_105 = tmpvar_104.xy;
vec4 tmpvar_106;
tmpvar_106 = texture2D (_LightTextureB0, tmpvar_105);
float tmpvar_107;
tmpvar_107 = tmpvar_106.w;
atten_78 = tmpvar_107;
float tmpvar_108;
tmpvar_108 = ComputeShadow (-(tolight_81), uv_86);
float tmpvar_109;
tmpvar_109 = (atten_78 * tmpvar_108);
atten_78 = tmpvar_109;
vec4 tmpvar_110;
tmpvar_110.w = 1.0;
tmpvar_110.xyz = vpos_82.xyz;
vec4 tmpvar_111;
tmpvar_111 = textureCube (_LightTexture0, (_ViewToCookie * tmpvar_110).xyz);
float tmpvar_112;
tmpvar_112 = (atten_78 * tmpvar_111.w);
atten_78 = tmpvar_112;
float tmpvar_113;
tmpvar_113 = dot (lightDir_80, normal_84);
float tmpvar_114;
tmpvar_114 = max (0.0, tmpvar_113);
float tmpvar_115;
tmpvar_115 = tmpvar_114;
diff_77 = tmpvar_115;
vec3 tmpvar_116;
tmpvar_116 = normalize (vpos_82);
vec3 tmpvar_117;
tmpvar_117 = normalize ((lightDir_80 - tmpvar_116));
vec3 tmpvar_118;
tmpvar_118 = tmpvar_117;
h_76 = tmpvar_118;
float tmpvar_119;
tmpvar_119 = dot (h_76, normal_84);
float tmpvar_120;
tmpvar_120 = max (0.0, tmpvar_119);
float tmpvar_121;
tmpvar_121 = pow (tmpvar_120, (nspec_85.w * 128.0));
float tmpvar_122;
tmpvar_122 = tmpvar_121;
spec_75 = tmpvar_122;
float tmpvar_123;
tmpvar_123 = xll_saturate (atten_78);
float tmpvar_124;
tmpvar_124 = (spec_75 * tmpvar_123);
spec_75 = tmpvar_124;
vec3 tmpvar_125;
tmpvar_125 = (_LightColor.xyz * (diff_77 * atten_78));
res_74.xyz = tmpvar_125.xyz.xyz;
float tmpvar_126;
tmpvar_126 = Luminance (_LightColor.xyz);
float tmpvar_127;
tmpvar_127 = (spec_75 * tmpvar_126);
res_74.w = vec4(tmpvar_127).w;
float tmpvar_128;
tmpvar_128 = ((vpos_82.z * unity_LightmapFade.z) + unity_LightmapFade.w);
fade_73 = tmpvar_128;
float tmpvar_129;
tmpvar_129 = xll_saturate ((1.0 - fade_73));
vec4 tmpvar_130;
tmpvar_130 = (res_74 * tmpvar_129);
res_74 = tmpvar_130;
vec4 tmpvar_131;
tmpvar_131 = exp2 (-(res_74));
return tmpvar_131;
}
void main ()
{
v2f xlt_i_132;
vec4 xl_retval_133;
vec4 tmpvar_134;
tmpvar_134 = vec4(0.0, 0.0, 0.0, 0.0);
xlt_i_132.pos = tmpvar_134;
vec4 tmpvar_135;
tmpvar_135 = gl_TexCoord[0].xyzw;
vec4 tmpvar_136;
tmpvar_136 = tmpvar_135;
xlt_i_132.uv = tmpvar_136;
vec3 tmpvar_137;
tmpvar_137 = gl_TexCoord[1].xyz;
vec3 tmpvar_138;
tmpvar_138 = tmpvar_137;
xlt_i_132.ray = tmpvar_138;
vec4 tmpvar_139;
tmpvar_139 = frag (xlt_i_132);
vec4 tmpvar_140;
tmpvar_140 = tmpvar_139;
xl_retval_133 = tmpvar_140;
vec4 tmpvar_141;
tmpvar_141 = xl_retval_133.xyzw;
vec4 tmpvar_142;
tmpvar_142 = tmpvar_141;
gl_FragData[0] = tmpvar_142;
}