mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-29 11:05:36 -05:00
329 lines
6.8 KiB
Text
329 lines
6.8 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;
|
|
vec3 _ShadowCoord0;
|
|
vec3 _ShadowCoord1;
|
|
vec3 _ShadowCoord2;
|
|
vec3 _ShadowCoord3;
|
|
vec2 _ShadowZFade;
|
|
vec3 worldPos;
|
|
};
|
|
uniform vec4 _LightShadowData;
|
|
uniform vec4 _LightSplitsFar;
|
|
uniform vec4 _LightSplitsNear;
|
|
uniform sampler2D _MainTex;
|
|
uniform vec4 _ProjectionParams;
|
|
uniform sampler2D _ShadowMapTexture;
|
|
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;
|
|
}
|
|
|
|
vec2 EncodeFloatRG (
|
|
in float v_39
|
|
)
|
|
{
|
|
vec2 enc_40;
|
|
float kEncodeBit_41;
|
|
vec2 kEncodeMul_42;
|
|
vec2 tmpvar_43;
|
|
tmpvar_43 = vec2(1.0, 255.0);
|
|
kEncodeMul_42 = tmpvar_43;
|
|
float tmpvar_44;
|
|
tmpvar_44 = 0.00392157;
|
|
kEncodeBit_41 = tmpvar_44;
|
|
vec2 tmpvar_45;
|
|
tmpvar_45 = (kEncodeMul_42 * v_39);
|
|
enc_40 = tmpvar_45;
|
|
vec2 tmpvar_46;
|
|
tmpvar_46 = fract (enc_40);
|
|
vec2 tmpvar_47;
|
|
tmpvar_47 = tmpvar_46;
|
|
enc_40 = tmpvar_47;
|
|
float tmpvar_48;
|
|
tmpvar_48 = (enc_40.x - (enc_40.y * kEncodeBit_41));
|
|
enc_40.x = tmpvar_48;
|
|
return enc_40;
|
|
}
|
|
|
|
vec4 frag_surf (
|
|
in v2f_surf IN_49
|
|
)
|
|
{
|
|
vec4 res_50;
|
|
float faded_51;
|
|
float shadow_52;
|
|
vec4 coord_53;
|
|
vec4 weights_54;
|
|
vec4 far_55;
|
|
vec4 near_56;
|
|
vec4 z_57;
|
|
SurfaceOutput o_58;
|
|
Input surfIN_59;
|
|
vec3 tmpvar_60;
|
|
tmpvar_60 = IN_49.worldPos;
|
|
surfIN_59.worldPos = tmpvar_60;
|
|
vec3 tmpvar_61;
|
|
tmpvar_61 = vec3(0.0, 0.0, 0.0);
|
|
o_58.Albedo = tmpvar_61;
|
|
vec3 tmpvar_62;
|
|
tmpvar_62 = vec3(0.0, 0.0, 0.0);
|
|
o_58.Emission = tmpvar_62;
|
|
float tmpvar_63;
|
|
tmpvar_63 = 0.0;
|
|
o_58.Specular = tmpvar_63;
|
|
float tmpvar_64;
|
|
tmpvar_64 = 0.0;
|
|
o_58.Alpha = tmpvar_64;
|
|
float tmpvar_65;
|
|
tmpvar_65 = 0.0;
|
|
o_58.Gloss = tmpvar_65;
|
|
surf (surfIN_59, o_58);
|
|
vec4 tmpvar_66;
|
|
tmpvar_66 = vec4(IN_49._ShadowZFade.x);
|
|
vec4 tmpvar_67;
|
|
tmpvar_67 = tmpvar_66;
|
|
z_57 = tmpvar_67;
|
|
bvec4 tmpvar_68;
|
|
tmpvar_68 = greaterThanEqual (z_57, _LightSplitsNear);
|
|
vec4 tmpvar_69;
|
|
tmpvar_69 = vec4(tmpvar_68).xyzw;
|
|
vec4 tmpvar_70;
|
|
tmpvar_70 = tmpvar_69;
|
|
near_56 = tmpvar_70;
|
|
bvec4 tmpvar_71;
|
|
tmpvar_71 = lessThan (z_57, _LightSplitsFar);
|
|
vec4 tmpvar_72;
|
|
tmpvar_72 = vec4(tmpvar_71).xyzw;
|
|
vec4 tmpvar_73;
|
|
tmpvar_73 = tmpvar_72;
|
|
far_55 = tmpvar_73;
|
|
vec4 tmpvar_74;
|
|
tmpvar_74 = (near_56 * far_55);
|
|
weights_54 = tmpvar_74;
|
|
vec4 tmpvar_75;
|
|
tmpvar_75.w = 1.0;
|
|
tmpvar_75.xyz = (((
|
|
(IN_49._ShadowCoord0 * weights_54.x)
|
|
+
|
|
(IN_49._ShadowCoord1 * weights_54.y)
|
|
) + (IN_49._ShadowCoord2 * weights_54.z)) + (IN_49._ShadowCoord3 * weights_54.w)).xyz;
|
|
vec4 tmpvar_76;
|
|
tmpvar_76 = tmpvar_75;
|
|
coord_53 = tmpvar_76;
|
|
vec4 tmpvar_77;
|
|
tmpvar_77 = texture2D (_ShadowMapTexture, coord_53.xy);
|
|
float tmpvar_78;
|
|
if ((tmpvar_77.x < coord_53.z)) {
|
|
tmpvar_78 = _LightShadowData.x;
|
|
} else {
|
|
tmpvar_78 = 1.0;
|
|
};
|
|
float tmpvar_79;
|
|
tmpvar_79 = tmpvar_78;
|
|
shadow_52 = tmpvar_79;
|
|
float tmpvar_80;
|
|
tmpvar_80 = xll_saturate (IN_49._ShadowZFade.y);
|
|
float tmpvar_81;
|
|
tmpvar_81 = xll_saturate ((shadow_52 + tmpvar_80));
|
|
float tmpvar_82;
|
|
tmpvar_82 = tmpvar_81;
|
|
faded_51 = tmpvar_82;
|
|
float tmpvar_83;
|
|
tmpvar_83 = faded_51;
|
|
res_50.x = tmpvar_83;
|
|
float tmpvar_84;
|
|
tmpvar_84 = 1.0;
|
|
res_50.y = vec2(tmpvar_84).y;
|
|
vec2 tmpvar_85;
|
|
tmpvar_85 = EncodeFloatRG ((1.0 - (z_57 * _ProjectionParams.w)).x);
|
|
vec2 tmpvar_86;
|
|
tmpvar_86 = tmpvar_85;
|
|
res_50.zw = tmpvar_86.xxxy.zw;
|
|
return res_50;
|
|
}
|
|
|
|
void main ()
|
|
{
|
|
v2f_surf xlt_IN_87;
|
|
vec4 xl_retval_88;
|
|
vec4 tmpvar_89;
|
|
tmpvar_89 = vec4(0.0, 0.0, 0.0, 0.0);
|
|
xlt_IN_87.pos = tmpvar_89;
|
|
vec3 tmpvar_90;
|
|
tmpvar_90 = gl_TexCoord[0].xyz;
|
|
vec3 tmpvar_91;
|
|
tmpvar_91 = tmpvar_90;
|
|
xlt_IN_87._ShadowCoord0 = tmpvar_91;
|
|
vec3 tmpvar_92;
|
|
tmpvar_92 = gl_TexCoord[1].xyz;
|
|
vec3 tmpvar_93;
|
|
tmpvar_93 = tmpvar_92;
|
|
xlt_IN_87._ShadowCoord1 = tmpvar_93;
|
|
vec3 tmpvar_94;
|
|
tmpvar_94 = gl_TexCoord[2].xyz;
|
|
vec3 tmpvar_95;
|
|
tmpvar_95 = tmpvar_94;
|
|
xlt_IN_87._ShadowCoord2 = tmpvar_95;
|
|
vec3 tmpvar_96;
|
|
tmpvar_96 = gl_TexCoord[3].xyz;
|
|
vec3 tmpvar_97;
|
|
tmpvar_97 = tmpvar_96;
|
|
xlt_IN_87._ShadowCoord3 = tmpvar_97;
|
|
vec2 tmpvar_98;
|
|
tmpvar_98 = gl_TexCoord[4].xy;
|
|
vec2 tmpvar_99;
|
|
tmpvar_99 = tmpvar_98;
|
|
xlt_IN_87._ShadowZFade = tmpvar_99;
|
|
vec3 tmpvar_100;
|
|
tmpvar_100 = gl_TexCoord[5].xyz;
|
|
vec3 tmpvar_101;
|
|
tmpvar_101 = tmpvar_100;
|
|
xlt_IN_87.worldPos = tmpvar_101;
|
|
vec4 tmpvar_102;
|
|
tmpvar_102 = frag_surf (xlt_IN_87);
|
|
vec4 tmpvar_103;
|
|
tmpvar_103 = tmpvar_102;
|
|
xl_retval_88 = tmpvar_103;
|
|
vec4 tmpvar_104;
|
|
tmpvar_104 = xl_retval_88.xyzw;
|
|
vec4 tmpvar_105;
|
|
tmpvar_105 = tmpvar_104;
|
|
gl_FragData[0] = tmpvar_105;
|
|
}
|
|
|