mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-25 17:18:12 -05:00
291 lines
6.6 KiB
Text
291 lines
6.6 KiB
Text
struct SurfaceOutput {
|
|
vec3 Albedo;
|
|
vec3 Normal;
|
|
vec3 Emission;
|
|
float Specular;
|
|
float Gloss;
|
|
float Alpha;
|
|
};
|
|
struct Input {
|
|
vec2 uv_MainTex;
|
|
vec2 uv_BumpMap;
|
|
vec2 uv_Illum;
|
|
vec3 viewDir;
|
|
};
|
|
struct v2f_surf {
|
|
vec4 pos;
|
|
float fog;
|
|
vec4 hip_pack0;
|
|
vec3 viewDir;
|
|
vec3 lightDir;
|
|
vec3 _LightCoord;
|
|
};
|
|
uniform sampler2D _BumpMap;
|
|
uniform vec4 _Color;
|
|
uniform sampler2D _Illum;
|
|
uniform vec4 _LightColor0;
|
|
uniform sampler2D _LightTexture0;
|
|
uniform sampler2D _MainTex;
|
|
uniform float _Parallax;
|
|
uniform sampler2D _ParallaxMap;
|
|
uniform float _Shininess;
|
|
uniform vec4 _SpecColor;
|
|
varying vec4 xlv_FOG;
|
|
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 c_16;
|
|
vec4 tex_17;
|
|
vec2 offset_18;
|
|
float h_19;
|
|
vec4 tmpvar_20;
|
|
tmpvar_20 = texture2D (_ParallaxMap, IN_14.uv_BumpMap);
|
|
float tmpvar_21;
|
|
tmpvar_21 = tmpvar_20.w;
|
|
h_19 = tmpvar_21;
|
|
vec2 tmpvar_22;
|
|
tmpvar_22 = ParallaxOffset (h_19, _Parallax, IN_14.viewDir);
|
|
vec2 tmpvar_23;
|
|
tmpvar_23 = tmpvar_22;
|
|
offset_18 = tmpvar_23;
|
|
vec2 tmpvar_24;
|
|
tmpvar_24 = (IN_14.uv_MainTex + offset_18);
|
|
IN_14.uv_MainTex = tmpvar_24;
|
|
vec2 tmpvar_25;
|
|
tmpvar_25 = (IN_14.uv_BumpMap + offset_18);
|
|
IN_14.uv_BumpMap = tmpvar_25;
|
|
vec2 tmpvar_26;
|
|
tmpvar_26 = (IN_14.uv_Illum + offset_18);
|
|
IN_14.uv_Illum = tmpvar_26;
|
|
vec4 tmpvar_27;
|
|
tmpvar_27 = texture2D (_MainTex, IN_14.uv_MainTex);
|
|
vec4 tmpvar_28;
|
|
tmpvar_28 = tmpvar_27;
|
|
tex_17 = tmpvar_28;
|
|
vec4 tmpvar_29;
|
|
tmpvar_29 = (tex_17 * _Color);
|
|
c_16 = tmpvar_29;
|
|
vec3 tmpvar_30;
|
|
tmpvar_30 = c_16.xyz;
|
|
o_15.Albedo = tmpvar_30;
|
|
float tmpvar_31;
|
|
tmpvar_31 = tex_17.w;
|
|
o_15.Gloss = tmpvar_31;
|
|
vec4 tmpvar_32;
|
|
tmpvar_32 = texture2D (_Illum, IN_14.uv_Illum);
|
|
vec3 tmpvar_33;
|
|
tmpvar_33 = (c_16.xyz * tmpvar_32.w);
|
|
o_15.Emission = tmpvar_33;
|
|
float tmpvar_34;
|
|
tmpvar_34 = _Shininess;
|
|
o_15.Specular = tmpvar_34;
|
|
float tmpvar_35;
|
|
tmpvar_35 = c_16.w;
|
|
o_15.Alpha = tmpvar_35;
|
|
vec4 tmpvar_36;
|
|
tmpvar_36 = texture2D (_BumpMap, IN_14.uv_BumpMap);
|
|
vec4 tmpvar_37;
|
|
tmpvar_37 = UnpackNormal (tmpvar_36);
|
|
vec3 tmpvar_38;
|
|
tmpvar_38 = tmpvar_37.xyz;
|
|
vec3 tmpvar_39;
|
|
tmpvar_39 = tmpvar_38;
|
|
o_15.Normal = tmpvar_39;
|
|
}
|
|
|
|
vec4 LightingBlinnPhong (
|
|
in SurfaceOutput s_40,
|
|
in vec3 lightDir_41,
|
|
in vec3 viewDir_42,
|
|
in float atten_43
|
|
)
|
|
{
|
|
vec4 c_44;
|
|
float spec_45;
|
|
float nh_46;
|
|
float diff_47;
|
|
vec3 h_48;
|
|
vec3 tmpvar_49;
|
|
tmpvar_49 = normalize ((lightDir_41 + viewDir_42));
|
|
vec3 tmpvar_50;
|
|
tmpvar_50 = tmpvar_49;
|
|
h_48 = tmpvar_50;
|
|
float tmpvar_51;
|
|
tmpvar_51 = dot (s_40.Normal, lightDir_41);
|
|
float tmpvar_52;
|
|
tmpvar_52 = max (0.0, tmpvar_51);
|
|
float tmpvar_53;
|
|
tmpvar_53 = tmpvar_52;
|
|
diff_47 = tmpvar_53;
|
|
float tmpvar_54;
|
|
tmpvar_54 = dot (s_40.Normal, h_48);
|
|
float tmpvar_55;
|
|
tmpvar_55 = max (0.0, tmpvar_54);
|
|
float tmpvar_56;
|
|
tmpvar_56 = tmpvar_55;
|
|
nh_46 = tmpvar_56;
|
|
float tmpvar_57;
|
|
tmpvar_57 = pow (nh_46, (s_40.Specular * 128.0));
|
|
float tmpvar_58;
|
|
tmpvar_58 = (tmpvar_57 * s_40.Gloss);
|
|
spec_45 = tmpvar_58;
|
|
vec3 tmpvar_59;
|
|
tmpvar_59 = (((
|
|
(s_40.Albedo * _LightColor0.xyz)
|
|
* diff_47) + (
|
|
(_LightColor0.xyz * _SpecColor.xyz)
|
|
* spec_45)) * (atten_43 * 2.0));
|
|
c_44.xyz = tmpvar_59.xyz.xyz;
|
|
float tmpvar_60;
|
|
tmpvar_60 = (s_40.Alpha + ((
|
|
(_LightColor0.w * _SpecColor.w)
|
|
* spec_45) * atten_43));
|
|
c_44.w = vec4(tmpvar_60).w;
|
|
return c_44;
|
|
}
|
|
|
|
vec4 frag_surf (
|
|
in v2f_surf IN_61
|
|
)
|
|
{
|
|
vec4 c_62;
|
|
vec3 lightDir_63;
|
|
SurfaceOutput o_64;
|
|
Input surfIN_65;
|
|
vec2 tmpvar_66;
|
|
tmpvar_66 = IN_61.hip_pack0.xy;
|
|
surfIN_65.uv_MainTex = tmpvar_66;
|
|
vec2 tmpvar_67;
|
|
tmpvar_67 = IN_61.hip_pack0.zw;
|
|
surfIN_65.uv_BumpMap = tmpvar_67;
|
|
vec3 tmpvar_68;
|
|
tmpvar_68 = IN_61.viewDir;
|
|
surfIN_65.viewDir = tmpvar_68;
|
|
vec3 tmpvar_69;
|
|
tmpvar_69 = vec3(0.0, 0.0, 0.0);
|
|
o_64.Albedo = tmpvar_69;
|
|
vec3 tmpvar_70;
|
|
tmpvar_70 = vec3(0.0, 0.0, 0.0);
|
|
o_64.Emission = tmpvar_70;
|
|
float tmpvar_71;
|
|
tmpvar_71 = 0.0;
|
|
o_64.Specular = tmpvar_71;
|
|
float tmpvar_72;
|
|
tmpvar_72 = 0.0;
|
|
o_64.Alpha = tmpvar_72;
|
|
float tmpvar_73;
|
|
tmpvar_73 = 0.0;
|
|
o_64.Gloss = tmpvar_73;
|
|
surf (surfIN_65, o_64);
|
|
vec3 tmpvar_74;
|
|
tmpvar_74 = IN_61.lightDir;
|
|
lightDir_63 = tmpvar_74;
|
|
vec3 tmpvar_75;
|
|
tmpvar_75 = normalize (lightDir_63);
|
|
vec3 tmpvar_76;
|
|
tmpvar_76 = tmpvar_75;
|
|
lightDir_63 = tmpvar_76;
|
|
vec3 tmpvar_77;
|
|
tmpvar_77 = IN_61.viewDir.xyz;
|
|
vec3 tmpvar_78;
|
|
tmpvar_78 = normalize (tmpvar_77);
|
|
float tmpvar_79;
|
|
tmpvar_79 = dot (IN_61._LightCoord, IN_61._LightCoord);
|
|
vec2 tmpvar_80;
|
|
tmpvar_80 = vec2(tmpvar_79);
|
|
vec2 tmpvar_81;
|
|
tmpvar_81 = tmpvar_80.xy;
|
|
vec4 tmpvar_82;
|
|
tmpvar_82 = texture2D (_LightTexture0, tmpvar_81);
|
|
vec4 tmpvar_83;
|
|
tmpvar_83 = LightingBlinnPhong (o_64, lightDir_63, tmpvar_78, tmpvar_82.w);
|
|
vec4 tmpvar_84;
|
|
tmpvar_84 = tmpvar_83;
|
|
c_62 = tmpvar_84;
|
|
float tmpvar_85;
|
|
tmpvar_85 = 0.0;
|
|
c_62.w = vec4(tmpvar_85).w;
|
|
return c_62;
|
|
}
|
|
|
|
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;
|
|
vec3 tmpvar_96;
|
|
tmpvar_96 = gl_TexCoord[3].xyz;
|
|
vec3 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;
|
|
}
|
|
|