mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-28 18:45:54 -05:00
279 lines
6.5 KiB
Text
279 lines
6.5 KiB
Text
struct SurfaceOutput {
|
|
vec3 Albedo;
|
|
vec3 Normal;
|
|
vec3 Emission;
|
|
float Specular;
|
|
float Gloss;
|
|
float Alpha;
|
|
};
|
|
struct Input {
|
|
vec2 uv_MainTex;
|
|
vec2 uv_BumpMap;
|
|
vec3 worldRefl;
|
|
vec3 viewDir;
|
|
};
|
|
struct v2f_surf {
|
|
vec4 pos;
|
|
float fog;
|
|
vec4 hip_pack0;
|
|
vec3 viewDir;
|
|
vec3 lightDir;
|
|
vec2 _LightCoord;
|
|
};
|
|
varying vec4 xlv_FOG;
|
|
uniform vec4 _SpecColor;
|
|
uniform float _Shininess;
|
|
uniform vec4 _ReflectColor;
|
|
uniform sampler2D _ParallaxMap;
|
|
uniform float _Parallax;
|
|
uniform sampler2D _MainTex;
|
|
uniform sampler2D _LightTexture0;
|
|
uniform vec4 _LightColor0;
|
|
uniform samplerCube _Cube;
|
|
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 reflcol_16;
|
|
vec3 worldRefl_17;
|
|
vec4 tex_18;
|
|
vec2 offset_19;
|
|
float h_20;
|
|
vec4 tmpvar_21;
|
|
tmpvar_21 = texture2D (_ParallaxMap, IN_14.uv_BumpMap);
|
|
float tmpvar_22;
|
|
tmpvar_22 = tmpvar_21.w;
|
|
h_20 = tmpvar_22;
|
|
vec2 tmpvar_23;
|
|
tmpvar_23 = ParallaxOffset (h_20, _Parallax, IN_14.viewDir);
|
|
vec2 tmpvar_24;
|
|
tmpvar_24 = tmpvar_23;
|
|
offset_19 = tmpvar_24;
|
|
vec2 tmpvar_25;
|
|
tmpvar_25 = (IN_14.uv_MainTex + offset_19);
|
|
IN_14.uv_MainTex = tmpvar_25;
|
|
vec2 tmpvar_26;
|
|
tmpvar_26 = (IN_14.uv_BumpMap + offset_19);
|
|
IN_14.uv_BumpMap = tmpvar_26;
|
|
vec4 tmpvar_27;
|
|
tmpvar_27 = texture2D (_MainTex, IN_14.uv_MainTex);
|
|
vec4 tmpvar_28;
|
|
tmpvar_28 = tmpvar_27;
|
|
tex_18 = tmpvar_28;
|
|
vec3 tmpvar_29;
|
|
tmpvar_29 = (tex_18.xyz * _Color.xyz);
|
|
o_15.Albedo = tmpvar_29;
|
|
float tmpvar_30;
|
|
tmpvar_30 = tex_18.w;
|
|
o_15.Gloss = tmpvar_30;
|
|
float tmpvar_31;
|
|
tmpvar_31 = _Shininess;
|
|
o_15.Specular = tmpvar_31;
|
|
vec4 tmpvar_32;
|
|
tmpvar_32 = texture2D (_BumpMap, IN_14.uv_BumpMap);
|
|
vec4 tmpvar_33;
|
|
tmpvar_33 = UnpackNormal (tmpvar_32);
|
|
vec3 tmpvar_34;
|
|
tmpvar_34 = tmpvar_33.xyz;
|
|
vec3 tmpvar_35;
|
|
tmpvar_35 = tmpvar_34;
|
|
o_15.Normal = tmpvar_35;
|
|
vec3 tmpvar_36;
|
|
tmpvar_36 = IN_14.worldRefl;
|
|
worldRefl_17 = tmpvar_36;
|
|
vec4 tmpvar_37;
|
|
tmpvar_37 = textureCube (_Cube, worldRefl_17);
|
|
vec4 tmpvar_38;
|
|
tmpvar_38 = tmpvar_37;
|
|
reflcol_16 = tmpvar_38;
|
|
vec4 tmpvar_39;
|
|
tmpvar_39 = (reflcol_16 * tex_18.w);
|
|
reflcol_16 = tmpvar_39;
|
|
vec3 tmpvar_40;
|
|
tmpvar_40 = (reflcol_16.xyz * _ReflectColor.xyz);
|
|
o_15.Emission = tmpvar_40;
|
|
float tmpvar_41;
|
|
tmpvar_41 = (reflcol_16.w * _ReflectColor.w);
|
|
o_15.Alpha = tmpvar_41;
|
|
}
|
|
|
|
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 = IN_63.viewDir.xyz;
|
|
vec3 tmpvar_78;
|
|
tmpvar_78 = normalize (tmpvar_77);
|
|
vec4 tmpvar_79;
|
|
tmpvar_79 = texture2D (_LightTexture0, IN_63._LightCoord);
|
|
vec4 tmpvar_80;
|
|
tmpvar_80 = LightingBlinnPhong (o_66, lightDir_65, tmpvar_78, (tmpvar_79.w * 1.0));
|
|
vec4 tmpvar_81;
|
|
tmpvar_81 = tmpvar_80;
|
|
c_64 = tmpvar_81;
|
|
float tmpvar_82;
|
|
tmpvar_82 = 0.0;
|
|
c_64.w = vec4(tmpvar_82).w;
|
|
return c_64;
|
|
}
|
|
|
|
void main ()
|
|
{
|
|
v2f_surf xlt_IN_83;
|
|
vec4 xl_retval_84;
|
|
vec4 tmpvar_85;
|
|
tmpvar_85 = vec4(0.0, 0.0, 0.0, 0.0);
|
|
xlt_IN_83.pos = tmpvar_85;
|
|
float tmpvar_86;
|
|
tmpvar_86 = xlv_FOG.x;
|
|
xlt_IN_83.fog = tmpvar_86;
|
|
vec4 tmpvar_87;
|
|
tmpvar_87 = gl_TexCoord[0].xyzw;
|
|
vec4 tmpvar_88;
|
|
tmpvar_88 = tmpvar_87;
|
|
xlt_IN_83.hip_pack0 = tmpvar_88;
|
|
vec3 tmpvar_89;
|
|
tmpvar_89 = gl_TexCoord[1].xyz;
|
|
vec3 tmpvar_90;
|
|
tmpvar_90 = tmpvar_89;
|
|
xlt_IN_83.viewDir = tmpvar_90;
|
|
vec3 tmpvar_91;
|
|
tmpvar_91 = gl_TexCoord[2].xyz;
|
|
vec3 tmpvar_92;
|
|
tmpvar_92 = tmpvar_91;
|
|
xlt_IN_83.lightDir = tmpvar_92;
|
|
vec2 tmpvar_93;
|
|
tmpvar_93 = gl_TexCoord[3].xy;
|
|
vec2 tmpvar_94;
|
|
tmpvar_94 = tmpvar_93;
|
|
xlt_IN_83._LightCoord = tmpvar_94;
|
|
vec4 tmpvar_95;
|
|
tmpvar_95 = frag_surf (xlt_IN_83);
|
|
vec4 tmpvar_96;
|
|
tmpvar_96 = tmpvar_95;
|
|
xl_retval_84 = tmpvar_96;
|
|
vec4 tmpvar_97;
|
|
tmpvar_97 = xl_retval_84.xyzw;
|
|
vec4 tmpvar_98;
|
|
tmpvar_98 = tmpvar_97;
|
|
gl_FragData[0] = tmpvar_98;
|
|
}
|
|
|