mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-12-11 00:31:28 -05:00
200 lines
4.1 KiB
Text
200 lines
4.1 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;
|
|
vec4 _LightCoord;
|
|
};
|
|
uniform vec4 _Color;
|
|
uniform float _Cutoff;
|
|
uniform vec4 _LightColor0;
|
|
uniform sampler2D _LightTexture0;
|
|
uniform sampler2D _LightTextureB0;
|
|
uniform sampler2D _MainTex;
|
|
varying vec4 xlv_FOG;
|
|
void xll_clip (
|
|
in float x_1
|
|
)
|
|
{
|
|
if ((x_1 < 0.0)) {
|
|
discard;
|
|
};
|
|
}
|
|
|
|
void surf (
|
|
in Input IN_2,
|
|
inout SurfaceOutput o_3
|
|
)
|
|
{
|
|
vec4 c_4;
|
|
vec4 tmpvar_5;
|
|
tmpvar_5 = texture2D (_MainTex, IN_2.uv_MainTex);
|
|
vec4 tmpvar_6;
|
|
tmpvar_6 = (tmpvar_5 * _Color);
|
|
c_4 = tmpvar_6;
|
|
vec3 tmpvar_7;
|
|
tmpvar_7 = c_4.xyz;
|
|
o_3.Albedo = tmpvar_7;
|
|
float tmpvar_8;
|
|
tmpvar_8 = c_4.w;
|
|
o_3.Alpha = tmpvar_8;
|
|
}
|
|
|
|
float UnitySpotCookie (
|
|
in vec4 LightCoord_9
|
|
)
|
|
{
|
|
vec4 tmpvar_10;
|
|
tmpvar_10 = texture2D (_LightTexture0, ((LightCoord_9.xy / LightCoord_9.w) + 0.5));
|
|
return tmpvar_10.w;
|
|
}
|
|
|
|
float UnitySpotAttenuate (
|
|
in vec3 LightCoord_11
|
|
)
|
|
{
|
|
float tmpvar_12;
|
|
tmpvar_12 = dot (LightCoord_11, LightCoord_11);
|
|
vec2 tmpvar_13;
|
|
tmpvar_13 = vec2(tmpvar_12);
|
|
vec2 tmpvar_14;
|
|
tmpvar_14 = tmpvar_13.xy;
|
|
vec4 tmpvar_15;
|
|
tmpvar_15 = texture2D (_LightTextureB0, tmpvar_14);
|
|
return tmpvar_15.w;
|
|
}
|
|
|
|
vec4 LightingLambert (
|
|
in SurfaceOutput s_16,
|
|
in vec3 lightDir_17,
|
|
in float atten_18
|
|
)
|
|
{
|
|
vec4 c_19;
|
|
float diff_20;
|
|
float tmpvar_21;
|
|
tmpvar_21 = dot (s_16.Normal, lightDir_17);
|
|
float tmpvar_22;
|
|
tmpvar_22 = max (0.0, tmpvar_21);
|
|
float tmpvar_23;
|
|
tmpvar_23 = tmpvar_22;
|
|
diff_20 = tmpvar_23;
|
|
vec3 tmpvar_24;
|
|
tmpvar_24 = ((s_16.Albedo * _LightColor0.xyz) * ((diff_20 * atten_18) * 2.0));
|
|
c_19.xyz = tmpvar_24.xyz.xyz;
|
|
float tmpvar_25;
|
|
tmpvar_25 = s_16.Alpha;
|
|
c_19.w = vec4(tmpvar_25).w;
|
|
return c_19;
|
|
}
|
|
|
|
vec4 frag_surf (
|
|
in v2f_surf IN_26
|
|
)
|
|
{
|
|
vec4 c_27;
|
|
vec3 lightDir_28;
|
|
SurfaceOutput o_29;
|
|
Input surfIN_30;
|
|
vec2 tmpvar_31;
|
|
tmpvar_31 = IN_26.hip_pack0.xy;
|
|
surfIN_30.uv_MainTex = tmpvar_31;
|
|
vec3 tmpvar_32;
|
|
tmpvar_32 = vec3(0.0, 0.0, 0.0);
|
|
o_29.Albedo = tmpvar_32;
|
|
vec3 tmpvar_33;
|
|
tmpvar_33 = vec3(0.0, 0.0, 0.0);
|
|
o_29.Emission = tmpvar_33;
|
|
float tmpvar_34;
|
|
tmpvar_34 = 0.0;
|
|
o_29.Specular = tmpvar_34;
|
|
float tmpvar_35;
|
|
tmpvar_35 = 0.0;
|
|
o_29.Alpha = tmpvar_35;
|
|
float tmpvar_36;
|
|
tmpvar_36 = 0.0;
|
|
o_29.Gloss = tmpvar_36;
|
|
vec3 tmpvar_37;
|
|
tmpvar_37 = IN_26.normal;
|
|
o_29.Normal = tmpvar_37;
|
|
surf (surfIN_30, o_29);
|
|
xll_clip ((o_29.Alpha - _Cutoff));
|
|
vec3 tmpvar_38;
|
|
tmpvar_38 = IN_26.lightDir;
|
|
lightDir_28 = tmpvar_38;
|
|
vec3 tmpvar_39;
|
|
tmpvar_39 = normalize (lightDir_28);
|
|
vec3 tmpvar_40;
|
|
tmpvar_40 = tmpvar_39;
|
|
lightDir_28 = tmpvar_40;
|
|
float tmpvar_41;
|
|
tmpvar_41 = UnitySpotCookie (IN_26._LightCoord);
|
|
float tmpvar_42;
|
|
tmpvar_42 = UnitySpotAttenuate (IN_26._LightCoord.xyz);
|
|
vec4 tmpvar_43;
|
|
tmpvar_43 = LightingLambert (o_29, lightDir_28, ((float(
|
|
(IN_26._LightCoord.z > 0.0)
|
|
) * tmpvar_41) * tmpvar_42));
|
|
vec4 tmpvar_44;
|
|
tmpvar_44 = tmpvar_43;
|
|
c_27 = tmpvar_44;
|
|
float tmpvar_45;
|
|
tmpvar_45 = o_29.Alpha;
|
|
c_27.w = vec4(tmpvar_45).w;
|
|
return c_27;
|
|
}
|
|
|
|
void main ()
|
|
{
|
|
v2f_surf xlt_IN_46;
|
|
vec4 xl_retval_47;
|
|
vec4 tmpvar_48;
|
|
tmpvar_48 = vec4(0.0, 0.0, 0.0, 0.0);
|
|
xlt_IN_46.pos = tmpvar_48;
|
|
float tmpvar_49;
|
|
tmpvar_49 = xlv_FOG.x;
|
|
xlt_IN_46.fog = tmpvar_49;
|
|
vec2 tmpvar_50;
|
|
tmpvar_50 = gl_TexCoord[0].xy;
|
|
vec2 tmpvar_51;
|
|
tmpvar_51 = tmpvar_50;
|
|
xlt_IN_46.hip_pack0 = tmpvar_51;
|
|
vec3 tmpvar_52;
|
|
tmpvar_52 = gl_TexCoord[1].xyz;
|
|
vec3 tmpvar_53;
|
|
tmpvar_53 = tmpvar_52;
|
|
xlt_IN_46.normal = tmpvar_53;
|
|
vec3 tmpvar_54;
|
|
tmpvar_54 = gl_TexCoord[2].xyz;
|
|
vec3 tmpvar_55;
|
|
tmpvar_55 = tmpvar_54;
|
|
xlt_IN_46.lightDir = tmpvar_55;
|
|
vec4 tmpvar_56;
|
|
tmpvar_56 = gl_TexCoord[3].xyzw;
|
|
vec4 tmpvar_57;
|
|
tmpvar_57 = tmpvar_56;
|
|
xlt_IN_46._LightCoord = tmpvar_57;
|
|
vec4 tmpvar_58;
|
|
tmpvar_58 = frag_surf (xlt_IN_46);
|
|
vec4 tmpvar_59;
|
|
tmpvar_59 = tmpvar_58;
|
|
xl_retval_47 = tmpvar_59;
|
|
vec4 tmpvar_60;
|
|
tmpvar_60 = xl_retval_47.xyzw;
|
|
vec4 tmpvar_61;
|
|
tmpvar_61 = tmpvar_60;
|
|
gl_FragData[0] = tmpvar_61;
|
|
}
|
|
|