mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-12-11 00:31:28 -05:00
200 lines
4.4 KiB
Text
200 lines
4.4 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;
|
|
vec3 viewDir;
|
|
vec2 _LightCoord;
|
|
};
|
|
uniform vec4 _Color;
|
|
uniform vec4 _LightColor0;
|
|
uniform sampler2D _LightTexture0;
|
|
uniform sampler2D _MainTex;
|
|
uniform float _Shininess;
|
|
uniform vec4 _SpecColor;
|
|
varying vec4 xlv_FOG;
|
|
void surf (
|
|
in Input IN_1,
|
|
inout SurfaceOutput o_2
|
|
)
|
|
{
|
|
vec4 tex_3;
|
|
vec4 tmpvar_4;
|
|
tmpvar_4 = texture2D (_MainTex, IN_1.uv_MainTex);
|
|
vec4 tmpvar_5;
|
|
tmpvar_5 = tmpvar_4;
|
|
tex_3 = tmpvar_5;
|
|
vec3 tmpvar_6;
|
|
tmpvar_6 = (tex_3.xyz * _Color.xyz);
|
|
o_2.Albedo = tmpvar_6;
|
|
float tmpvar_7;
|
|
tmpvar_7 = tex_3.w;
|
|
o_2.Gloss = tmpvar_7;
|
|
float tmpvar_8;
|
|
tmpvar_8 = (tex_3.w * _Color.w);
|
|
o_2.Alpha = tmpvar_8;
|
|
float tmpvar_9;
|
|
tmpvar_9 = _Shininess;
|
|
o_2.Specular = tmpvar_9;
|
|
}
|
|
|
|
vec4 LightingBlinnPhong (
|
|
in SurfaceOutput s_10,
|
|
in vec3 lightDir_11,
|
|
in vec3 viewDir_12,
|
|
in float atten_13
|
|
)
|
|
{
|
|
vec4 c_14;
|
|
float spec_15;
|
|
float nh_16;
|
|
float diff_17;
|
|
vec3 h_18;
|
|
vec3 tmpvar_19;
|
|
tmpvar_19 = normalize ((lightDir_11 + viewDir_12));
|
|
vec3 tmpvar_20;
|
|
tmpvar_20 = tmpvar_19;
|
|
h_18 = tmpvar_20;
|
|
float tmpvar_21;
|
|
tmpvar_21 = dot (s_10.Normal, lightDir_11);
|
|
float tmpvar_22;
|
|
tmpvar_22 = max (0.0, tmpvar_21);
|
|
float tmpvar_23;
|
|
tmpvar_23 = tmpvar_22;
|
|
diff_17 = tmpvar_23;
|
|
float tmpvar_24;
|
|
tmpvar_24 = dot (s_10.Normal, h_18);
|
|
float tmpvar_25;
|
|
tmpvar_25 = max (0.0, tmpvar_24);
|
|
float tmpvar_26;
|
|
tmpvar_26 = tmpvar_25;
|
|
nh_16 = tmpvar_26;
|
|
float tmpvar_27;
|
|
tmpvar_27 = pow (nh_16, (s_10.Specular * 128.0));
|
|
float tmpvar_28;
|
|
tmpvar_28 = (tmpvar_27 * s_10.Gloss);
|
|
spec_15 = tmpvar_28;
|
|
vec3 tmpvar_29;
|
|
tmpvar_29 = (((
|
|
(s_10.Albedo * _LightColor0.xyz)
|
|
* diff_17) + (
|
|
(_LightColor0.xyz * _SpecColor.xyz)
|
|
* spec_15)) * (atten_13 * 2.0));
|
|
c_14.xyz = tmpvar_29.xyz.xyz;
|
|
float tmpvar_30;
|
|
tmpvar_30 = (s_10.Alpha + ((
|
|
(_LightColor0.w * _SpecColor.w)
|
|
* spec_15) * atten_13));
|
|
c_14.w = vec4(tmpvar_30).w;
|
|
return c_14;
|
|
}
|
|
|
|
vec4 frag_surf (
|
|
in v2f_surf IN_31
|
|
)
|
|
{
|
|
vec4 c_32;
|
|
vec3 lightDir_33;
|
|
SurfaceOutput o_34;
|
|
Input surfIN_35;
|
|
vec2 tmpvar_36;
|
|
tmpvar_36 = IN_31.hip_pack0.xy;
|
|
surfIN_35.uv_MainTex = tmpvar_36;
|
|
vec3 tmpvar_37;
|
|
tmpvar_37 = vec3(0.0, 0.0, 0.0);
|
|
o_34.Albedo = tmpvar_37;
|
|
vec3 tmpvar_38;
|
|
tmpvar_38 = vec3(0.0, 0.0, 0.0);
|
|
o_34.Emission = tmpvar_38;
|
|
float tmpvar_39;
|
|
tmpvar_39 = 0.0;
|
|
o_34.Specular = tmpvar_39;
|
|
float tmpvar_40;
|
|
tmpvar_40 = 0.0;
|
|
o_34.Alpha = tmpvar_40;
|
|
float tmpvar_41;
|
|
tmpvar_41 = 0.0;
|
|
o_34.Gloss = tmpvar_41;
|
|
vec3 tmpvar_42;
|
|
tmpvar_42 = IN_31.normal;
|
|
o_34.Normal = tmpvar_42;
|
|
surf (surfIN_35, o_34);
|
|
vec3 tmpvar_43;
|
|
tmpvar_43 = IN_31.lightDir;
|
|
lightDir_33 = tmpvar_43;
|
|
vec3 tmpvar_44;
|
|
tmpvar_44 = IN_31.viewDir.xyz;
|
|
vec3 tmpvar_45;
|
|
tmpvar_45 = normalize (tmpvar_44);
|
|
vec4 tmpvar_46;
|
|
tmpvar_46 = texture2D (_LightTexture0, IN_31._LightCoord);
|
|
vec4 tmpvar_47;
|
|
tmpvar_47 = LightingBlinnPhong (o_34, lightDir_33, tmpvar_45, (tmpvar_46.w * 1.0));
|
|
vec4 tmpvar_48;
|
|
tmpvar_48 = tmpvar_47;
|
|
c_32 = tmpvar_48;
|
|
float tmpvar_49;
|
|
tmpvar_49 = o_34.Alpha;
|
|
c_32.w = vec4(tmpvar_49).w;
|
|
return c_32;
|
|
}
|
|
|
|
void main ()
|
|
{
|
|
v2f_surf xlt_IN_50;
|
|
vec4 xl_retval_51;
|
|
vec4 tmpvar_52;
|
|
tmpvar_52 = vec4(0.0, 0.0, 0.0, 0.0);
|
|
xlt_IN_50.pos = tmpvar_52;
|
|
float tmpvar_53;
|
|
tmpvar_53 = xlv_FOG.x;
|
|
xlt_IN_50.fog = tmpvar_53;
|
|
vec2 tmpvar_54;
|
|
tmpvar_54 = gl_TexCoord[0].xy;
|
|
vec2 tmpvar_55;
|
|
tmpvar_55 = tmpvar_54;
|
|
xlt_IN_50.hip_pack0 = tmpvar_55;
|
|
vec3 tmpvar_56;
|
|
tmpvar_56 = gl_TexCoord[1].xyz;
|
|
vec3 tmpvar_57;
|
|
tmpvar_57 = tmpvar_56;
|
|
xlt_IN_50.normal = tmpvar_57;
|
|
vec3 tmpvar_58;
|
|
tmpvar_58 = gl_TexCoord[2].xyz;
|
|
vec3 tmpvar_59;
|
|
tmpvar_59 = tmpvar_58;
|
|
xlt_IN_50.lightDir = tmpvar_59;
|
|
vec3 tmpvar_60;
|
|
tmpvar_60 = gl_TexCoord[3].xyz;
|
|
vec3 tmpvar_61;
|
|
tmpvar_61 = tmpvar_60;
|
|
xlt_IN_50.viewDir = tmpvar_61;
|
|
vec2 tmpvar_62;
|
|
tmpvar_62 = gl_TexCoord[4].xy;
|
|
vec2 tmpvar_63;
|
|
tmpvar_63 = tmpvar_62;
|
|
xlt_IN_50._LightCoord = tmpvar_63;
|
|
vec4 tmpvar_64;
|
|
tmpvar_64 = frag_surf (xlt_IN_50);
|
|
vec4 tmpvar_65;
|
|
tmpvar_65 = tmpvar_64;
|
|
xl_retval_51 = tmpvar_65;
|
|
vec4 tmpvar_66;
|
|
tmpvar_66 = xl_retval_51.xyzw;
|
|
vec4 tmpvar_67;
|
|
tmpvar_67 = tmpvar_66;
|
|
gl_FragData[0] = tmpvar_67;
|
|
}
|
|
|