mirror of
https://github.com/blender/blender
synced 2026-10-25 03:07:01 +03:00
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
33 lines
1.1 KiB
Text
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;
|
|
}
|