mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-25 17:18:12 -05:00
192 lines
4.2 KiB
Text
192 lines
4.2 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;
|
|
};
|
|
uniform sampler2D _BumpMap;
|
|
uniform vec4 _Color;
|
|
uniform sampler2D _Illum;
|
|
uniform sampler2D _LightBuffer;
|
|
uniform sampler2D _MainTex;
|
|
uniform float _Shininess;
|
|
uniform vec4 _SpecColor;
|
|
uniform vec4 unity_Ambient;
|
|
varying vec4 xlv_FOG;
|
|
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 = tex_9.w;
|
|
o_7.Gloss = tmpvar_16;
|
|
float tmpvar_17;
|
|
tmpvar_17 = c_8.w;
|
|
o_7.Alpha = tmpvar_17;
|
|
float tmpvar_18;
|
|
tmpvar_18 = _Shininess;
|
|
o_7.Specular = tmpvar_18;
|
|
vec4 tmpvar_19;
|
|
tmpvar_19 = texture2D (_BumpMap, IN_6.uv_BumpMap);
|
|
vec4 tmpvar_20;
|
|
tmpvar_20 = UnpackNormal (tmpvar_19);
|
|
vec3 tmpvar_21;
|
|
tmpvar_21 = tmpvar_20.xyz;
|
|
vec3 tmpvar_22;
|
|
tmpvar_22 = tmpvar_21;
|
|
o_7.Normal = tmpvar_22;
|
|
}
|
|
|
|
vec4 LightingBlinnPhong_PrePass (
|
|
in SurfaceOutput s_23,
|
|
in vec4 light_24
|
|
)
|
|
{
|
|
vec4 c_25;
|
|
float spec_26;
|
|
float tmpvar_27;
|
|
tmpvar_27 = (light_24.w * s_23.Gloss);
|
|
spec_26 = tmpvar_27;
|
|
vec3 tmpvar_28;
|
|
tmpvar_28 = ((s_23.Albedo * light_24.xyz) + ((light_24.xyz * _SpecColor.xyz) * spec_26));
|
|
c_25.xyz = tmpvar_28.xyz.xyz;
|
|
float tmpvar_29;
|
|
tmpvar_29 = (s_23.Alpha + (spec_26 * _SpecColor.w));
|
|
c_25.w = vec4(tmpvar_29).w;
|
|
return c_25;
|
|
}
|
|
|
|
vec4 frag_surf (
|
|
in v2f_surf IN_30
|
|
)
|
|
{
|
|
vec4 col_31;
|
|
vec4 light_32;
|
|
SurfaceOutput o_33;
|
|
Input surfIN_34;
|
|
vec2 tmpvar_35;
|
|
tmpvar_35 = IN_30.hip_pack0.xy;
|
|
surfIN_34.uv_MainTex = tmpvar_35;
|
|
vec2 tmpvar_36;
|
|
tmpvar_36 = IN_30.hip_pack0.zw;
|
|
surfIN_34.uv_Illum = tmpvar_36;
|
|
vec3 tmpvar_37;
|
|
tmpvar_37 = vec3(0.0, 0.0, 0.0);
|
|
o_33.Albedo = tmpvar_37;
|
|
vec3 tmpvar_38;
|
|
tmpvar_38 = vec3(0.0, 0.0, 0.0);
|
|
o_33.Emission = tmpvar_38;
|
|
float tmpvar_39;
|
|
tmpvar_39 = 0.0;
|
|
o_33.Specular = tmpvar_39;
|
|
float tmpvar_40;
|
|
tmpvar_40 = 0.0;
|
|
o_33.Alpha = tmpvar_40;
|
|
float tmpvar_41;
|
|
tmpvar_41 = 0.0;
|
|
o_33.Gloss = tmpvar_41;
|
|
surf (surfIN_34, o_33);
|
|
vec4 tmpvar_42;
|
|
tmpvar_42 = texture2DProj (_LightBuffer, IN_30.hip_screen);
|
|
vec4 tmpvar_43;
|
|
tmpvar_43 = tmpvar_42;
|
|
light_32 = tmpvar_43;
|
|
vec4 tmpvar_44;
|
|
tmpvar_44 = log2 (light_32);
|
|
vec4 tmpvar_45;
|
|
tmpvar_45 = -(tmpvar_44);
|
|
light_32 = tmpvar_45;
|
|
vec3 tmpvar_46;
|
|
tmpvar_46 = (light_32.xyz + unity_Ambient.xyz);
|
|
light_32.xyz = tmpvar_46.xyz.xyz;
|
|
vec4 tmpvar_47;
|
|
tmpvar_47 = LightingBlinnPhong_PrePass (o_33, light_32);
|
|
vec4 tmpvar_48;
|
|
tmpvar_48 = tmpvar_47;
|
|
col_31 = tmpvar_48;
|
|
vec3 tmpvar_49;
|
|
tmpvar_49 = (col_31.xyz + o_33.Emission);
|
|
col_31.xyz = tmpvar_49.xyz.xyz;
|
|
return col_31;
|
|
}
|
|
|
|
void main ()
|
|
{
|
|
v2f_surf xlt_IN_50;
|
|
vec4 xl_retval_51;
|
|
vec4 tmpvar_52;
|
|
tmpvar_52 = vec4(0.0, 0.0, 0.0, 0.0);
|
|
xlt_IN_50.pos = tmpvar_52;
|
|
float tmpvar_53;
|
|
tmpvar_53 = xlv_FOG.x;
|
|
xlt_IN_50.fog = tmpvar_53;
|
|
vec4 tmpvar_54;
|
|
tmpvar_54 = gl_TexCoord[0].xyzw;
|
|
vec4 tmpvar_55;
|
|
tmpvar_55 = tmpvar_54;
|
|
xlt_IN_50.hip_pack0 = tmpvar_55;
|
|
vec4 tmpvar_56;
|
|
tmpvar_56 = gl_TexCoord[1].xyzw;
|
|
vec4 tmpvar_57;
|
|
tmpvar_57 = tmpvar_56;
|
|
xlt_IN_50.hip_screen = tmpvar_57;
|
|
vec4 tmpvar_58;
|
|
tmpvar_58 = frag_surf (xlt_IN_50);
|
|
vec4 tmpvar_59;
|
|
tmpvar_59 = tmpvar_58;
|
|
xl_retval_51 = tmpvar_59;
|
|
vec4 tmpvar_60;
|
|
tmpvar_60 = xl_retval_51.xyzw;
|
|
vec4 tmpvar_61;
|
|
tmpvar_61 = tmpvar_60;
|
|
gl_FragData[0] = tmpvar_61;
|
|
}
|
|
|