mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-29 02:55:36 -05:00
219 lines
4.8 KiB
Text
219 lines
4.8 KiB
Text
struct SurfaceOutput {
|
|
vec3 Albedo;
|
|
vec3 Normal;
|
|
vec3 Emission;
|
|
float Specular;
|
|
float Gloss;
|
|
float Alpha;
|
|
};
|
|
struct Input {
|
|
vec2 uv_MainTex;
|
|
vec2 uv_Illum;
|
|
vec2 uv_BumpMap;
|
|
};
|
|
struct v2f_surf {
|
|
vec4 pos;
|
|
float fog;
|
|
vec4 hip_pack0;
|
|
vec3 lightDir;
|
|
vec4 _LightCoord;
|
|
};
|
|
varying vec4 xlv_FOG;
|
|
uniform sampler2D _MainTex;
|
|
uniform sampler2D _LightTextureB0;
|
|
uniform sampler2D _LightTexture0;
|
|
uniform vec4 _LightColor0;
|
|
uniform sampler2D _Illum;
|
|
uniform vec4 _Color;
|
|
uniform sampler2D _BumpMap;
|
|
vec4 UnpackNormal (
|
|
in vec4 packednormal_1
|
|
)
|
|
{
|
|
vec4 normal_2;
|
|
vec2 tmpvar_3;
|
|
tmpvar_3 = ((packednormal_1.wy * 2.0) - 1.0);
|
|
normal_2.xy = tmpvar_3.xy.xy;
|
|
float tmpvar_4;
|
|
tmpvar_4 = sqrt (((1.0 - (normal_2.x * normal_2.x)) - (normal_2.y * normal_2.y)));
|
|
float tmpvar_5;
|
|
tmpvar_5 = tmpvar_4;
|
|
normal_2.z = vec3(tmpvar_5).z;
|
|
return normal_2;
|
|
}
|
|
|
|
void surf (
|
|
in Input IN_6,
|
|
inout SurfaceOutput o_7
|
|
)
|
|
{
|
|
vec4 c_8;
|
|
vec4 tex_9;
|
|
vec4 tmpvar_10;
|
|
tmpvar_10 = texture2D (_MainTex, IN_6.uv_MainTex);
|
|
vec4 tmpvar_11;
|
|
tmpvar_11 = tmpvar_10;
|
|
tex_9 = tmpvar_11;
|
|
vec4 tmpvar_12;
|
|
tmpvar_12 = (tex_9 * _Color);
|
|
c_8 = tmpvar_12;
|
|
vec3 tmpvar_13;
|
|
tmpvar_13 = c_8.xyz;
|
|
o_7.Albedo = tmpvar_13;
|
|
vec4 tmpvar_14;
|
|
tmpvar_14 = texture2D (_Illum, IN_6.uv_Illum);
|
|
vec3 tmpvar_15;
|
|
tmpvar_15 = (c_8.xyz * tmpvar_14.w);
|
|
o_7.Emission = tmpvar_15;
|
|
float tmpvar_16;
|
|
tmpvar_16 = c_8.w;
|
|
o_7.Alpha = tmpvar_16;
|
|
vec4 tmpvar_17;
|
|
tmpvar_17 = texture2D (_BumpMap, IN_6.uv_BumpMap);
|
|
vec4 tmpvar_18;
|
|
tmpvar_18 = UnpackNormal (tmpvar_17);
|
|
vec3 tmpvar_19;
|
|
tmpvar_19 = tmpvar_18.xyz;
|
|
vec3 tmpvar_20;
|
|
tmpvar_20 = tmpvar_19;
|
|
o_7.Normal = tmpvar_20;
|
|
}
|
|
|
|
float UnitySpotCookie (
|
|
in vec4 LightCoord_21
|
|
)
|
|
{
|
|
vec4 tmpvar_22;
|
|
tmpvar_22 = texture2D (_LightTexture0, ((LightCoord_21.xy / LightCoord_21.w) + 0.5));
|
|
return tmpvar_22.w;
|
|
}
|
|
|
|
float UnitySpotAttenuate (
|
|
in vec3 LightCoord_23
|
|
)
|
|
{
|
|
float tmpvar_24;
|
|
tmpvar_24 = dot (LightCoord_23, LightCoord_23);
|
|
vec2 tmpvar_25;
|
|
tmpvar_25 = vec2(tmpvar_24);
|
|
vec2 tmpvar_26;
|
|
tmpvar_26 = tmpvar_25.xy;
|
|
vec4 tmpvar_27;
|
|
tmpvar_27 = texture2D (_LightTextureB0, tmpvar_26);
|
|
return tmpvar_27.w;
|
|
}
|
|
|
|
vec4 LightingLambert (
|
|
in SurfaceOutput s_28,
|
|
in vec3 lightDir_29,
|
|
in float atten_30
|
|
)
|
|
{
|
|
vec4 c_31;
|
|
float diff_32;
|
|
float tmpvar_33;
|
|
tmpvar_33 = dot (s_28.Normal, lightDir_29);
|
|
float tmpvar_34;
|
|
tmpvar_34 = max (0.0, tmpvar_33);
|
|
float tmpvar_35;
|
|
tmpvar_35 = tmpvar_34;
|
|
diff_32 = tmpvar_35;
|
|
vec3 tmpvar_36;
|
|
tmpvar_36 = ((s_28.Albedo * _LightColor0.xyz) * ((diff_32 * atten_30) * 2.0));
|
|
c_31.xyz = tmpvar_36.xyz.xyz;
|
|
float tmpvar_37;
|
|
tmpvar_37 = s_28.Alpha;
|
|
c_31.w = vec4(tmpvar_37).w;
|
|
return c_31;
|
|
}
|
|
|
|
vec4 frag_surf (
|
|
in v2f_surf IN_38
|
|
)
|
|
{
|
|
vec4 c_39;
|
|
vec3 lightDir_40;
|
|
SurfaceOutput o_41;
|
|
Input surfIN_42;
|
|
vec2 tmpvar_43;
|
|
tmpvar_43 = IN_38.hip_pack0.xy;
|
|
surfIN_42.uv_MainTex = tmpvar_43;
|
|
vec2 tmpvar_44;
|
|
tmpvar_44 = IN_38.hip_pack0.zw;
|
|
surfIN_42.uv_BumpMap = tmpvar_44;
|
|
vec3 tmpvar_45;
|
|
tmpvar_45 = vec3(0.0, 0.0, 0.0);
|
|
o_41.Albedo = tmpvar_45;
|
|
vec3 tmpvar_46;
|
|
tmpvar_46 = vec3(0.0, 0.0, 0.0);
|
|
o_41.Emission = tmpvar_46;
|
|
float tmpvar_47;
|
|
tmpvar_47 = 0.0;
|
|
o_41.Specular = tmpvar_47;
|
|
float tmpvar_48;
|
|
tmpvar_48 = 0.0;
|
|
o_41.Alpha = tmpvar_48;
|
|
float tmpvar_49;
|
|
tmpvar_49 = 0.0;
|
|
o_41.Gloss = tmpvar_49;
|
|
surf (surfIN_42, o_41);
|
|
vec3 tmpvar_50;
|
|
tmpvar_50 = IN_38.lightDir;
|
|
lightDir_40 = tmpvar_50;
|
|
vec3 tmpvar_51;
|
|
tmpvar_51 = normalize (lightDir_40);
|
|
vec3 tmpvar_52;
|
|
tmpvar_52 = tmpvar_51;
|
|
lightDir_40 = tmpvar_52;
|
|
float tmpvar_53;
|
|
tmpvar_53 = UnitySpotCookie (IN_38._LightCoord);
|
|
float tmpvar_54;
|
|
tmpvar_54 = UnitySpotAttenuate (IN_38._LightCoord.xyz);
|
|
vec4 tmpvar_55;
|
|
tmpvar_55 = LightingLambert (o_41, lightDir_40, ((float((IN_38._LightCoord.z > 0.0)) * tmpvar_53) * tmpvar_54));
|
|
vec4 tmpvar_56;
|
|
tmpvar_56 = tmpvar_55;
|
|
c_39 = tmpvar_56;
|
|
float tmpvar_57;
|
|
tmpvar_57 = 0.0;
|
|
c_39.w = vec4(tmpvar_57).w;
|
|
return c_39;
|
|
}
|
|
|
|
void main ()
|
|
{
|
|
v2f_surf xlt_IN_58;
|
|
vec4 xl_retval_59;
|
|
vec4 tmpvar_60;
|
|
tmpvar_60 = vec4(0.0, 0.0, 0.0, 0.0);
|
|
xlt_IN_58.pos = tmpvar_60;
|
|
float tmpvar_61;
|
|
tmpvar_61 = xlv_FOG.x;
|
|
xlt_IN_58.fog = tmpvar_61;
|
|
vec4 tmpvar_62;
|
|
tmpvar_62 = gl_TexCoord[0].xyzw;
|
|
vec4 tmpvar_63;
|
|
tmpvar_63 = tmpvar_62;
|
|
xlt_IN_58.hip_pack0 = tmpvar_63;
|
|
vec3 tmpvar_64;
|
|
tmpvar_64 = gl_TexCoord[1].xyz;
|
|
vec3 tmpvar_65;
|
|
tmpvar_65 = tmpvar_64;
|
|
xlt_IN_58.lightDir = tmpvar_65;
|
|
vec4 tmpvar_66;
|
|
tmpvar_66 = gl_TexCoord[2].xyzw;
|
|
vec4 tmpvar_67;
|
|
tmpvar_67 = tmpvar_66;
|
|
xlt_IN_58._LightCoord = tmpvar_67;
|
|
vec4 tmpvar_68;
|
|
tmpvar_68 = frag_surf (xlt_IN_58);
|
|
vec4 tmpvar_69;
|
|
tmpvar_69 = tmpvar_68;
|
|
xl_retval_59 = tmpvar_69;
|
|
vec4 tmpvar_70;
|
|
tmpvar_70 = xl_retval_59.xyzw;
|
|
vec4 tmpvar_71;
|
|
tmpvar_71 = tmpvar_70;
|
|
gl_FragData[0] = tmpvar_71;
|
|
}
|
|
|