mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-28 18:45:54 -05:00
186 lines
3.9 KiB
Text
186 lines
3.9 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;
|
|
vec2 hip_pack0;
|
|
vec4 hip_screen;
|
|
};
|
|
uniform sampler2D _BumpMap;
|
|
uniform vec4 _Color;
|
|
uniform float _Cutoff;
|
|
uniform sampler2D _LightBuffer;
|
|
uniform sampler2D _MainTex;
|
|
uniform float _Shininess;
|
|
uniform vec4 _SpecColor;
|
|
uniform vec4 unity_Ambient;
|
|
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 tex_9;
|
|
vec4 tmpvar_10;
|
|
tmpvar_10 = texture2D (_MainTex, IN_7.uv_MainTex);
|
|
vec4 tmpvar_11;
|
|
tmpvar_11 = tmpvar_10;
|
|
tex_9 = tmpvar_11;
|
|
vec3 tmpvar_12;
|
|
tmpvar_12 = (tex_9.xyz * _Color.xyz);
|
|
o_8.Albedo = tmpvar_12;
|
|
float tmpvar_13;
|
|
tmpvar_13 = tex_9.w;
|
|
o_8.Gloss = tmpvar_13;
|
|
float tmpvar_14;
|
|
tmpvar_14 = (tex_9.w * _Color.w);
|
|
o_8.Alpha = tmpvar_14;
|
|
float tmpvar_15;
|
|
tmpvar_15 = _Shininess;
|
|
o_8.Specular = tmpvar_15;
|
|
vec4 tmpvar_16;
|
|
tmpvar_16 = texture2D (_BumpMap, IN_7.uv_BumpMap);
|
|
vec4 tmpvar_17;
|
|
tmpvar_17 = UnpackNormal (tmpvar_16);
|
|
vec3 tmpvar_18;
|
|
tmpvar_18 = tmpvar_17.xyz;
|
|
vec3 tmpvar_19;
|
|
tmpvar_19 = tmpvar_18;
|
|
o_8.Normal = tmpvar_19;
|
|
}
|
|
|
|
vec4 LightingBlinnPhong_PrePass (
|
|
in SurfaceOutput s_20,
|
|
in vec4 light_21
|
|
)
|
|
{
|
|
vec4 c_22;
|
|
float spec_23;
|
|
float tmpvar_24;
|
|
tmpvar_24 = (light_21.w * s_20.Gloss);
|
|
spec_23 = tmpvar_24;
|
|
vec3 tmpvar_25;
|
|
tmpvar_25 = ((s_20.Albedo * light_21.xyz) + ((light_21.xyz * _SpecColor.xyz) * spec_23));
|
|
c_22.xyz = tmpvar_25.xyz.xyz;
|
|
float tmpvar_26;
|
|
tmpvar_26 = (s_20.Alpha + (spec_23 * _SpecColor.w));
|
|
c_22.w = vec4(tmpvar_26).w;
|
|
return c_22;
|
|
}
|
|
|
|
vec4 frag_surf (
|
|
in v2f_surf IN_27
|
|
)
|
|
{
|
|
vec4 col_28;
|
|
vec4 light_29;
|
|
SurfaceOutput o_30;
|
|
Input surfIN_31;
|
|
vec2 tmpvar_32;
|
|
tmpvar_32 = IN_27.hip_pack0.xy;
|
|
surfIN_31.uv_MainTex = tmpvar_32;
|
|
vec3 tmpvar_33;
|
|
tmpvar_33 = vec3(0.0, 0.0, 0.0);
|
|
o_30.Albedo = tmpvar_33;
|
|
vec3 tmpvar_34;
|
|
tmpvar_34 = vec3(0.0, 0.0, 0.0);
|
|
o_30.Emission = tmpvar_34;
|
|
float tmpvar_35;
|
|
tmpvar_35 = 0.0;
|
|
o_30.Specular = tmpvar_35;
|
|
float tmpvar_36;
|
|
tmpvar_36 = 0.0;
|
|
o_30.Alpha = tmpvar_36;
|
|
float tmpvar_37;
|
|
tmpvar_37 = 0.0;
|
|
o_30.Gloss = tmpvar_37;
|
|
surf (surfIN_31, o_30);
|
|
xll_clip ((o_30.Alpha - _Cutoff));
|
|
vec4 tmpvar_38;
|
|
tmpvar_38 = texture2DProj (_LightBuffer, IN_27.hip_screen);
|
|
vec4 tmpvar_39;
|
|
tmpvar_39 = tmpvar_38;
|
|
light_29 = tmpvar_39;
|
|
vec4 tmpvar_40;
|
|
tmpvar_40 = log2 (light_29);
|
|
vec4 tmpvar_41;
|
|
tmpvar_41 = -(tmpvar_40);
|
|
light_29 = tmpvar_41;
|
|
vec3 tmpvar_42;
|
|
tmpvar_42 = (light_29.xyz + unity_Ambient.xyz);
|
|
light_29.xyz = tmpvar_42.xyz.xyz;
|
|
vec4 tmpvar_43;
|
|
tmpvar_43 = LightingBlinnPhong_PrePass (o_30, light_29);
|
|
vec4 tmpvar_44;
|
|
tmpvar_44 = tmpvar_43;
|
|
col_28 = tmpvar_44;
|
|
return col_28;
|
|
}
|
|
|
|
void main ()
|
|
{
|
|
v2f_surf xlt_IN_45;
|
|
vec4 xl_retval_46;
|
|
vec4 tmpvar_47;
|
|
tmpvar_47 = vec4(0.0, 0.0, 0.0, 0.0);
|
|
xlt_IN_45.pos = tmpvar_47;
|
|
float tmpvar_48;
|
|
tmpvar_48 = xlv_FOG.x;
|
|
xlt_IN_45.fog = tmpvar_48;
|
|
vec2 tmpvar_49;
|
|
tmpvar_49 = gl_TexCoord[0].xy;
|
|
vec2 tmpvar_50;
|
|
tmpvar_50 = tmpvar_49;
|
|
xlt_IN_45.hip_pack0 = tmpvar_50;
|
|
vec4 tmpvar_51;
|
|
tmpvar_51 = gl_TexCoord[1].xyzw;
|
|
vec4 tmpvar_52;
|
|
tmpvar_52 = tmpvar_51;
|
|
xlt_IN_45.hip_screen = tmpvar_52;
|
|
vec4 tmpvar_53;
|
|
tmpvar_53 = frag_surf (xlt_IN_45);
|
|
vec4 tmpvar_54;
|
|
tmpvar_54 = tmpvar_53;
|
|
xl_retval_46 = tmpvar_54;
|
|
vec4 tmpvar_55;
|
|
tmpvar_55 = xl_retval_46.xyzw;
|
|
vec4 tmpvar_56;
|
|
tmpvar_56 = tmpvar_55;
|
|
gl_FragData[0] = tmpvar_56;
|
|
}
|
|
|