mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-25 17:18:12 -05:00
246 lines
5.4 KiB
Text
246 lines
5.4 KiB
Text
struct SurfaceOutput {
|
|
vec3 Albedo;
|
|
vec3 Normal;
|
|
vec3 Emission;
|
|
float Specular;
|
|
float Gloss;
|
|
float Alpha;
|
|
};
|
|
struct Input {
|
|
vec2 uv_MainTex;
|
|
vec2 uv_BumpMap;
|
|
vec3 viewDir;
|
|
};
|
|
struct v2f_surf {
|
|
vec4 pos;
|
|
float fog;
|
|
vec4 hip_pack0;
|
|
vec3 viewDir;
|
|
vec3 lightDir;
|
|
vec3 vlight;
|
|
vec4 _ShadowCoord;
|
|
};
|
|
uniform sampler2D _BumpMap;
|
|
uniform vec4 _Color;
|
|
uniform vec4 _LightColor0;
|
|
uniform sampler2D _MainTex;
|
|
uniform float _Parallax;
|
|
uniform sampler2D _ParallaxMap;
|
|
uniform sampler2D _ShadowMapTexture;
|
|
varying vec4 xlv_FOG;
|
|
float unitySampleShadow (
|
|
in vec4 shadowCoord_1
|
|
)
|
|
{
|
|
float shadow_2;
|
|
vec4 tmpvar_3;
|
|
tmpvar_3 = texture2DProj (_ShadowMapTexture, shadowCoord_1);
|
|
float tmpvar_4;
|
|
tmpvar_4 = tmpvar_3.x;
|
|
shadow_2 = tmpvar_4;
|
|
return shadow_2;
|
|
}
|
|
|
|
vec4 UnpackNormal (
|
|
in vec4 packednormal_5
|
|
)
|
|
{
|
|
vec4 normal_6;
|
|
vec2 tmpvar_7;
|
|
tmpvar_7 = ((packednormal_5.wy * 2.0) - 1.0);
|
|
normal_6.xy = tmpvar_7.xy.xy;
|
|
float tmpvar_8;
|
|
tmpvar_8 = sqrt (((1.0 - (normal_6.x * normal_6.x)) - (normal_6.y * normal_6.y)));
|
|
float tmpvar_9;
|
|
tmpvar_9 = tmpvar_8;
|
|
normal_6.z = vec3(tmpvar_9).z;
|
|
return normal_6;
|
|
}
|
|
|
|
vec2 ParallaxOffset (
|
|
in float h_10,
|
|
in float height_11,
|
|
in vec3 viewDir_12
|
|
)
|
|
{
|
|
vec3 v_13;
|
|
float tmpvar_14;
|
|
tmpvar_14 = ((h_10 * height_11) - (height_11 / 2.0));
|
|
h_10 = tmpvar_14;
|
|
vec3 tmpvar_15;
|
|
tmpvar_15 = normalize (viewDir_12);
|
|
vec3 tmpvar_16;
|
|
tmpvar_16 = tmpvar_15;
|
|
v_13 = tmpvar_16;
|
|
float tmpvar_17;
|
|
tmpvar_17 = (v_13.z + 0.42);
|
|
v_13.z = vec3(tmpvar_17).z;
|
|
return (h_10 * (v_13.xy / v_13.z));
|
|
}
|
|
|
|
void surf (
|
|
in Input IN_18,
|
|
inout SurfaceOutput o_19
|
|
)
|
|
{
|
|
vec4 c_20;
|
|
vec2 offset_21;
|
|
float h_22;
|
|
vec4 tmpvar_23;
|
|
tmpvar_23 = texture2D (_ParallaxMap, IN_18.uv_BumpMap);
|
|
float tmpvar_24;
|
|
tmpvar_24 = tmpvar_23.w;
|
|
h_22 = tmpvar_24;
|
|
vec2 tmpvar_25;
|
|
tmpvar_25 = ParallaxOffset (h_22, _Parallax, IN_18.viewDir);
|
|
vec2 tmpvar_26;
|
|
tmpvar_26 = tmpvar_25;
|
|
offset_21 = tmpvar_26;
|
|
vec2 tmpvar_27;
|
|
tmpvar_27 = (IN_18.uv_MainTex + offset_21);
|
|
IN_18.uv_MainTex = tmpvar_27;
|
|
vec2 tmpvar_28;
|
|
tmpvar_28 = (IN_18.uv_BumpMap + offset_21);
|
|
IN_18.uv_BumpMap = tmpvar_28;
|
|
vec4 tmpvar_29;
|
|
tmpvar_29 = texture2D (_MainTex, IN_18.uv_MainTex);
|
|
vec4 tmpvar_30;
|
|
tmpvar_30 = (tmpvar_29 * _Color);
|
|
c_20 = tmpvar_30;
|
|
vec3 tmpvar_31;
|
|
tmpvar_31 = c_20.xyz;
|
|
o_19.Albedo = tmpvar_31;
|
|
float tmpvar_32;
|
|
tmpvar_32 = c_20.w;
|
|
o_19.Alpha = tmpvar_32;
|
|
vec4 tmpvar_33;
|
|
tmpvar_33 = texture2D (_BumpMap, IN_18.uv_BumpMap);
|
|
vec4 tmpvar_34;
|
|
tmpvar_34 = UnpackNormal (tmpvar_33);
|
|
vec3 tmpvar_35;
|
|
tmpvar_35 = tmpvar_34.xyz;
|
|
vec3 tmpvar_36;
|
|
tmpvar_36 = tmpvar_35;
|
|
o_19.Normal = tmpvar_36;
|
|
}
|
|
|
|
vec4 LightingLambert (
|
|
in SurfaceOutput s_37,
|
|
in vec3 lightDir_38,
|
|
in float atten_39
|
|
)
|
|
{
|
|
vec4 c_40;
|
|
float diff_41;
|
|
float tmpvar_42;
|
|
tmpvar_42 = dot (s_37.Normal, lightDir_38);
|
|
float tmpvar_43;
|
|
tmpvar_43 = max (0.0, tmpvar_42);
|
|
float tmpvar_44;
|
|
tmpvar_44 = tmpvar_43;
|
|
diff_41 = tmpvar_44;
|
|
vec3 tmpvar_45;
|
|
tmpvar_45 = ((s_37.Albedo * _LightColor0.xyz) * ((diff_41 * atten_39) * 2.0));
|
|
c_40.xyz = tmpvar_45.xyz.xyz;
|
|
float tmpvar_46;
|
|
tmpvar_46 = s_37.Alpha;
|
|
c_40.w = vec4(tmpvar_46).w;
|
|
return c_40;
|
|
}
|
|
|
|
vec4 frag_surf (
|
|
in v2f_surf IN_47
|
|
)
|
|
{
|
|
vec4 c_48;
|
|
float atten_49;
|
|
SurfaceOutput o_50;
|
|
Input surfIN_51;
|
|
vec2 tmpvar_52;
|
|
tmpvar_52 = IN_47.hip_pack0.xy;
|
|
surfIN_51.uv_MainTex = tmpvar_52;
|
|
vec2 tmpvar_53;
|
|
tmpvar_53 = IN_47.hip_pack0.zw;
|
|
surfIN_51.uv_BumpMap = tmpvar_53;
|
|
vec3 tmpvar_54;
|
|
tmpvar_54 = IN_47.viewDir;
|
|
surfIN_51.viewDir = tmpvar_54;
|
|
vec3 tmpvar_55;
|
|
tmpvar_55 = vec3(0.0, 0.0, 0.0);
|
|
o_50.Albedo = tmpvar_55;
|
|
vec3 tmpvar_56;
|
|
tmpvar_56 = vec3(0.0, 0.0, 0.0);
|
|
o_50.Emission = tmpvar_56;
|
|
float tmpvar_57;
|
|
tmpvar_57 = 0.0;
|
|
o_50.Specular = tmpvar_57;
|
|
float tmpvar_58;
|
|
tmpvar_58 = 0.0;
|
|
o_50.Alpha = tmpvar_58;
|
|
float tmpvar_59;
|
|
tmpvar_59 = 0.0;
|
|
o_50.Gloss = tmpvar_59;
|
|
surf (surfIN_51, o_50);
|
|
float tmpvar_60;
|
|
tmpvar_60 = unitySampleShadow (IN_47._ShadowCoord);
|
|
float tmpvar_61;
|
|
tmpvar_61 = tmpvar_60;
|
|
atten_49 = tmpvar_61;
|
|
vec4 tmpvar_62;
|
|
tmpvar_62 = LightingLambert (o_50, IN_47.lightDir, atten_49);
|
|
vec4 tmpvar_63;
|
|
tmpvar_63 = tmpvar_62;
|
|
c_48 = tmpvar_63;
|
|
vec3 tmpvar_64;
|
|
tmpvar_64 = (c_48.xyz + (o_50.Albedo * IN_47.vlight));
|
|
c_48.xyz = tmpvar_64.xyz.xyz;
|
|
return c_48;
|
|
}
|
|
|
|
void main ()
|
|
{
|
|
v2f_surf xlt_IN_65;
|
|
vec4 xl_retval_66;
|
|
vec4 tmpvar_67;
|
|
tmpvar_67 = vec4(0.0, 0.0, 0.0, 0.0);
|
|
xlt_IN_65.pos = tmpvar_67;
|
|
float tmpvar_68;
|
|
tmpvar_68 = xlv_FOG.x;
|
|
xlt_IN_65.fog = tmpvar_68;
|
|
vec4 tmpvar_69;
|
|
tmpvar_69 = gl_TexCoord[0].xyzw;
|
|
vec4 tmpvar_70;
|
|
tmpvar_70 = tmpvar_69;
|
|
xlt_IN_65.hip_pack0 = tmpvar_70;
|
|
vec3 tmpvar_71;
|
|
tmpvar_71 = gl_TexCoord[1].xyz;
|
|
vec3 tmpvar_72;
|
|
tmpvar_72 = tmpvar_71;
|
|
xlt_IN_65.viewDir = tmpvar_72;
|
|
vec3 tmpvar_73;
|
|
tmpvar_73 = gl_TexCoord[2].xyz;
|
|
vec3 tmpvar_74;
|
|
tmpvar_74 = tmpvar_73;
|
|
xlt_IN_65.lightDir = tmpvar_74;
|
|
vec3 tmpvar_75;
|
|
tmpvar_75 = gl_TexCoord[3].xyz;
|
|
vec3 tmpvar_76;
|
|
tmpvar_76 = tmpvar_75;
|
|
xlt_IN_65.vlight = tmpvar_76;
|
|
vec4 tmpvar_77;
|
|
tmpvar_77 = gl_TexCoord[4].xyzw;
|
|
vec4 tmpvar_78;
|
|
tmpvar_78 = tmpvar_77;
|
|
xlt_IN_65._ShadowCoord = tmpvar_78;
|
|
vec4 tmpvar_79;
|
|
tmpvar_79 = frag_surf (xlt_IN_65);
|
|
vec4 tmpvar_80;
|
|
tmpvar_80 = tmpvar_79;
|
|
xl_retval_66 = tmpvar_80;
|
|
vec4 tmpvar_81;
|
|
tmpvar_81 = xl_retval_66.xyzw;
|
|
vec4 tmpvar_82;
|
|
tmpvar_82 = tmpvar_81;
|
|
gl_FragData[0] = tmpvar_82;
|
|
}
|
|
|