mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-28 18:45:54 -05:00
237 lines
5.3 KiB
Text
237 lines
5.3 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;
|
|
vec2 _LightCoord;
|
|
};
|
|
varying vec4 xlv_FOG;
|
|
uniform sampler2D _ParallaxMap;
|
|
uniform float _Parallax;
|
|
uniform sampler2D _MainTex;
|
|
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;
|
|
}
|
|
|
|
vec4 LightingLambert (
|
|
in SurfaceOutput s_36,
|
|
in vec3 lightDir_37,
|
|
in float atten_38
|
|
)
|
|
{
|
|
vec4 c_39;
|
|
float diff_40;
|
|
float tmpvar_41;
|
|
tmpvar_41 = dot (s_36.Normal, lightDir_37);
|
|
float tmpvar_42;
|
|
tmpvar_42 = max (0.0, tmpvar_41);
|
|
float tmpvar_43;
|
|
tmpvar_43 = tmpvar_42;
|
|
diff_40 = tmpvar_43;
|
|
vec3 tmpvar_44;
|
|
tmpvar_44 = ((s_36.Albedo * _LightColor0.xyz) * ((diff_40 * atten_38) * 2.0));
|
|
c_39.xyz = tmpvar_44.xyz.xyz;
|
|
float tmpvar_45;
|
|
tmpvar_45 = s_36.Alpha;
|
|
c_39.w = vec4(tmpvar_45).w;
|
|
return c_39;
|
|
}
|
|
|
|
vec4 frag_surf (
|
|
in v2f_surf IN_46
|
|
)
|
|
{
|
|
vec4 c_47;
|
|
vec3 lightDir_48;
|
|
SurfaceOutput o_49;
|
|
Input surfIN_50;
|
|
vec2 tmpvar_51;
|
|
tmpvar_51 = IN_46.hip_pack0.xy;
|
|
surfIN_50.uv_MainTex = tmpvar_51;
|
|
vec2 tmpvar_52;
|
|
tmpvar_52 = IN_46.hip_pack0.zw;
|
|
surfIN_50.uv_BumpMap = tmpvar_52;
|
|
vec3 tmpvar_53;
|
|
tmpvar_53 = IN_46.viewDir;
|
|
surfIN_50.viewDir = tmpvar_53;
|
|
vec3 tmpvar_54;
|
|
tmpvar_54 = vec3(0.0, 0.0, 0.0);
|
|
o_49.Albedo = tmpvar_54;
|
|
vec3 tmpvar_55;
|
|
tmpvar_55 = vec3(0.0, 0.0, 0.0);
|
|
o_49.Emission = tmpvar_55;
|
|
float tmpvar_56;
|
|
tmpvar_56 = 0.0;
|
|
o_49.Specular = tmpvar_56;
|
|
float tmpvar_57;
|
|
tmpvar_57 = 0.0;
|
|
o_49.Alpha = tmpvar_57;
|
|
float tmpvar_58;
|
|
tmpvar_58 = 0.0;
|
|
o_49.Gloss = tmpvar_58;
|
|
surf (surfIN_50, o_49);
|
|
vec3 tmpvar_59;
|
|
tmpvar_59 = IN_46.lightDir;
|
|
lightDir_48 = tmpvar_59;
|
|
vec4 tmpvar_60;
|
|
tmpvar_60 = texture2D (_LightTexture0, IN_46._LightCoord);
|
|
vec4 tmpvar_61;
|
|
tmpvar_61 = LightingLambert (o_49, lightDir_48, (tmpvar_60.w * 1.0));
|
|
vec4 tmpvar_62;
|
|
tmpvar_62 = tmpvar_61;
|
|
c_47 = tmpvar_62;
|
|
float tmpvar_63;
|
|
tmpvar_63 = 0.0;
|
|
c_47.w = vec4(tmpvar_63).w;
|
|
return c_47;
|
|
}
|
|
|
|
void main ()
|
|
{
|
|
v2f_surf xlt_IN_64;
|
|
vec4 xl_retval_65;
|
|
vec4 tmpvar_66;
|
|
tmpvar_66 = vec4(0.0, 0.0, 0.0, 0.0);
|
|
xlt_IN_64.pos = tmpvar_66;
|
|
float tmpvar_67;
|
|
tmpvar_67 = xlv_FOG.x;
|
|
xlt_IN_64.fog = tmpvar_67;
|
|
vec4 tmpvar_68;
|
|
tmpvar_68 = gl_TexCoord[0].xyzw;
|
|
vec4 tmpvar_69;
|
|
tmpvar_69 = tmpvar_68;
|
|
xlt_IN_64.hip_pack0 = tmpvar_69;
|
|
vec3 tmpvar_70;
|
|
tmpvar_70 = gl_TexCoord[1].xyz;
|
|
vec3 tmpvar_71;
|
|
tmpvar_71 = tmpvar_70;
|
|
xlt_IN_64.viewDir = tmpvar_71;
|
|
vec3 tmpvar_72;
|
|
tmpvar_72 = gl_TexCoord[2].xyz;
|
|
vec3 tmpvar_73;
|
|
tmpvar_73 = tmpvar_72;
|
|
xlt_IN_64.lightDir = tmpvar_73;
|
|
vec2 tmpvar_74;
|
|
tmpvar_74 = gl_TexCoord[3].xy;
|
|
vec2 tmpvar_75;
|
|
tmpvar_75 = tmpvar_74;
|
|
xlt_IN_64._LightCoord = tmpvar_75;
|
|
vec4 tmpvar_76;
|
|
tmpvar_76 = frag_surf (xlt_IN_64);
|
|
vec4 tmpvar_77;
|
|
tmpvar_77 = tmpvar_76;
|
|
xl_retval_65 = tmpvar_77;
|
|
vec4 tmpvar_78;
|
|
tmpvar_78 = xl_retval_65.xyzw;
|
|
vec4 tmpvar_79;
|
|
tmpvar_79 = tmpvar_78;
|
|
gl_FragData[0] = tmpvar_79;
|
|
}
|
|
|