mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-29 11:05:36 -05:00
187 lines
4 KiB
Text
187 lines
4 KiB
Text
struct SurfaceOutput {
|
|
vec3 Albedo;
|
|
vec3 Normal;
|
|
vec3 Emission;
|
|
float Specular;
|
|
float Gloss;
|
|
float Alpha;
|
|
};
|
|
struct Input {
|
|
vec2 uv_Decal;
|
|
vec2 uv_DecalBump;
|
|
};
|
|
struct v2f_surf {
|
|
vec4 pos;
|
|
float fog;
|
|
vec4 hip_pack0;
|
|
vec3 lightDir;
|
|
vec3 vlight;
|
|
vec4 _ShadowCoord;
|
|
};
|
|
uniform sampler2D _Decal;
|
|
uniform sampler2D _DecalBump;
|
|
uniform vec4 _LightColor0;
|
|
uniform sampler2D _ShadowMapTexture;
|
|
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 tmpvar_12;
|
|
tmpvar_12 = texture2D (_Decal, IN_10.uv_Decal);
|
|
vec3 tmpvar_13;
|
|
tmpvar_13 = (tmpvar_12.xyz * 0.5);
|
|
o_11.Albedo = tmpvar_13;
|
|
vec4 tmpvar_14;
|
|
tmpvar_14 = texture2D (_DecalBump, IN_10.uv_DecalBump);
|
|
vec4 tmpvar_15;
|
|
tmpvar_15 = UnpackNormal (tmpvar_14);
|
|
vec3 tmpvar_16;
|
|
tmpvar_16 = tmpvar_15.xyz;
|
|
vec3 tmpvar_17;
|
|
tmpvar_17 = tmpvar_16;
|
|
o_11.Normal = tmpvar_17;
|
|
}
|
|
|
|
vec4 LightingLambert (
|
|
in SurfaceOutput s_18,
|
|
in vec3 lightDir_19,
|
|
in float atten_20
|
|
)
|
|
{
|
|
vec4 c_21;
|
|
float diff_22;
|
|
float tmpvar_23;
|
|
tmpvar_23 = dot (s_18.Normal, lightDir_19);
|
|
float tmpvar_24;
|
|
tmpvar_24 = max (0.0, tmpvar_23);
|
|
float tmpvar_25;
|
|
tmpvar_25 = tmpvar_24;
|
|
diff_22 = tmpvar_25;
|
|
vec3 tmpvar_26;
|
|
tmpvar_26 = ((s_18.Albedo * _LightColor0.xyz) * ((diff_22 * atten_20) * 2.0));
|
|
c_21.xyz = tmpvar_26.xyz.xyz;
|
|
float tmpvar_27;
|
|
tmpvar_27 = s_18.Alpha;
|
|
c_21.w = vec4(tmpvar_27).w;
|
|
return c_21;
|
|
}
|
|
|
|
vec4 frag_surf (
|
|
in v2f_surf IN_28
|
|
)
|
|
{
|
|
vec4 c_29;
|
|
float atten_30;
|
|
SurfaceOutput o_31;
|
|
Input surfIN_32;
|
|
vec2 tmpvar_33;
|
|
tmpvar_33 = IN_28.hip_pack0.xy;
|
|
surfIN_32.uv_Decal = tmpvar_33;
|
|
vec2 tmpvar_34;
|
|
tmpvar_34 = IN_28.hip_pack0.zw;
|
|
surfIN_32.uv_DecalBump = tmpvar_34;
|
|
vec3 tmpvar_35;
|
|
tmpvar_35 = vec3(0.0, 0.0, 0.0);
|
|
o_31.Albedo = tmpvar_35;
|
|
vec3 tmpvar_36;
|
|
tmpvar_36 = vec3(0.0, 0.0, 0.0);
|
|
o_31.Emission = tmpvar_36;
|
|
float tmpvar_37;
|
|
tmpvar_37 = 0.0;
|
|
o_31.Specular = tmpvar_37;
|
|
float tmpvar_38;
|
|
tmpvar_38 = 0.0;
|
|
o_31.Alpha = tmpvar_38;
|
|
float tmpvar_39;
|
|
tmpvar_39 = 0.0;
|
|
o_31.Gloss = tmpvar_39;
|
|
surf (surfIN_32, o_31);
|
|
float tmpvar_40;
|
|
tmpvar_40 = unitySampleShadow (IN_28._ShadowCoord);
|
|
float tmpvar_41;
|
|
tmpvar_41 = tmpvar_40;
|
|
atten_30 = tmpvar_41;
|
|
vec4 tmpvar_42;
|
|
tmpvar_42 = LightingLambert (o_31, IN_28.lightDir, atten_30);
|
|
vec4 tmpvar_43;
|
|
tmpvar_43 = tmpvar_42;
|
|
c_29 = tmpvar_43;
|
|
vec3 tmpvar_44;
|
|
tmpvar_44 = (c_29.xyz + (o_31.Albedo * IN_28.vlight));
|
|
c_29.xyz = tmpvar_44.xyz.xyz;
|
|
return c_29;
|
|
}
|
|
|
|
void main ()
|
|
{
|
|
v2f_surf xlt_IN_45;
|
|
vec4 xl_retval_46;
|
|
vec4 tmpvar_47;
|
|
tmpvar_47 = vec4(0.0, 0.0, 0.0, 0.0);
|
|
xlt_IN_45.pos = tmpvar_47;
|
|
float tmpvar_48;
|
|
tmpvar_48 = xlv_FOG.x;
|
|
xlt_IN_45.fog = tmpvar_48;
|
|
vec4 tmpvar_49;
|
|
tmpvar_49 = gl_TexCoord[0].xyzw;
|
|
vec4 tmpvar_50;
|
|
tmpvar_50 = tmpvar_49;
|
|
xlt_IN_45.hip_pack0 = tmpvar_50;
|
|
vec3 tmpvar_51;
|
|
tmpvar_51 = gl_TexCoord[1].xyz;
|
|
vec3 tmpvar_52;
|
|
tmpvar_52 = tmpvar_51;
|
|
xlt_IN_45.lightDir = tmpvar_52;
|
|
vec3 tmpvar_53;
|
|
tmpvar_53 = gl_TexCoord[2].xyz;
|
|
vec3 tmpvar_54;
|
|
tmpvar_54 = tmpvar_53;
|
|
xlt_IN_45.vlight = tmpvar_54;
|
|
vec4 tmpvar_55;
|
|
tmpvar_55 = gl_TexCoord[3].xyzw;
|
|
vec4 tmpvar_56;
|
|
tmpvar_56 = tmpvar_55;
|
|
xlt_IN_45._ShadowCoord = tmpvar_56;
|
|
vec4 tmpvar_57;
|
|
tmpvar_57 = frag_surf (xlt_IN_45);
|
|
vec4 tmpvar_58;
|
|
tmpvar_58 = tmpvar_57;
|
|
xl_retval_46 = tmpvar_58;
|
|
vec4 tmpvar_59;
|
|
tmpvar_59 = xl_retval_46.xyzw;
|
|
vec4 tmpvar_60;
|
|
tmpvar_60 = tmpvar_59;
|
|
gl_FragData[0] = tmpvar_60;
|
|
}
|
|
|