diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2021-03-08 19:19:06 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2021-03-08 19:25:38 +0300 |
commit | 30cb4326fe0f5f0a8dbcbb8f4b474226c833d793 (patch) | |
tree | 0f6ca82a1085711b4998a7870790388109a9fc88 | |
parent | 1540f1df076ccd4fda224b7f56aa6ca0d2a9b1c2 (diff) |
EEVEE: Ambient Occlusion: Add sample parameter support for the AO node
The actual sample count is rounded up to a multiple of 4 because we
sample 4 horizons directions.
Changing this setting forces the shader to recompile (because using a
GPU_constant).
-rw-r--r-- | source/blender/gpu/shaders/material/gpu_shader_material_ambient_occlusion.glsl | 3 | ||||
-rw-r--r-- | source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.c | 9 |
2 files changed, 10 insertions, 2 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 0231aeca04b..edf2c93c9a0 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 @@ -3,12 +3,13 @@ void node_ambient_occlusion(vec4 color, float dist, vec3 normal, const float inverted, + const float sample_count, out vec4 result_color, out float result_ao) { vec3 bent_normal; vec4 rand = texelfetch_noise_tex(gl_FragCoord.xy); - OcclusionData data = occlusion_search(viewPosition, maxzBuffer, dist, inverted, 8.0); + OcclusionData data = occlusion_search(viewPosition, maxzBuffer, dist, inverted, sample_count); vec3 V = cameraVec(worldPosition); vec3 N = normalize(normal); diff --git a/source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.c b/source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.c index 36971d4e799..abe80ebcefb 100644 --- a/source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.c +++ b/source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.c @@ -47,8 +47,15 @@ static int node_shader_gpu_ambient_occlusion(GPUMaterial *mat, GPU_material_flag_set(mat, GPU_MATFLAG_DIFFUSE); float inverted = node->custom2 ? 1.0f : 0.0f; + float f_samples = divide_ceil_u(node->custom1, 4); - return GPU_stack_link(mat, node, "node_ambient_occlusion", in, out, GPU_constant(&inverted)); + return GPU_stack_link(mat, + node, + "node_ambient_occlusion", + in, + out, + GPU_constant(&inverted), + GPU_constant(&f_samples)); } static void node_shader_init_ambient_occlusion(bNodeTree *UNUSED(ntree), bNode *node) |