mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-12-01 11:56:58 -05:00
295 lines
5.9 KiB
Text
295 lines
5.9 KiB
Text
struct SurfaceOutput {
|
|
vec3 Albedo;
|
|
vec3 Normal;
|
|
vec3 Emission;
|
|
float Specular;
|
|
float Gloss;
|
|
float Alpha;
|
|
};
|
|
struct Input {
|
|
vec2 uv_MainTex;
|
|
vec3 worldPos;
|
|
};
|
|
struct v2f_surf {
|
|
vec4 pos;
|
|
float fog;
|
|
vec2 hip_pack0;
|
|
vec3 worldPos;
|
|
vec4 hip_screen;
|
|
vec3 hip_lmapFade;
|
|
};
|
|
uniform sampler2D _LightBuffer;
|
|
uniform sampler2D _MainTex;
|
|
uniform sampler2D unity_Lightmap;
|
|
uniform sampler2D unity_LightmapInd;
|
|
varying vec4 xlv_FOG;
|
|
void xll_clip (
|
|
in float x_1
|
|
)
|
|
{
|
|
if ((x_1 < 0.0)) {
|
|
discard;
|
|
};
|
|
}
|
|
|
|
float xll_saturate (
|
|
in float x_2
|
|
)
|
|
{
|
|
float tmpvar_3;
|
|
tmpvar_3 = clamp (x_2, 0.0, 1.0);
|
|
return tmpvar_3;
|
|
}
|
|
|
|
vec2 xll_saturate (
|
|
in vec2 x_4
|
|
)
|
|
{
|
|
vec2 tmpvar_5;
|
|
tmpvar_5 = clamp (x_4, 0.0, 1.0);
|
|
return tmpvar_5;
|
|
}
|
|
|
|
vec3 xll_saturate (
|
|
in vec3 x_6
|
|
)
|
|
{
|
|
vec3 tmpvar_7;
|
|
tmpvar_7 = clamp (x_6, 0.0, 1.0);
|
|
return tmpvar_7;
|
|
}
|
|
|
|
vec4 xll_saturate (
|
|
in vec4 x_8
|
|
)
|
|
{
|
|
vec4 tmpvar_9;
|
|
tmpvar_9 = clamp (x_8, 0.0, 1.0);
|
|
return tmpvar_9;
|
|
}
|
|
|
|
mat2 xll_saturate (
|
|
in mat2 m_10
|
|
)
|
|
{
|
|
vec2 tmpvar_11;
|
|
tmpvar_11 = clamp (m_10[0], 0.0, 1.0);
|
|
vec2 tmpvar_12;
|
|
tmpvar_12 = clamp (m_10[1], 0.0, 1.0);
|
|
mat2 tmpvar_13;
|
|
vec2 tmpvar_14;
|
|
tmpvar_14 = tmpvar_11;
|
|
tmpvar_13[0] = tmpvar_14;
|
|
vec2 tmpvar_15;
|
|
tmpvar_15 = tmpvar_12;
|
|
tmpvar_13[1] = tmpvar_15;
|
|
return tmpvar_13;
|
|
}
|
|
|
|
mat3 xll_saturate (
|
|
in mat3 m_16
|
|
)
|
|
{
|
|
vec3 tmpvar_17;
|
|
tmpvar_17 = clamp (m_16[0], 0.0, 1.0);
|
|
vec3 tmpvar_18;
|
|
tmpvar_18 = clamp (m_16[1], 0.0, 1.0);
|
|
vec3 tmpvar_19;
|
|
tmpvar_19 = clamp (m_16[2], 0.0, 1.0);
|
|
mat3 tmpvar_20;
|
|
vec3 tmpvar_21;
|
|
tmpvar_21 = tmpvar_17;
|
|
tmpvar_20[0] = tmpvar_21;
|
|
vec3 tmpvar_22;
|
|
tmpvar_22 = tmpvar_18;
|
|
tmpvar_20[1] = tmpvar_22;
|
|
vec3 tmpvar_23;
|
|
tmpvar_23 = tmpvar_19;
|
|
tmpvar_20[2] = tmpvar_23;
|
|
return tmpvar_20;
|
|
}
|
|
|
|
mat4 xll_saturate (
|
|
in mat4 m_24
|
|
)
|
|
{
|
|
vec4 tmpvar_25;
|
|
tmpvar_25 = clamp (m_24[0], 0.0, 1.0);
|
|
vec4 tmpvar_26;
|
|
tmpvar_26 = clamp (m_24[1], 0.0, 1.0);
|
|
vec4 tmpvar_27;
|
|
tmpvar_27 = clamp (m_24[2], 0.0, 1.0);
|
|
vec4 tmpvar_28;
|
|
tmpvar_28 = clamp (m_24[3], 0.0, 1.0);
|
|
mat4 tmpvar_29;
|
|
vec4 tmpvar_30;
|
|
tmpvar_30 = tmpvar_25;
|
|
tmpvar_29[0] = tmpvar_30;
|
|
vec4 tmpvar_31;
|
|
tmpvar_31 = tmpvar_26;
|
|
tmpvar_29[1] = tmpvar_31;
|
|
vec4 tmpvar_32;
|
|
tmpvar_32 = tmpvar_27;
|
|
tmpvar_29[2] = tmpvar_32;
|
|
vec4 tmpvar_33;
|
|
tmpvar_33 = tmpvar_28;
|
|
tmpvar_29[3] = tmpvar_33;
|
|
return tmpvar_29;
|
|
}
|
|
|
|
void surf (
|
|
in Input IN_34,
|
|
inout SurfaceOutput o_35
|
|
)
|
|
{
|
|
float tmpvar_36;
|
|
tmpvar_36 = fract (((IN_34.worldPos.y + (IN_34.worldPos.z * 0.1)) * 5.0));
|
|
xll_clip ((tmpvar_36 - 0.5));
|
|
vec4 tmpvar_37;
|
|
tmpvar_37 = texture2D (_MainTex, IN_34.uv_MainTex);
|
|
vec3 tmpvar_38;
|
|
tmpvar_38 = tmpvar_37.xyz;
|
|
o_35.Albedo = tmpvar_38;
|
|
}
|
|
|
|
vec4 LightingLambert_PrePass (
|
|
in SurfaceOutput s_39,
|
|
in vec4 light_40
|
|
)
|
|
{
|
|
vec4 c_41;
|
|
vec3 tmpvar_42;
|
|
tmpvar_42 = (s_39.Albedo * light_40.xyz);
|
|
c_41.xyz = tmpvar_42.xyz.xyz;
|
|
float tmpvar_43;
|
|
tmpvar_43 = s_39.Alpha;
|
|
c_41.w = vec4(tmpvar_43).w;
|
|
return c_41;
|
|
}
|
|
|
|
vec3 DecodeLightmap (
|
|
in vec4 color_44
|
|
)
|
|
{
|
|
return (2.0 * color_44.xyz);
|
|
}
|
|
|
|
vec4 frag_surf (
|
|
in v2f_surf IN_45
|
|
)
|
|
{
|
|
vec4 col_46;
|
|
vec3 lm_47;
|
|
vec3 lmIndirect_48;
|
|
vec3 lmFull_49;
|
|
vec4 light_50;
|
|
SurfaceOutput o_51;
|
|
Input surfIN_52;
|
|
vec2 tmpvar_53;
|
|
tmpvar_53 = IN_45.hip_pack0.xy;
|
|
surfIN_52.uv_MainTex = tmpvar_53;
|
|
vec3 tmpvar_54;
|
|
tmpvar_54 = IN_45.worldPos;
|
|
surfIN_52.worldPos = tmpvar_54;
|
|
vec3 tmpvar_55;
|
|
tmpvar_55 = vec3(0.0, 0.0, 0.0);
|
|
o_51.Albedo = tmpvar_55;
|
|
vec3 tmpvar_56;
|
|
tmpvar_56 = vec3(0.0, 0.0, 0.0);
|
|
o_51.Emission = tmpvar_56;
|
|
float tmpvar_57;
|
|
tmpvar_57 = 0.0;
|
|
o_51.Specular = tmpvar_57;
|
|
float tmpvar_58;
|
|
tmpvar_58 = 0.0;
|
|
o_51.Alpha = tmpvar_58;
|
|
float tmpvar_59;
|
|
tmpvar_59 = 0.0;
|
|
o_51.Gloss = tmpvar_59;
|
|
surf (surfIN_52, o_51);
|
|
vec4 tmpvar_60;
|
|
tmpvar_60 = texture2DProj (_LightBuffer, IN_45.hip_screen);
|
|
vec4 tmpvar_61;
|
|
tmpvar_61 = tmpvar_60;
|
|
light_50 = tmpvar_61;
|
|
vec4 tmpvar_62;
|
|
tmpvar_62 = log2 (light_50);
|
|
vec4 tmpvar_63;
|
|
tmpvar_63 = -(tmpvar_62);
|
|
light_50 = tmpvar_63;
|
|
vec4 tmpvar_64;
|
|
tmpvar_64 = texture2D (unity_Lightmap, IN_45.hip_lmapFade.xy);
|
|
vec3 tmpvar_65;
|
|
tmpvar_65 = DecodeLightmap (tmpvar_64);
|
|
vec3 tmpvar_66;
|
|
tmpvar_66 = tmpvar_65;
|
|
lmFull_49 = tmpvar_66;
|
|
vec4 tmpvar_67;
|
|
tmpvar_67 = texture2D (unity_LightmapInd, IN_45.hip_lmapFade.xy);
|
|
vec3 tmpvar_68;
|
|
tmpvar_68 = DecodeLightmap (tmpvar_67);
|
|
vec3 tmpvar_69;
|
|
tmpvar_69 = tmpvar_68;
|
|
lmIndirect_48 = tmpvar_69;
|
|
float tmpvar_70;
|
|
tmpvar_70 = xll_saturate (IN_45.hip_lmapFade.z);
|
|
vec3 tmpvar_71;
|
|
tmpvar_71 = vec3(tmpvar_70);
|
|
vec3 tmpvar_72;
|
|
tmpvar_72 = mix (lmIndirect_48, lmFull_49, tmpvar_71);
|
|
vec3 tmpvar_73;
|
|
tmpvar_73 = tmpvar_72;
|
|
lm_47 = tmpvar_73;
|
|
vec3 tmpvar_74;
|
|
tmpvar_74 = (light_50.xyz + lm_47);
|
|
light_50.xyz = tmpvar_74.xyz.xyz;
|
|
vec4 tmpvar_75;
|
|
tmpvar_75 = LightingLambert_PrePass (o_51, light_50);
|
|
vec4 tmpvar_76;
|
|
tmpvar_76 = tmpvar_75;
|
|
col_46 = tmpvar_76;
|
|
return col_46;
|
|
}
|
|
|
|
void main ()
|
|
{
|
|
v2f_surf xlt_IN_77;
|
|
vec4 xl_retval_78;
|
|
vec4 tmpvar_79;
|
|
tmpvar_79 = vec4(0.0, 0.0, 0.0, 0.0);
|
|
xlt_IN_77.pos = tmpvar_79;
|
|
float tmpvar_80;
|
|
tmpvar_80 = xlv_FOG.x;
|
|
xlt_IN_77.fog = tmpvar_80;
|
|
vec2 tmpvar_81;
|
|
tmpvar_81 = gl_TexCoord[0].xy;
|
|
vec2 tmpvar_82;
|
|
tmpvar_82 = tmpvar_81;
|
|
xlt_IN_77.hip_pack0 = tmpvar_82;
|
|
vec3 tmpvar_83;
|
|
tmpvar_83 = gl_TexCoord[1].xyz;
|
|
vec3 tmpvar_84;
|
|
tmpvar_84 = tmpvar_83;
|
|
xlt_IN_77.worldPos = tmpvar_84;
|
|
vec4 tmpvar_85;
|
|
tmpvar_85 = gl_TexCoord[2].xyzw;
|
|
vec4 tmpvar_86;
|
|
tmpvar_86 = tmpvar_85;
|
|
xlt_IN_77.hip_screen = tmpvar_86;
|
|
vec3 tmpvar_87;
|
|
tmpvar_87 = gl_TexCoord[3].xyz;
|
|
vec3 tmpvar_88;
|
|
tmpvar_88 = tmpvar_87;
|
|
xlt_IN_77.hip_lmapFade = tmpvar_88;
|
|
vec4 tmpvar_89;
|
|
tmpvar_89 = frag_surf (xlt_IN_77);
|
|
vec4 tmpvar_90;
|
|
tmpvar_90 = tmpvar_89;
|
|
xl_retval_78 = tmpvar_90;
|
|
vec4 tmpvar_91;
|
|
tmpvar_91 = xl_retval_78.xyzw;
|
|
vec4 tmpvar_92;
|
|
tmpvar_92 = tmpvar_91;
|
|
gl_FragData[0] = tmpvar_92;
|
|
}
|
|
|