blender/intern/cycles/kernel/osl/shaders/node_ambient_occlusion.osl
Alaska 2e829ca4cf 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
2025-03-27 02:58:19 +01:00

33 lines
1.1 KiB
Text

/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
*
* SPDX-License-Identifier: Apache-2.0 */
#include "stdcycles.h"
shader node_ambient_occlusion(color ColorIn = color(1.0, 1.0, 1.0),
int samples = 16,
float Distance = 1.0,
normal Normal = N,
int inside = 0,
int only_local = 0,
output color ColorOut = color(1.0, 1.0, 1.0),
output float AO = 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,
normalized_normal[0],
normalized_normal[1],
normalized_normal[2],
inside,
"sblur",
only_local,
"tblur",
global_radius);
ColorOut = ColorIn * AO;
}