bgfx/3rdparty/glsl-optimizer/tests/fragment/zun-Parallax_Specular-ir.txt

293 lines
6.7 KiB
Text
Raw Normal View History

2012-10-07 23:41:18 -04:00
struct SurfaceOutput {
vec3 Albedo;
vec3 Normal;
vec3 Emission;
float Specular;
float Gloss;
float Alpha;
};
struct Input {
vec2 uv_MainTex;
vec2 uv_BumpMap;
vec3 viewDir;
};
struct v2f_surf {
vec4 pos;
float fog;
vec4 hip_pack0;
vec3 viewDir;
vec3 lightDir;
vec4 _LightCoord;
};
varying vec4 xlv_FOG;
uniform vec4 _SpecColor;
uniform float _Shininess;
uniform sampler2D _ParallaxMap;
uniform float _Parallax;
uniform sampler2D _MainTex;
uniform sampler2D _LightTextureB0;
uniform sampler2D _LightTexture0;
uniform vec4 _LightColor0;
uniform vec4 _Color;
uniform sampler2D _BumpMap;
vec4 UnpackNormal (
in vec4 packednormal_1
)
{
vec4 normal_2;
vec2 tmpvar_3;
tmpvar_3 = ((packednormal_1.wy * 2.0) - 1.0);
normal_2.xy = tmpvar_3.xy.xy;
float tmpvar_4;
tmpvar_4 = sqrt (((1.0 - (normal_2.x * normal_2.x)) - (normal_2.y * normal_2.y)));
float tmpvar_5;
tmpvar_5 = tmpvar_4;
normal_2.z = vec3(tmpvar_5).z;
return normal_2;
}
vec2 ParallaxOffset (
in float h_6,
in float height_7,
in vec3 viewDir_8
)
{
vec3 v_9;
float tmpvar_10;
tmpvar_10 = ((h_6 * height_7) - (height_7 / 2.0));
h_6 = tmpvar_10;
vec3 tmpvar_11;
tmpvar_11 = normalize (viewDir_8);
vec3 tmpvar_12;
tmpvar_12 = tmpvar_11;
v_9 = tmpvar_12;
float tmpvar_13;
tmpvar_13 = (v_9.z + 0.42);
v_9.z = vec3(tmpvar_13).z;
return (h_6 * (v_9.xy / v_9.z));
}
void surf (
in Input IN_14,
inout SurfaceOutput o_15
)
{
vec4 tex_16;
vec2 offset_17;
float h_18;
vec4 tmpvar_19;
tmpvar_19 = texture2D (_ParallaxMap, IN_14.uv_BumpMap);
float tmpvar_20;
tmpvar_20 = tmpvar_19.w;
h_18 = tmpvar_20;
vec2 tmpvar_21;
tmpvar_21 = ParallaxOffset (h_18, _Parallax, IN_14.viewDir);
vec2 tmpvar_22;
tmpvar_22 = tmpvar_21;
offset_17 = tmpvar_22;
vec2 tmpvar_23;
tmpvar_23 = (IN_14.uv_MainTex + offset_17);
IN_14.uv_MainTex = tmpvar_23;
vec2 tmpvar_24;
tmpvar_24 = (IN_14.uv_BumpMap + offset_17);
IN_14.uv_BumpMap = tmpvar_24;
vec4 tmpvar_25;
tmpvar_25 = texture2D (_MainTex, IN_14.uv_MainTex);
vec4 tmpvar_26;
tmpvar_26 = tmpvar_25;
tex_16 = tmpvar_26;
vec3 tmpvar_27;
tmpvar_27 = (tex_16.xyz * _Color.xyz);
o_15.Albedo = tmpvar_27;
float tmpvar_28;
tmpvar_28 = tex_16.w;
o_15.Gloss = tmpvar_28;
float tmpvar_29;
tmpvar_29 = (tex_16.w * _Color.w);
o_15.Alpha = tmpvar_29;
float tmpvar_30;
tmpvar_30 = _Shininess;
o_15.Specular = tmpvar_30;
vec4 tmpvar_31;
tmpvar_31 = texture2D (_BumpMap, IN_14.uv_BumpMap);
vec4 tmpvar_32;
tmpvar_32 = UnpackNormal (tmpvar_31);
vec3 tmpvar_33;
tmpvar_33 = tmpvar_32.xyz;
vec3 tmpvar_34;
tmpvar_34 = tmpvar_33;
o_15.Normal = tmpvar_34;
}
float UnitySpotCookie (
in vec4 LightCoord_35
)
{
vec4 tmpvar_36;
tmpvar_36 = texture2D (_LightTexture0, ((LightCoord_35.xy / LightCoord_35.w) + 0.5));
return tmpvar_36.w;
}
float UnitySpotAttenuate (
in vec3 LightCoord_37
)
{
float tmpvar_38;
tmpvar_38 = dot (LightCoord_37, LightCoord_37);
vec2 tmpvar_39;
tmpvar_39 = vec2(tmpvar_38);
vec2 tmpvar_40;
tmpvar_40 = tmpvar_39.xy;
vec4 tmpvar_41;
tmpvar_41 = texture2D (_LightTextureB0, tmpvar_40);
return tmpvar_41.w;
}
vec4 LightingBlinnPhong (
in SurfaceOutput s_42,
in vec3 lightDir_43,
in vec3 viewDir_44,
in float atten_45
)
{
vec4 c_46;
float spec_47;
float nh_48;
float diff_49;
vec3 h_50;
vec3 tmpvar_51;
tmpvar_51 = normalize ((lightDir_43 + viewDir_44));
vec3 tmpvar_52;
tmpvar_52 = tmpvar_51;
h_50 = tmpvar_52;
float tmpvar_53;
tmpvar_53 = dot (s_42.Normal, lightDir_43);
float tmpvar_54;
tmpvar_54 = max (0.0, tmpvar_53);
float tmpvar_55;
tmpvar_55 = tmpvar_54;
diff_49 = tmpvar_55;
float tmpvar_56;
tmpvar_56 = dot (s_42.Normal, h_50);
float tmpvar_57;
tmpvar_57 = max (0.0, tmpvar_56);
float tmpvar_58;
tmpvar_58 = tmpvar_57;
nh_48 = tmpvar_58;
float tmpvar_59;
tmpvar_59 = pow (nh_48, (s_42.Specular * 128.0));
float tmpvar_60;
tmpvar_60 = (tmpvar_59 * s_42.Gloss);
spec_47 = tmpvar_60;
vec3 tmpvar_61;
tmpvar_61 = ((((s_42.Albedo * _LightColor0.xyz) * diff_49) + ((_LightColor0.xyz * _SpecColor.xyz) * spec_47)) * (atten_45 * 2.0));
c_46.xyz = tmpvar_61.xyz.xyz;
float tmpvar_62;
tmpvar_62 = (s_42.Alpha + (((_LightColor0.w * _SpecColor.w) * spec_47) * atten_45));
c_46.w = vec4(tmpvar_62).w;
return c_46;
}
vec4 frag_surf (
in v2f_surf IN_63
)
{
vec4 c_64;
vec3 lightDir_65;
SurfaceOutput o_66;
Input surfIN_67;
vec2 tmpvar_68;
tmpvar_68 = IN_63.hip_pack0.xy;
surfIN_67.uv_MainTex = tmpvar_68;
vec2 tmpvar_69;
tmpvar_69 = IN_63.hip_pack0.zw;
surfIN_67.uv_BumpMap = tmpvar_69;
vec3 tmpvar_70;
tmpvar_70 = IN_63.viewDir;
surfIN_67.viewDir = tmpvar_70;
vec3 tmpvar_71;
tmpvar_71 = vec3(0.0, 0.0, 0.0);
o_66.Albedo = tmpvar_71;
vec3 tmpvar_72;
tmpvar_72 = vec3(0.0, 0.0, 0.0);
o_66.Emission = tmpvar_72;
float tmpvar_73;
tmpvar_73 = 0.0;
o_66.Specular = tmpvar_73;
float tmpvar_74;
tmpvar_74 = 0.0;
o_66.Alpha = tmpvar_74;
float tmpvar_75;
tmpvar_75 = 0.0;
o_66.Gloss = tmpvar_75;
surf (surfIN_67, o_66);
vec3 tmpvar_76;
tmpvar_76 = IN_63.lightDir;
lightDir_65 = tmpvar_76;
vec3 tmpvar_77;
tmpvar_77 = normalize (lightDir_65);
vec3 tmpvar_78;
tmpvar_78 = tmpvar_77;
lightDir_65 = tmpvar_78;
vec3 tmpvar_79;
tmpvar_79 = IN_63.viewDir.xyz;
vec3 tmpvar_80;
tmpvar_80 = normalize (tmpvar_79);
float tmpvar_81;
tmpvar_81 = UnitySpotCookie (IN_63._LightCoord);
float tmpvar_82;
tmpvar_82 = UnitySpotAttenuate (IN_63._LightCoord.xyz);
vec4 tmpvar_83;
tmpvar_83 = LightingBlinnPhong (o_66, lightDir_65, tmpvar_80, ((float((IN_63._LightCoord.z > 0.0)) * tmpvar_81) * tmpvar_82));
vec4 tmpvar_84;
tmpvar_84 = tmpvar_83;
c_64 = tmpvar_84;
float tmpvar_85;
tmpvar_85 = 0.0;
c_64.w = vec4(tmpvar_85).w;
return c_64;
}
void main ()
{
v2f_surf xlt_IN_86;
vec4 xl_retval_87;
vec4 tmpvar_88;
tmpvar_88 = vec4(0.0, 0.0, 0.0, 0.0);
xlt_IN_86.pos = tmpvar_88;
float tmpvar_89;
tmpvar_89 = xlv_FOG.x;
xlt_IN_86.fog = tmpvar_89;
vec4 tmpvar_90;
tmpvar_90 = gl_TexCoord[0].xyzw;
vec4 tmpvar_91;
tmpvar_91 = tmpvar_90;
xlt_IN_86.hip_pack0 = tmpvar_91;
vec3 tmpvar_92;
tmpvar_92 = gl_TexCoord[1].xyz;
vec3 tmpvar_93;
tmpvar_93 = tmpvar_92;
xlt_IN_86.viewDir = tmpvar_93;
vec3 tmpvar_94;
tmpvar_94 = gl_TexCoord[2].xyz;
vec3 tmpvar_95;
tmpvar_95 = tmpvar_94;
xlt_IN_86.lightDir = tmpvar_95;
vec4 tmpvar_96;
tmpvar_96 = gl_TexCoord[3].xyzw;
vec4 tmpvar_97;
tmpvar_97 = tmpvar_96;
xlt_IN_86._LightCoord = tmpvar_97;
vec4 tmpvar_98;
tmpvar_98 = frag_surf (xlt_IN_86);
vec4 tmpvar_99;
tmpvar_99 = tmpvar_98;
xl_retval_87 = tmpvar_99;
vec4 tmpvar_100;
tmpvar_100 = xl_retval_87.xyzw;
vec4 tmpvar_101;
tmpvar_101 = tmpvar_100;
gl_FragData[0] = tmpvar_101;
}