HDR, Bloom and SSR
This commit is contained in:
parent
577836a03f
commit
04befce27d
44 changed files with 1377 additions and 269 deletions
|
|
@ -30,8 +30,9 @@ layout(set = 0, binding = 3) uniform sampler2D pbrSampler;
|
|||
layout(set = 0, binding = 4) uniform sampler2D emissiveSampler;
|
||||
layout(set = 0, binding = 5) uniform sampler2D TranslucencySampler;
|
||||
layout(set = 0, binding = 6) uniform sampler2D OpacitySampler;
|
||||
layout(set = 0, binding = 7) uniform sampler2D ssaoBlur;
|
||||
layout(set = 0, binding = 8) uniform sampler2DArray shadowSampler;
|
||||
layout(set = 0, binding = 7) uniform sampler2D viewPos;
|
||||
layout(set = 0, binding = 8) uniform sampler2D ssaoBlur;
|
||||
layout(set = 0, binding = 9) uniform sampler2DArray shadowSampler;
|
||||
|
||||
|
||||
layout(scalar, set = 1, binding = 0) readonly buffer Lights {
|
||||
|
|
@ -62,12 +63,12 @@ float chebyshevUpperBound(vec2 moments, float t) {
|
|||
float p_max = variance / (variance + d * d);
|
||||
|
||||
// Reduce light bleeding
|
||||
p_max = smoothstep(0.2, 1.0, p_max);
|
||||
p_max = smoothstep(0.5, 1.0, p_max);
|
||||
|
||||
return p_max;
|
||||
}
|
||||
|
||||
float calcVisibility(vec4 worldPosition, uint cascadeIndex, float ShadowBias) {
|
||||
float calcVisibility(vec4 worldPosition, uint cascadeIndex, float ShadowBias, vec2 texelSize) {
|
||||
vec4 shadowMapPosition = shadows.cascadeshadows[cascadeIndex].projViewMatrix * worldPosition;
|
||||
|
||||
shadowMapPosition.xyz /= shadowMapPosition.w;
|
||||
|
|
@ -87,19 +88,18 @@ float calcVisibility(vec4 worldPosition, uint cascadeIndex, float ShadowBias) {
|
|||
|
||||
float shadow = 0.0;
|
||||
|
||||
vec2 texelSize = 1.0 / textureSize(shadowSampler, 0).rg;
|
||||
for(int x = -1; x <= 1; ++x)
|
||||
{
|
||||
for(int y = -1; y <= 1; ++y)
|
||||
{
|
||||
vec2 moments = texture(shadowSampler, vec3((uv + vec2(x, y) * texelSize), cascadeIndex)).rg;
|
||||
float visibility = chebyshevUpperBound(moments, depth);
|
||||
shadow += depth - ShadowBias > visibility ? 1.0 : 0.0;
|
||||
shadow += visibility;
|
||||
}
|
||||
}
|
||||
shadow /= 9.0;
|
||||
|
||||
return 1 - shadow;
|
||||
return shadow;
|
||||
}
|
||||
|
||||
float distributionGGX(vec3 N, vec3 H, float roughness) {
|
||||
|
|
@ -193,13 +193,17 @@ vec3 calculateDirectionalLight(Light light, vec3 V, vec3 N, vec3 F0, vec3 albedo
|
|||
|
||||
void main() {
|
||||
vec3 albedo = texture(albedoSampler, inTextCoord).rgb;
|
||||
vec3 normal = texture(normalsSampler, inTextCoord).rgb;
|
||||
vec4 normalW = texture(normalsSampler, inTextCoord);
|
||||
vec3 normal = normalW.rgb;
|
||||
vec4 worldPosW = texture(posSampler, inTextCoord);
|
||||
vec3 worldPos = worldPosW.xyz;
|
||||
vec3 pbr = texture(pbrSampler, inTextCoord).rgb;
|
||||
vec4 pbrW = texture(pbrSampler, inTextCoord);
|
||||
vec3 pbr = pbrW.rgb;
|
||||
vec3 emissive = texture(emissiveSampler, inTextCoord).rgb;
|
||||
vec3 Opacity = texture(OpacitySampler, inTextCoord).rgb;
|
||||
vec3 translucency = texture(TranslucencySampler, inTextCoord).rgb;
|
||||
float Reflectivity = pbrW.a;
|
||||
float Refractivity = normalW.a;
|
||||
|
||||
float emissiveness = emissive.r;
|
||||
float translucencyf = translucency.r;
|
||||
|
|
@ -231,7 +235,10 @@ void main() {
|
|||
cascadeIndex = i + 1;
|
||||
}
|
||||
}
|
||||
float shadow = calcVisibility(vec4(worldPos, 1), cascadeIndex,ShadowBias);
|
||||
|
||||
vec2 texelSizeShadow = 1.0 / textureSize(shadowSampler, 0).rg;
|
||||
|
||||
float shadow = calcVisibility(vec4(worldPos, 1), cascadeIndex,ShadowBias, texelSizeShadow);
|
||||
|
||||
vec3 Lo = vec3(0.0);
|
||||
for (uint i = 0; i < sceneInfo.numLights; i++) {
|
||||
|
|
@ -242,7 +249,7 @@ void main() {
|
|||
Lo += calculatePointLight(light, worldPos, V, N, F0, albedo, metallic, roughness);
|
||||
}
|
||||
}
|
||||
vec3 ambient = sceneInfo.ambientLightColor * albedo * sceneInfo.ambientLightIntensity * vec3(ssao,ssao,ssao);;
|
||||
vec3 ambient = sceneInfo.ambientLightColor * albedo * sceneInfo.ambientLightIntensity * vec3(ssao,ssao,ssao);
|
||||
if(emissive.x > 0 || emissive.y > 0 || emissive.z > 0) ambient = emissive;
|
||||
outFragColor = vec4(Lo + ambient, 1.0f);
|
||||
outFragColor = vec4(outFragColor.xyz/2 + (outFragColor.xyz/2) * vec3(ssao,ssao,ssao),1);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue