mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-25 09:08:22 -05:00
179 lines
3.9 KiB
Text
179 lines
3.9 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 _LightCoord;
|
|
};
|
|
varying vec4 xlv_FOG;
|
|
uniform sampler2D _LightTexture0;
|
|
uniform vec4 _LightColor0;
|
|
uniform sampler2D _DecalBump;
|
|
uniform sampler2D _Decal;
|
|
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;
|
|
}
|
|
|
|
void surf (
|
|
in Input IN_6,
|
|
inout SurfaceOutput o_7
|
|
)
|
|
{
|
|
vec4 tmpvar_8;
|
|
tmpvar_8 = texture2D (_Decal, IN_6.uv_Decal);
|
|
vec3 tmpvar_9;
|
|
tmpvar_9 = (tmpvar_8.xyz * 0.5);
|
|
o_7.Albedo = tmpvar_9;
|
|
vec4 tmpvar_10;
|
|
tmpvar_10 = texture2D (_DecalBump, IN_6.uv_DecalBump);
|
|
vec4 tmpvar_11;
|
|
tmpvar_11 = UnpackNormal (tmpvar_10);
|
|
vec3 tmpvar_12;
|
|
tmpvar_12 = tmpvar_11.xyz;
|
|
vec3 tmpvar_13;
|
|
tmpvar_13 = tmpvar_12;
|
|
o_7.Normal = tmpvar_13;
|
|
}
|
|
|
|
vec4 LightingLambert (
|
|
in SurfaceOutput s_14,
|
|
in vec3 lightDir_15,
|
|
in float atten_16
|
|
)
|
|
{
|
|
vec4 c_17;
|
|
float diff_18;
|
|
float tmpvar_19;
|
|
tmpvar_19 = dot (s_14.Normal, lightDir_15);
|
|
float tmpvar_20;
|
|
tmpvar_20 = max (0.0, tmpvar_19);
|
|
float tmpvar_21;
|
|
tmpvar_21 = tmpvar_20;
|
|
diff_18 = tmpvar_21;
|
|
vec3 tmpvar_22;
|
|
tmpvar_22 = ((s_14.Albedo * _LightColor0.xyz) * ((diff_18 * atten_16) * 2.0));
|
|
c_17.xyz = tmpvar_22.xyz.xyz;
|
|
float tmpvar_23;
|
|
tmpvar_23 = s_14.Alpha;
|
|
c_17.w = vec4(tmpvar_23).w;
|
|
return c_17;
|
|
}
|
|
|
|
vec4 frag_surf (
|
|
in v2f_surf IN_24
|
|
)
|
|
{
|
|
vec4 c_25;
|
|
vec3 lightDir_26;
|
|
SurfaceOutput o_27;
|
|
Input surfIN_28;
|
|
vec2 tmpvar_29;
|
|
tmpvar_29 = IN_24.hip_pack0.xy;
|
|
surfIN_28.uv_Decal = tmpvar_29;
|
|
vec2 tmpvar_30;
|
|
tmpvar_30 = IN_24.hip_pack0.zw;
|
|
surfIN_28.uv_DecalBump = tmpvar_30;
|
|
vec3 tmpvar_31;
|
|
tmpvar_31 = vec3(0.0, 0.0, 0.0);
|
|
o_27.Albedo = tmpvar_31;
|
|
vec3 tmpvar_32;
|
|
tmpvar_32 = vec3(0.0, 0.0, 0.0);
|
|
o_27.Emission = tmpvar_32;
|
|
float tmpvar_33;
|
|
tmpvar_33 = 0.0;
|
|
o_27.Specular = tmpvar_33;
|
|
float tmpvar_34;
|
|
tmpvar_34 = 0.0;
|
|
o_27.Alpha = tmpvar_34;
|
|
float tmpvar_35;
|
|
tmpvar_35 = 0.0;
|
|
o_27.Gloss = tmpvar_35;
|
|
surf (surfIN_28, o_27);
|
|
vec3 tmpvar_36;
|
|
tmpvar_36 = IN_24.lightDir;
|
|
lightDir_26 = tmpvar_36;
|
|
vec3 tmpvar_37;
|
|
tmpvar_37 = normalize (lightDir_26);
|
|
vec3 tmpvar_38;
|
|
tmpvar_38 = tmpvar_37;
|
|
lightDir_26 = tmpvar_38;
|
|
float tmpvar_39;
|
|
tmpvar_39 = dot (IN_24._LightCoord, IN_24._LightCoord);
|
|
vec2 tmpvar_40;
|
|
tmpvar_40 = vec2(tmpvar_39);
|
|
vec2 tmpvar_41;
|
|
tmpvar_41 = tmpvar_40.xy;
|
|
vec4 tmpvar_42;
|
|
tmpvar_42 = texture2D (_LightTexture0, tmpvar_41);
|
|
vec4 tmpvar_43;
|
|
tmpvar_43 = LightingLambert (o_27, lightDir_26, tmpvar_42.w);
|
|
vec4 tmpvar_44;
|
|
tmpvar_44 = tmpvar_43;
|
|
c_25 = tmpvar_44;
|
|
float tmpvar_45;
|
|
tmpvar_45 = 0.0;
|
|
c_25.w = vec4(tmpvar_45).w;
|
|
return c_25;
|
|
}
|
|
|
|
void main ()
|
|
{
|
|
v2f_surf xlt_IN_46;
|
|
vec4 xl_retval_47;
|
|
vec4 tmpvar_48;
|
|
tmpvar_48 = vec4(0.0, 0.0, 0.0, 0.0);
|
|
xlt_IN_46.pos = tmpvar_48;
|
|
float tmpvar_49;
|
|
tmpvar_49 = xlv_FOG.x;
|
|
xlt_IN_46.fog = tmpvar_49;
|
|
vec4 tmpvar_50;
|
|
tmpvar_50 = gl_TexCoord[0].xyzw;
|
|
vec4 tmpvar_51;
|
|
tmpvar_51 = tmpvar_50;
|
|
xlt_IN_46.hip_pack0 = tmpvar_51;
|
|
vec3 tmpvar_52;
|
|
tmpvar_52 = gl_TexCoord[1].xyz;
|
|
vec3 tmpvar_53;
|
|
tmpvar_53 = tmpvar_52;
|
|
xlt_IN_46.lightDir = tmpvar_53;
|
|
vec3 tmpvar_54;
|
|
tmpvar_54 = gl_TexCoord[2].xyz;
|
|
vec3 tmpvar_55;
|
|
tmpvar_55 = tmpvar_54;
|
|
xlt_IN_46._LightCoord = tmpvar_55;
|
|
vec4 tmpvar_56;
|
|
tmpvar_56 = frag_surf (xlt_IN_46);
|
|
vec4 tmpvar_57;
|
|
tmpvar_57 = tmpvar_56;
|
|
xl_retval_47 = tmpvar_57;
|
|
vec4 tmpvar_58;
|
|
tmpvar_58 = xl_retval_47.xyzw;
|
|
vec4 tmpvar_59;
|
|
tmpvar_59 = tmpvar_58;
|
|
gl_FragData[0] = tmpvar_59;
|
|
}
|
|
|