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