Hi there, i am rendering volumetrics pass into a half resolution texture. Old problem: Adding it to my full res lighting pass will introduce ugly edges. Now i would like to implement a depth aware upsampling and to keep things simple i would like to start with the nearest depth upsampling. Here it is explained pretty well:
mutantstargoat → on-depth-aware-upsampling (use google pls. no links allowed here)
Now i feel extra stupid, cause i dont understand how the downsampling needs to be implemented. What i understood:
- Take the full res depth and send it to the downsample shader
- Attach a color attachement texture for the downsampled depth (half size - the texture you are writing to)
- Apply the filtering algorithm per fragment and write it to the attached downsample texture.
What i dont get: Do i render this pass with half resolution (glViewport(…)) ? Cause i dont get any good results. The “upsampled” image still looks jaggy as before
This is my downsample shader code (this pass is rendered in half resolution):
#shader vertex
#version 460 core
layout(location = 0) in vec2 position;
layout(location = 1) in vec2 texCoords;
out vec2 v_TexCoords;
void main()
{
// Full screen quad
gl_Position = vec4(position.x, position.y, 0.0, 1.0);
v_TexCoords = texCoords;
}
#shader fragment
#version 460 core
in vec2 v_TexCoords;
uniform sampler2D u_FullResolutionDepth;
layout(location = 0) out float DownSampledDepthTexture;
void main()
{
//Get max depth from 2x2
float d1 = textureOffset(u_FullResolutionDepth, v_TexCoords, ivec2(0, 0)).x;
float d2 = textureOffset(u_FullResolutionDepth, v_TexCoords, ivec2(0, 1)).x;
float d3 = textureOffset(u_FullResolutionDepth, v_TexCoords, ivec2(1, 1)).x;
float d4 = textureOffset(u_FullResolutionDepth, v_TexCoords, ivec2(1, 0)).x;
DownSampledDepthTexture = max(max(d1, d2), max(d3, d4));
}
The upsampling is exaclty implemented as described in the link above:
- Pass both textures to lighting shader (full res depth and downsampled half res depth)
- Render lighting pass in full res
- Upsample my half res volumetrics texture by nearest depth
still no luck. i feel the topic is pretty nicely described here and there but all the important details are missing
looking forward to little hint on this. thanks guys
Still jaggy:
Here is the bad result and second image what i would expect (maybe not that perfect but close to it. For showcase i simply rendered this in full res):