mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-12-11 08:41:31 -05:00
220 lines
4.9 KiB
Text
220 lines
4.9 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;
|
||
|
vec3 _LightCoord;
|
||
|
};
|
||
|
varying vec4 xlv_FOG;
|
||
|
uniform vec4 _SpecColor;
|
||
|
uniform float _Shininess;
|
||
|
uniform sampler2D _MainTex;
|
||
|
uniform sampler2D _LightTextureB0;
|
||
|
uniform samplerCube _LightTexture0;
|
||
|
uniform vec4 _LightColor0;
|
||
|
uniform float _Cutoff;
|
||
|
uniform vec4 _Color;
|
||
|
void xll_clip (
|
||
|
in float x_1
|
||
|
)
|
||
|
{
|
||
|
if ((x_1 < 0.0)) {
|
||
|
discard;
|
||
|
};
|
||
|
}
|
||
|
|
||
|
void surf (
|
||
|
in Input IN_2,
|
||
|
inout SurfaceOutput o_3
|
||
|
)
|
||
|
{
|
||
|
vec4 tex_4;
|
||
|
vec4 tmpvar_5;
|
||
|
tmpvar_5 = texture2D (_MainTex, IN_2.uv_MainTex);
|
||
|
vec4 tmpvar_6;
|
||
|
tmpvar_6 = tmpvar_5;
|
||
|
tex_4 = tmpvar_6;
|
||
|
vec3 tmpvar_7;
|
||
|
tmpvar_7 = (tex_4.xyz * _Color.xyz);
|
||
|
o_3.Albedo = tmpvar_7;
|
||
|
float tmpvar_8;
|
||
|
tmpvar_8 = tex_4.w;
|
||
|
o_3.Gloss = tmpvar_8;
|
||
|
float tmpvar_9;
|
||
|
tmpvar_9 = (tex_4.w * _Color.w);
|
||
|
o_3.Alpha = tmpvar_9;
|
||
|
float tmpvar_10;
|
||
|
tmpvar_10 = _Shininess;
|
||
|
o_3.Specular = tmpvar_10;
|
||
|
}
|
||
|
|
||
|
vec4 LightingBlinnPhong (
|
||
|
in SurfaceOutput s_11,
|
||
|
in vec3 lightDir_12,
|
||
|
in vec3 viewDir_13,
|
||
|
in float atten_14
|
||
|
)
|
||
|
{
|
||
|
vec4 c_15;
|
||
|
float spec_16;
|
||
|
float nh_17;
|
||
|
float diff_18;
|
||
|
vec3 h_19;
|
||
|
vec3 tmpvar_20;
|
||
|
tmpvar_20 = normalize ((lightDir_12 + viewDir_13));
|
||
|
vec3 tmpvar_21;
|
||
|
tmpvar_21 = tmpvar_20;
|
||
|
h_19 = tmpvar_21;
|
||
|
float tmpvar_22;
|
||
|
tmpvar_22 = dot (s_11.Normal, lightDir_12);
|
||
|
float tmpvar_23;
|
||
|
tmpvar_23 = max (0.0, tmpvar_22);
|
||
|
float tmpvar_24;
|
||
|
tmpvar_24 = tmpvar_23;
|
||
|
diff_18 = tmpvar_24;
|
||
|
float tmpvar_25;
|
||
|
tmpvar_25 = dot (s_11.Normal, h_19);
|
||
|
float tmpvar_26;
|
||
|
tmpvar_26 = max (0.0, tmpvar_25);
|
||
|
float tmpvar_27;
|
||
|
tmpvar_27 = tmpvar_26;
|
||
|
nh_17 = tmpvar_27;
|
||
|
float tmpvar_28;
|
||
|
tmpvar_28 = pow (nh_17, (s_11.Specular * 128.0));
|
||
|
float tmpvar_29;
|
||
|
tmpvar_29 = (tmpvar_28 * s_11.Gloss);
|
||
|
spec_16 = tmpvar_29;
|
||
|
vec3 tmpvar_30;
|
||
|
tmpvar_30 = ((((s_11.Albedo * _LightColor0.xyz) * diff_18) + ((_LightColor0.xyz * _SpecColor.xyz) * spec_16)) * (atten_14 * 2.0));
|
||
|
c_15.xyz = tmpvar_30.xyz.xyz;
|
||
|
float tmpvar_31;
|
||
|
tmpvar_31 = (s_11.Alpha + (((_LightColor0.w * _SpecColor.w) * spec_16) * atten_14));
|
||
|
c_15.w = vec4(tmpvar_31).w;
|
||
|
return c_15;
|
||
|
}
|
||
|
|
||
|
vec4 frag_surf (
|
||
|
in v2f_surf IN_32
|
||
|
)
|
||
|
{
|
||
|
vec4 c_33;
|
||
|
vec3 lightDir_34;
|
||
|
SurfaceOutput o_35;
|
||
|
Input surfIN_36;
|
||
|
vec2 tmpvar_37;
|
||
|
tmpvar_37 = IN_32.hip_pack0.xy;
|
||
|
surfIN_36.uv_MainTex = tmpvar_37;
|
||
|
vec3 tmpvar_38;
|
||
|
tmpvar_38 = vec3(0.0, 0.0, 0.0);
|
||
|
o_35.Albedo = tmpvar_38;
|
||
|
vec3 tmpvar_39;
|
||
|
tmpvar_39 = vec3(0.0, 0.0, 0.0);
|
||
|
o_35.Emission = tmpvar_39;
|
||
|
float tmpvar_40;
|
||
|
tmpvar_40 = 0.0;
|
||
|
o_35.Specular = tmpvar_40;
|
||
|
float tmpvar_41;
|
||
|
tmpvar_41 = 0.0;
|
||
|
o_35.Alpha = tmpvar_41;
|
||
|
float tmpvar_42;
|
||
|
tmpvar_42 = 0.0;
|
||
|
o_35.Gloss = tmpvar_42;
|
||
|
vec3 tmpvar_43;
|
||
|
tmpvar_43 = IN_32.normal;
|
||
|
o_35.Normal = tmpvar_43;
|
||
|
surf (surfIN_36, o_35);
|
||
|
xll_clip ((o_35.Alpha - _Cutoff));
|
||
|
vec3 tmpvar_44;
|
||
|
tmpvar_44 = IN_32.lightDir;
|
||
|
lightDir_34 = tmpvar_44;
|
||
|
vec3 tmpvar_45;
|
||
|
tmpvar_45 = normalize (lightDir_34);
|
||
|
vec3 tmpvar_46;
|
||
|
tmpvar_46 = tmpvar_45;
|
||
|
lightDir_34 = tmpvar_46;
|
||
|
vec3 tmpvar_47;
|
||
|
tmpvar_47 = IN_32.viewDir.xyz;
|
||
|
vec3 tmpvar_48;
|
||
|
tmpvar_48 = normalize (tmpvar_47);
|
||
|
float tmpvar_49;
|
||
|
tmpvar_49 = dot (IN_32._LightCoord, IN_32._LightCoord);
|
||
|
vec2 tmpvar_50;
|
||
|
tmpvar_50 = vec2(tmpvar_49);
|
||
|
vec2 tmpvar_51;
|
||
|
tmpvar_51 = tmpvar_50.xy;
|
||
|
vec4 tmpvar_52;
|
||
|
tmpvar_52 = texture2D (_LightTextureB0, tmpvar_51);
|
||
|
vec4 tmpvar_53;
|
||
|
tmpvar_53 = textureCube (_LightTexture0, IN_32._LightCoord);
|
||
|
vec4 tmpvar_54;
|
||
|
tmpvar_54 = LightingBlinnPhong (o_35, lightDir_34, tmpvar_48, (tmpvar_52.w * tmpvar_53.w));
|
||
|
vec4 tmpvar_55;
|
||
|
tmpvar_55 = tmpvar_54;
|
||
|
c_33 = tmpvar_55;
|
||
|
float tmpvar_56;
|
||
|
tmpvar_56 = o_35.Alpha;
|
||
|
c_33.w = vec4(tmpvar_56).w;
|
||
|
return c_33;
|
||
|
}
|
||
|
|
||
|
void main ()
|
||
|
{
|
||
|
v2f_surf xlt_IN_57;
|
||
|
vec4 xl_retval_58;
|
||
|
vec4 tmpvar_59;
|
||
|
tmpvar_59 = vec4(0.0, 0.0, 0.0, 0.0);
|
||
|
xlt_IN_57.pos = tmpvar_59;
|
||
|
float tmpvar_60;
|
||
|
tmpvar_60 = xlv_FOG.x;
|
||
|
xlt_IN_57.fog = tmpvar_60;
|
||
|
vec2 tmpvar_61;
|
||
|
tmpvar_61 = gl_TexCoord[0].xy;
|
||
|
vec2 tmpvar_62;
|
||
|
tmpvar_62 = tmpvar_61;
|
||
|
xlt_IN_57.hip_pack0 = tmpvar_62;
|
||
|
vec3 tmpvar_63;
|
||
|
tmpvar_63 = gl_TexCoord[1].xyz;
|
||
|
vec3 tmpvar_64;
|
||
|
tmpvar_64 = tmpvar_63;
|
||
|
xlt_IN_57.normal = tmpvar_64;
|
||
|
vec3 tmpvar_65;
|
||
|
tmpvar_65 = gl_TexCoord[2].xyz;
|
||
|
vec3 tmpvar_66;
|
||
|
tmpvar_66 = tmpvar_65;
|
||
|
xlt_IN_57.lightDir = tmpvar_66;
|
||
|
vec3 tmpvar_67;
|
||
|
tmpvar_67 = gl_TexCoord[3].xyz;
|
||
|
vec3 tmpvar_68;
|
||
|
tmpvar_68 = tmpvar_67;
|
||
|
xlt_IN_57.viewDir = tmpvar_68;
|
||
|
vec3 tmpvar_69;
|
||
|
tmpvar_69 = gl_TexCoord[4].xyz;
|
||
|
vec3 tmpvar_70;
|
||
|
tmpvar_70 = tmpvar_69;
|
||
|
xlt_IN_57._LightCoord = tmpvar_70;
|
||
|
vec4 tmpvar_71;
|
||
|
tmpvar_71 = frag_surf (xlt_IN_57);
|
||
|
vec4 tmpvar_72;
|
||
|
tmpvar_72 = tmpvar_71;
|
||
|
xl_retval_58 = tmpvar_72;
|
||
|
vec4 tmpvar_73;
|
||
|
tmpvar_73 = xl_retval_58.xyzw;
|
||
|
vec4 tmpvar_74;
|
||
|
tmpvar_74 = tmpvar_73;
|
||
|
gl_FragData[0] = tmpvar_74;
|
||
|
}
|
||
|
|