mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-29 02:55:36 -05:00
186 lines
4 KiB
Text
186 lines
4 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 uv2_LightMap;
|
||
|
};
|
||
|
struct v2f_surf {
|
||
|
vec4 pos;
|
||
|
float fog;
|
||
|
vec4 hip_pack0;
|
||
|
vec3 lightDir;
|
||
|
vec2 _LightCoord;
|
||
|
};
|
||
|
varying vec4 xlv_FOG;
|
||
|
uniform sampler2D _MainTex;
|
||
|
uniform sampler2D _LightTexture0;
|
||
|
uniform sampler2D _LightMap;
|
||
|
uniform vec4 _LightColor0;
|
||
|
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;
|
||
|
}
|
||
|
|
||
|
void surf (
|
||
|
in Input IN_6,
|
||
|
inout SurfaceOutput o_7
|
||
|
)
|
||
|
{
|
||
|
vec4 lm_8;
|
||
|
vec4 tmpvar_9;
|
||
|
tmpvar_9 = texture2D (_MainTex, IN_6.uv_MainTex);
|
||
|
vec3 tmpvar_10;
|
||
|
tmpvar_10 = _Color.xyz;
|
||
|
vec3 tmpvar_11;
|
||
|
tmpvar_11 = (tmpvar_9.xyz * tmpvar_10);
|
||
|
o_7.Albedo = tmpvar_11;
|
||
|
vec4 tmpvar_12;
|
||
|
tmpvar_12 = texture2D (_LightMap, IN_6.uv2_LightMap);
|
||
|
vec4 tmpvar_13;
|
||
|
tmpvar_13 = tmpvar_12;
|
||
|
lm_8 = tmpvar_13;
|
||
|
vec3 tmpvar_14;
|
||
|
tmpvar_14 = (lm_8.xyz * o_7.Albedo.xyz);
|
||
|
o_7.Emission = tmpvar_14;
|
||
|
float tmpvar_15;
|
||
|
tmpvar_15 = (lm_8.w * _Color.w);
|
||
|
o_7.Alpha = tmpvar_15;
|
||
|
vec4 tmpvar_16;
|
||
|
tmpvar_16 = texture2D (_BumpMap, IN_6.uv_BumpMap);
|
||
|
vec4 tmpvar_17;
|
||
|
tmpvar_17 = UnpackNormal (tmpvar_16);
|
||
|
vec3 tmpvar_18;
|
||
|
tmpvar_18 = tmpvar_17.xyz;
|
||
|
vec3 tmpvar_19;
|
||
|
tmpvar_19 = tmpvar_18;
|
||
|
o_7.Normal = tmpvar_19;
|
||
|
}
|
||
|
|
||
|
vec4 LightingLambert (
|
||
|
in SurfaceOutput s_20,
|
||
|
in vec3 lightDir_21,
|
||
|
in float atten_22
|
||
|
)
|
||
|
{
|
||
|
vec4 c_23;
|
||
|
float diff_24;
|
||
|
float tmpvar_25;
|
||
|
tmpvar_25 = dot (s_20.Normal, lightDir_21);
|
||
|
float tmpvar_26;
|
||
|
tmpvar_26 = max (0.0, tmpvar_25);
|
||
|
float tmpvar_27;
|
||
|
tmpvar_27 = tmpvar_26;
|
||
|
diff_24 = tmpvar_27;
|
||
|
vec3 tmpvar_28;
|
||
|
tmpvar_28 = ((s_20.Albedo * _LightColor0.xyz) * ((diff_24 * atten_22) * 2.0));
|
||
|
c_23.xyz = tmpvar_28.xyz.xyz;
|
||
|
float tmpvar_29;
|
||
|
tmpvar_29 = s_20.Alpha;
|
||
|
c_23.w = vec4(tmpvar_29).w;
|
||
|
return c_23;
|
||
|
}
|
||
|
|
||
|
vec4 frag_surf (
|
||
|
in v2f_surf IN_30
|
||
|
)
|
||
|
{
|
||
|
vec4 c_31;
|
||
|
vec3 lightDir_32;
|
||
|
SurfaceOutput o_33;
|
||
|
Input surfIN_34;
|
||
|
vec2 tmpvar_35;
|
||
|
tmpvar_35 = IN_30.hip_pack0.xy;
|
||
|
surfIN_34.uv_MainTex = tmpvar_35;
|
||
|
vec2 tmpvar_36;
|
||
|
tmpvar_36 = IN_30.hip_pack0.zw;
|
||
|
surfIN_34.uv_BumpMap = tmpvar_36;
|
||
|
vec3 tmpvar_37;
|
||
|
tmpvar_37 = vec3(0.0, 0.0, 0.0);
|
||
|
o_33.Albedo = tmpvar_37;
|
||
|
vec3 tmpvar_38;
|
||
|
tmpvar_38 = vec3(0.0, 0.0, 0.0);
|
||
|
o_33.Emission = tmpvar_38;
|
||
|
float tmpvar_39;
|
||
|
tmpvar_39 = 0.0;
|
||
|
o_33.Specular = tmpvar_39;
|
||
|
float tmpvar_40;
|
||
|
tmpvar_40 = 0.0;
|
||
|
o_33.Alpha = tmpvar_40;
|
||
|
float tmpvar_41;
|
||
|
tmpvar_41 = 0.0;
|
||
|
o_33.Gloss = tmpvar_41;
|
||
|
surf (surfIN_34, o_33);
|
||
|
vec3 tmpvar_42;
|
||
|
tmpvar_42 = IN_30.lightDir;
|
||
|
lightDir_32 = tmpvar_42;
|
||
|
vec4 tmpvar_43;
|
||
|
tmpvar_43 = texture2D (_LightTexture0, IN_30._LightCoord);
|
||
|
vec4 tmpvar_44;
|
||
|
tmpvar_44 = LightingLambert (o_33, lightDir_32, (tmpvar_43.w * 1.0));
|
||
|
vec4 tmpvar_45;
|
||
|
tmpvar_45 = tmpvar_44;
|
||
|
c_31 = tmpvar_45;
|
||
|
float tmpvar_46;
|
||
|
tmpvar_46 = 0.0;
|
||
|
c_31.w = vec4(tmpvar_46).w;
|
||
|
return c_31;
|
||
|
}
|
||
|
|
||
|
void main ()
|
||
|
{
|
||
|
v2f_surf xlt_IN_47;
|
||
|
vec4 xl_retval_48;
|
||
|
vec4 tmpvar_49;
|
||
|
tmpvar_49 = vec4(0.0, 0.0, 0.0, 0.0);
|
||
|
xlt_IN_47.pos = tmpvar_49;
|
||
|
float tmpvar_50;
|
||
|
tmpvar_50 = xlv_FOG.x;
|
||
|
xlt_IN_47.fog = tmpvar_50;
|
||
|
vec4 tmpvar_51;
|
||
|
tmpvar_51 = gl_TexCoord[0].xyzw;
|
||
|
vec4 tmpvar_52;
|
||
|
tmpvar_52 = tmpvar_51;
|
||
|
xlt_IN_47.hip_pack0 = tmpvar_52;
|
||
|
vec3 tmpvar_53;
|
||
|
tmpvar_53 = gl_TexCoord[1].xyz;
|
||
|
vec3 tmpvar_54;
|
||
|
tmpvar_54 = tmpvar_53;
|
||
|
xlt_IN_47.lightDir = tmpvar_54;
|
||
|
vec2 tmpvar_55;
|
||
|
tmpvar_55 = gl_TexCoord[2].xy;
|
||
|
vec2 tmpvar_56;
|
||
|
tmpvar_56 = tmpvar_55;
|
||
|
xlt_IN_47._LightCoord = tmpvar_56;
|
||
|
vec4 tmpvar_57;
|
||
|
tmpvar_57 = frag_surf (xlt_IN_47);
|
||
|
vec4 tmpvar_58;
|
||
|
tmpvar_58 = tmpvar_57;
|
||
|
xl_retval_48 = tmpvar_58;
|
||
|
vec4 tmpvar_59;
|
||
|
tmpvar_59 = xl_retval_48.xyzw;
|
||
|
vec4 tmpvar_60;
|
||
|
tmpvar_60 = tmpvar_59;
|
||
|
gl_FragData[0] = tmpvar_60;
|
||
|
}
|
||
|
|