I am building a 3d renderer in C++ using Vulkan.hpp. I am in the process of…
- User
I am building a 3d renderer in C++ using Vulkan.hpp. I am in the process of incorporating a SSAO stage into the rendering pipeline. I have set up all the inputs and Vulkan code, along with a downstream blur shader to adjust the SSAO output, I just need a high quality SSAO fragment shader. I want this shader to take the depth buffer as an input and reconstruct the position information from the depth buffer. It will need to manage projection transformations and also accommodate the near and far planes of the projection as part of some projection transformations. For the time being, I want to hard-code the near and far plane information in the shader code. Based on all of this, can you complete the following partially written SSAO fragment shader code?
The inputs to the shader are as follows:
kernelSize = 64 radius = 0.5 bias = 0.025 noiseScale = swapChainExtent / 8
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; } inputsUBO;
layout(binding = 5) uniform ProjBufferObject { mat4 proj; mat4 projInv; } projUBO;
void main() { float nearPlane = 0.1; float farPlane = 100.0;
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.