bgfx/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_ShowDepthTexture-in.txt
Branimir Karadzic dee3fe5266 Initial commit.
2012-04-03 20:30:07 -07:00

41 lines
914 B
Text

struct v2f_vertex_lit {
vec2 uv;
vec4 diff;
vec4 spec;
};
struct v2f_img {
vec4 pos;
vec2 uv;
};
struct appdata_img {
vec4 vertex;
vec2 texcoord;
};
uniform sampler2D _CameraDepthTexture;
uniform sampler2D _MainTex;
uniform vec4 _ZBufferParams;
float LinearEyeDepth( in float z );
vec4 frag( in v2f_img i );
float LinearEyeDepth( in float z ) {
return (1.00000 / ((_ZBufferParams.z * z) + _ZBufferParams.w ));
}
vec4 frag( in v2f_img i ) {
vec4 tex;
vec4 depth;
float z;
vec4 col;
tex = texture2D( _MainTex, i.uv);
depth = texture2D( _CameraDepthTexture, i.uv);
z = (LinearEyeDepth( depth.x ) * 0.0100000);
col = tex;
col.xy = vec2( z);
return col;
}
void main() {
vec4 xl_retval;
v2f_img xlt_i;
xlt_i.pos = vec4(0.0);
xlt_i.uv = vec2( gl_TexCoord[0]);
xl_retval = frag( xlt_i);
gl_FragData[0] = vec4( xl_retval);
}