mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-25 09:08:22 -05:00
144 lines
2.9 KiB
Text
144 lines
2.9 KiB
Text
|
struct v2f {
|
||
|
vec4 pos;
|
||
|
vec2 uv;
|
||
|
};
|
||
|
uniform vec4 _ZBufferParams;
|
||
|
uniform sampler2D _CameraNormalsTexture;
|
||
|
uniform sampler2D _CameraDepthTexture;
|
||
|
float Linear01Depth (
|
||
|
in float z_1
|
||
|
)
|
||
|
{
|
||
|
return (1.0 / ((_ZBufferParams.x * z_1) + _ZBufferParams.y));
|
||
|
}
|
||
|
|
||
|
vec2 EncodeViewNormalStereo (
|
||
|
in vec3 n_2
|
||
|
)
|
||
|
{
|
||
|
vec2 enc_3;
|
||
|
float kScale_4;
|
||
|
float tmpvar_5;
|
||
|
tmpvar_5 = 1.7777;
|
||
|
kScale_4 = tmpvar_5;
|
||
|
vec2 tmpvar_6;
|
||
|
tmpvar_6 = (n_2.xy / (n_2.z + 1.0));
|
||
|
enc_3 = tmpvar_6;
|
||
|
vec2 tmpvar_7;
|
||
|
tmpvar_7 = (enc_3 / kScale_4);
|
||
|
enc_3 = tmpvar_7;
|
||
|
vec2 tmpvar_8;
|
||
|
tmpvar_8 = ((enc_3 * 0.5) + 0.5);
|
||
|
enc_3 = tmpvar_8;
|
||
|
return enc_3;
|
||
|
}
|
||
|
|
||
|
vec2 EncodeFloatRG (
|
||
|
in float v_9
|
||
|
)
|
||
|
{
|
||
|
vec2 enc_10;
|
||
|
float kEncodeBit_11;
|
||
|
vec2 kEncodeMul_12;
|
||
|
vec2 tmpvar_13;
|
||
|
tmpvar_13 = vec2(1.0, 255.0);
|
||
|
kEncodeMul_12 = tmpvar_13;
|
||
|
float tmpvar_14;
|
||
|
tmpvar_14 = 0.00392157;
|
||
|
kEncodeBit_11 = tmpvar_14;
|
||
|
vec2 tmpvar_15;
|
||
|
tmpvar_15 = (kEncodeMul_12 * v_9);
|
||
|
enc_10 = tmpvar_15;
|
||
|
vec2 tmpvar_16;
|
||
|
tmpvar_16 = fract (enc_10);
|
||
|
vec2 tmpvar_17;
|
||
|
tmpvar_17 = tmpvar_16;
|
||
|
enc_10 = tmpvar_17;
|
||
|
float tmpvar_18;
|
||
|
tmpvar_18 = (enc_10.x - (enc_10.y * kEncodeBit_11));
|
||
|
enc_10.x = tmpvar_18;
|
||
|
return enc_10;
|
||
|
}
|
||
|
|
||
|
vec4 EncodeDepthNormal (
|
||
|
in float depth_19,
|
||
|
in vec3 normal_20
|
||
|
)
|
||
|
{
|
||
|
vec4 enc_21;
|
||
|
vec2 tmpvar_22;
|
||
|
tmpvar_22 = EncodeViewNormalStereo (normal_20);
|
||
|
vec2 tmpvar_23;
|
||
|
tmpvar_23 = tmpvar_22;
|
||
|
enc_21.xy = tmpvar_23.xy.xy;
|
||
|
vec2 tmpvar_24;
|
||
|
tmpvar_24 = EncodeFloatRG (depth_19);
|
||
|
vec2 tmpvar_25;
|
||
|
tmpvar_25 = tmpvar_24;
|
||
|
enc_21.zw = tmpvar_25.xxxy.zw;
|
||
|
return enc_21;
|
||
|
}
|
||
|
|
||
|
vec4 frag (
|
||
|
in v2f i_26
|
||
|
)
|
||
|
{
|
||
|
vec4 n_27;
|
||
|
float d_28;
|
||
|
vec4 tmpvar_29;
|
||
|
tmpvar_29 = texture2D (_CameraDepthTexture, i_26.uv);
|
||
|
float tmpvar_30;
|
||
|
tmpvar_30 = tmpvar_29.x;
|
||
|
d_28 = tmpvar_30;
|
||
|
vec4 tmpvar_31;
|
||
|
tmpvar_31 = texture2D (_CameraNormalsTexture, i_26.uv);
|
||
|
vec4 tmpvar_32;
|
||
|
tmpvar_32 = tmpvar_31;
|
||
|
n_27 = tmpvar_32;
|
||
|
float tmpvar_33;
|
||
|
tmpvar_33 = Linear01Depth (d_28);
|
||
|
float tmpvar_34;
|
||
|
tmpvar_34 = tmpvar_33;
|
||
|
d_28 = tmpvar_34;
|
||
|
vec3 tmpvar_35;
|
||
|
tmpvar_35 = ((n_27.xyz * 2.0) - 1.0);
|
||
|
n_27.xyz = tmpvar_35.xyz.xyz;
|
||
|
float tmpvar_36;
|
||
|
tmpvar_36 = -(n_27.z);
|
||
|
n_27.z = vec3(tmpvar_36).z;
|
||
|
vec4 tmpvar_37;
|
||
|
if ((d_28 < 0.999985)) {
|
||
|
vec4 tmpvar_38;
|
||
|
tmpvar_38 = EncodeDepthNormal (d_28, n_27.xyz);
|
||
|
tmpvar_37 = tmpvar_38;
|
||
|
} else {
|
||
|
tmpvar_37 = vec4(0.5, 0.5, 1.0, 1.0);
|
||
|
};
|
||
|
return tmpvar_37;
|
||
|
}
|
||
|
|
||
|
void main ()
|
||
|
{
|
||
|
v2f xlt_i_39;
|
||
|
vec4 xl_retval_40;
|
||
|
vec4 tmpvar_41;
|
||
|
tmpvar_41 = vec4(0.0, 0.0, 0.0, 0.0);
|
||
|
xlt_i_39.pos = tmpvar_41;
|
||
|
vec2 tmpvar_42;
|
||
|
tmpvar_42 = gl_TexCoord[0].xy;
|
||
|
vec2 tmpvar_43;
|
||
|
tmpvar_43 = tmpvar_42;
|
||
|
xlt_i_39.uv = tmpvar_43;
|
||
|
vec4 tmpvar_44;
|
||
|
tmpvar_44 = frag (xlt_i_39);
|
||
|
vec4 tmpvar_45;
|
||
|
tmpvar_45 = tmpvar_44;
|
||
|
xl_retval_40 = tmpvar_45;
|
||
|
vec4 tmpvar_46;
|
||
|
tmpvar_46 = xl_retval_40.xyzw;
|
||
|
vec4 tmpvar_47;
|
||
|
tmpvar_47 = tmpvar_46;
|
||
|
gl_FragData[0] = tmpvar_47;
|
||
|
}
|
||
|
|