HDR, Bloom and SSR

This commit is contained in:
Halbear 2026-09-04 00:23:48 +01:00
parent 577836a03f
commit 04befce27d
44 changed files with 1377 additions and 269 deletions

View file

@ -4,18 +4,42 @@ layout(location = 0) in vec2 inTextCoord;
layout(location = 0) out float outAO;
layout(set = 0, binding = 0) uniform sampler2D ssaoSampler;
layout(set = 0, binding = 1) uniform sampler2D viewPosSampler;
void main() {
vec2 texelSize = 2.0 / vec2(textureSize(ssaoSampler, 0));
vec2 texelSize = 1.0 / vec2(textureSize(ssaoSampler, 0));
float result = 0.0;
float centerAO = texture(ssaoSampler, inTextCoord).r;
float centerDepth = texture(viewPosSampler, inTextCoord).z;
for (int x = -2; x <= 2; x++) {
for (int y = -2; y <= 2; y++) {
vec2 offset = vec2(float(x), float(y)) * texelSize;
result += texture(ssaoSampler, vec2(inTextCoord.x,inTextCoord.y) + offset).r;
}
float totalAO = centerAO;
float totalWeight = 1.0;
float weights[4] = float[](0.227027, 0.1216216, 0.054054, 0.016216);
int offsets[4] = int[](-2, -1, 1, 2);
const float Sharpness = 20.0;
for (int i = 0; i < 4; i++) {
vec2 offsetH = vec2(float(offsets[i]), 0.0) * texelSize;
vec2 uvH = inTextCoord + offsetH;
float neighborAOH = texture(ssaoSampler, uvH).r;
float neighborDepthH = texture(viewPosSampler, uvH).z;
float weightH = weights[i] * max(0.0, 1.0 - Sharpness * abs(centerDepth - neighborDepthH));
totalAO += neighborAOH * weightH;
totalWeight += weightH;
vec2 offsetV = vec2(0.0, float(offsets[i])) * texelSize;
vec2 uvV = inTextCoord + offsetV;
float neighborAOV = texture(ssaoSampler, uvV).r;
float neighborDepthV = texture(viewPosSampler, uvV).z;
float weightV = weights[i] * max(0.0, 1.0 - Sharpness * abs(centerDepth - neighborDepthV));
totalAO += neighborAOV * weightV;
totalWeight += weightV;
}
outAO = result / 25.0;
outAO = totalAO / totalWeight;
}