mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-12-01 11:56:58 -05:00
163 lines
3.4 KiB
Text
163 lines
3.4 KiB
Text
struct SurfaceOutput {
|
|
vec3 Albedo;
|
|
vec3 Normal;
|
|
vec3 Emission;
|
|
float Specular;
|
|
float Gloss;
|
|
float Alpha;
|
|
};
|
|
struct Input {
|
|
vec2 uv_MainTex;
|
|
vec2 uv_BumpMap;
|
|
};
|
|
struct v2f_surf {
|
|
vec4 pos;
|
|
float fog;
|
|
vec2 hip_pack0;
|
|
vec4 hip_screen;
|
|
};
|
|
varying vec4 xlv_FOG;
|
|
uniform vec4 unity_Ambient;
|
|
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;
|
|
}
|
|
|
|
void surf (
|
|
in Input IN_6,
|
|
inout SurfaceOutput o_7
|
|
)
|
|
{
|
|
vec4 c_8;
|
|
vec4 tmpvar_9;
|
|
tmpvar_9 = texture2D (_MainTex, IN_6.uv_MainTex);
|
|
vec4 tmpvar_10;
|
|
tmpvar_10 = (tmpvar_9 * _Color);
|
|
c_8 = tmpvar_10;
|
|
vec3 tmpvar_11;
|
|
tmpvar_11 = c_8.xyz;
|
|
o_7.Albedo = tmpvar_11;
|
|
float tmpvar_12;
|
|
tmpvar_12 = c_8.w;
|
|
o_7.Alpha = tmpvar_12;
|
|
vec4 tmpvar_13;
|
|
tmpvar_13 = texture2D (_BumpMap, IN_6.uv_BumpMap);
|
|
vec4 tmpvar_14;
|
|
tmpvar_14 = UnpackNormal (tmpvar_13);
|
|
vec3 tmpvar_15;
|
|
tmpvar_15 = tmpvar_14.xyz;
|
|
vec3 tmpvar_16;
|
|
tmpvar_16 = tmpvar_15;
|
|
o_7.Normal = tmpvar_16;
|
|
}
|
|
|
|
vec4 LightingLambert_PrePass (
|
|
in SurfaceOutput s_17,
|
|
in vec4 light_18
|
|
)
|
|
{
|
|
vec4 c_19;
|
|
vec3 tmpvar_20;
|
|
tmpvar_20 = (s_17.Albedo * light_18.xyz);
|
|
c_19.xyz = tmpvar_20.xyz.xyz;
|
|
float tmpvar_21;
|
|
tmpvar_21 = s_17.Alpha;
|
|
c_19.w = vec4(tmpvar_21).w;
|
|
return c_19;
|
|
}
|
|
|
|
vec4 frag_surf (
|
|
in v2f_surf IN_22
|
|
)
|
|
{
|
|
vec4 col_23;
|
|
vec4 light_24;
|
|
SurfaceOutput o_25;
|
|
Input surfIN_26;
|
|
vec2 tmpvar_27;
|
|
tmpvar_27 = IN_22.hip_pack0.xy;
|
|
surfIN_26.uv_MainTex = tmpvar_27;
|
|
vec3 tmpvar_28;
|
|
tmpvar_28 = vec3(0.0, 0.0, 0.0);
|
|
o_25.Albedo = tmpvar_28;
|
|
vec3 tmpvar_29;
|
|
tmpvar_29 = vec3(0.0, 0.0, 0.0);
|
|
o_25.Emission = tmpvar_29;
|
|
float tmpvar_30;
|
|
tmpvar_30 = 0.0;
|
|
o_25.Specular = tmpvar_30;
|
|
float tmpvar_31;
|
|
tmpvar_31 = 0.0;
|
|
o_25.Alpha = tmpvar_31;
|
|
float tmpvar_32;
|
|
tmpvar_32 = 0.0;
|
|
o_25.Gloss = tmpvar_32;
|
|
surf (surfIN_26, o_25);
|
|
vec4 tmpvar_33;
|
|
tmpvar_33 = texture2DProj (_LightBuffer, IN_22.hip_screen);
|
|
vec4 tmpvar_34;
|
|
tmpvar_34 = tmpvar_33;
|
|
light_24 = tmpvar_34;
|
|
vec4 tmpvar_35;
|
|
tmpvar_35 = log2 (light_24);
|
|
vec4 tmpvar_36;
|
|
tmpvar_36 = -(tmpvar_35);
|
|
light_24 = tmpvar_36;
|
|
vec3 tmpvar_37;
|
|
tmpvar_37 = (light_24.xyz + unity_Ambient.xyz);
|
|
light_24.xyz = tmpvar_37.xyz.xyz;
|
|
vec4 tmpvar_38;
|
|
tmpvar_38 = LightingLambert_PrePass (o_25, light_24);
|
|
vec4 tmpvar_39;
|
|
tmpvar_39 = tmpvar_38;
|
|
col_23 = tmpvar_39;
|
|
return col_23;
|
|
}
|
|
|
|
void main ()
|
|
{
|
|
v2f_surf xlt_IN_40;
|
|
vec4 xl_retval_41;
|
|
vec4 tmpvar_42;
|
|
tmpvar_42 = vec4(0.0, 0.0, 0.0, 0.0);
|
|
xlt_IN_40.pos = tmpvar_42;
|
|
float tmpvar_43;
|
|
tmpvar_43 = xlv_FOG.x;
|
|
xlt_IN_40.fog = tmpvar_43;
|
|
vec2 tmpvar_44;
|
|
tmpvar_44 = gl_TexCoord[0].xy;
|
|
vec2 tmpvar_45;
|
|
tmpvar_45 = tmpvar_44;
|
|
xlt_IN_40.hip_pack0 = tmpvar_45;
|
|
vec4 tmpvar_46;
|
|
tmpvar_46 = gl_TexCoord[1].xyzw;
|
|
vec4 tmpvar_47;
|
|
tmpvar_47 = tmpvar_46;
|
|
xlt_IN_40.hip_screen = tmpvar_47;
|
|
vec4 tmpvar_48;
|
|
tmpvar_48 = frag_surf (xlt_IN_40);
|
|
vec4 tmpvar_49;
|
|
tmpvar_49 = tmpvar_48;
|
|
xl_retval_41 = tmpvar_49;
|
|
vec4 tmpvar_50;
|
|
tmpvar_50 = xl_retval_41.xyzw;
|
|
vec4 tmpvar_51;
|
|
tmpvar_51 = tmpvar_50;
|
|
gl_FragData[0] = tmpvar_51;
|
|
}
|
|
|