mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-25 17:18:12 -05:00
218 lines
4.7 KiB
Text
218 lines
4.7 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;
|
||
|
vec4 hip_screen;
|
||
|
};
|
||
|
varying vec4 xlv_FOG;
|
||
|
uniform vec4 unity_Ambient;
|
||
|
uniform sampler2D _ParallaxMap;
|
||
|
uniform float _Parallax;
|
||
|
uniform sampler2D _MainTex;
|
||
|
uniform sampler2D _LightBuffer;
|
||
|
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;
|
||
|
vec4 tmpvar_25;
|
||
|
tmpvar_25 = texture2D (_MainTex, IN_14.uv_MainTex);
|
||
|
vec4 tmpvar_26;
|
||
|
tmpvar_26 = (tmpvar_25 * _Color);
|
||
|
c_16 = tmpvar_26;
|
||
|
vec3 tmpvar_27;
|
||
|
tmpvar_27 = c_16.xyz;
|
||
|
o_15.Albedo = tmpvar_27;
|
||
|
float tmpvar_28;
|
||
|
tmpvar_28 = c_16.w;
|
||
|
o_15.Alpha = tmpvar_28;
|
||
|
vec4 tmpvar_29;
|
||
|
tmpvar_29 = texture2D (_BumpMap, IN_14.uv_BumpMap);
|
||
|
vec4 tmpvar_30;
|
||
|
tmpvar_30 = UnpackNormal (tmpvar_29);
|
||
|
vec3 tmpvar_31;
|
||
|
tmpvar_31 = tmpvar_30.xyz;
|
||
|
vec3 tmpvar_32;
|
||
|
tmpvar_32 = tmpvar_31;
|
||
|
o_15.Normal = tmpvar_32;
|
||
|
}
|
||
|
|
||
|
vec4 LightingLambert_PrePass (
|
||
|
in SurfaceOutput s_33,
|
||
|
in vec4 light_34
|
||
|
)
|
||
|
{
|
||
|
vec4 c_35;
|
||
|
vec3 tmpvar_36;
|
||
|
tmpvar_36 = (s_33.Albedo * light_34.xyz);
|
||
|
c_35.xyz = tmpvar_36.xyz.xyz;
|
||
|
float tmpvar_37;
|
||
|
tmpvar_37 = s_33.Alpha;
|
||
|
c_35.w = vec4(tmpvar_37).w;
|
||
|
return c_35;
|
||
|
}
|
||
|
|
||
|
vec4 frag_surf (
|
||
|
in v2f_surf IN_38
|
||
|
)
|
||
|
{
|
||
|
vec4 col_39;
|
||
|
vec4 light_40;
|
||
|
SurfaceOutput o_41;
|
||
|
Input surfIN_42;
|
||
|
vec2 tmpvar_43;
|
||
|
tmpvar_43 = IN_38.hip_pack0.xy;
|
||
|
surfIN_42.uv_MainTex = tmpvar_43;
|
||
|
vec2 tmpvar_44;
|
||
|
tmpvar_44 = IN_38.hip_pack0.zw;
|
||
|
surfIN_42.uv_BumpMap = tmpvar_44;
|
||
|
vec3 tmpvar_45;
|
||
|
tmpvar_45 = IN_38.viewDir;
|
||
|
surfIN_42.viewDir = tmpvar_45;
|
||
|
vec3 tmpvar_46;
|
||
|
tmpvar_46 = vec3(0.0, 0.0, 0.0);
|
||
|
o_41.Albedo = tmpvar_46;
|
||
|
vec3 tmpvar_47;
|
||
|
tmpvar_47 = vec3(0.0, 0.0, 0.0);
|
||
|
o_41.Emission = tmpvar_47;
|
||
|
float tmpvar_48;
|
||
|
tmpvar_48 = 0.0;
|
||
|
o_41.Specular = tmpvar_48;
|
||
|
float tmpvar_49;
|
||
|
tmpvar_49 = 0.0;
|
||
|
o_41.Alpha = tmpvar_49;
|
||
|
float tmpvar_50;
|
||
|
tmpvar_50 = 0.0;
|
||
|
o_41.Gloss = tmpvar_50;
|
||
|
surf (surfIN_42, o_41);
|
||
|
vec4 tmpvar_51;
|
||
|
tmpvar_51 = texture2DProj (_LightBuffer, IN_38.hip_screen);
|
||
|
vec4 tmpvar_52;
|
||
|
tmpvar_52 = tmpvar_51;
|
||
|
light_40 = tmpvar_52;
|
||
|
vec4 tmpvar_53;
|
||
|
tmpvar_53 = log2 (light_40);
|
||
|
vec4 tmpvar_54;
|
||
|
tmpvar_54 = -(tmpvar_53);
|
||
|
light_40 = tmpvar_54;
|
||
|
vec3 tmpvar_55;
|
||
|
tmpvar_55 = (light_40.xyz + unity_Ambient.xyz);
|
||
|
light_40.xyz = tmpvar_55.xyz.xyz;
|
||
|
vec4 tmpvar_56;
|
||
|
tmpvar_56 = LightingLambert_PrePass (o_41, light_40);
|
||
|
vec4 tmpvar_57;
|
||
|
tmpvar_57 = tmpvar_56;
|
||
|
col_39 = tmpvar_57;
|
||
|
return col_39;
|
||
|
}
|
||
|
|
||
|
void main ()
|
||
|
{
|
||
|
v2f_surf xlt_IN_58;
|
||
|
vec4 xl_retval_59;
|
||
|
vec4 tmpvar_60;
|
||
|
tmpvar_60 = vec4(0.0, 0.0, 0.0, 0.0);
|
||
|
xlt_IN_58.pos = tmpvar_60;
|
||
|
float tmpvar_61;
|
||
|
tmpvar_61 = xlv_FOG.x;
|
||
|
xlt_IN_58.fog = tmpvar_61;
|
||
|
vec4 tmpvar_62;
|
||
|
tmpvar_62 = gl_TexCoord[0].xyzw;
|
||
|
vec4 tmpvar_63;
|
||
|
tmpvar_63 = tmpvar_62;
|
||
|
xlt_IN_58.hip_pack0 = tmpvar_63;
|
||
|
vec3 tmpvar_64;
|
||
|
tmpvar_64 = gl_TexCoord[1].xyz;
|
||
|
vec3 tmpvar_65;
|
||
|
tmpvar_65 = tmpvar_64;
|
||
|
xlt_IN_58.viewDir = tmpvar_65;
|
||
|
vec4 tmpvar_66;
|
||
|
tmpvar_66 = gl_TexCoord[2].xyzw;
|
||
|
vec4 tmpvar_67;
|
||
|
tmpvar_67 = tmpvar_66;
|
||
|
xlt_IN_58.hip_screen = tmpvar_67;
|
||
|
vec4 tmpvar_68;
|
||
|
tmpvar_68 = frag_surf (xlt_IN_58);
|
||
|
vec4 tmpvar_69;
|
||
|
tmpvar_69 = tmpvar_68;
|
||
|
xl_retval_59 = tmpvar_69;
|
||
|
vec4 tmpvar_70;
|
||
|
tmpvar_70 = xl_retval_59.xyzw;
|
||
|
vec4 tmpvar_71;
|
||
|
tmpvar_71 = tmpvar_70;
|
||
|
gl_FragData[0] = tmpvar_71;
|
||
|
}
|
||
|
|