mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-29 02:55:36 -05:00
178 lines
3.6 KiB
Text
178 lines
3.6 KiB
Text
struct SurfaceOutput {
|
|
vec3 Albedo;
|
|
vec3 Normal;
|
|
vec3 Emission;
|
|
float Specular;
|
|
float Gloss;
|
|
float Alpha;
|
|
};
|
|
struct Input {
|
|
vec2 uv_MainTex;
|
|
vec2 uv_BumpMap;
|
|
};
|
|
struct v2f_surf {
|
|
vec4 pos;
|
|
float fog;
|
|
vec4 hip_pack0;
|
|
vec3 lightDir;
|
|
};
|
|
uniform sampler2D _BumpMap;
|
|
uniform vec4 _Color;
|
|
uniform float _Cutoff;
|
|
uniform vec4 _LightColor0;
|
|
uniform sampler2D _MainTex;
|
|
varying vec4 xlv_FOG;
|
|
void xll_clip (
|
|
in float x_1
|
|
)
|
|
{
|
|
if ((x_1 < 0.0)) {
|
|
discard;
|
|
};
|
|
}
|
|
|
|
vec4 UnpackNormal (
|
|
in vec4 packednormal_2
|
|
)
|
|
{
|
|
vec4 normal_3;
|
|
vec2 tmpvar_4;
|
|
tmpvar_4 = ((packednormal_2.wy * 2.0) - 1.0);
|
|
normal_3.xy = tmpvar_4.xy.xy;
|
|
float tmpvar_5;
|
|
tmpvar_5 = sqrt (((1.0 - (normal_3.x * normal_3.x)) - (normal_3.y * normal_3.y)));
|
|
float tmpvar_6;
|
|
tmpvar_6 = tmpvar_5;
|
|
normal_3.z = vec3(tmpvar_6).z;
|
|
return normal_3;
|
|
}
|
|
|
|
void surf (
|
|
in Input IN_7,
|
|
inout SurfaceOutput o_8
|
|
)
|
|
{
|
|
vec4 c_9;
|
|
vec4 tmpvar_10;
|
|
tmpvar_10 = texture2D (_MainTex, IN_7.uv_MainTex);
|
|
vec4 tmpvar_11;
|
|
tmpvar_11 = (tmpvar_10 * _Color);
|
|
c_9 = tmpvar_11;
|
|
vec3 tmpvar_12;
|
|
tmpvar_12 = c_9.xyz;
|
|
o_8.Albedo = tmpvar_12;
|
|
float tmpvar_13;
|
|
tmpvar_13 = c_9.w;
|
|
o_8.Alpha = tmpvar_13;
|
|
vec4 tmpvar_14;
|
|
tmpvar_14 = texture2D (_BumpMap, IN_7.uv_BumpMap);
|
|
vec4 tmpvar_15;
|
|
tmpvar_15 = UnpackNormal (tmpvar_14);
|
|
vec3 tmpvar_16;
|
|
tmpvar_16 = tmpvar_15.xyz;
|
|
vec3 tmpvar_17;
|
|
tmpvar_17 = tmpvar_16;
|
|
o_8.Normal = tmpvar_17;
|
|
}
|
|
|
|
vec4 LightingLambert (
|
|
in SurfaceOutput s_18,
|
|
in vec3 lightDir_19,
|
|
in float atten_20
|
|
)
|
|
{
|
|
vec4 c_21;
|
|
float diff_22;
|
|
float tmpvar_23;
|
|
tmpvar_23 = dot (s_18.Normal, lightDir_19);
|
|
float tmpvar_24;
|
|
tmpvar_24 = max (0.0, tmpvar_23);
|
|
float tmpvar_25;
|
|
tmpvar_25 = tmpvar_24;
|
|
diff_22 = tmpvar_25;
|
|
vec3 tmpvar_26;
|
|
tmpvar_26 = ((s_18.Albedo * _LightColor0.xyz) * ((diff_22 * atten_20) * 2.0));
|
|
c_21.xyz = tmpvar_26.xyz.xyz;
|
|
float tmpvar_27;
|
|
tmpvar_27 = s_18.Alpha;
|
|
c_21.w = vec4(tmpvar_27).w;
|
|
return c_21;
|
|
}
|
|
|
|
vec4 frag_surf (
|
|
in v2f_surf IN_28
|
|
)
|
|
{
|
|
vec4 c_29;
|
|
vec3 lightDir_30;
|
|
SurfaceOutput o_31;
|
|
Input surfIN_32;
|
|
vec2 tmpvar_33;
|
|
tmpvar_33 = IN_28.hip_pack0.xy;
|
|
surfIN_32.uv_MainTex = tmpvar_33;
|
|
vec2 tmpvar_34;
|
|
tmpvar_34 = IN_28.hip_pack0.zw;
|
|
surfIN_32.uv_BumpMap = tmpvar_34;
|
|
vec3 tmpvar_35;
|
|
tmpvar_35 = vec3(0.0, 0.0, 0.0);
|
|
o_31.Albedo = tmpvar_35;
|
|
vec3 tmpvar_36;
|
|
tmpvar_36 = vec3(0.0, 0.0, 0.0);
|
|
o_31.Emission = tmpvar_36;
|
|
float tmpvar_37;
|
|
tmpvar_37 = 0.0;
|
|
o_31.Specular = tmpvar_37;
|
|
float tmpvar_38;
|
|
tmpvar_38 = 0.0;
|
|
o_31.Alpha = tmpvar_38;
|
|
float tmpvar_39;
|
|
tmpvar_39 = 0.0;
|
|
o_31.Gloss = tmpvar_39;
|
|
surf (surfIN_32, o_31);
|
|
xll_clip ((o_31.Alpha - _Cutoff));
|
|
vec3 tmpvar_40;
|
|
tmpvar_40 = IN_28.lightDir;
|
|
lightDir_30 = tmpvar_40;
|
|
vec4 tmpvar_41;
|
|
tmpvar_41 = LightingLambert (o_31, lightDir_30, 1.0);
|
|
vec4 tmpvar_42;
|
|
tmpvar_42 = tmpvar_41;
|
|
c_29 = tmpvar_42;
|
|
float tmpvar_43;
|
|
tmpvar_43 = o_31.Alpha;
|
|
c_29.w = vec4(tmpvar_43).w;
|
|
return c_29;
|
|
}
|
|
|
|
void main ()
|
|
{
|
|
v2f_surf xlt_IN_44;
|
|
vec4 xl_retval_45;
|
|
vec4 tmpvar_46;
|
|
tmpvar_46 = vec4(0.0, 0.0, 0.0, 0.0);
|
|
xlt_IN_44.pos = tmpvar_46;
|
|
float tmpvar_47;
|
|
tmpvar_47 = xlv_FOG.x;
|
|
xlt_IN_44.fog = tmpvar_47;
|
|
vec4 tmpvar_48;
|
|
tmpvar_48 = gl_TexCoord[0].xyzw;
|
|
vec4 tmpvar_49;
|
|
tmpvar_49 = tmpvar_48;
|
|
xlt_IN_44.hip_pack0 = tmpvar_49;
|
|
vec3 tmpvar_50;
|
|
tmpvar_50 = gl_TexCoord[1].xyz;
|
|
vec3 tmpvar_51;
|
|
tmpvar_51 = tmpvar_50;
|
|
xlt_IN_44.lightDir = tmpvar_51;
|
|
vec4 tmpvar_52;
|
|
tmpvar_52 = frag_surf (xlt_IN_44);
|
|
vec4 tmpvar_53;
|
|
tmpvar_53 = tmpvar_52;
|
|
xl_retval_45 = tmpvar_53;
|
|
vec4 tmpvar_54;
|
|
tmpvar_54 = xl_retval_45.xyzw;
|
|
vec4 tmpvar_55;
|
|
tmpvar_55 = tmpvar_54;
|
|
gl_FragData[0] = tmpvar_55;
|
|
}
|
|
|