mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-12-04 21:31:11 -05:00
240 lines
5.3 KiB
Text
240 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;
|
||
|
vec2 hip_pack1;
|
||
|
vec3 viewDir;
|
||
|
vec4 hip_screen;
|
||
|
};
|
||
|
varying vec4 xlv_FOG;
|
||
|
uniform vec4 unity_Ambient;
|
||
|
uniform sampler2D _ParallaxMap;
|
||
|
uniform float _Parallax;
|
||
|
uniform sampler2D _MainTex;
|
||
|
uniform sampler2D _LightBuffer;
|
||
|
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_PrePass (
|
||
|
in SurfaceOutput s_36,
|
||
|
in vec4 light_37
|
||
|
)
|
||
|
{
|
||
|
vec4 c_38;
|
||
|
vec3 tmpvar_39;
|
||
|
tmpvar_39 = (s_36.Albedo * light_37.xyz);
|
||
|
c_38.xyz = tmpvar_39.xyz.xyz;
|
||
|
float tmpvar_40;
|
||
|
tmpvar_40 = s_36.Alpha;
|
||
|
c_38.w = vec4(tmpvar_40).w;
|
||
|
return c_38;
|
||
|
}
|
||
|
|
||
|
vec4 frag_surf (
|
||
|
in v2f_surf IN_41
|
||
|
)
|
||
|
{
|
||
|
vec4 col_42;
|
||
|
vec4 light_43;
|
||
|
SurfaceOutput o_44;
|
||
|
Input surfIN_45;
|
||
|
vec2 tmpvar_46;
|
||
|
tmpvar_46 = IN_41.hip_pack0.xy;
|
||
|
surfIN_45.uv_MainTex = tmpvar_46;
|
||
|
vec2 tmpvar_47;
|
||
|
tmpvar_47 = IN_41.hip_pack0.zw;
|
||
|
surfIN_45.uv_BumpMap = tmpvar_47;
|
||
|
vec2 tmpvar_48;
|
||
|
tmpvar_48 = IN_41.hip_pack1.xy;
|
||
|
surfIN_45.uv_Illum = tmpvar_48;
|
||
|
vec3 tmpvar_49;
|
||
|
tmpvar_49 = IN_41.viewDir;
|
||
|
surfIN_45.viewDir = tmpvar_49;
|
||
|
vec3 tmpvar_50;
|
||
|
tmpvar_50 = vec3(0.0, 0.0, 0.0);
|
||
|
o_44.Albedo = tmpvar_50;
|
||
|
vec3 tmpvar_51;
|
||
|
tmpvar_51 = vec3(0.0, 0.0, 0.0);
|
||
|
o_44.Emission = tmpvar_51;
|
||
|
float tmpvar_52;
|
||
|
tmpvar_52 = 0.0;
|
||
|
o_44.Specular = tmpvar_52;
|
||
|
float tmpvar_53;
|
||
|
tmpvar_53 = 0.0;
|
||
|
o_44.Alpha = tmpvar_53;
|
||
|
float tmpvar_54;
|
||
|
tmpvar_54 = 0.0;
|
||
|
o_44.Gloss = tmpvar_54;
|
||
|
surf (surfIN_45, o_44);
|
||
|
vec4 tmpvar_55;
|
||
|
tmpvar_55 = texture2DProj (_LightBuffer, IN_41.hip_screen);
|
||
|
vec4 tmpvar_56;
|
||
|
tmpvar_56 = tmpvar_55;
|
||
|
light_43 = tmpvar_56;
|
||
|
vec4 tmpvar_57;
|
||
|
tmpvar_57 = log2 (light_43);
|
||
|
vec4 tmpvar_58;
|
||
|
tmpvar_58 = -(tmpvar_57);
|
||
|
light_43 = tmpvar_58;
|
||
|
vec3 tmpvar_59;
|
||
|
tmpvar_59 = (light_43.xyz + unity_Ambient.xyz);
|
||
|
light_43.xyz = tmpvar_59.xyz.xyz;
|
||
|
vec4 tmpvar_60;
|
||
|
tmpvar_60 = LightingLambert_PrePass (o_44, light_43);
|
||
|
vec4 tmpvar_61;
|
||
|
tmpvar_61 = tmpvar_60;
|
||
|
col_42 = tmpvar_61;
|
||
|
vec3 tmpvar_62;
|
||
|
tmpvar_62 = (col_42.xyz + o_44.Emission);
|
||
|
col_42.xyz = tmpvar_62.xyz.xyz;
|
||
|
return col_42;
|
||
|
}
|
||
|
|
||
|
void main ()
|
||
|
{
|
||
|
v2f_surf xlt_IN_63;
|
||
|
vec4 xl_retval_64;
|
||
|
vec4 tmpvar_65;
|
||
|
tmpvar_65 = vec4(0.0, 0.0, 0.0, 0.0);
|
||
|
xlt_IN_63.pos = tmpvar_65;
|
||
|
float tmpvar_66;
|
||
|
tmpvar_66 = xlv_FOG.x;
|
||
|
xlt_IN_63.fog = tmpvar_66;
|
||
|
vec4 tmpvar_67;
|
||
|
tmpvar_67 = gl_TexCoord[0].xyzw;
|
||
|
vec4 tmpvar_68;
|
||
|
tmpvar_68 = tmpvar_67;
|
||
|
xlt_IN_63.hip_pack0 = tmpvar_68;
|
||
|
vec2 tmpvar_69;
|
||
|
tmpvar_69 = gl_TexCoord[1].xy;
|
||
|
vec2 tmpvar_70;
|
||
|
tmpvar_70 = tmpvar_69;
|
||
|
xlt_IN_63.hip_pack1 = tmpvar_70;
|
||
|
vec3 tmpvar_71;
|
||
|
tmpvar_71 = gl_TexCoord[2].xyz;
|
||
|
vec3 tmpvar_72;
|
||
|
tmpvar_72 = tmpvar_71;
|
||
|
xlt_IN_63.viewDir = tmpvar_72;
|
||
|
vec4 tmpvar_73;
|
||
|
tmpvar_73 = gl_TexCoord[3].xyzw;
|
||
|
vec4 tmpvar_74;
|
||
|
tmpvar_74 = tmpvar_73;
|
||
|
xlt_IN_63.hip_screen = tmpvar_74;
|
||
|
vec4 tmpvar_75;
|
||
|
tmpvar_75 = frag_surf (xlt_IN_63);
|
||
|
vec4 tmpvar_76;
|
||
|
tmpvar_76 = tmpvar_75;
|
||
|
xl_retval_64 = tmpvar_76;
|
||
|
vec4 tmpvar_77;
|
||
|
tmpvar_77 = xl_retval_64.xyzw;
|
||
|
vec4 tmpvar_78;
|
||
|
tmpvar_78 = tmpvar_77;
|
||
|
gl_FragData[0] = tmpvar_78;
|
||
|
}
|
||
|
|