mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-25 17:18:12 -05:00
174 lines
3.6 KiB
Text
174 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;
|
|
vec2 hip_pack0;
|
|
vec4 hip_screen;
|
|
};
|
|
uniform sampler2D _BumpMap;
|
|
uniform vec4 _Color;
|
|
uniform float _Cutoff;
|
|
uniform sampler2D _LightBuffer;
|
|
uniform sampler2D _MainTex;
|
|
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 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_PrePass (
|
|
in SurfaceOutput s_18,
|
|
in vec4 light_19
|
|
)
|
|
{
|
|
vec4 c_20;
|
|
vec3 tmpvar_21;
|
|
tmpvar_21 = (s_18.Albedo * light_19.xyz);
|
|
c_20.xyz = tmpvar_21.xyz.xyz;
|
|
float tmpvar_22;
|
|
tmpvar_22 = s_18.Alpha;
|
|
c_20.w = vec4(tmpvar_22).w;
|
|
return c_20;
|
|
}
|
|
|
|
vec4 frag_surf (
|
|
in v2f_surf IN_23
|
|
)
|
|
{
|
|
vec4 col_24;
|
|
vec4 light_25;
|
|
SurfaceOutput o_26;
|
|
Input surfIN_27;
|
|
vec2 tmpvar_28;
|
|
tmpvar_28 = IN_23.hip_pack0.xy;
|
|
surfIN_27.uv_MainTex = tmpvar_28;
|
|
vec3 tmpvar_29;
|
|
tmpvar_29 = vec3(0.0, 0.0, 0.0);
|
|
o_26.Albedo = tmpvar_29;
|
|
vec3 tmpvar_30;
|
|
tmpvar_30 = vec3(0.0, 0.0, 0.0);
|
|
o_26.Emission = tmpvar_30;
|
|
float tmpvar_31;
|
|
tmpvar_31 = 0.0;
|
|
o_26.Specular = tmpvar_31;
|
|
float tmpvar_32;
|
|
tmpvar_32 = 0.0;
|
|
o_26.Alpha = tmpvar_32;
|
|
float tmpvar_33;
|
|
tmpvar_33 = 0.0;
|
|
o_26.Gloss = tmpvar_33;
|
|
surf (surfIN_27, o_26);
|
|
xll_clip ((o_26.Alpha - _Cutoff));
|
|
vec4 tmpvar_34;
|
|
tmpvar_34 = texture2DProj (_LightBuffer, IN_23.hip_screen);
|
|
vec4 tmpvar_35;
|
|
tmpvar_35 = tmpvar_34;
|
|
light_25 = tmpvar_35;
|
|
vec4 tmpvar_36;
|
|
tmpvar_36 = log2 (light_25);
|
|
vec4 tmpvar_37;
|
|
tmpvar_37 = -(tmpvar_36);
|
|
light_25 = tmpvar_37;
|
|
vec3 tmpvar_38;
|
|
tmpvar_38 = (light_25.xyz + unity_Ambient.xyz);
|
|
light_25.xyz = tmpvar_38.xyz.xyz;
|
|
vec4 tmpvar_39;
|
|
tmpvar_39 = LightingLambert_PrePass (o_26, light_25);
|
|
vec4 tmpvar_40;
|
|
tmpvar_40 = tmpvar_39;
|
|
col_24 = tmpvar_40;
|
|
return col_24;
|
|
}
|
|
|
|
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;
|
|
vec2 tmpvar_45;
|
|
tmpvar_45 = gl_TexCoord[0].xy;
|
|
vec2 tmpvar_46;
|
|
tmpvar_46 = tmpvar_45;
|
|
xlt_IN_41.hip_pack0 = tmpvar_46;
|
|
vec4 tmpvar_47;
|
|
tmpvar_47 = gl_TexCoord[1].xyzw;
|
|
vec4 tmpvar_48;
|
|
tmpvar_48 = tmpvar_47;
|
|
xlt_IN_41.hip_screen = tmpvar_48;
|
|
vec4 tmpvar_49;
|
|
tmpvar_49 = frag_surf (xlt_IN_41);
|
|
vec4 tmpvar_50;
|
|
tmpvar_50 = tmpvar_49;
|
|
xl_retval_42 = tmpvar_50;
|
|
vec4 tmpvar_51;
|
|
tmpvar_51 = xl_retval_42.xyzw;
|
|
vec4 tmpvar_52;
|
|
tmpvar_52 = tmpvar_51;
|
|
gl_FragData[0] = tmpvar_52;
|
|
}
|
|
|