mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-29 02:55:36 -05:00
269 lines
6 KiB
Text
269 lines
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;
|
|
vec2 uv_Illum;
|
|
vec3 viewDir;
|
|
};
|
|
struct v2f_surf {
|
|
vec4 pos;
|
|
float fog;
|
|
vec4 hip_pack0;
|
|
vec3 viewDir;
|
|
vec3 lightDir;
|
|
vec4 _LightCoord;
|
|
};
|
|
varying vec4 xlv_FOG;
|
|
uniform sampler2D _ParallaxMap;
|
|
uniform float _Parallax;
|
|
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;
|
|
}
|
|
|
|
vec2 ParallaxOffset (
|
|
in float h_6,
|
|
in float height_7,
|
|
in vec3 viewDir_8
|
|
)
|
|
{
|
|
vec3 v_9;
|
|
float tmpvar_10;
|
|
tmpvar_10 = ((h_6 * height_7) - (height_7 / 2.0));
|
|
h_6 = tmpvar_10;
|
|
vec3 tmpvar_11;
|
|
tmpvar_11 = normalize (viewDir_8);
|
|
vec3 tmpvar_12;
|
|
tmpvar_12 = tmpvar_11;
|
|
v_9 = tmpvar_12;
|
|
float tmpvar_13;
|
|
tmpvar_13 = (v_9.z + 0.42);
|
|
v_9.z = vec3(tmpvar_13).z;
|
|
return (h_6 * (v_9.xy / v_9.z));
|
|
}
|
|
|
|
void surf (
|
|
in Input IN_14,
|
|
inout SurfaceOutput o_15
|
|
)
|
|
{
|
|
vec4 c_16;
|
|
vec2 offset_17;
|
|
float h_18;
|
|
vec4 tmpvar_19;
|
|
tmpvar_19 = texture2D (_ParallaxMap, IN_14.uv_BumpMap);
|
|
float tmpvar_20;
|
|
tmpvar_20 = tmpvar_19.w;
|
|
h_18 = tmpvar_20;
|
|
vec2 tmpvar_21;
|
|
tmpvar_21 = ParallaxOffset (h_18, _Parallax, IN_14.viewDir);
|
|
vec2 tmpvar_22;
|
|
tmpvar_22 = tmpvar_21;
|
|
offset_17 = tmpvar_22;
|
|
vec2 tmpvar_23;
|
|
tmpvar_23 = (IN_14.uv_MainTex + offset_17);
|
|
IN_14.uv_MainTex = tmpvar_23;
|
|
vec2 tmpvar_24;
|
|
tmpvar_24 = (IN_14.uv_BumpMap + offset_17);
|
|
IN_14.uv_BumpMap = tmpvar_24;
|
|
vec2 tmpvar_25;
|
|
tmpvar_25 = (IN_14.uv_Illum + offset_17);
|
|
IN_14.uv_Illum = tmpvar_25;
|
|
vec4 tmpvar_26;
|
|
tmpvar_26 = texture2D (_MainTex, IN_14.uv_MainTex);
|
|
vec4 tmpvar_27;
|
|
tmpvar_27 = (tmpvar_26 * _Color);
|
|
c_16 = tmpvar_27;
|
|
vec3 tmpvar_28;
|
|
tmpvar_28 = c_16.xyz;
|
|
o_15.Albedo = tmpvar_28;
|
|
vec4 tmpvar_29;
|
|
tmpvar_29 = texture2D (_Illum, IN_14.uv_Illum);
|
|
vec3 tmpvar_30;
|
|
tmpvar_30 = (c_16.xyz * tmpvar_29.w);
|
|
o_15.Emission = tmpvar_30;
|
|
float tmpvar_31;
|
|
tmpvar_31 = c_16.w;
|
|
o_15.Alpha = tmpvar_31;
|
|
vec4 tmpvar_32;
|
|
tmpvar_32 = texture2D (_BumpMap, IN_14.uv_BumpMap);
|
|
vec4 tmpvar_33;
|
|
tmpvar_33 = UnpackNormal (tmpvar_32);
|
|
vec3 tmpvar_34;
|
|
tmpvar_34 = tmpvar_33.xyz;
|
|
vec3 tmpvar_35;
|
|
tmpvar_35 = tmpvar_34;
|
|
o_15.Normal = tmpvar_35;
|
|
}
|
|
|
|
float UnitySpotCookie (
|
|
in vec4 LightCoord_36
|
|
)
|
|
{
|
|
vec4 tmpvar_37;
|
|
tmpvar_37 = texture2D (_LightTexture0, ((LightCoord_36.xy / LightCoord_36.w) + 0.5));
|
|
return tmpvar_37.w;
|
|
}
|
|
|
|
float UnitySpotAttenuate (
|
|
in vec3 LightCoord_38
|
|
)
|
|
{
|
|
float tmpvar_39;
|
|
tmpvar_39 = dot (LightCoord_38, LightCoord_38);
|
|
vec2 tmpvar_40;
|
|
tmpvar_40 = vec2(tmpvar_39);
|
|
vec2 tmpvar_41;
|
|
tmpvar_41 = tmpvar_40.xy;
|
|
vec4 tmpvar_42;
|
|
tmpvar_42 = texture2D (_LightTextureB0, tmpvar_41);
|
|
return tmpvar_42.w;
|
|
}
|
|
|
|
vec4 LightingLambert (
|
|
in SurfaceOutput s_43,
|
|
in vec3 lightDir_44,
|
|
in float atten_45
|
|
)
|
|
{
|
|
vec4 c_46;
|
|
float diff_47;
|
|
float tmpvar_48;
|
|
tmpvar_48 = dot (s_43.Normal, lightDir_44);
|
|
float tmpvar_49;
|
|
tmpvar_49 = max (0.0, tmpvar_48);
|
|
float tmpvar_50;
|
|
tmpvar_50 = tmpvar_49;
|
|
diff_47 = tmpvar_50;
|
|
vec3 tmpvar_51;
|
|
tmpvar_51 = ((s_43.Albedo * _LightColor0.xyz) * ((diff_47 * atten_45) * 2.0));
|
|
c_46.xyz = tmpvar_51.xyz.xyz;
|
|
float tmpvar_52;
|
|
tmpvar_52 = s_43.Alpha;
|
|
c_46.w = vec4(tmpvar_52).w;
|
|
return c_46;
|
|
}
|
|
|
|
vec4 frag_surf (
|
|
in v2f_surf IN_53
|
|
)
|
|
{
|
|
vec4 c_54;
|
|
vec3 lightDir_55;
|
|
SurfaceOutput o_56;
|
|
Input surfIN_57;
|
|
vec2 tmpvar_58;
|
|
tmpvar_58 = IN_53.hip_pack0.xy;
|
|
surfIN_57.uv_MainTex = tmpvar_58;
|
|
vec2 tmpvar_59;
|
|
tmpvar_59 = IN_53.hip_pack0.zw;
|
|
surfIN_57.uv_BumpMap = tmpvar_59;
|
|
vec3 tmpvar_60;
|
|
tmpvar_60 = IN_53.viewDir;
|
|
surfIN_57.viewDir = tmpvar_60;
|
|
vec3 tmpvar_61;
|
|
tmpvar_61 = vec3(0.0, 0.0, 0.0);
|
|
o_56.Albedo = tmpvar_61;
|
|
vec3 tmpvar_62;
|
|
tmpvar_62 = vec3(0.0, 0.0, 0.0);
|
|
o_56.Emission = tmpvar_62;
|
|
float tmpvar_63;
|
|
tmpvar_63 = 0.0;
|
|
o_56.Specular = tmpvar_63;
|
|
float tmpvar_64;
|
|
tmpvar_64 = 0.0;
|
|
o_56.Alpha = tmpvar_64;
|
|
float tmpvar_65;
|
|
tmpvar_65 = 0.0;
|
|
o_56.Gloss = tmpvar_65;
|
|
surf (surfIN_57, o_56);
|
|
vec3 tmpvar_66;
|
|
tmpvar_66 = IN_53.lightDir;
|
|
lightDir_55 = tmpvar_66;
|
|
vec3 tmpvar_67;
|
|
tmpvar_67 = normalize (lightDir_55);
|
|
vec3 tmpvar_68;
|
|
tmpvar_68 = tmpvar_67;
|
|
lightDir_55 = tmpvar_68;
|
|
float tmpvar_69;
|
|
tmpvar_69 = UnitySpotCookie (IN_53._LightCoord);
|
|
float tmpvar_70;
|
|
tmpvar_70 = UnitySpotAttenuate (IN_53._LightCoord.xyz);
|
|
vec4 tmpvar_71;
|
|
tmpvar_71 = LightingLambert (o_56, lightDir_55, ((float((IN_53._LightCoord.z > 0.0)) * tmpvar_69) * tmpvar_70));
|
|
vec4 tmpvar_72;
|
|
tmpvar_72 = tmpvar_71;
|
|
c_54 = tmpvar_72;
|
|
float tmpvar_73;
|
|
tmpvar_73 = 0.0;
|
|
c_54.w = vec4(tmpvar_73).w;
|
|
return c_54;
|
|
}
|
|
|
|
void main ()
|
|
{
|
|
v2f_surf xlt_IN_74;
|
|
vec4 xl_retval_75;
|
|
vec4 tmpvar_76;
|
|
tmpvar_76 = vec4(0.0, 0.0, 0.0, 0.0);
|
|
xlt_IN_74.pos = tmpvar_76;
|
|
float tmpvar_77;
|
|
tmpvar_77 = xlv_FOG.x;
|
|
xlt_IN_74.fog = tmpvar_77;
|
|
vec4 tmpvar_78;
|
|
tmpvar_78 = gl_TexCoord[0].xyzw;
|
|
vec4 tmpvar_79;
|
|
tmpvar_79 = tmpvar_78;
|
|
xlt_IN_74.hip_pack0 = tmpvar_79;
|
|
vec3 tmpvar_80;
|
|
tmpvar_80 = gl_TexCoord[1].xyz;
|
|
vec3 tmpvar_81;
|
|
tmpvar_81 = tmpvar_80;
|
|
xlt_IN_74.viewDir = tmpvar_81;
|
|
vec3 tmpvar_82;
|
|
tmpvar_82 = gl_TexCoord[2].xyz;
|
|
vec3 tmpvar_83;
|
|
tmpvar_83 = tmpvar_82;
|
|
xlt_IN_74.lightDir = tmpvar_83;
|
|
vec4 tmpvar_84;
|
|
tmpvar_84 = gl_TexCoord[3].xyzw;
|
|
vec4 tmpvar_85;
|
|
tmpvar_85 = tmpvar_84;
|
|
xlt_IN_74._LightCoord = tmpvar_85;
|
|
vec4 tmpvar_86;
|
|
tmpvar_86 = frag_surf (xlt_IN_74);
|
|
vec4 tmpvar_87;
|
|
tmpvar_87 = tmpvar_86;
|
|
xl_retval_75 = tmpvar_87;
|
|
vec4 tmpvar_88;
|
|
tmpvar_88 = xl_retval_75.xyzw;
|
|
vec4 tmpvar_89;
|
|
tmpvar_89 = tmpvar_88;
|
|
gl_FragData[0] = tmpvar_89;
|
|
}
|
|
|