Should this depth buffer visualization look smooth?

I am debugging a problem using SSAO and trying to visualize my depth buffer. Here is the result: enter image description here I store the depth and normals in one 16-bit RGBA texture. This is my depth shader:

// Vertex shader
#version 150 core
#extension GL_ARB_explicit_attrib_location : enable

uniform mat4 _ViewMatrix;
uniform mat4 _ViewProjectionMatrix;
uniform mat4 modelMatrix;

layout (location = 0) in vec4 aPosition;
layout (location = 2) in vec3 aNormal;

out vec4 vPosition;
out vec3 vNormal;

void main()
{
    gl_Position = _ViewProjectionMatrix * modelMatrix * aPosition;

    mat4 modelViewMatrix = _ViewMatrix * modelMatrix;

    vPosition = modelViewMatrix * aPosition;
    vNormal = mat3( modelViewMatrix ) * aNormal;
}

// Fragment shader.
#version 150 core

// Calculated as 1.0 / (far - near)
uniform float uLinearDepthConstant;

in vec4 vPosition;
in vec3 vNormal;

out vec4 outDepthNormal;

void main()
{
    float linearDepth = -vPosition.z * uLinearDepthConstant;

    outDepthNormal = vec4( linearDepth, normalize( vNormal ) );
}

Then I visualize the depth in the shader that displays the texture (I hardcoded the long and long distances):

void main()
{
    float depth = texture( depthNormalMap, vTexCoord ).r;
    fragColor = vec4((2.0 * 1.0) / (200.0 + 1.0 - depth * (200.0 - 1.0)));
}

Should the result look smooth or what could be the problem? I create the texture as follows:

glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA16F, width, height, 0, GL_RGBA, GL_HALF_FLOAT, 0 );
+3
source share
1 answer

If you think that the hardware does not actually offer a 16-bit floating point buffer , this looks right.

(, Xbox 360) 24- , , , - , 32- , . 64- Depth + Stencil, , , ATI D3D Xbox 360 24- + 8- + , OpenGL. GL , GL_DEPTH24F_STENCIL8.

, 16- , , / . RGBA 10: 10: 10: 2 ( ) RGB 11:11:10 ( ) ( RGBA8 ), 32- .

, . 16- . 24- 32- , . - .

, , 1- , ( ). , 0-1 , . 16 , , . - , .

+1

All Articles