mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-12-01 11:56:58 -05:00
311 lines
6.5 KiB
Text
311 lines
6.5 KiB
Text
struct SurfaceOutput {
|
|
vec3 Albedo;
|
|
vec3 Normal;
|
|
vec3 Emission;
|
|
float Specular;
|
|
float Gloss;
|
|
float Alpha;
|
|
};
|
|
struct Input {
|
|
vec2 uv_MainTex;
|
|
};
|
|
struct v2f_surf {
|
|
vec4 pos;
|
|
vec3 _ShadowCoord0;
|
|
vec3 _ShadowCoord1;
|
|
vec3 _ShadowCoord2;
|
|
vec3 _ShadowCoord3;
|
|
vec2 _ShadowZFade;
|
|
};
|
|
uniform sampler2D _ShadowMapTexture;
|
|
uniform vec4 _ProjectionParams;
|
|
uniform sampler2D _MainTex;
|
|
uniform vec4 _LightSplitsNear;
|
|
uniform vec4 _LightSplitsFar;
|
|
uniform vec4 _LightShadowData;
|
|
uniform vec4 _Color;
|
|
float xll_saturate (
|
|
in float x_1
|
|
)
|
|
{
|
|
float tmpvar_2;
|
|
tmpvar_2 = clamp (x_1, 0.0, 1.0);
|
|
return tmpvar_2;
|
|
}
|
|
|
|
vec2 xll_saturate (
|
|
in vec2 x_3
|
|
)
|
|
{
|
|
vec2 tmpvar_4;
|
|
tmpvar_4 = clamp (x_3, 0.0, 1.0);
|
|
return tmpvar_4;
|
|
}
|
|
|
|
vec3 xll_saturate (
|
|
in vec3 x_5
|
|
)
|
|
{
|
|
vec3 tmpvar_6;
|
|
tmpvar_6 = clamp (x_5, 0.0, 1.0);
|
|
return tmpvar_6;
|
|
}
|
|
|
|
vec4 xll_saturate (
|
|
in vec4 x_7
|
|
)
|
|
{
|
|
vec4 tmpvar_8;
|
|
tmpvar_8 = clamp (x_7, 0.0, 1.0);
|
|
return tmpvar_8;
|
|
}
|
|
|
|
mat2 xll_saturate (
|
|
in mat2 m_9
|
|
)
|
|
{
|
|
vec2 tmpvar_10;
|
|
tmpvar_10 = clamp (m_9[0], 0.0, 1.0);
|
|
vec2 tmpvar_11;
|
|
tmpvar_11 = clamp (m_9[1], 0.0, 1.0);
|
|
mat2 tmpvar_12;
|
|
vec2 tmpvar_13;
|
|
tmpvar_13 = tmpvar_10;
|
|
tmpvar_12[0] = tmpvar_13;
|
|
vec2 tmpvar_14;
|
|
tmpvar_14 = tmpvar_11;
|
|
tmpvar_12[1] = tmpvar_14;
|
|
return tmpvar_12;
|
|
}
|
|
|
|
mat3 xll_saturate (
|
|
in mat3 m_15
|
|
)
|
|
{
|
|
vec3 tmpvar_16;
|
|
tmpvar_16 = clamp (m_15[0], 0.0, 1.0);
|
|
vec3 tmpvar_17;
|
|
tmpvar_17 = clamp (m_15[1], 0.0, 1.0);
|
|
vec3 tmpvar_18;
|
|
tmpvar_18 = clamp (m_15[2], 0.0, 1.0);
|
|
mat3 tmpvar_19;
|
|
vec3 tmpvar_20;
|
|
tmpvar_20 = tmpvar_16;
|
|
tmpvar_19[0] = tmpvar_20;
|
|
vec3 tmpvar_21;
|
|
tmpvar_21 = tmpvar_17;
|
|
tmpvar_19[1] = tmpvar_21;
|
|
vec3 tmpvar_22;
|
|
tmpvar_22 = tmpvar_18;
|
|
tmpvar_19[2] = tmpvar_22;
|
|
return tmpvar_19;
|
|
}
|
|
|
|
mat4 xll_saturate (
|
|
in mat4 m_23
|
|
)
|
|
{
|
|
vec4 tmpvar_24;
|
|
tmpvar_24 = clamp (m_23[0], 0.0, 1.0);
|
|
vec4 tmpvar_25;
|
|
tmpvar_25 = clamp (m_23[1], 0.0, 1.0);
|
|
vec4 tmpvar_26;
|
|
tmpvar_26 = clamp (m_23[2], 0.0, 1.0);
|
|
vec4 tmpvar_27;
|
|
tmpvar_27 = clamp (m_23[3], 0.0, 1.0);
|
|
mat4 tmpvar_28;
|
|
vec4 tmpvar_29;
|
|
tmpvar_29 = tmpvar_24;
|
|
tmpvar_28[0] = tmpvar_29;
|
|
vec4 tmpvar_30;
|
|
tmpvar_30 = tmpvar_25;
|
|
tmpvar_28[1] = tmpvar_30;
|
|
vec4 tmpvar_31;
|
|
tmpvar_31 = tmpvar_26;
|
|
tmpvar_28[2] = tmpvar_31;
|
|
vec4 tmpvar_32;
|
|
tmpvar_32 = tmpvar_27;
|
|
tmpvar_28[3] = tmpvar_32;
|
|
return tmpvar_28;
|
|
}
|
|
|
|
void surf (
|
|
in Input IN_33,
|
|
inout SurfaceOutput o_34
|
|
)
|
|
{
|
|
vec4 c_35;
|
|
vec4 tmpvar_36;
|
|
tmpvar_36 = texture2D (_MainTex, IN_33.uv_MainTex);
|
|
vec4 tmpvar_37;
|
|
tmpvar_37 = (tmpvar_36 * _Color);
|
|
c_35 = tmpvar_37;
|
|
vec3 tmpvar_38;
|
|
tmpvar_38 = c_35.xyz;
|
|
o_34.Albedo = tmpvar_38;
|
|
float tmpvar_39;
|
|
tmpvar_39 = c_35.w;
|
|
o_34.Alpha = tmpvar_39;
|
|
}
|
|
|
|
vec2 EncodeFloatRG (
|
|
in float v_40
|
|
)
|
|
{
|
|
vec2 enc_41;
|
|
float kEncodeBit_42;
|
|
vec2 kEncodeMul_43;
|
|
vec2 tmpvar_44;
|
|
tmpvar_44 = vec2(1.0, 255.0);
|
|
kEncodeMul_43 = tmpvar_44;
|
|
float tmpvar_45;
|
|
tmpvar_45 = 0.00392157;
|
|
kEncodeBit_42 = tmpvar_45;
|
|
vec2 tmpvar_46;
|
|
tmpvar_46 = (kEncodeMul_43 * v_40);
|
|
enc_41 = tmpvar_46;
|
|
vec2 tmpvar_47;
|
|
tmpvar_47 = fract (enc_41);
|
|
vec2 tmpvar_48;
|
|
tmpvar_48 = tmpvar_47;
|
|
enc_41 = tmpvar_48;
|
|
float tmpvar_49;
|
|
tmpvar_49 = (enc_41.x - (enc_41.y * kEncodeBit_42));
|
|
enc_41.x = tmpvar_49;
|
|
return enc_41;
|
|
}
|
|
|
|
vec4 frag_surf (
|
|
in v2f_surf IN_50
|
|
)
|
|
{
|
|
vec4 res_51;
|
|
float faded_52;
|
|
float shadow_53;
|
|
vec4 coord_54;
|
|
vec4 weights_55;
|
|
vec4 far_56;
|
|
vec4 near_57;
|
|
vec4 z_58;
|
|
Input surfIN_59;
|
|
SurfaceOutput o_60;
|
|
vec3 tmpvar_61;
|
|
tmpvar_61 = vec3(0.0, 0.0, 0.0);
|
|
o_60.Albedo = tmpvar_61;
|
|
vec3 tmpvar_62;
|
|
tmpvar_62 = vec3(0.0, 0.0, 0.0);
|
|
o_60.Emission = tmpvar_62;
|
|
float tmpvar_63;
|
|
tmpvar_63 = 0.0;
|
|
o_60.Specular = tmpvar_63;
|
|
float tmpvar_64;
|
|
tmpvar_64 = 0.0;
|
|
o_60.Alpha = tmpvar_64;
|
|
float tmpvar_65;
|
|
tmpvar_65 = 0.0;
|
|
o_60.Gloss = tmpvar_65;
|
|
surf (surfIN_59, o_60);
|
|
vec4 tmpvar_66;
|
|
tmpvar_66 = vec4(IN_50._ShadowZFade.x);
|
|
vec4 tmpvar_67;
|
|
tmpvar_67 = tmpvar_66;
|
|
z_58 = tmpvar_67;
|
|
bvec4 tmpvar_68;
|
|
tmpvar_68 = greaterThanEqual (z_58, _LightSplitsNear);
|
|
vec4 tmpvar_69;
|
|
tmpvar_69 = vec4(tmpvar_68).xyzw;
|
|
vec4 tmpvar_70;
|
|
tmpvar_70 = tmpvar_69;
|
|
near_57 = tmpvar_70;
|
|
bvec4 tmpvar_71;
|
|
tmpvar_71 = lessThan (z_58, _LightSplitsFar);
|
|
vec4 tmpvar_72;
|
|
tmpvar_72 = vec4(tmpvar_71).xyzw;
|
|
vec4 tmpvar_73;
|
|
tmpvar_73 = tmpvar_72;
|
|
far_56 = tmpvar_73;
|
|
vec4 tmpvar_74;
|
|
tmpvar_74 = (near_57 * far_56);
|
|
weights_55 = tmpvar_74;
|
|
vec4 tmpvar_75;
|
|
tmpvar_75.w = 1.0;
|
|
tmpvar_75.xyz = ((((IN_50._ShadowCoord0 * weights_55.x) + (IN_50._ShadowCoord1 * weights_55.y)) + (IN_50._ShadowCoord2 * weights_55.z)) + (IN_50._ShadowCoord3 * weights_55.w)).xyz;
|
|
vec4 tmpvar_76;
|
|
tmpvar_76 = tmpvar_75;
|
|
coord_54 = tmpvar_76;
|
|
vec4 tmpvar_77;
|
|
tmpvar_77 = texture2D (_ShadowMapTexture, coord_54.xy);
|
|
float tmpvar_78;
|
|
if ((tmpvar_77.x < coord_54.z)) {
|
|
tmpvar_78 = _LightShadowData.x;
|
|
} else {
|
|
tmpvar_78 = 1.0;
|
|
};
|
|
float tmpvar_79;
|
|
tmpvar_79 = tmpvar_78;
|
|
shadow_53 = tmpvar_79;
|
|
float tmpvar_80;
|
|
tmpvar_80 = xll_saturate (IN_50._ShadowZFade.y);
|
|
float tmpvar_81;
|
|
tmpvar_81 = xll_saturate ((shadow_53 + tmpvar_80));
|
|
float tmpvar_82;
|
|
tmpvar_82 = tmpvar_81;
|
|
faded_52 = tmpvar_82;
|
|
float tmpvar_83;
|
|
tmpvar_83 = faded_52;
|
|
res_51.x = tmpvar_83;
|
|
float tmpvar_84;
|
|
tmpvar_84 = 1.0;
|
|
res_51.y = vec2(tmpvar_84).y;
|
|
vec2 tmpvar_85;
|
|
tmpvar_85 = EncodeFloatRG ((1.0 - (z_58 * _ProjectionParams.w)).x);
|
|
vec2 tmpvar_86;
|
|
tmpvar_86 = tmpvar_85;
|
|
res_51.zw = tmpvar_86.xxxy.zw;
|
|
return res_51;
|
|
}
|
|
|
|
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;
|
|
vec4 tmpvar_100;
|
|
tmpvar_100 = frag_surf (xlt_IN_87);
|
|
vec4 tmpvar_101;
|
|
tmpvar_101 = tmpvar_100;
|
|
xl_retval_88 = tmpvar_101;
|
|
vec4 tmpvar_102;
|
|
tmpvar_102 = xl_retval_88.xyzw;
|
|
vec4 tmpvar_103;
|
|
tmpvar_103 = tmpvar_102;
|
|
gl_FragData[0] = tmpvar_103;
|
|
}
|
|
|