mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-12-11 00:31:28 -05:00
240 lines
5.3 KiB
Text
240 lines
5.3 KiB
Text
struct SurfaceOutput {
|
|
vec3 Albedo;
|
|
vec3 Normal;
|
|
vec3 Emission;
|
|
float Specular;
|
|
float Gloss;
|
|
float Alpha;
|
|
};
|
|
struct Input {
|
|
vec2 uv_MainTex;
|
|
vec2 uv_BumpMap;
|
|
};
|
|
struct v2f_surf {
|
|
vec4 pos;
|
|
float fog;
|
|
vec4 hip_pack0;
|
|
vec3 viewDir;
|
|
vec3 lightDir;
|
|
vec3 vlight;
|
|
vec4 _ShadowCoord;
|
|
};
|
|
uniform sampler2D _BumpMap;
|
|
uniform vec4 _Color;
|
|
uniform vec4 _LightColor0;
|
|
uniform sampler2D _MainTex;
|
|
uniform sampler2D _ShadowMapTexture;
|
|
uniform float _Shininess;
|
|
uniform vec4 _SpecColor;
|
|
varying vec4 xlv_FOG;
|
|
float unitySampleShadow (
|
|
in vec4 shadowCoord_1
|
|
)
|
|
{
|
|
float shadow_2;
|
|
vec4 tmpvar_3;
|
|
tmpvar_3 = texture2DProj (_ShadowMapTexture, shadowCoord_1);
|
|
float tmpvar_4;
|
|
tmpvar_4 = tmpvar_3.x;
|
|
shadow_2 = tmpvar_4;
|
|
return shadow_2;
|
|
}
|
|
|
|
vec4 UnpackNormal (
|
|
in vec4 packednormal_5
|
|
)
|
|
{
|
|
vec4 normal_6;
|
|
vec2 tmpvar_7;
|
|
tmpvar_7 = ((packednormal_5.wy * 2.0) - 1.0);
|
|
normal_6.xy = tmpvar_7.xy.xy;
|
|
float tmpvar_8;
|
|
tmpvar_8 = sqrt (((1.0 - (normal_6.x * normal_6.x)) - (normal_6.y * normal_6.y)));
|
|
float tmpvar_9;
|
|
tmpvar_9 = tmpvar_8;
|
|
normal_6.z = vec3(tmpvar_9).z;
|
|
return normal_6;
|
|
}
|
|
|
|
void surf (
|
|
in Input IN_10,
|
|
inout SurfaceOutput o_11
|
|
)
|
|
{
|
|
vec4 tex_12;
|
|
vec4 tmpvar_13;
|
|
tmpvar_13 = texture2D (_MainTex, IN_10.uv_MainTex);
|
|
vec4 tmpvar_14;
|
|
tmpvar_14 = tmpvar_13;
|
|
tex_12 = tmpvar_14;
|
|
vec3 tmpvar_15;
|
|
tmpvar_15 = (tex_12.xyz * _Color.xyz);
|
|
o_11.Albedo = tmpvar_15;
|
|
float tmpvar_16;
|
|
tmpvar_16 = tex_12.w;
|
|
o_11.Gloss = tmpvar_16;
|
|
float tmpvar_17;
|
|
tmpvar_17 = (tex_12.w * _Color.w);
|
|
o_11.Alpha = tmpvar_17;
|
|
float tmpvar_18;
|
|
tmpvar_18 = _Shininess;
|
|
o_11.Specular = tmpvar_18;
|
|
vec4 tmpvar_19;
|
|
tmpvar_19 = texture2D (_BumpMap, IN_10.uv_BumpMap);
|
|
vec4 tmpvar_20;
|
|
tmpvar_20 = UnpackNormal (tmpvar_19);
|
|
vec3 tmpvar_21;
|
|
tmpvar_21 = tmpvar_20.xyz;
|
|
vec3 tmpvar_22;
|
|
tmpvar_22 = tmpvar_21;
|
|
o_11.Normal = tmpvar_22;
|
|
}
|
|
|
|
vec4 LightingBlinnPhong (
|
|
in SurfaceOutput s_23,
|
|
in vec3 lightDir_24,
|
|
in vec3 viewDir_25,
|
|
in float atten_26
|
|
)
|
|
{
|
|
vec4 c_27;
|
|
float spec_28;
|
|
float nh_29;
|
|
float diff_30;
|
|
vec3 h_31;
|
|
vec3 tmpvar_32;
|
|
tmpvar_32 = normalize ((lightDir_24 + viewDir_25));
|
|
vec3 tmpvar_33;
|
|
tmpvar_33 = tmpvar_32;
|
|
h_31 = tmpvar_33;
|
|
float tmpvar_34;
|
|
tmpvar_34 = dot (s_23.Normal, lightDir_24);
|
|
float tmpvar_35;
|
|
tmpvar_35 = max (0.0, tmpvar_34);
|
|
float tmpvar_36;
|
|
tmpvar_36 = tmpvar_35;
|
|
diff_30 = tmpvar_36;
|
|
float tmpvar_37;
|
|
tmpvar_37 = dot (s_23.Normal, h_31);
|
|
float tmpvar_38;
|
|
tmpvar_38 = max (0.0, tmpvar_37);
|
|
float tmpvar_39;
|
|
tmpvar_39 = tmpvar_38;
|
|
nh_29 = tmpvar_39;
|
|
float tmpvar_40;
|
|
tmpvar_40 = pow (nh_29, (s_23.Specular * 128.0));
|
|
float tmpvar_41;
|
|
tmpvar_41 = (tmpvar_40 * s_23.Gloss);
|
|
spec_28 = tmpvar_41;
|
|
vec3 tmpvar_42;
|
|
tmpvar_42 = (((
|
|
(s_23.Albedo * _LightColor0.xyz)
|
|
* diff_30) + (
|
|
(_LightColor0.xyz * _SpecColor.xyz)
|
|
* spec_28)) * (atten_26 * 2.0));
|
|
c_27.xyz = tmpvar_42.xyz.xyz;
|
|
float tmpvar_43;
|
|
tmpvar_43 = (s_23.Alpha + ((
|
|
(_LightColor0.w * _SpecColor.w)
|
|
* spec_28) * atten_26));
|
|
c_27.w = vec4(tmpvar_43).w;
|
|
return c_27;
|
|
}
|
|
|
|
vec4 frag_surf (
|
|
in v2f_surf IN_44
|
|
)
|
|
{
|
|
vec4 c_45;
|
|
float atten_46;
|
|
SurfaceOutput o_47;
|
|
Input surfIN_48;
|
|
vec2 tmpvar_49;
|
|
tmpvar_49 = IN_44.hip_pack0.xy;
|
|
surfIN_48.uv_MainTex = tmpvar_49;
|
|
vec2 tmpvar_50;
|
|
tmpvar_50 = IN_44.hip_pack0.zw;
|
|
surfIN_48.uv_BumpMap = tmpvar_50;
|
|
vec3 tmpvar_51;
|
|
tmpvar_51 = vec3(0.0, 0.0, 0.0);
|
|
o_47.Albedo = tmpvar_51;
|
|
vec3 tmpvar_52;
|
|
tmpvar_52 = vec3(0.0, 0.0, 0.0);
|
|
o_47.Emission = tmpvar_52;
|
|
float tmpvar_53;
|
|
tmpvar_53 = 0.0;
|
|
o_47.Specular = tmpvar_53;
|
|
float tmpvar_54;
|
|
tmpvar_54 = 0.0;
|
|
o_47.Alpha = tmpvar_54;
|
|
float tmpvar_55;
|
|
tmpvar_55 = 0.0;
|
|
o_47.Gloss = tmpvar_55;
|
|
surf (surfIN_48, o_47);
|
|
float tmpvar_56;
|
|
tmpvar_56 = unitySampleShadow (IN_44._ShadowCoord);
|
|
float tmpvar_57;
|
|
tmpvar_57 = tmpvar_56;
|
|
atten_46 = tmpvar_57;
|
|
vec3 tmpvar_58;
|
|
tmpvar_58 = IN_44.viewDir.xyz;
|
|
vec3 tmpvar_59;
|
|
tmpvar_59 = normalize (tmpvar_58);
|
|
vec4 tmpvar_60;
|
|
tmpvar_60 = LightingBlinnPhong (o_47, IN_44.lightDir, tmpvar_59, atten_46);
|
|
vec4 tmpvar_61;
|
|
tmpvar_61 = tmpvar_60;
|
|
c_45 = tmpvar_61;
|
|
vec3 tmpvar_62;
|
|
tmpvar_62 = (c_45.xyz + (o_47.Albedo * IN_44.vlight));
|
|
c_45.xyz = tmpvar_62.xyz.xyz;
|
|
return c_45;
|
|
}
|
|
|
|
void main ()
|
|
{
|
|
v2f_surf xlt_IN_63;
|
|
vec4 xl_retval_64;
|
|
vec4 tmpvar_65;
|
|
tmpvar_65 = vec4(0.0, 0.0, 0.0, 0.0);
|
|
xlt_IN_63.pos = tmpvar_65;
|
|
float tmpvar_66;
|
|
tmpvar_66 = xlv_FOG.x;
|
|
xlt_IN_63.fog = tmpvar_66;
|
|
vec4 tmpvar_67;
|
|
tmpvar_67 = gl_TexCoord[0].xyzw;
|
|
vec4 tmpvar_68;
|
|
tmpvar_68 = tmpvar_67;
|
|
xlt_IN_63.hip_pack0 = tmpvar_68;
|
|
vec3 tmpvar_69;
|
|
tmpvar_69 = gl_TexCoord[1].xyz;
|
|
vec3 tmpvar_70;
|
|
tmpvar_70 = tmpvar_69;
|
|
xlt_IN_63.viewDir = tmpvar_70;
|
|
vec3 tmpvar_71;
|
|
tmpvar_71 = gl_TexCoord[2].xyz;
|
|
vec3 tmpvar_72;
|
|
tmpvar_72 = tmpvar_71;
|
|
xlt_IN_63.lightDir = tmpvar_72;
|
|
vec3 tmpvar_73;
|
|
tmpvar_73 = gl_TexCoord[3].xyz;
|
|
vec3 tmpvar_74;
|
|
tmpvar_74 = tmpvar_73;
|
|
xlt_IN_63.vlight = tmpvar_74;
|
|
vec4 tmpvar_75;
|
|
tmpvar_75 = gl_TexCoord[4].xyzw;
|
|
vec4 tmpvar_76;
|
|
tmpvar_76 = tmpvar_75;
|
|
xlt_IN_63._ShadowCoord = tmpvar_76;
|
|
vec4 tmpvar_77;
|
|
tmpvar_77 = frag_surf (xlt_IN_63);
|
|
vec4 tmpvar_78;
|
|
tmpvar_78 = tmpvar_77;
|
|
xl_retval_64 = tmpvar_78;
|
|
vec4 tmpvar_79;
|
|
tmpvar_79 = xl_retval_64.xyzw;
|
|
vec4 tmpvar_80;
|
|
tmpvar_80 = tmpvar_79;
|
|
gl_FragData[0] = tmpvar_80;
|
|
}
|
|
|