mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-25 09:08:22 -05:00
132 lines
2.4 KiB
Text
132 lines
2.4 KiB
Text
struct v2f_img {
|
|
vec4 pos;
|
|
vec2 uv;
|
|
};
|
|
uniform sampler2D _MainTex;
|
|
uniform sampler2D _CameraDepthNormalsTexture;
|
|
vec3 DecodeViewNormalStereo (
|
|
in vec4 enc4
|
|
)
|
|
{
|
|
vec3 n;
|
|
float g;
|
|
vec3 nn;
|
|
float kScale;
|
|
float tmpvar_1;
|
|
tmpvar_1 = 1.7777;
|
|
kScale = tmpvar_1;
|
|
vec3 tmpvar_2;
|
|
tmpvar_2.z = 0.0;
|
|
tmpvar_2.x = (2.0 * kScale);
|
|
tmpvar_2.y = (2.0 * kScale);
|
|
vec3 tmpvar_3;
|
|
tmpvar_3.z = 1.0;
|
|
tmpvar_3.x = -(kScale);
|
|
tmpvar_3.y = -(kScale);
|
|
vec3 tmpvar_4;
|
|
tmpvar_4 = ((enc4.xyz * tmpvar_2) + tmpvar_3);
|
|
nn = tmpvar_4;
|
|
float tmpvar_5;
|
|
tmpvar_5 = dot (nn.xyz, nn.xyz);
|
|
float tmpvar_6;
|
|
tmpvar_6 = (2.0 / tmpvar_5);
|
|
g = tmpvar_6;
|
|
vec2 tmpvar_7;
|
|
tmpvar_7 = (g * nn.xy);
|
|
n.xy = tmpvar_7.xy.xy;
|
|
float tmpvar_8;
|
|
tmpvar_8 = (g - 1.0);
|
|
n.z = vec3(tmpvar_8).z;
|
|
return n;
|
|
}
|
|
|
|
float DecodeFloatRG (
|
|
in vec2 enc
|
|
)
|
|
{
|
|
vec2 kDecodeDot;
|
|
vec2 tmpvar_1;
|
|
tmpvar_1 = vec2(1.0, 0.00392157);
|
|
kDecodeDot = tmpvar_1;
|
|
float tmpvar_2;
|
|
tmpvar_2 = dot (enc, kDecodeDot);
|
|
return tmpvar_2;
|
|
}
|
|
|
|
void DecodeDepthNormal (
|
|
in vec4 enc,
|
|
out float depth,
|
|
out vec3 normal
|
|
)
|
|
{
|
|
float tmpvar_1;
|
|
tmpvar_1 = DecodeFloatRG (enc.zw);
|
|
float tmpvar_2;
|
|
tmpvar_2 = tmpvar_1;
|
|
depth = tmpvar_2;
|
|
vec3 tmpvar_3;
|
|
tmpvar_3 = DecodeViewNormalStereo (enc);
|
|
vec3 tmpvar_4;
|
|
tmpvar_4 = tmpvar_3;
|
|
normal = tmpvar_4;
|
|
}
|
|
|
|
vec4 frag (
|
|
in v2f_img i
|
|
)
|
|
{
|
|
vec4 col;
|
|
vec3 n;
|
|
float z;
|
|
vec4 depth;
|
|
vec4 tex;
|
|
vec4 tmpvar_1;
|
|
tmpvar_1 = texture2D (_MainTex, i.uv);
|
|
vec4 tmpvar_2;
|
|
tmpvar_2 = tmpvar_1;
|
|
tex = tmpvar_2;
|
|
vec4 tmpvar_3;
|
|
tmpvar_3 = texture2D (_CameraDepthNormalsTexture, i.uv);
|
|
vec4 tmpvar_4;
|
|
tmpvar_4 = tmpvar_3;
|
|
depth = tmpvar_4;
|
|
DecodeDepthNormal (depth, z, n);
|
|
float tmpvar_5;
|
|
tmpvar_5 = z;
|
|
col.x = tmpvar_5;
|
|
float tmpvar_6;
|
|
tmpvar_6 = ((n.x * 0.5) + 0.5);
|
|
col.y = vec2(tmpvar_6).y;
|
|
float tmpvar_7;
|
|
tmpvar_7 = ((n.y * 0.5) + 0.5);
|
|
col.z = vec3(tmpvar_7).z;
|
|
float tmpvar_8;
|
|
tmpvar_8 = tex.w;
|
|
col.w = vec4(tmpvar_8).w;
|
|
return col;
|
|
}
|
|
|
|
void main ()
|
|
{
|
|
v2f_img xlt_i;
|
|
vec4 xl_retval;
|
|
vec4 tmpvar_1;
|
|
tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0);
|
|
xlt_i.pos = tmpvar_1;
|
|
vec2 tmpvar_2;
|
|
tmpvar_2 = gl_TexCoord[0].xy;
|
|
vec2 tmpvar_3;
|
|
tmpvar_3 = tmpvar_2;
|
|
xlt_i.uv = tmpvar_3;
|
|
vec4 tmpvar_4;
|
|
tmpvar_4 = frag (xlt_i);
|
|
vec4 tmpvar_5;
|
|
tmpvar_5 = tmpvar_4;
|
|
xl_retval = tmpvar_5;
|
|
vec4 tmpvar_6;
|
|
tmpvar_6 = xl_retval.xyzw;
|
|
vec4 tmpvar_7;
|
|
tmpvar_7 = tmpvar_6;
|
|
gl_FragData[0] = tmpvar_7;
|
|
}
|
|
|