mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-29 02:55:36 -05:00
181 lines
3.9 KiB
Text
181 lines
3.9 KiB
Text
|
struct SurfaceOutput {
|
||
|
vec3 Albedo;
|
||
|
vec3 Normal;
|
||
|
vec3 Emission;
|
||
|
float Specular;
|
||
|
float Gloss;
|
||
|
float Alpha;
|
||
|
};
|
||
|
struct Input {
|
||
|
vec2 uv_MainTex;
|
||
|
vec2 uv_Illum;
|
||
|
vec2 uv_BumpMap;
|
||
|
};
|
||
|
struct v2f_surf {
|
||
|
vec4 pos;
|
||
|
float fog;
|
||
|
vec4 hip_pack0;
|
||
|
vec4 hip_screen;
|
||
|
};
|
||
|
varying vec4 xlv_FOG;
|
||
|
uniform vec4 unity_Ambient;
|
||
|
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;
|
||
|
}
|
||
|
|
||
|
void surf (
|
||
|
in Input IN_6,
|
||
|
inout SurfaceOutput o_7
|
||
|
)
|
||
|
{
|
||
|
vec4 c_8;
|
||
|
vec4 tex_9;
|
||
|
vec4 tmpvar_10;
|
||
|
tmpvar_10 = texture2D (_MainTex, IN_6.uv_MainTex);
|
||
|
vec4 tmpvar_11;
|
||
|
tmpvar_11 = tmpvar_10;
|
||
|
tex_9 = tmpvar_11;
|
||
|
vec4 tmpvar_12;
|
||
|
tmpvar_12 = (tex_9 * _Color);
|
||
|
c_8 = tmpvar_12;
|
||
|
vec3 tmpvar_13;
|
||
|
tmpvar_13 = c_8.xyz;
|
||
|
o_7.Albedo = tmpvar_13;
|
||
|
vec4 tmpvar_14;
|
||
|
tmpvar_14 = texture2D (_Illum, IN_6.uv_Illum);
|
||
|
vec3 tmpvar_15;
|
||
|
tmpvar_15 = (c_8.xyz * tmpvar_14.w);
|
||
|
o_7.Emission = tmpvar_15;
|
||
|
float tmpvar_16;
|
||
|
tmpvar_16 = c_8.w;
|
||
|
o_7.Alpha = tmpvar_16;
|
||
|
vec4 tmpvar_17;
|
||
|
tmpvar_17 = texture2D (_BumpMap, IN_6.uv_BumpMap);
|
||
|
vec4 tmpvar_18;
|
||
|
tmpvar_18 = UnpackNormal (tmpvar_17);
|
||
|
vec3 tmpvar_19;
|
||
|
tmpvar_19 = tmpvar_18.xyz;
|
||
|
vec3 tmpvar_20;
|
||
|
tmpvar_20 = tmpvar_19;
|
||
|
o_7.Normal = tmpvar_20;
|
||
|
}
|
||
|
|
||
|
vec4 LightingLambert_PrePass (
|
||
|
in SurfaceOutput s_21,
|
||
|
in vec4 light_22
|
||
|
)
|
||
|
{
|
||
|
vec4 c_23;
|
||
|
vec3 tmpvar_24;
|
||
|
tmpvar_24 = (s_21.Albedo * light_22.xyz);
|
||
|
c_23.xyz = tmpvar_24.xyz.xyz;
|
||
|
float tmpvar_25;
|
||
|
tmpvar_25 = s_21.Alpha;
|
||
|
c_23.w = vec4(tmpvar_25).w;
|
||
|
return c_23;
|
||
|
}
|
||
|
|
||
|
vec4 frag_surf (
|
||
|
in v2f_surf IN_26
|
||
|
)
|
||
|
{
|
||
|
vec4 col_27;
|
||
|
vec4 light_28;
|
||
|
SurfaceOutput o_29;
|
||
|
Input surfIN_30;
|
||
|
vec2 tmpvar_31;
|
||
|
tmpvar_31 = IN_26.hip_pack0.xy;
|
||
|
surfIN_30.uv_MainTex = tmpvar_31;
|
||
|
vec2 tmpvar_32;
|
||
|
tmpvar_32 = IN_26.hip_pack0.zw;
|
||
|
surfIN_30.uv_Illum = tmpvar_32;
|
||
|
vec3 tmpvar_33;
|
||
|
tmpvar_33 = vec3(0.0, 0.0, 0.0);
|
||
|
o_29.Albedo = tmpvar_33;
|
||
|
vec3 tmpvar_34;
|
||
|
tmpvar_34 = vec3(0.0, 0.0, 0.0);
|
||
|
o_29.Emission = tmpvar_34;
|
||
|
float tmpvar_35;
|
||
|
tmpvar_35 = 0.0;
|
||
|
o_29.Specular = tmpvar_35;
|
||
|
float tmpvar_36;
|
||
|
tmpvar_36 = 0.0;
|
||
|
o_29.Alpha = tmpvar_36;
|
||
|
float tmpvar_37;
|
||
|
tmpvar_37 = 0.0;
|
||
|
o_29.Gloss = tmpvar_37;
|
||
|
surf (surfIN_30, o_29);
|
||
|
vec4 tmpvar_38;
|
||
|
tmpvar_38 = texture2DProj (_LightBuffer, IN_26.hip_screen);
|
||
|
vec4 tmpvar_39;
|
||
|
tmpvar_39 = tmpvar_38;
|
||
|
light_28 = tmpvar_39;
|
||
|
vec4 tmpvar_40;
|
||
|
tmpvar_40 = log2 (light_28);
|
||
|
vec4 tmpvar_41;
|
||
|
tmpvar_41 = -(tmpvar_40);
|
||
|
light_28 = tmpvar_41;
|
||
|
vec3 tmpvar_42;
|
||
|
tmpvar_42 = (light_28.xyz + unity_Ambient.xyz);
|
||
|
light_28.xyz = tmpvar_42.xyz.xyz;
|
||
|
vec4 tmpvar_43;
|
||
|
tmpvar_43 = LightingLambert_PrePass (o_29, light_28);
|
||
|
vec4 tmpvar_44;
|
||
|
tmpvar_44 = tmpvar_43;
|
||
|
col_27 = tmpvar_44;
|
||
|
vec3 tmpvar_45;
|
||
|
tmpvar_45 = (col_27.xyz + o_29.Emission);
|
||
|
col_27.xyz = tmpvar_45.xyz.xyz;
|
||
|
return col_27;
|
||
|
}
|
||
|
|
||
|
void main ()
|
||
|
{
|
||
|
v2f_surf xlt_IN_46;
|
||
|
vec4 xl_retval_47;
|
||
|
vec4 tmpvar_48;
|
||
|
tmpvar_48 = vec4(0.0, 0.0, 0.0, 0.0);
|
||
|
xlt_IN_46.pos = tmpvar_48;
|
||
|
float tmpvar_49;
|
||
|
tmpvar_49 = xlv_FOG.x;
|
||
|
xlt_IN_46.fog = tmpvar_49;
|
||
|
vec4 tmpvar_50;
|
||
|
tmpvar_50 = gl_TexCoord[0].xyzw;
|
||
|
vec4 tmpvar_51;
|
||
|
tmpvar_51 = tmpvar_50;
|
||
|
xlt_IN_46.hip_pack0 = tmpvar_51;
|
||
|
vec4 tmpvar_52;
|
||
|
tmpvar_52 = gl_TexCoord[1].xyzw;
|
||
|
vec4 tmpvar_53;
|
||
|
tmpvar_53 = tmpvar_52;
|
||
|
xlt_IN_46.hip_screen = tmpvar_53;
|
||
|
vec4 tmpvar_54;
|
||
|
tmpvar_54 = frag_surf (xlt_IN_46);
|
||
|
vec4 tmpvar_55;
|
||
|
tmpvar_55 = tmpvar_54;
|
||
|
xl_retval_47 = tmpvar_55;
|
||
|
vec4 tmpvar_56;
|
||
|
tmpvar_56 = xl_retval_47.xyzw;
|
||
|
vec4 tmpvar_57;
|
||
|
tmpvar_57 = tmpvar_56;
|
||
|
gl_FragData[0] = tmpvar_57;
|
||
|
}
|
||
|
|