I am building a 3d renderer in C++ with Vulkan.hpp. I am in the process of incorporating…
- User
I am building a 3d renderer in C++ with Vulkan.hpp. I am in the process of incorporating a SSAO stage in the rendering pipeline. I have already created all of the necessary inputs and a downstream blur shader that is ready for the SSAO output. I now just need a SSAO fragment shader. This fragment shader will need to reconstruct the position information using the depth buffer. To do this it will need to manage projection transformations and be able to linearize depth using the near and far planes. The intention is for the renderer to be used as part of a game engine, so the SSAO process will need to be of high quality, but also efficient. Based on the all this information, can you complete the partial SSAO fragment shader code below? I have also provided some of the input values that will feed into the shader for additional context.
Inputs:
kernelSize = 64 radius = 0.5 bias = 0.025 noiseScale = swapchainExtent / 8 nearPlane = 0.1 farPlane = 100.0
SSAO Fragment Shader code:
#version 450
layout(location = 0) out vec4 FragColor;
layout(location = 0) in vec2 TexCoords;
layout(set = 0, binding = 0) uniform sampler2D gDepth; layout(set = 0, binding = 1) uniform sampler2D gNormal; layout(set = 0, binding = 2) uniform sampler2D texNoise;
layout(binding = 3) buffer SamplesBufferObject { vec3 samples[]; } samplesUBO;
layout(binding = 4) uniform InputsBufferObject { int kernelSize; float radius; float bias; vec2 noiseScale; float nearPlane; float farPlane; } inputsUBO;
layout(binding = 5) uniform ProjBufferObject { mat4 proj; mat4 projInv; } projUBO;
- Assistant
- User
It seems the occlusion effect only effect objects very close to the camera. I want the effect to occur across the entire scene.
- Assistant