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 already set everything up in Vulkan and also already have a downstream blur shader ready to accept the outputs of the SSAO. I now just need to good SSAO fragment shader. The shader will need to reconstruct the position information from the depth buffer. The samples that are supplied to the shader are hemispherical samples. Using the following inputs as a guide, and the beginnings of the shader showing the input data, can you complete the SSAO fragment shader code? Please ensure your syntax is correct, you refer to the input buffer objects correctly and you don't use any variable names that are reserved by GLSL.
Inputs:
kernelSize = 64 radius = 0.5 bias = 0.025 noiseScalewidth = swapChainWidth / 2 = 400 noiseScaleheight = swapChainHeight / 2 = 300 nearPlane = 0.1 farPlane = 100
SSAO Fragment Shader code start:
#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; float noiseScalewidth; float noiseScaleheight; float nearPlane; float farPlane; } inputsUBO;
layout(binding = 5) uniform ProjBufferObject { mat4 proj; mat4 projInv; } projUBO;
- Assistant