mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-12-11 00:31:28 -05:00
162 lines
3.5 KiB
Text
162 lines
3.5 KiB
Text
struct SurfaceOutput {
|
|
vec3 Albedo;
|
|
vec3 Normal;
|
|
vec3 Emission;
|
|
float Specular;
|
|
float Gloss;
|
|
float Alpha;
|
|
};
|
|
struct Input {
|
|
vec4 screenPos;
|
|
};
|
|
struct v2f_surf {
|
|
vec4 pos;
|
|
float fog;
|
|
vec3 normal;
|
|
vec3 lightDir;
|
|
vec3 _LightCoord;
|
|
};
|
|
varying vec4 xlv_FOG;
|
|
uniform sampler2D _MainTex;
|
|
uniform sampler2D _LightTextureB0;
|
|
uniform samplerCube _LightTexture0;
|
|
uniform vec4 _LightColor0;
|
|
void surf (
|
|
in Input IN_1,
|
|
inout SurfaceOutput o_2
|
|
)
|
|
{
|
|
vec2 uv_3;
|
|
vec2 tmpvar_4;
|
|
tmpvar_4 = (IN_1.screenPos.xy / IN_1.screenPos.w);
|
|
uv_3 = tmpvar_4;
|
|
vec2 tmpvar_5;
|
|
tmpvar_5 = (uv_3 * vec2(2.0, 1.0));
|
|
uv_3 = tmpvar_5;
|
|
vec3 tmpvar_6;
|
|
tmpvar_6 = vec3(0.5, 0.5, 0.5);
|
|
o_2.Albedo = tmpvar_6;
|
|
vec4 tmpvar_7;
|
|
tmpvar_7 = texture2D (_MainTex, uv_3);
|
|
vec3 tmpvar_8;
|
|
tmpvar_8 = (tmpvar_7.xyz * 0.5);
|
|
o_2.Emission = tmpvar_8;
|
|
}
|
|
|
|
vec4 LightingLambert (
|
|
in SurfaceOutput s_9,
|
|
in vec3 lightDir_10,
|
|
in float atten_11
|
|
)
|
|
{
|
|
vec4 c_12;
|
|
float diff_13;
|
|
float tmpvar_14;
|
|
tmpvar_14 = dot (s_9.Normal, lightDir_10);
|
|
float tmpvar_15;
|
|
tmpvar_15 = max (0.0, tmpvar_14);
|
|
float tmpvar_16;
|
|
tmpvar_16 = tmpvar_15;
|
|
diff_13 = tmpvar_16;
|
|
vec3 tmpvar_17;
|
|
tmpvar_17 = ((s_9.Albedo * _LightColor0.xyz) * ((diff_13 * atten_11) * 2.0));
|
|
c_12.xyz = tmpvar_17.xyz.xyz;
|
|
float tmpvar_18;
|
|
tmpvar_18 = s_9.Alpha;
|
|
c_12.w = vec4(tmpvar_18).w;
|
|
return c_12;
|
|
}
|
|
|
|
vec4 frag_surf (
|
|
in v2f_surf IN_19
|
|
)
|
|
{
|
|
vec4 c_20;
|
|
vec3 lightDir_21;
|
|
Input surfIN_22;
|
|
SurfaceOutput o_23;
|
|
vec3 tmpvar_24;
|
|
tmpvar_24 = vec3(0.0, 0.0, 0.0);
|
|
o_23.Albedo = tmpvar_24;
|
|
vec3 tmpvar_25;
|
|
tmpvar_25 = vec3(0.0, 0.0, 0.0);
|
|
o_23.Emission = tmpvar_25;
|
|
float tmpvar_26;
|
|
tmpvar_26 = 0.0;
|
|
o_23.Specular = tmpvar_26;
|
|
float tmpvar_27;
|
|
tmpvar_27 = 0.0;
|
|
o_23.Alpha = tmpvar_27;
|
|
float tmpvar_28;
|
|
tmpvar_28 = 0.0;
|
|
o_23.Gloss = tmpvar_28;
|
|
vec3 tmpvar_29;
|
|
tmpvar_29 = IN_19.normal;
|
|
o_23.Normal = tmpvar_29;
|
|
surf (surfIN_22, o_23);
|
|
vec3 tmpvar_30;
|
|
tmpvar_30 = IN_19.lightDir;
|
|
lightDir_21 = tmpvar_30;
|
|
vec3 tmpvar_31;
|
|
tmpvar_31 = normalize (lightDir_21);
|
|
vec3 tmpvar_32;
|
|
tmpvar_32 = tmpvar_31;
|
|
lightDir_21 = tmpvar_32;
|
|
float tmpvar_33;
|
|
tmpvar_33 = dot (IN_19._LightCoord, IN_19._LightCoord);
|
|
vec2 tmpvar_34;
|
|
tmpvar_34 = vec2(tmpvar_33);
|
|
vec2 tmpvar_35;
|
|
tmpvar_35 = tmpvar_34.xy;
|
|
vec4 tmpvar_36;
|
|
tmpvar_36 = texture2D (_LightTextureB0, tmpvar_35);
|
|
vec4 tmpvar_37;
|
|
tmpvar_37 = textureCube (_LightTexture0, IN_19._LightCoord);
|
|
vec4 tmpvar_38;
|
|
tmpvar_38 = LightingLambert (o_23, lightDir_21, (tmpvar_36.w * tmpvar_37.w));
|
|
vec4 tmpvar_39;
|
|
tmpvar_39 = tmpvar_38;
|
|
c_20 = tmpvar_39;
|
|
float tmpvar_40;
|
|
tmpvar_40 = 0.0;
|
|
c_20.w = vec4(tmpvar_40).w;
|
|
return c_20;
|
|
}
|
|
|
|
void main ()
|
|
{
|
|
v2f_surf xlt_IN_41;
|
|
vec4 xl_retval_42;
|
|
vec4 tmpvar_43;
|
|
tmpvar_43 = vec4(0.0, 0.0, 0.0, 0.0);
|
|
xlt_IN_41.pos = tmpvar_43;
|
|
float tmpvar_44;
|
|
tmpvar_44 = xlv_FOG.x;
|
|
xlt_IN_41.fog = tmpvar_44;
|
|
vec3 tmpvar_45;
|
|
tmpvar_45 = gl_TexCoord[0].xyz;
|
|
vec3 tmpvar_46;
|
|
tmpvar_46 = tmpvar_45;
|
|
xlt_IN_41.normal = tmpvar_46;
|
|
vec3 tmpvar_47;
|
|
tmpvar_47 = gl_TexCoord[1].xyz;
|
|
vec3 tmpvar_48;
|
|
tmpvar_48 = tmpvar_47;
|
|
xlt_IN_41.lightDir = tmpvar_48;
|
|
vec3 tmpvar_49;
|
|
tmpvar_49 = gl_TexCoord[2].xyz;
|
|
vec3 tmpvar_50;
|
|
tmpvar_50 = tmpvar_49;
|
|
xlt_IN_41._LightCoord = tmpvar_50;
|
|
vec4 tmpvar_51;
|
|
tmpvar_51 = frag_surf (xlt_IN_41);
|
|
vec4 tmpvar_52;
|
|
tmpvar_52 = tmpvar_51;
|
|
xl_retval_42 = tmpvar_52;
|
|
vec4 tmpvar_53;
|
|
tmpvar_53 = xl_retval_42.xyzw;
|
|
vec4 tmpvar_54;
|
|
tmpvar_54 = tmpvar_53;
|
|
gl_FragData[0] = tmpvar_54;
|
|
}
|
|
|