mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-12-01 11:56:58 -05:00
149 lines
3.1 KiB
Text
149 lines
3.1 KiB
Text
struct SurfaceOutput {
|
|
vec3 Albedo;
|
|
vec3 Normal;
|
|
vec3 Emission;
|
|
float Specular;
|
|
float Gloss;
|
|
float Alpha;
|
|
};
|
|
struct Input {
|
|
vec2 uv_MainTex;
|
|
};
|
|
struct v2f_surf {
|
|
vec4 pos;
|
|
float fog;
|
|
vec2 hip_pack0;
|
|
vec3 normal;
|
|
vec3 lightDir;
|
|
vec2 _LightCoord;
|
|
};
|
|
uniform vec4 _LightColor0;
|
|
uniform sampler2D _LightTexture0;
|
|
uniform sampler2D _MainTex;
|
|
varying vec4 xlv_FOG;
|
|
void surf (
|
|
in Input IN_1,
|
|
inout SurfaceOutput o_2
|
|
)
|
|
{
|
|
vec4 tmpvar_3;
|
|
tmpvar_3 = texture2D (_MainTex, IN_1.uv_MainTex);
|
|
vec3 tmpvar_4;
|
|
tmpvar_4 = tmpvar_3.xyz;
|
|
o_2.Albedo = tmpvar_4;
|
|
}
|
|
|
|
vec4 LightingWrapLambert (
|
|
in SurfaceOutput s_5,
|
|
in vec3 lightDir_6,
|
|
in float atten_7
|
|
)
|
|
{
|
|
vec4 c_8;
|
|
float diff_9;
|
|
float NdotL_10;
|
|
float tmpvar_11;
|
|
tmpvar_11 = dot (s_5.Normal, lightDir_6);
|
|
float tmpvar_12;
|
|
tmpvar_12 = tmpvar_11;
|
|
NdotL_10 = tmpvar_12;
|
|
float tmpvar_13;
|
|
tmpvar_13 = ((NdotL_10 * 0.5) + 0.5);
|
|
diff_9 = tmpvar_13;
|
|
vec3 tmpvar_14;
|
|
tmpvar_14 = ((s_5.Albedo * _LightColor0.xyz) * ((diff_9 * atten_7) * 2.0));
|
|
c_8.xyz = tmpvar_14.xyz.xyz;
|
|
float tmpvar_15;
|
|
tmpvar_15 = s_5.Alpha;
|
|
c_8.w = vec4(tmpvar_15).w;
|
|
return c_8;
|
|
}
|
|
|
|
vec4 frag_surf (
|
|
in v2f_surf IN_16
|
|
)
|
|
{
|
|
vec4 c_17;
|
|
vec3 lightDir_18;
|
|
SurfaceOutput o_19;
|
|
Input surfIN_20;
|
|
vec2 tmpvar_21;
|
|
tmpvar_21 = IN_16.hip_pack0.xy;
|
|
surfIN_20.uv_MainTex = tmpvar_21;
|
|
vec3 tmpvar_22;
|
|
tmpvar_22 = vec3(0.0, 0.0, 0.0);
|
|
o_19.Albedo = tmpvar_22;
|
|
vec3 tmpvar_23;
|
|
tmpvar_23 = vec3(0.0, 0.0, 0.0);
|
|
o_19.Emission = tmpvar_23;
|
|
float tmpvar_24;
|
|
tmpvar_24 = 0.0;
|
|
o_19.Specular = tmpvar_24;
|
|
float tmpvar_25;
|
|
tmpvar_25 = 0.0;
|
|
o_19.Alpha = tmpvar_25;
|
|
float tmpvar_26;
|
|
tmpvar_26 = 0.0;
|
|
o_19.Gloss = tmpvar_26;
|
|
vec3 tmpvar_27;
|
|
tmpvar_27 = IN_16.normal;
|
|
o_19.Normal = tmpvar_27;
|
|
surf (surfIN_20, o_19);
|
|
vec3 tmpvar_28;
|
|
tmpvar_28 = IN_16.lightDir;
|
|
lightDir_18 = tmpvar_28;
|
|
vec4 tmpvar_29;
|
|
tmpvar_29 = texture2D (_LightTexture0, IN_16._LightCoord);
|
|
vec4 tmpvar_30;
|
|
tmpvar_30 = LightingWrapLambert (o_19, lightDir_18, (tmpvar_29.w * 1.0));
|
|
vec4 tmpvar_31;
|
|
tmpvar_31 = tmpvar_30;
|
|
c_17 = tmpvar_31;
|
|
float tmpvar_32;
|
|
tmpvar_32 = 0.0;
|
|
c_17.w = vec4(tmpvar_32).w;
|
|
return c_17;
|
|
}
|
|
|
|
void main ()
|
|
{
|
|
v2f_surf xlt_IN_33;
|
|
vec4 xl_retval_34;
|
|
vec4 tmpvar_35;
|
|
tmpvar_35 = vec4(0.0, 0.0, 0.0, 0.0);
|
|
xlt_IN_33.pos = tmpvar_35;
|
|
float tmpvar_36;
|
|
tmpvar_36 = xlv_FOG.x;
|
|
xlt_IN_33.fog = tmpvar_36;
|
|
vec2 tmpvar_37;
|
|
tmpvar_37 = gl_TexCoord[0].xy;
|
|
vec2 tmpvar_38;
|
|
tmpvar_38 = tmpvar_37;
|
|
xlt_IN_33.hip_pack0 = tmpvar_38;
|
|
vec3 tmpvar_39;
|
|
tmpvar_39 = gl_TexCoord[1].xyz;
|
|
vec3 tmpvar_40;
|
|
tmpvar_40 = tmpvar_39;
|
|
xlt_IN_33.normal = tmpvar_40;
|
|
vec3 tmpvar_41;
|
|
tmpvar_41 = gl_TexCoord[2].xyz;
|
|
vec3 tmpvar_42;
|
|
tmpvar_42 = tmpvar_41;
|
|
xlt_IN_33.lightDir = tmpvar_42;
|
|
vec2 tmpvar_43;
|
|
tmpvar_43 = gl_TexCoord[3].xy;
|
|
vec2 tmpvar_44;
|
|
tmpvar_44 = tmpvar_43;
|
|
xlt_IN_33._LightCoord = tmpvar_44;
|
|
vec4 tmpvar_45;
|
|
tmpvar_45 = frag_surf (xlt_IN_33);
|
|
vec4 tmpvar_46;
|
|
tmpvar_46 = tmpvar_45;
|
|
xl_retval_34 = tmpvar_46;
|
|
vec4 tmpvar_47;
|
|
tmpvar_47 = xl_retval_34.xyzw;
|
|
vec4 tmpvar_48;
|
|
tmpvar_48 = tmpvar_47;
|
|
gl_FragData[0] = tmpvar_48;
|
|
}
|
|
|