mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-12-11 00:31:28 -05:00
192 lines
4.2 KiB
Text
192 lines
4.2 KiB
Text
|
struct v2f {
|
||
|
vec4 pos;
|
||
|
vec2 uv;
|
||
|
vec3 ray;
|
||
|
};
|
||
|
uniform vec4 _ZBufferParams;
|
||
|
uniform mat4 _View2Shadow3;
|
||
|
uniform mat4 _View2Shadow2;
|
||
|
uniform mat4 _View2Shadow1;
|
||
|
uniform mat4 _View2Shadow;
|
||
|
uniform sampler2D _ShadowMapTexture;
|
||
|
uniform vec4 _LightSplitsNear;
|
||
|
uniform vec4 _LightSplitsFar;
|
||
|
uniform vec4 _LightShadowData;
|
||
|
uniform sampler2D _CameraDepthTexture;
|
||
|
float unitySampleShadow (
|
||
|
in vec4 eyePos_1
|
||
|
)
|
||
|
{
|
||
|
float shadow_2;
|
||
|
vec4 coord_3;
|
||
|
vec4 weights_4;
|
||
|
vec4 far_5;
|
||
|
vec4 near_6;
|
||
|
float z_7;
|
||
|
vec3 sc3_8;
|
||
|
vec3 sc2_9;
|
||
|
vec3 sc1_10;
|
||
|
vec3 sc0_11;
|
||
|
vec3 tmpvar_12;
|
||
|
tmpvar_12 = (_View2Shadow * eyePos_1).xyz;
|
||
|
sc0_11 = tmpvar_12;
|
||
|
vec3 tmpvar_13;
|
||
|
tmpvar_13 = (_View2Shadow1 * eyePos_1).xyz;
|
||
|
sc1_10 = tmpvar_13;
|
||
|
vec3 tmpvar_14;
|
||
|
tmpvar_14 = (_View2Shadow2 * eyePos_1).xyz;
|
||
|
sc2_9 = tmpvar_14;
|
||
|
vec3 tmpvar_15;
|
||
|
tmpvar_15 = (_View2Shadow3 * eyePos_1).xyz;
|
||
|
sc3_8 = tmpvar_15;
|
||
|
float tmpvar_16;
|
||
|
tmpvar_16 = eyePos_1.z;
|
||
|
z_7 = tmpvar_16;
|
||
|
vec4 tmpvar_17;
|
||
|
tmpvar_17 = vec4(z_7);
|
||
|
bvec4 tmpvar_18;
|
||
|
tmpvar_18 = greaterThanEqual (tmpvar_17, _LightSplitsNear);
|
||
|
vec4 tmpvar_19;
|
||
|
tmpvar_19 = vec4(tmpvar_18).xyzw;
|
||
|
vec4 tmpvar_20;
|
||
|
tmpvar_20 = tmpvar_19;
|
||
|
near_6 = tmpvar_20;
|
||
|
vec4 tmpvar_21;
|
||
|
tmpvar_21 = vec4(z_7);
|
||
|
bvec4 tmpvar_22;
|
||
|
tmpvar_22 = lessThan (tmpvar_21, _LightSplitsFar);
|
||
|
vec4 tmpvar_23;
|
||
|
tmpvar_23 = vec4(tmpvar_22).xyzw;
|
||
|
vec4 tmpvar_24;
|
||
|
tmpvar_24 = tmpvar_23;
|
||
|
far_5 = tmpvar_24;
|
||
|
vec4 tmpvar_25;
|
||
|
tmpvar_25 = (near_6 * far_5);
|
||
|
weights_4 = tmpvar_25;
|
||
|
vec4 tmpvar_26;
|
||
|
tmpvar_26.w = 1.0;
|
||
|
tmpvar_26.xyz = ((((sc0_11 * weights_4.x) + (sc1_10 * weights_4.y)) + (sc2_9 * weights_4.z)) + (sc3_8 * weights_4.w)).xyz;
|
||
|
vec4 tmpvar_27;
|
||
|
tmpvar_27 = tmpvar_26;
|
||
|
coord_3 = tmpvar_27;
|
||
|
vec4 tmpvar_28;
|
||
|
tmpvar_28 = texture2D (_ShadowMapTexture, coord_3.xy);
|
||
|
float tmpvar_29;
|
||
|
if ((tmpvar_28.x < coord_3.z)) {
|
||
|
tmpvar_29 = _LightShadowData.x;
|
||
|
} else {
|
||
|
tmpvar_29 = 1.0;
|
||
|
};
|
||
|
float tmpvar_30;
|
||
|
tmpvar_30 = tmpvar_29;
|
||
|
shadow_2 = tmpvar_30;
|
||
|
return shadow_2;
|
||
|
}
|
||
|
|
||
|
float Linear01Depth (
|
||
|
in float z_31
|
||
|
)
|
||
|
{
|
||
|
return (1.0 / ((_ZBufferParams.x * z_31) + _ZBufferParams.y));
|
||
|
}
|
||
|
|
||
|
vec2 EncodeFloatRG (
|
||
|
in float v_32
|
||
|
)
|
||
|
{
|
||
|
vec2 enc_33;
|
||
|
float kEncodeBit_34;
|
||
|
vec2 kEncodeMul_35;
|
||
|
vec2 tmpvar_36;
|
||
|
tmpvar_36 = vec2(1.0, 255.0);
|
||
|
kEncodeMul_35 = tmpvar_36;
|
||
|
float tmpvar_37;
|
||
|
tmpvar_37 = 0.00392157;
|
||
|
kEncodeBit_34 = tmpvar_37;
|
||
|
vec2 tmpvar_38;
|
||
|
tmpvar_38 = (kEncodeMul_35 * v_32);
|
||
|
enc_33 = tmpvar_38;
|
||
|
vec2 tmpvar_39;
|
||
|
tmpvar_39 = fract (enc_33);
|
||
|
vec2 tmpvar_40;
|
||
|
tmpvar_40 = tmpvar_39;
|
||
|
enc_33 = tmpvar_40;
|
||
|
float tmpvar_41;
|
||
|
tmpvar_41 = (enc_33.x - (enc_33.y * kEncodeBit_34));
|
||
|
enc_33.x = tmpvar_41;
|
||
|
return enc_33;
|
||
|
}
|
||
|
|
||
|
vec4 frag (
|
||
|
in v2f i_42
|
||
|
)
|
||
|
{
|
||
|
vec4 res_43;
|
||
|
float shadow_44;
|
||
|
vec4 vpos_45;
|
||
|
float depth_46;
|
||
|
vec4 tmpvar_47;
|
||
|
tmpvar_47 = texture2D (_CameraDepthTexture, i_42.uv);
|
||
|
float tmpvar_48;
|
||
|
tmpvar_48 = tmpvar_47.x;
|
||
|
depth_46 = tmpvar_48;
|
||
|
float tmpvar_49;
|
||
|
tmpvar_49 = Linear01Depth (depth_46);
|
||
|
float tmpvar_50;
|
||
|
tmpvar_50 = tmpvar_49;
|
||
|
depth_46 = tmpvar_50;
|
||
|
vec4 tmpvar_51;
|
||
|
tmpvar_51.w = 1.0;
|
||
|
tmpvar_51.xyz = (i_42.ray * depth_46).xyz;
|
||
|
vec4 tmpvar_52;
|
||
|
tmpvar_52 = tmpvar_51;
|
||
|
vpos_45 = tmpvar_52;
|
||
|
float tmpvar_53;
|
||
|
tmpvar_53 = unitySampleShadow (vpos_45);
|
||
|
float tmpvar_54;
|
||
|
tmpvar_54 = tmpvar_53;
|
||
|
shadow_44 = tmpvar_54;
|
||
|
float tmpvar_55;
|
||
|
tmpvar_55 = shadow_44;
|
||
|
res_43.x = tmpvar_55;
|
||
|
float tmpvar_56;
|
||
|
tmpvar_56 = 1.0;
|
||
|
res_43.y = vec2(tmpvar_56).y;
|
||
|
vec2 tmpvar_57;
|
||
|
tmpvar_57 = EncodeFloatRG ((1.0 - depth_46));
|
||
|
vec2 tmpvar_58;
|
||
|
tmpvar_58 = tmpvar_57;
|
||
|
res_43.zw = tmpvar_58.xxxy.zw;
|
||
|
return res_43;
|
||
|
}
|
||
|
|
||
|
void main ()
|
||
|
{
|
||
|
v2f xlt_i_59;
|
||
|
vec4 xl_retval_60;
|
||
|
vec4 tmpvar_61;
|
||
|
tmpvar_61 = vec4(0.0, 0.0, 0.0, 0.0);
|
||
|
xlt_i_59.pos = tmpvar_61;
|
||
|
vec2 tmpvar_62;
|
||
|
tmpvar_62 = gl_TexCoord[0].xy;
|
||
|
vec2 tmpvar_63;
|
||
|
tmpvar_63 = tmpvar_62;
|
||
|
xlt_i_59.uv = tmpvar_63;
|
||
|
vec3 tmpvar_64;
|
||
|
tmpvar_64 = gl_TexCoord[1].xyz;
|
||
|
vec3 tmpvar_65;
|
||
|
tmpvar_65 = tmpvar_64;
|
||
|
xlt_i_59.ray = tmpvar_65;
|
||
|
vec4 tmpvar_66;
|
||
|
tmpvar_66 = frag (xlt_i_59);
|
||
|
vec4 tmpvar_67;
|
||
|
tmpvar_67 = tmpvar_66;
|
||
|
xl_retval_60 = tmpvar_67;
|
||
|
vec4 tmpvar_68;
|
||
|
tmpvar_68 = xl_retval_60.xyzw;
|
||
|
vec4 tmpvar_69;
|
||
|
tmpvar_69 = tmpvar_68;
|
||
|
gl_FragData[0] = tmpvar_69;
|
||
|
}
|
||
|
|