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

384 lines
8.3 KiB
Text

struct LeafSurfaceOutput {
vec3 Albedo;
vec3 Normal;
vec3 Emission;
vec3 Translucency;
float Specular;
float Gloss;
float Alpha;
};
struct Input {
vec2 uv_MainTex;
vec4 color;
};
struct v2f_surf {
vec4 pos;
float fog;
vec2 hip_pack0;
vec4 lop_color;
vec3 lightDir;
vec3 viewDir;
vec3 _LightCoord;
};
uniform sampler2D _BumpSpecMap;
uniform float _Cutoff;
uniform vec4 _LightColor0;
uniform samplerCube _LightTexture0;
uniform sampler2D _LightTextureB0;
uniform sampler2D _MainTex;
uniform sampler2D _TranslucencyMap;
varying vec4 xlv_FOG;
void xll_clip (
in float x_1
)
{
if ((x_1 < 0.0)) {
discard;
};
}
float xll_saturate (
in float x_2
)
{
float tmpvar_3;
tmpvar_3 = clamp (x_2, 0.0, 1.0);
return tmpvar_3;
}
vec2 xll_saturate (
in vec2 x_4
)
{
vec2 tmpvar_5;
tmpvar_5 = clamp (x_4, 0.0, 1.0);
return tmpvar_5;
}
vec3 xll_saturate (
in vec3 x_6
)
{
vec3 tmpvar_7;
tmpvar_7 = clamp (x_6, 0.0, 1.0);
return tmpvar_7;
}
vec4 xll_saturate (
in vec4 x_8
)
{
vec4 tmpvar_9;
tmpvar_9 = clamp (x_8, 0.0, 1.0);
return tmpvar_9;
}
mat2 xll_saturate (
in mat2 m_10
)
{
vec2 tmpvar_11;
tmpvar_11 = clamp (m_10[0], 0.0, 1.0);
vec2 tmpvar_12;
tmpvar_12 = clamp (m_10[1], 0.0, 1.0);
mat2 tmpvar_13;
vec2 tmpvar_14;
tmpvar_14 = tmpvar_11;
tmpvar_13[0] = tmpvar_14;
vec2 tmpvar_15;
tmpvar_15 = tmpvar_12;
tmpvar_13[1] = tmpvar_15;
return tmpvar_13;
}
mat3 xll_saturate (
in mat3 m_16
)
{
vec3 tmpvar_17;
tmpvar_17 = clamp (m_16[0], 0.0, 1.0);
vec3 tmpvar_18;
tmpvar_18 = clamp (m_16[1], 0.0, 1.0);
vec3 tmpvar_19;
tmpvar_19 = clamp (m_16[2], 0.0, 1.0);
mat3 tmpvar_20;
vec3 tmpvar_21;
tmpvar_21 = tmpvar_17;
tmpvar_20[0] = tmpvar_21;
vec3 tmpvar_22;
tmpvar_22 = tmpvar_18;
tmpvar_20[1] = tmpvar_22;
vec3 tmpvar_23;
tmpvar_23 = tmpvar_19;
tmpvar_20[2] = tmpvar_23;
return tmpvar_20;
}
mat4 xll_saturate (
in mat4 m_24
)
{
vec4 tmpvar_25;
tmpvar_25 = clamp (m_24[0], 0.0, 1.0);
vec4 tmpvar_26;
tmpvar_26 = clamp (m_24[1], 0.0, 1.0);
vec4 tmpvar_27;
tmpvar_27 = clamp (m_24[2], 0.0, 1.0);
vec4 tmpvar_28;
tmpvar_28 = clamp (m_24[3], 0.0, 1.0);
mat4 tmpvar_29;
vec4 tmpvar_30;
tmpvar_30 = tmpvar_25;
tmpvar_29[0] = tmpvar_30;
vec4 tmpvar_31;
tmpvar_31 = tmpvar_26;
tmpvar_29[1] = tmpvar_31;
vec4 tmpvar_32;
tmpvar_32 = tmpvar_27;
tmpvar_29[2] = tmpvar_32;
vec4 tmpvar_33;
tmpvar_33 = tmpvar_28;
tmpvar_29[3] = tmpvar_33;
return tmpvar_29;
}
vec4 UnpackNormal (
in vec4 packednormal_34
)
{
vec4 normal_35;
vec2 tmpvar_36;
tmpvar_36 = ((packednormal_34.wy * 2.0) - 1.0);
normal_35.xy = tmpvar_36.xy.xy;
float tmpvar_37;
tmpvar_37 = sqrt (((1.0 - (normal_35.x * normal_35.x)) - (normal_35.y * normal_35.y)));
float tmpvar_38;
tmpvar_38 = tmpvar_37;
normal_35.z = vec3(tmpvar_38).z;
return normal_35;
}
void surf (
in Input IN_39,
inout LeafSurfaceOutput o_40
)
{
vec4 norspc_41;
vec4 trngls_42;
vec4 c_43;
vec4 tmpvar_44;
tmpvar_44 = texture2D (_MainTex, IN_39.uv_MainTex);
vec4 tmpvar_45;
tmpvar_45 = tmpvar_44;
c_43 = tmpvar_45;
vec3 tmpvar_46;
tmpvar_46 = (c_43.xyz * IN_39.color.xyz);
o_40.Albedo = tmpvar_46;
vec4 tmpvar_47;
tmpvar_47 = texture2D (_TranslucencyMap, IN_39.uv_MainTex);
vec4 tmpvar_48;
tmpvar_48 = tmpvar_47;
trngls_42 = tmpvar_48;
vec3 tmpvar_49;
tmpvar_49 = trngls_42.xyz;
o_40.Translucency = tmpvar_49;
float tmpvar_50;
tmpvar_50 = trngls_42.w;
o_40.Gloss = tmpvar_50;
float tmpvar_51;
tmpvar_51 = (c_43.w * IN_39.color.w);
o_40.Alpha = tmpvar_51;
vec4 tmpvar_52;
tmpvar_52 = texture2D (_BumpSpecMap, IN_39.uv_MainTex);
vec4 tmpvar_53;
tmpvar_53 = tmpvar_52;
norspc_41 = tmpvar_53;
float tmpvar_54;
tmpvar_54 = norspc_41.x;
o_40.Specular = tmpvar_54;
vec4 tmpvar_55;
tmpvar_55 = UnpackNormal (norspc_41);
vec3 tmpvar_56;
tmpvar_56 = tmpvar_55.xyz;
vec3 tmpvar_57;
tmpvar_57 = tmpvar_56;
o_40.Normal = tmpvar_57;
}
vec4 LightingTreeLeaf (
in LeafSurfaceOutput s_58,
in vec3 lightDir_59,
in vec3 viewDir_60,
in float atten_61
)
{
vec4 c_62;
vec3 col_63;
vec3 translucencyColor_64;
float trans_65;
float spec_66;
float nh_67;
float diff_68;
vec3 h_69;
vec3 tmpvar_70;
tmpvar_70 = normalize ((lightDir_59 + viewDir_60));
vec3 tmpvar_71;
tmpvar_71 = tmpvar_70;
h_69 = tmpvar_71;
float tmpvar_72;
tmpvar_72 = dot (s_58.Normal, lightDir_59);
float tmpvar_73;
tmpvar_73 = tmpvar_72;
diff_68 = tmpvar_73;
float tmpvar_74;
tmpvar_74 = dot (s_58.Normal, h_69);
float tmpvar_75;
tmpvar_75 = max (0.0, tmpvar_74);
float tmpvar_76;
tmpvar_76 = tmpvar_75;
nh_67 = tmpvar_76;
float tmpvar_77;
tmpvar_77 = pow (nh_67, (s_58.Specular * 128.0));
float tmpvar_78;
tmpvar_78 = (tmpvar_77 * s_58.Gloss);
spec_66 = tmpvar_78;
float tmpvar_79;
tmpvar_79 = max (0.0, -(diff_68));
float tmpvar_80;
tmpvar_80 = tmpvar_79;
trans_65 = tmpvar_80;
vec3 tmpvar_81;
tmpvar_81 = ((s_58.Translucency * trans_65) * 2.0);
translucencyColor_64 = tmpvar_81;
float tmpvar_82;
tmpvar_82 = max (0.0, ((diff_68 * 0.5) + 0.5));
float tmpvar_83;
tmpvar_83 = tmpvar_82;
diff_68 = tmpvar_83;
vec3 tmpvar_84;
tmpvar_84 = (s_58.Albedo * (diff_68 + translucencyColor_64));
col_63 = tmpvar_84;
float tmpvar_85;
tmpvar_85 = ceil (trans_65);
float tmpvar_86;
tmpvar_86 = xll_saturate (tmpvar_85);
vec3 tmpvar_87;
tmpvar_87 = (col_63 + (spec_66 * (1.0 - tmpvar_86)));
col_63 = tmpvar_87;
vec3 tmpvar_88;
tmpvar_88 = (col_63 * _LightColor0.xyz);
col_63 = tmpvar_88;
vec3 tmpvar_89;
tmpvar_89 = (col_63 * (atten_61 * 2.0));
c_62.xyz = tmpvar_89.xyz.xyz;
return c_62;
}
vec4 frag_surf (
in v2f_surf IN_90
)
{
vec4 c_91;
vec3 lightDir_92;
LeafSurfaceOutput o_93;
Input surfIN_94;
vec2 tmpvar_95;
tmpvar_95 = IN_90.hip_pack0.xy;
surfIN_94.uv_MainTex = tmpvar_95;
vec4 tmpvar_96;
tmpvar_96 = IN_90.lop_color;
surfIN_94.color = tmpvar_96;
vec3 tmpvar_97;
tmpvar_97 = vec3(0.0, 0.0, 0.0);
o_93.Albedo = tmpvar_97;
vec3 tmpvar_98;
tmpvar_98 = vec3(0.0, 0.0, 0.0);
o_93.Emission = tmpvar_98;
float tmpvar_99;
tmpvar_99 = 0.0;
o_93.Specular = tmpvar_99;
float tmpvar_100;
tmpvar_100 = 0.0;
o_93.Alpha = tmpvar_100;
surf (surfIN_94, o_93);
xll_clip ((o_93.Alpha - _Cutoff));
vec3 tmpvar_101;
tmpvar_101 = IN_90.lightDir;
lightDir_92 = tmpvar_101;
vec3 tmpvar_102;
tmpvar_102 = normalize (lightDir_92);
vec3 tmpvar_103;
tmpvar_103 = tmpvar_102;
lightDir_92 = tmpvar_103;
vec3 tmpvar_104;
tmpvar_104 = IN_90.viewDir.xyz;
vec3 tmpvar_105;
tmpvar_105 = normalize (tmpvar_104);
float tmpvar_106;
tmpvar_106 = dot (IN_90._LightCoord, IN_90._LightCoord);
vec2 tmpvar_107;
tmpvar_107 = vec2(tmpvar_106);
vec2 tmpvar_108;
tmpvar_108 = tmpvar_107.xy;
vec4 tmpvar_109;
tmpvar_109 = texture2D (_LightTextureB0, tmpvar_108);
vec4 tmpvar_110;
tmpvar_110 = textureCube (_LightTexture0, IN_90._LightCoord);
vec4 tmpvar_111;
tmpvar_111 = LightingTreeLeaf (o_93, lightDir_92, tmpvar_105, (tmpvar_109.w * tmpvar_110.w));
vec4 tmpvar_112;
tmpvar_112 = tmpvar_111;
c_91 = tmpvar_112;
float tmpvar_113;
tmpvar_113 = o_93.Alpha;
c_91.w = vec4(tmpvar_113).w;
return c_91;
}
void main ()
{
v2f_surf xlt_IN_114;
vec4 xl_retval_115;
vec4 tmpvar_116;
tmpvar_116 = vec4(0.0, 0.0, 0.0, 0.0);
xlt_IN_114.pos = tmpvar_116;
float tmpvar_117;
tmpvar_117 = xlv_FOG.x;
xlt_IN_114.fog = tmpvar_117;
vec2 tmpvar_118;
tmpvar_118 = gl_TexCoord[0].xy;
vec2 tmpvar_119;
tmpvar_119 = tmpvar_118;
xlt_IN_114.hip_pack0 = tmpvar_119;
vec4 tmpvar_120;
tmpvar_120 = gl_Color.xyzw;
vec4 tmpvar_121;
tmpvar_121 = tmpvar_120;
xlt_IN_114.lop_color = tmpvar_121;
vec3 tmpvar_122;
tmpvar_122 = gl_TexCoord[1].xyz;
vec3 tmpvar_123;
tmpvar_123 = tmpvar_122;
xlt_IN_114.lightDir = tmpvar_123;
vec3 tmpvar_124;
tmpvar_124 = gl_TexCoord[2].xyz;
vec3 tmpvar_125;
tmpvar_125 = tmpvar_124;
xlt_IN_114.viewDir = tmpvar_125;
vec3 tmpvar_126;
tmpvar_126 = gl_TexCoord[3].xyz;
vec3 tmpvar_127;
tmpvar_127 = tmpvar_126;
xlt_IN_114._LightCoord = tmpvar_127;
vec4 tmpvar_128;
tmpvar_128 = frag_surf (xlt_IN_114);
vec4 tmpvar_129;
tmpvar_129 = tmpvar_128;
xl_retval_115 = tmpvar_129;
vec4 tmpvar_130;
tmpvar_130 = xl_retval_115.xyzw;
vec4 tmpvar_131;
tmpvar_131 = tmpvar_130;
gl_FragData[0] = tmpvar_131;
}