Clamp some of the inputs of the Glossy BSDF, Glass BSDF, Sheen BSDF, and Subsurface Scattering nodes to improve consistency between render engines and to avoid unexpected results. * Clamp roughness to 0..1 * Clamp subsurface radius to 0..inf * Clamp colors to 0..inf Pull Request: https://projects.blender.org/blender/blender/pulls/120390
26 lines
787 B
Plaintext
26 lines
787 B
Plaintext
/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0 */
|
|
|
|
#include "node_fresnel.h"
|
|
#include "stdcycles.h"
|
|
|
|
shader node_glass_bsdf(color Color = 0.8,
|
|
string distribution = "ggx",
|
|
float Roughness = 0.2,
|
|
float IOR = 1.45,
|
|
normal Normal = N,
|
|
output closure color BSDF = 0)
|
|
{
|
|
color base_color = max(Color, color(0.0));
|
|
float r2 = clamp(Roughness, 0.0, 1.0);
|
|
r2 = r2 * r2;
|
|
float eta = max(IOR, 1e-5);
|
|
eta = backfacing() ? 1.0 / eta : eta;
|
|
color F0 = F0_from_ior(eta);
|
|
color F90 = color(1.0);
|
|
|
|
BSDF = generalized_schlick_bsdf(
|
|
Normal, vector(0.0), base_color, base_color, r2, r2, F0, F90, -eta, distribution);
|
|
}
|