diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2021-02-20 22:33:28 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2021-02-21 03:33:56 +0300 |
commit | dee94afd039de7b7d3002ff2f8f1f0bf4c515bb3 (patch) | |
tree | 8aee8c086ece945e8b29491911f6d7cfb9ab422d /source/blender/gpu/shaders | |
parent | 764082676b4c8761573f5e7b91e004a3a83f2ec7 (diff) |
EEVEE: Ambient Occlusion Node: Support inverted and distance parameters
This adds an approximation of inverted AO by reversing the max horizon
search (becoming a min horizon). The horizons are correctly clamped in
the reverse direction to the shading and geometric normals.
The arc integration is untouched as it seems to be symetrical.
The limitation of this technique is that since it is still screen-space
AO you don't get other hidden surfaces occlusion. This is more
problematic in the case of inverted AO than for normal AO but it's
better than no support AO.
Support of distance parameter was easy thanks to recent AO refactor.
Diffstat (limited to 'source/blender/gpu/shaders')
-rw-r--r-- | source/blender/gpu/shaders/material/gpu_shader_material_ambient_occlusion.glsl | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_ambient_occlusion.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_ambient_occlusion.glsl index f3eea9869e5..4721b9f0132 100644 --- a/source/blender/gpu/shaders/material/gpu_shader_material_ambient_occlusion.glsl +++ b/source/blender/gpu/shaders/material/gpu_shader_material_ambient_occlusion.glsl @@ -1,19 +1,24 @@ #ifndef VOLUMETRICS -void node_ambient_occlusion( - vec4 color, float distance, vec3 normal, out vec4 result_color, out float result_ao) +void node_ambient_occlusion(vec4 color, + float dist, + vec3 normal, + const float inverted, + out vec4 result_color, + out float result_ao) { vec3 bent_normal; vec4 rand = texelfetch_noise_tex(gl_FragCoord.xy); - OcclusionData data = occlusion_load(viewPosition, 1.0); + OcclusionData data = occlusion_search(viewPosition, maxzBuffer, dist, inverted, 8.0); vec3 V = cameraVec; vec3 N = normalize(normal); vec3 Ng = safe_normalize(cross(dFdx(worldPosition), dFdy(worldPosition))); - result_ao = diffuse_occlusion(data, V, N, Ng); + vec3 unused; + occlusion_eval(data, V, N, Ng, inverted, result_ao, unused); result_color = result_ao * color; } #else /* Stub ambient occlusion because it is not compatible with volumetrics. */ -# define node_ambient_occlusion(a, b, c, d, e) (e = CLOSURE_DEFAULT) +# define node_ambient_occlusion(a, b, c, d, e, f) (e = vec4(0); f = 0.0) #endif |