bgfx/3rdparty/glsl-optimizer/tests/fragment/z-treeleaf-irES.txt
2014-02-10 23:06:13 -08:00

381 lines
9.1 KiB
Text

struct LeafSurfaceOutput {
mediump vec3 Albedo;
mediump vec3 Normal;
mediump vec3 Emission;
mediump float Translucency;
mediump float ShadowOffset;
mediump float Specular;
mediump float Gloss;
mediump float Alpha;
};
struct Input {
highp vec2 uv_MainTex;
highp vec4 color;
};
struct v2f_surf {
highp vec4 pos;
highp vec2 hip_pack0;
highp vec4 lop_color;
highp vec3 lightDir;
highp vec3 viewDir;
highp vec2 _LightCoord;
};
uniform sampler2D _BumpSpecMap;
uniform highp vec4 _Color;
uniform highp float _Cutoff;
uniform highp vec4 _LightColor0;
uniform sampler2D _LightTexture0;
uniform sampler2D _MainTex;
uniform mediump float _ShadowStrength;
uniform mediump vec3 _TranslucencyColor;
uniform sampler2D _TranslucencyMap;
uniform mediump float _TranslucencyViewDependency;
varying highp vec2 xlv_TEXCOORD0;
varying highp vec4 xlv_COLOR0;
varying highp vec3 xlv_TEXCOORD1;
varying highp vec3 xlv_TEXCOORD2;
varying highp vec2 xlv_TEXCOORD3;
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;
}
mediump vec4 UnpackNormal (
in mediump vec4 packednormal_34
)
{
mediump vec4 normal_35;
mediump vec2 tmpvar_36;
tmpvar_36 = ((packednormal_34.wy * 2.0) - 1.0);
normal_35.xy = tmpvar_36.xy.xy;
mediump float tmpvar_37;
tmpvar_37 = sqrt (((1.0 - (normal_35.x * normal_35.x)) - (normal_35.y * normal_35.y)));
mediump 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
)
{
mediump vec4 norspc_41;
mediump vec4 trngls_42;
mediump vec4 c_43;
lowp vec4 tmpvar_44;
tmpvar_44 = texture2D (_MainTex, IN_39.uv_MainTex);
lowp vec4 tmpvar_45;
tmpvar_45 = tmpvar_44;
c_43 = tmpvar_45;
highp vec3 tmpvar_46;
tmpvar_46 = ((c_43.xyz * _Color.xyz) * IN_39.color.w);
o_40.Albedo = tmpvar_46;
lowp vec4 tmpvar_47;
tmpvar_47 = texture2D (_TranslucencyMap, IN_39.uv_MainTex);
lowp vec4 tmpvar_48;
tmpvar_48 = tmpvar_47;
trngls_42 = tmpvar_48;
mediump float tmpvar_49;
tmpvar_49 = trngls_42.z;
o_40.Translucency = tmpvar_49;
highp float tmpvar_50;
tmpvar_50 = (trngls_42.w * _Color.x);
o_40.Gloss = tmpvar_50;
mediump float tmpvar_51;
tmpvar_51 = c_43.w;
o_40.Alpha = tmpvar_51;
lowp vec4 tmpvar_52;
tmpvar_52 = texture2D (_BumpSpecMap, IN_39.uv_MainTex);
lowp vec4 tmpvar_53;
tmpvar_53 = tmpvar_52;
norspc_41 = tmpvar_53;
mediump float tmpvar_54;
tmpvar_54 = norspc_41.x;
o_40.Specular = tmpvar_54;
mediump float tmpvar_55;
tmpvar_55 = norspc_41.z;
o_40.ShadowOffset = tmpvar_55;
mediump vec4 tmpvar_56;
tmpvar_56 = UnpackNormal (norspc_41);
mediump vec3 tmpvar_57;
tmpvar_57 = tmpvar_56.xyz;
mediump vec3 tmpvar_58;
tmpvar_58 = tmpvar_57;
o_40.Normal = tmpvar_58;
}
mediump vec4 LightingTreeLeaf (
in LeafSurfaceOutput s_59,
in mediump vec3 lightDir_60,
in mediump vec3 viewDir_61,
in mediump float atten_62
)
{
mediump vec4 c_63;
mediump vec3 translucencyColor_64;
mediump float backContrib_65;
mediump float spec_66;
mediump float nh_67;
mediump float nl_68;
mediump vec3 h_69;
mediump vec3 tmpvar_70;
tmpvar_70 = normalize ((lightDir_60 + viewDir_61));
mediump vec3 tmpvar_71;
tmpvar_71 = tmpvar_70;
h_69 = tmpvar_71;
mediump float tmpvar_72;
tmpvar_72 = dot (s_59.Normal, lightDir_60);
mediump float tmpvar_73;
tmpvar_73 = tmpvar_72;
nl_68 = tmpvar_73;
mediump float tmpvar_74;
tmpvar_74 = dot (s_59.Normal, h_69);
mediump float tmpvar_75;
tmpvar_75 = max (0.0, tmpvar_74);
mediump float tmpvar_76;
tmpvar_76 = tmpvar_75;
nh_67 = tmpvar_76;
mediump float tmpvar_77;
tmpvar_77 = pow (nh_67, (s_59.Specular * 128.0));
mediump float tmpvar_78;
tmpvar_78 = (tmpvar_77 * s_59.Gloss);
spec_66 = tmpvar_78;
mediump float tmpvar_79;
tmpvar_79 = dot (viewDir_61, -(lightDir_60));
float tmpvar_80;
tmpvar_80 = xll_saturate (tmpvar_79);
float tmpvar_81;
tmpvar_81 = tmpvar_80;
backContrib_65 = tmpvar_81;
float tmpvar_82;
tmpvar_82 = xll_saturate (-(nl_68));
mediump float tmpvar_83;
tmpvar_83 = mix (tmpvar_82, backContrib_65, _TranslucencyViewDependency);
mediump float tmpvar_84;
tmpvar_84 = tmpvar_83;
backContrib_65 = tmpvar_84;
mediump vec3 tmpvar_85;
tmpvar_85 = ((backContrib_65 * s_59.Translucency) * _TranslucencyColor);
translucencyColor_64 = tmpvar_85;
mediump float tmpvar_86;
tmpvar_86 = max (0.0, ((nl_68 * 0.6) + 0.4));
mediump float tmpvar_87;
tmpvar_87 = tmpvar_86;
nl_68 = tmpvar_87;
mediump vec3 tmpvar_88;
tmpvar_88 = (s_59.Albedo * ((translucencyColor_64 * 2.0) + nl_68));
c_63.xyz = tmpvar_88.xyz.xyz;
highp vec3 tmpvar_89;
tmpvar_89 = ((c_63.xyz * _LightColor0.xyz) + spec_66);
c_63.xyz = tmpvar_89.xyz.xyz;
mediump float tmpvar_90;
tmpvar_90 = mix (2.0, (atten_62 * 2.0), _ShadowStrength);
mediump vec3 tmpvar_91;
tmpvar_91 = (c_63.xyz * tmpvar_90);
c_63.xyz = tmpvar_91.xyz.xyz;
return c_63;
}
mediump vec4 xlat_main (
in v2f_surf IN_92
)
{
mediump vec4 c_93;
mediump vec3 lightDir_94;
LeafSurfaceOutput o_95;
Input surfIN_96;
highp vec2 tmpvar_97;
tmpvar_97 = IN_92.hip_pack0.xy;
surfIN_96.uv_MainTex = tmpvar_97;
highp vec4 tmpvar_98;
tmpvar_98 = IN_92.lop_color;
surfIN_96.color = tmpvar_98;
vec3 tmpvar_99;
tmpvar_99 = vec3(0.0, 0.0, 0.0);
o_95.Albedo = tmpvar_99;
vec3 tmpvar_100;
tmpvar_100 = vec3(0.0, 0.0, 0.0);
o_95.Emission = tmpvar_100;
float tmpvar_101;
tmpvar_101 = 0.0;
o_95.Specular = tmpvar_101;
float tmpvar_102;
tmpvar_102 = 0.0;
o_95.Alpha = tmpvar_102;
surf (surfIN_96, o_95);
xll_clip ((o_95.Alpha - _Cutoff));
highp vec3 tmpvar_103;
tmpvar_103 = IN_92.lightDir;
lightDir_94 = tmpvar_103;
highp vec3 tmpvar_104;
tmpvar_104 = IN_92.viewDir.xyz;
highp vec3 tmpvar_105;
tmpvar_105 = normalize (tmpvar_104);
lowp vec4 tmpvar_106;
tmpvar_106 = texture2D (_LightTexture0, IN_92._LightCoord);
mediump vec4 tmpvar_107;
tmpvar_107 = LightingTreeLeaf (o_95, lightDir_94, tmpvar_105, (tmpvar_106.w * 1.0));
mediump vec4 tmpvar_108;
tmpvar_108 = tmpvar_107;
c_93 = tmpvar_108;
mediump float tmpvar_109;
tmpvar_109 = o_95.Alpha;
c_93.w = vec4(tmpvar_109).w;
return c_93;
}
void main ()
{
v2f_surf xlt_IN_110;
mediump vec4 xl_retval_111;
vec4 tmpvar_112;
tmpvar_112 = vec4(0.0, 0.0, 0.0, 0.0);
xlt_IN_110.pos = tmpvar_112;
highp vec2 tmpvar_113;
tmpvar_113 = xlv_TEXCOORD0.xy;
highp vec2 tmpvar_114;
tmpvar_114 = tmpvar_113;
xlt_IN_110.hip_pack0 = tmpvar_114;
highp vec4 tmpvar_115;
tmpvar_115 = xlv_COLOR0.xyzw;
highp vec4 tmpvar_116;
tmpvar_116 = tmpvar_115;
xlt_IN_110.lop_color = tmpvar_116;
highp vec3 tmpvar_117;
tmpvar_117 = xlv_TEXCOORD1.xyz;
highp vec3 tmpvar_118;
tmpvar_118 = tmpvar_117;
xlt_IN_110.lightDir = tmpvar_118;
highp vec3 tmpvar_119;
tmpvar_119 = xlv_TEXCOORD2.xyz;
highp vec3 tmpvar_120;
tmpvar_120 = tmpvar_119;
xlt_IN_110.viewDir = tmpvar_120;
highp vec2 tmpvar_121;
tmpvar_121 = xlv_TEXCOORD3.xy;
highp vec2 tmpvar_122;
tmpvar_122 = tmpvar_121;
xlt_IN_110._LightCoord = tmpvar_122;
mediump vec4 tmpvar_123;
tmpvar_123 = xlat_main (xlt_IN_110);
mediump vec4 tmpvar_124;
tmpvar_124 = tmpvar_123;
xl_retval_111 = tmpvar_124;
mediump vec4 tmpvar_125;
tmpvar_125 = xl_retval_111.xyzw;
mediump vec4 tmpvar_126;
tmpvar_126 = tmpvar_125;
gl_FragData[0] = tmpvar_126;
}