blender/intern/cycles/kernel/osl/shaders/stdcycles.h
Weizhen Huang 01fd268921 Fix: Render: Wrong thin glass roughness mapping
The original mapping from Kulla applies on perceptual roughness instead
of alpha. After this fix, thin glass with low IOR matches the thick
glass better.

Also rename `roughness` to `alpha` in Cycles where it refers to the
`alpha` parameter in GGX for clarity.

Pull Request: https://projects.blender.org/blender/blender/pulls/165250
2026-10-20 11:24:23 +02:00

101 lines
3.6 KiB
C

/* SPDX-FileCopyrightText: 2009-2010 Sony Pictures Imageworks Inc., et al. All Rights Reserved.
* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
*
* SPDX-License-Identifier: BSD-3-Clause
*
* Adapted code from Open Shading Language. */
#ifndef CCL_STDCYCLESOSL_H
#define CCL_STDCYCLESOSL_H
#include "stdosl.h"
// Constants
#define FLT_MAX 3.402823466e+38 // max value
/* Default offset of coordinates for evaluating bump node. Unit in pixel. */
#define BUMP_FILTER_WIDTH 0.1
// Declaration of built-in functions and closures, stdosl.h does not make
// these available so we have to redefine them.
#define BUILTIN [[int builtin = 1]]
#define BUILTIN_DERIV [[ int builtin = 1, int deriv = 1 ]]
closure color diffuse_ramp(normal N, color colors[8]) BUILTIN;
closure color phong_ramp(normal N, float exponent, color colors[8]) BUILTIN;
closure color diffuse_toon(normal N, float size, float smooth) BUILTIN;
closure color glossy_toon(normal N, float size, float smooth) BUILTIN;
closure color ashikhmin_velvet(normal N, float sigma) BUILTIN;
closure color microfacet_f82_tint(
string distribution, vector N, vector T, float ax, float ay, color f0, color f82) BUILTIN;
/* Needed to pass along the color for multi-scattering saturation adjustment,
* otherwise could be replaced by microfacet() */
closure color microfacet_multi_ggx_glass(normal N, float ag, float eta, color C) BUILTIN;
closure color microfacet_multi_ggx_aniso(normal N, vector T, float ax, float ay, color C) BUILTIN;
closure color thin_glass(normal N,
vector T,
color reflection,
color transmission,
float ior,
float alpha,
float thinfilm_thickness,
float thinfilm_ior) BUILTIN;
closure color
thin_subsurface(normal N, vector T, color C, float anisotropy, float roughness) BUILTIN;
closure color coat_bsdf(color C, float ior, float roughness, normal N) BUILTIN;
// BSSRDF
closure color bssrdf(string method, normal N, vector radius, color albedo) BUILTIN;
// Hair
closure color
hair_reflection(normal N, float roughnessu, float roughnessv, vector T, float offset) BUILTIN;
closure color
hair_transmission(normal N, float roughnessu, float roughnessv, vector T, float offset) BUILTIN;
closure color hair_chiang(normal N,
color sigma,
float roughnessu,
float roughnessv,
float coat,
float alpha,
float eta) BUILTIN;
closure color hair_huang(normal N,
color sigma,
float roughness,
float tilt,
float eta,
float aspect_ratio,
float r_lobe,
float tt_lobe,
float trt_lobe) BUILTIN;
// Volume
closure color henyey_greenstein(float g) BUILTIN;
closure color fournier_forand(float B, float IOR) BUILTIN;
closure color draine(float g, float alpha) BUILTIN;
closure color rayleigh() BUILTIN;
closure color absorption() BUILTIN;
// Ray Portal
closure color ray_portal_bsdf(vector position, vector direction) BUILTIN;
point camera_shader_raster_position()
{
return P;
}
vector camera_shader_random_sample()
{
return vector(N);
}
/* Deprecated, should use `sheen_bsdf()` instead. Can remove in 6.0. */
closure color sheen(normal N, float roughness)
{
return sheen_bsdf(N, color(1.0), roughness);
}
#endif /* CCL_STDOSL_H */