Blender V5.0
wavelength.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2009-2010 Sony Pictures Imageworks Inc., et al. All Rights Reserved.
2 * SPDX-FileCopyrightText: 2011-2022 Blender Foundation
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 * Adapted code from Open Shading Language. */
7
8#pragma once
9
11#include "kernel/svm/util.h"
12
14
16
17/* Wavelength to RGB */
18
20 ccl_private float *stack,
21 const uint wavelength,
22 const uint color_out)
23{
24 const float lambda_nm = stack_load_float(stack, wavelength);
25
26 float3 color = svm_math_wavelength_color_xyz(lambda_nm);
27 color = xyz_to_rgb(kg, color);
28 color *= 1.0f / 2.52f; // Empirical scale from lg to make all comps <= 1
29
30 /* Clamp to zero if values are smaller */
31 color = max(color, make_float3(0.0f, 0.0f, 0.0f));
32
33 stack_store_float3(stack, color_out, color);
34}
35
unsigned int uint
ccl_device_inline float stack_load_float(const ccl_private float *stack, const uint a)
ccl_device_inline void stack_store_float3(ccl_private float *stack, const uint a, const float3 f)
#define ccl_private
const ThreadKernelGlobalsCPU * KernelGlobals
#define ccl_device_noinline
#define CCL_NAMESPACE_END
ccl_device_forceinline float3 make_float3(const float x, const float y, const float z)
ccl_device float3 svm_math_wavelength_color_xyz(const float lambda_nm)
Definition math_util.h:260
color xyz_to_rgb(float x, float y, float z)
Definition node_color.h:73
max
Definition text_draw.cc:251
CCL_NAMESPACE_BEGIN ccl_device_noinline void svm_node_wavelength(KernelGlobals kg, ccl_private float *stack, const uint wavelength, const uint color_out)
Definition wavelength.h:19