mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-25 00:58:30 -05:00
292 lines
6.6 KiB
Text
292 lines
6.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;
|
|
vec3 worldRefl;
|
|
vec3 viewDir;
|
|
vec3 TtoW0;
|
|
vec3 TtoW1;
|
|
vec3 TtoW2;
|
|
};
|
|
struct v2f_surf {
|
|
vec4 pos;
|
|
float fog;
|
|
vec4 hip_pack0;
|
|
vec3 viewDir;
|
|
vec4 hip_screen;
|
|
vec4 TtoW0;
|
|
vec4 TtoW1;
|
|
vec4 TtoW2;
|
|
};
|
|
varying vec4 xlv_FOG;
|
|
uniform vec4 unity_Ambient;
|
|
uniform vec4 _ReflectColor;
|
|
uniform sampler2D _ParallaxMap;
|
|
uniform float _Parallax;
|
|
uniform sampler2D _MainTex;
|
|
uniform sampler2D _LightBuffer;
|
|
uniform samplerCube _Cube;
|
|
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 reflcol_16;
|
|
vec3 worldRefl_17;
|
|
vec4 c_18;
|
|
vec4 tex_19;
|
|
vec2 offset_20;
|
|
float h_21;
|
|
vec4 tmpvar_22;
|
|
tmpvar_22 = texture2D (_ParallaxMap, IN_14.uv_BumpMap);
|
|
float tmpvar_23;
|
|
tmpvar_23 = tmpvar_22.w;
|
|
h_21 = tmpvar_23;
|
|
vec2 tmpvar_24;
|
|
tmpvar_24 = ParallaxOffset (h_21, _Parallax, IN_14.viewDir);
|
|
vec2 tmpvar_25;
|
|
tmpvar_25 = tmpvar_24;
|
|
offset_20 = tmpvar_25;
|
|
vec2 tmpvar_26;
|
|
tmpvar_26 = (IN_14.uv_MainTex + offset_20);
|
|
IN_14.uv_MainTex = tmpvar_26;
|
|
vec2 tmpvar_27;
|
|
tmpvar_27 = (IN_14.uv_BumpMap + offset_20);
|
|
IN_14.uv_BumpMap = tmpvar_27;
|
|
vec4 tmpvar_28;
|
|
tmpvar_28 = texture2D (_MainTex, IN_14.uv_MainTex);
|
|
vec4 tmpvar_29;
|
|
tmpvar_29 = tmpvar_28;
|
|
tex_19 = tmpvar_29;
|
|
vec4 tmpvar_30;
|
|
tmpvar_30 = (tex_19 * _Color);
|
|
c_18 = tmpvar_30;
|
|
vec3 tmpvar_31;
|
|
tmpvar_31 = c_18.xyz;
|
|
o_15.Albedo = 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 tmpvar_36;
|
|
tmpvar_36 = dot (IN_14.TtoW0, o_15.Normal);
|
|
float tmpvar_37;
|
|
tmpvar_37 = dot (IN_14.TtoW1, o_15.Normal);
|
|
float tmpvar_38;
|
|
tmpvar_38 = dot (IN_14.TtoW2, o_15.Normal);
|
|
vec3 tmpvar_39;
|
|
tmpvar_39.x = tmpvar_36;
|
|
tmpvar_39.y = tmpvar_37;
|
|
tmpvar_39.z = tmpvar_38;
|
|
vec3 tmpvar_40;
|
|
tmpvar_40 = reflect (IN_14.worldRefl, tmpvar_39);
|
|
vec3 tmpvar_41;
|
|
tmpvar_41 = tmpvar_40;
|
|
worldRefl_17 = tmpvar_41;
|
|
vec4 tmpvar_42;
|
|
tmpvar_42 = textureCube (_Cube, worldRefl_17);
|
|
vec4 tmpvar_43;
|
|
tmpvar_43 = tmpvar_42;
|
|
reflcol_16 = tmpvar_43;
|
|
vec4 tmpvar_44;
|
|
tmpvar_44 = (reflcol_16 * tex_19.w);
|
|
reflcol_16 = tmpvar_44;
|
|
vec3 tmpvar_45;
|
|
tmpvar_45 = (reflcol_16.xyz * _ReflectColor.xyz);
|
|
o_15.Emission = tmpvar_45;
|
|
float tmpvar_46;
|
|
tmpvar_46 = (reflcol_16.w * _ReflectColor.w);
|
|
o_15.Alpha = tmpvar_46;
|
|
}
|
|
|
|
vec4 LightingLambert_PrePass (
|
|
in SurfaceOutput s_47,
|
|
in vec4 light_48
|
|
)
|
|
{
|
|
vec4 c_49;
|
|
vec3 tmpvar_50;
|
|
tmpvar_50 = (s_47.Albedo * light_48.xyz);
|
|
c_49.xyz = tmpvar_50.xyz.xyz;
|
|
float tmpvar_51;
|
|
tmpvar_51 = s_47.Alpha;
|
|
c_49.w = vec4(tmpvar_51).w;
|
|
return c_49;
|
|
}
|
|
|
|
vec4 frag_surf (
|
|
in v2f_surf IN_52
|
|
)
|
|
{
|
|
vec4 col_53;
|
|
vec4 light_54;
|
|
SurfaceOutput o_55;
|
|
Input surfIN_56;
|
|
vec2 tmpvar_57;
|
|
tmpvar_57 = IN_52.hip_pack0.xy;
|
|
surfIN_56.uv_MainTex = tmpvar_57;
|
|
vec2 tmpvar_58;
|
|
tmpvar_58 = IN_52.hip_pack0.zw;
|
|
surfIN_56.uv_BumpMap = tmpvar_58;
|
|
vec3 tmpvar_59;
|
|
tmpvar_59.x = IN_52.TtoW0.w;
|
|
tmpvar_59.y = IN_52.TtoW1.w;
|
|
tmpvar_59.z = IN_52.TtoW2.w;
|
|
vec3 tmpvar_60;
|
|
tmpvar_60 = tmpvar_59;
|
|
surfIN_56.worldRefl = tmpvar_60;
|
|
vec3 tmpvar_61;
|
|
tmpvar_61 = IN_52.TtoW0.xyz;
|
|
surfIN_56.TtoW0 = tmpvar_61;
|
|
vec3 tmpvar_62;
|
|
tmpvar_62 = IN_52.TtoW1.xyz;
|
|
surfIN_56.TtoW1 = tmpvar_62;
|
|
vec3 tmpvar_63;
|
|
tmpvar_63 = IN_52.TtoW2.xyz;
|
|
surfIN_56.TtoW2 = tmpvar_63;
|
|
vec3 tmpvar_64;
|
|
tmpvar_64 = IN_52.viewDir;
|
|
surfIN_56.viewDir = tmpvar_64;
|
|
vec3 tmpvar_65;
|
|
tmpvar_65 = vec3(0.0, 0.0, 0.0);
|
|
o_55.Albedo = tmpvar_65;
|
|
vec3 tmpvar_66;
|
|
tmpvar_66 = vec3(0.0, 0.0, 0.0);
|
|
o_55.Emission = tmpvar_66;
|
|
float tmpvar_67;
|
|
tmpvar_67 = 0.0;
|
|
o_55.Specular = tmpvar_67;
|
|
float tmpvar_68;
|
|
tmpvar_68 = 0.0;
|
|
o_55.Alpha = tmpvar_68;
|
|
float tmpvar_69;
|
|
tmpvar_69 = 0.0;
|
|
o_55.Gloss = tmpvar_69;
|
|
surf (surfIN_56, o_55);
|
|
vec4 tmpvar_70;
|
|
tmpvar_70 = texture2DProj (_LightBuffer, IN_52.hip_screen);
|
|
vec4 tmpvar_71;
|
|
tmpvar_71 = tmpvar_70;
|
|
light_54 = tmpvar_71;
|
|
vec4 tmpvar_72;
|
|
tmpvar_72 = log2 (light_54);
|
|
vec4 tmpvar_73;
|
|
tmpvar_73 = -(tmpvar_72);
|
|
light_54 = tmpvar_73;
|
|
vec3 tmpvar_74;
|
|
tmpvar_74 = (light_54.xyz + unity_Ambient.xyz);
|
|
light_54.xyz = tmpvar_74.xyz.xyz;
|
|
vec4 tmpvar_75;
|
|
tmpvar_75 = LightingLambert_PrePass (o_55, light_54);
|
|
vec4 tmpvar_76;
|
|
tmpvar_76 = tmpvar_75;
|
|
col_53 = tmpvar_76;
|
|
vec3 tmpvar_77;
|
|
tmpvar_77 = (col_53.xyz + o_55.Emission);
|
|
col_53.xyz = tmpvar_77.xyz.xyz;
|
|
return col_53;
|
|
}
|
|
|
|
void main ()
|
|
{
|
|
v2f_surf xlt_IN_78;
|
|
vec4 xl_retval_79;
|
|
vec4 tmpvar_80;
|
|
tmpvar_80 = vec4(0.0, 0.0, 0.0, 0.0);
|
|
xlt_IN_78.pos = tmpvar_80;
|
|
float tmpvar_81;
|
|
tmpvar_81 = xlv_FOG.x;
|
|
xlt_IN_78.fog = tmpvar_81;
|
|
vec4 tmpvar_82;
|
|
tmpvar_82 = gl_TexCoord[0].xyzw;
|
|
vec4 tmpvar_83;
|
|
tmpvar_83 = tmpvar_82;
|
|
xlt_IN_78.hip_pack0 = tmpvar_83;
|
|
vec3 tmpvar_84;
|
|
tmpvar_84 = gl_TexCoord[1].xyz;
|
|
vec3 tmpvar_85;
|
|
tmpvar_85 = tmpvar_84;
|
|
xlt_IN_78.viewDir = tmpvar_85;
|
|
vec4 tmpvar_86;
|
|
tmpvar_86 = gl_TexCoord[2].xyzw;
|
|
vec4 tmpvar_87;
|
|
tmpvar_87 = tmpvar_86;
|
|
xlt_IN_78.hip_screen = tmpvar_87;
|
|
vec4 tmpvar_88;
|
|
tmpvar_88 = gl_TexCoord[3].xyzw;
|
|
vec4 tmpvar_89;
|
|
tmpvar_89 = tmpvar_88;
|
|
xlt_IN_78.TtoW0 = tmpvar_89;
|
|
vec4 tmpvar_90;
|
|
tmpvar_90 = gl_TexCoord[4].xyzw;
|
|
vec4 tmpvar_91;
|
|
tmpvar_91 = tmpvar_90;
|
|
xlt_IN_78.TtoW1 = tmpvar_91;
|
|
vec4 tmpvar_92;
|
|
tmpvar_92 = gl_TexCoord[5].xyzw;
|
|
vec4 tmpvar_93;
|
|
tmpvar_93 = tmpvar_92;
|
|
xlt_IN_78.TtoW2 = tmpvar_93;
|
|
vec4 tmpvar_94;
|
|
tmpvar_94 = frag_surf (xlt_IN_78);
|
|
vec4 tmpvar_95;
|
|
tmpvar_95 = tmpvar_94;
|
|
xl_retval_79 = tmpvar_95;
|
|
vec4 tmpvar_96;
|
|
tmpvar_96 = xl_retval_79.xyzw;
|
|
vec4 tmpvar_97;
|
|
tmpvar_97 = tmpvar_96;
|
|
gl_FragData[0] = tmpvar_97;
|
|
}
|
|
|