Fix #136303: Normalize the normals on the Ambient Occlusion node
This commit simply normalizes the normals of the Ambient occlusion node before computing the output to avoid odd behaviour with unnormalized normals. Pull Request: https://projects.blender.org/blender/blender/pulls/136315
This commit is contained in:
@@ -15,13 +15,15 @@ shader node_ambient_occlusion(color ColorIn = color(1.0, 1.0, 1.0),
|
||||
{
|
||||
int global_radius = (Distance == 0.0 && !isconnected(Distance));
|
||||
|
||||
normal normalized_normal = normalize(Normal);
|
||||
|
||||
/* Abuse texture call with special @ao token. */
|
||||
AO = texture("@ao",
|
||||
samples,
|
||||
Distance,
|
||||
Normal[0],
|
||||
Normal[1],
|
||||
Normal[2],
|
||||
normalized_normal[0],
|
||||
normalized_normal[1],
|
||||
normalized_normal[2],
|
||||
inside,
|
||||
"sblur",
|
||||
only_local,
|
||||
|
||||
@@ -124,6 +124,7 @@ ccl_device_noinline
|
||||
{
|
||||
float dist = stack_load_float_default(stack, dist_offset, node.w);
|
||||
float3 normal = stack_valid(normal_offset) ? stack_load_float3(stack, normal_offset) : sd->N;
|
||||
normal = safe_normalize(normal);
|
||||
|
||||
# ifdef __KERNEL_OPTIX__
|
||||
ao = optixDirectCall<float>(0, kg, state, sd, normal, dist, samples, flags);
|
||||
|
||||
@@ -10,6 +10,6 @@ void node_ambient_occlusion(vec4 color,
|
||||
out vec4 result_color,
|
||||
out float result_ao)
|
||||
{
|
||||
result_ao = ambient_occlusion_eval(normal, dist, inverted, sample_count);
|
||||
result_ao = ambient_occlusion_eval(safe_normalize(normal), dist, inverted, sample_count);
|
||||
result_color = result_ao * color;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user