blender/intern/cycles/kernel/osl/shaders/node_refraction_bsdf.osl
Sebastian 144e9f6efb Refactor: Cycles: Moving IOR inversion inside the OSL closures
In Cycles we previously assumed that the IOR inversion, when hitting a
surface from the backside, for dielectric closures
(e.g., generalized_schlick, microfacet, refract, etc.) is done by the
user in the OSL code. While experimenting with the OSL code generated
by MaterialX and by looking at the example OSL shaders of the OSL
testrender it shows that OSL assumes that this inversion is done
implicitly, inside the closures. This change matches Cycles IOR
inversion behavior with the one expected by MaterialX and OSL
testrender.

Pull Request: https://projects.blender.org/blender/blender/pulls/162634
2026-09-09 09:12:30 +02:00

18 lines
581 B
Text

/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
*
* SPDX-License-Identifier: Apache-2.0 */
#include "stdcycles.h"
shader node_refraction_bsdf(color Color = 0.8,
string distribution = "ggx",
float Roughness = 0.2,
float IOR = 1.45,
normal Normal = N,
output closure color BSDF = 0)
{
float eta = max(IOR, 1e-5);
float roughness = Roughness * Roughness;
BSDF = Color * microfacet(distribution, Normal, roughness, eta, 1);
}