Hi there,
I’m trying to visualize the depth buffer
in a texture created in a example application
and writing it through a quad command in the renderpath.
// texture creation
SharedPtr<Texture2D> renderTexture(new Texture2D(context_));
float div = 2.0f;
renderTexture->SetSize(graphics->GetWidth() / div, graphics->GetHeight() / div, Graphics::GetRGBFormat(), TEXTURE_RENDERTARGET);
renderTexture->SetName("DepthBuffer");
// command added to the renderpath Deferred.xml
<command type="quad" vs="CopyFramebufferDepth" ps="CopyFramebufferDepth" blend="replace" output="DepthBuffer">
<texture unit="depth" name="depth" />
</command>
// PS CopyFramebufferDepth.glsl
float x = vScreenPos.x;
float y = 1.0f - vScreenPos.y;
float depth = DecodeDepth(texture2D(sDepthBuffer, vec2(x, y)).rgb);
vec3 color = vec3(depth, depth, depth);
gl_FragColor = vec4(color, 1.0);
What I get is the following. the depths should not be on a grayscale?
should I define a readable depth texture, like docs says?