2#ifndef _TINYPBRT_COLOR_HPP_
3#define _TINYPBRT_COLOR_HPP_
49 case DCI_P3:
return "dci-p3";
50 case SRGB:
return "srgb";
52 default:
return "UNKNOWN";
87 case RGB:
return "rgb";
89 case FILE:
return "file";
93 default:
return "UNKNOWN";
101 struct wavelength : detail::wrapper<wavelength, tpbrt_wavelength_t> {
103 using wrapper::wrapper;
106 [[nodiscard]]
constexpr float_t lambda() const noexcept {
return _native->wavelength; }
109 [[nodiscard]]
constexpr float_t value() const noexcept {
return _native->value; }
245 default:
return "UNKNOWN";
254 struct blackbody : detail::wrapper<blackbody, tpbrt_blackbody_t> {
256 using wrapper::wrapper;
269 struct spectrum : detail::wrapper<spectrum, tpbrt_spectrum_t>,
270 detail::with_variant<spectrum, wavelength_array, rgb, blackbody, string, spectrum_builtin, float_t> {
272 using wrapper::wrapper;
296 [[nodiscard]]
constexpr std::optional<wavelength_array>
as_wavelengths() const noexcept {
298 return _native->as.wavelengths;
302 [[nodiscard]]
constexpr std::optional<rgb>
as_rgb() const noexcept {
303 if (!
is_rgb()) {
return std::nullopt; }
304 return _native->as.rgb;
308 [[nodiscard]]
constexpr std::optional<blackbody>
as_blackbody() const noexcept {
310 return _native->as.blackbody;
314 [[nodiscard]]
constexpr std::optional<string>
as_file() const noexcept {
315 if (!
is_file()) {
return std::nullopt; }
316 return _native->as.file_name;
320 [[nodiscard]]
constexpr std::optional<spectrum_builtin>
as_builtin() const noexcept {
326 [[nodiscard]]
constexpr std::optional<float_t>
as_constant() const noexcept {
328 return _native->as.constant;
332 [[nodiscard]]
constexpr variant_type
to_variant() const noexcept {
336 case RGB:
return _native->as.rgb;
339 _native->as.blackbody
341 case FILE:
return _native->as.file_name;
343 case CONSTANT:
return _native->as.constant;
constexpr std::string_view to_string(const accelerator_type type) noexcept
Converts accelerator_type enum value to string.
Definition accelerator.hpp:39
@ MAX_NUM
Count of available accelerator types.
@ BUILTIN
Aperture value is a builtin aperture.
spectrum_type
Spectrum value type.
Definition color.hpp:60
spectrum_builtin
Spectrum builtins.
Definition color.hpp:119
color_space
Color space types.
Definition color.hpp:25
@ WAVELENGTHS
Spectrum defined as list of pairs (wavelength, value).
@ RGB
Spectrum defined as RGB value.
@ CONSTANT
Spectrum defined as single constant float value.
@ FILE
Spectrum defined as file which contains wavelengths.
@ BLACKBODY
Spectrum defined as Blackbody temperature in Kelvins.
@ BUILTIN
Spectrum defined as builtin value.
@ METAL_AG_K
Extinction coefficient for silver.
@ STD_ILLUM_D65
CIE standard illuminant D65.
@ STD_ILLUM_F2
CIE standard illuminant F2.
@ STD_ILLUM_D50
CIE standard illuminant D50.
@ GLASS_F11
Index of refraction for F11 glass.
@ GLASS_LASF9
Index of refraction for LASF9 glass.
@ METAL_CU_ETA
Index of refraction for copper.
@ STD_ILLUM_F11
CIE standard illuminant F11.
@ STD_ILLUM_F7
CIE standard illuminant F7.
@ METAL_CU_ZN_K
Extinction coefficient for copper zinc alloy.
@ STD_ILLUM_F1
CIE standard illuminant F1.
@ STD_ILLUM_F5
CIE standard illuminant F5.
@ GLASS_BAF10
Index of refraction for BAF10 glass.
@ METAL_TI_O2_ETA
Index of refraction for titanium dioxide.
@ METAL_AL_K
Extinction coefficient for aluminum.
@ STD_ILLUM_F8
CIE standard illuminant F8.
@ STD_ILLUM_F6
CIE standard illuminant F6.
@ METAL_AG_ETA
Index of refraction for silver.
@ STD_ILLUM_F10
CIE standard illuminant F10.
@ METAL_MG_O_K
Extinction coefficient for magnesium oxide.
@ METAL_TI_O2_K
Extinction coefficient for titanium dioxide.
@ METAL_AL_ETA
Index of refraction for aluminum.
@ METAL_MG_O_ETA
Index of refraction for magnesium oxide.
@ STD_ILLUM_F3
CIE standard illuminant F3.
@ STD_ILLUM_A
CIE standard illuminant A.
@ GLASS_FK51A
Index of refraction for FK51A glass.
@ METAL_CU_ZN_ETA
Index of refraction for copper zinc alloy.
@ ILLUM_ACES_D60
D60 illuminant from ACES.
@ METAL_CU_K
Extinction coefficient for copper.
@ STD_ILLUM_F9
CIE standard illuminant F9.
@ GLASS_F10
Index of refraction for F10 glass.
@ METAL_AU_K
Extinction coefficient for gold.
@ STD_ILLUM_F4
CIE standard illuminant F4.
@ GLASS_F5
Index of refraction for F5 glass.
@ METAL_AU_ETA
Index of refraction for gold.
@ GLASS_BK7
Index of refraction for BK7 glass.
@ STD_ILLUM_F12
CIE standard illuminant F12.
@ SRGB
The venerable sRGB color space; it has the smallest gamut of pbrt-v4's color spaces,...
@ ACES_2065_1
The standard color space defined in the Academy Color Encoding System.
@ DCI_P3
The DCI-P3 color space, widely used in current displays.
@ REC_2020
The ITU-R Recommendation BT.2020 color space.
@ TPBRT_SPECTRUM_BUILTIN_STD_ILLUM_F5
CIE standard illuminant F5.
Definition color.h:141
@ TPBRT_SPECTRUM_BUILTIN_METAL_CU_ZN_K
Extinction coefficient for copper zinc alloy.
Definition color.h:117
@ TPBRT_SPECTRUM_BUILTIN_STD_ILLUM_A
CIE standard illuminant A.
Definition color.h:127
@ TPBRT_SPECTRUM_BUILTIN_METAL_CU_ZN_ETA
Index of refraction for copper zinc alloy.
Definition color.h:115
@ TPBRT_SPECTRUM_BUILTIN_STD_ILLUM_F7
CIE standard illuminant F7.
Definition color.h:145
@ TPBRT_SPECTRUM_BUILTIN_MAX_NUM
Count of available spectrum builtins.
Definition color.h:159
@ TPBRT_SPECTRUM_BUILTIN_STD_ILLUM_F11
CIE standard illuminant F11.
Definition color.h:153
@ TPBRT_SPECTRUM_BUILTIN_METAL_AU_K
Extinction coefficient for gold.
Definition color.h:109
@ TPBRT_SPECTRUM_BUILTIN_GLASS_F11
Index of refraction for F11 glass.
Definition color.h:97
@ TPBRT_SPECTRUM_BUILTIN_METAL_TI_O2_ETA
Index of refraction for titanium dioxide.
Definition color.h:123
@ TPBRT_SPECTRUM_BUILTIN_STD_ILLUM_F2
CIE standard illuminant F2.
Definition color.h:135
@ TPBRT_SPECTRUM_BUILTIN_METAL_CU_K
Extinction coefficient for copper.
Definition color.h:113
@ TPBRT_SPECTRUM_BUILTIN_STD_ILLUM_F12
CIE standard illuminant F12.
Definition color.h:155
@ TPBRT_SPECTRUM_BUILTIN_METAL_MG_O_K
Extinction coefficient for magnesium oxide.
Definition color.h:121
@ TPBRT_SPECTRUM_BUILTIN_STD_ILLUM_F9
CIE standard illuminant F9.
Definition color.h:149
@ TPBRT_SPECTRUM_BUILTIN_GLASS_F10
Index of refraction for F10 glass.
Definition color.h:95
@ TPBRT_SPECTRUM_BUILTIN_METAL_TI_O2_K
Extinction coefficient for titanium dioxide.
Definition color.h:125
@ TPBRT_SPECTRUM_BUILTIN_METAL_AL_ETA
Index of refraction for aluminum.
Definition color.h:103
@ TPBRT_SPECTRUM_BUILTIN_STD_ILLUM_F10
CIE standard illuminant F10.
Definition color.h:151
@ TPBRT_SPECTRUM_BUILTIN_GLASS_LASF9
Index of refraction for LASF9 glass.
Definition color.h:91
@ TPBRT_SPECTRUM_BUILTIN_STD_ILLUM_F3
CIE standard illuminant F3.
Definition color.h:137
@ TPBRT_SPECTRUM_BUILTIN_METAL_AU_ETA
Index of refraction for gold.
Definition color.h:107
@ TPBRT_SPECTRUM_BUILTIN_GLASS_BK7
Index of refraction for BK7 glass.
Definition color.h:85
@ TPBRT_SPECTRUM_BUILTIN_METAL_AL_K
Extinction coefficient for aluminum.
Definition color.h:105
@ TPBRT_SPECTRUM_BUILTIN_STD_ILLUM_F4
CIE standard illuminant F4.
Definition color.h:139
@ TPBRT_SPECTRUM_BUILTIN_METAL_CU_ETA
Index of refraction for copper.
Definition color.h:111
@ TPBRT_SPECTRUM_BUILTIN_STD_ILLUM_D65
CIE standard illuminant D65.
Definition color.h:131
@ TPBRT_SPECTRUM_BUILTIN_METAL_AG_ETA
Index of refraction for silver.
Definition color.h:99
@ TPBRT_SPECTRUM_BUILTIN_ILLUM_ACES_D60
D60 illuminant from ACES.
Definition color.h:157
@ TPBRT_SPECTRUM_BUILTIN_METAL_MG_O_ETA
Index of refraction for magnesium oxide.
Definition color.h:119
@ TPBRT_SPECTRUM_BUILTIN_STD_ILLUM_F8
CIE standard illuminant F8.
Definition color.h:147
@ TPBRT_SPECTRUM_BUILTIN_GLASS_FK51A
Index of refraction for FK51A glass.
Definition color.h:89
@ TPBRT_SPECTRUM_BUILTIN_METAL_AG_K
Extinction coefficient for silver.
Definition color.h:101
@ TPBRT_SPECTRUM_BUILTIN_GLASS_BAF10
Index of refraction for BAF10 glass.
Definition color.h:87
@ TPBRT_SPECTRUM_BUILTIN_GLASS_F5
Index of refraction for F5 glass.
Definition color.h:93
@ TPBRT_SPECTRUM_BUILTIN_STD_ILLUM_F6
CIE standard illuminant F6.
Definition color.h:143
@ TPBRT_SPECTRUM_BUILTIN_STD_ILLUM_F1
CIE standard illuminant F1.
Definition color.h:133
@ TPBRT_SPECTRUM_BUILTIN_STD_ILLUM_D50
CIE standard illuminant D50.
Definition color.h:129
@ TPBRT_COLOR_SPACE_ACES_2065_1
The standard color space defined in the Academy Color Encoding System.
Definition color.h:25
@ TPBRT_COLOR_SPACE_REC_2020
The ITU-R Recommendation BT.2020 color space.
Definition color.h:27
@ TPBRT_COLOR_SPACE_DCI_P3
The DCI-P3 color space, widely used in current displays.
Definition color.h:29
@ TPBRT_COLOR_SPACE_MAX_NUM
Count of available color spaces.
Definition color.h:33
@ TPBRT_COLOR_SPACE_SRGB
The venerable sRGB color space; it has the smallest gamut of pbrt-v4's color spaces,...
Definition color.h:31
@ TPBRT_SPECTRUM_TYPE_BUILTIN
Spectrum defined as builtin value.
Definition color.h:50
@ TPBRT_SPECTRUM_TYPE_BLACKBODY
Spectrum defined as Blackbody temperature in Kelvins.
Definition color.h:46
@ TPBRT_SPECTRUM_TYPE_CONSTANT
Spectrum defined as single constant float value.
Definition color.h:52
@ TPBRT_SPECTRUM_TYPE_MAX_NUM
Count of available spectrum value types.
Definition color.h:54
@ TPBRT_SPECTRUM_TYPE_WAVELENGTHS
Spectrum defined as list of pairs (wavelength, value).
Definition color.h:42
@ TPBRT_SPECTRUM_TYPE_RGB
Spectrum defined as RGB value.
Definition color.h:44
@ TPBRT_SPECTRUM_TYPE_FILE
Spectrum defined as file which contains wavelengths.
Definition color.h:48
tpbrt_uchar_t uchar_t
Unsigned char type.
Definition fwd.hpp:34
bool bool_t
Bool type.
Definition fwd.hpp:82
tpbrt_float_t float_t
Float type.
Definition fwd.hpp:97
Definition accelerator.hpp:14
C++ wrapper for tpbrt_blackbody_t (a separate type, so a blackbody spectrum is not confused with a co...
Definition color.hpp:254
constexpr float_t temperature() const noexcept
Returns blackbody temperature in Kelvin.
Definition color.hpp:259
constexpr auto reflect() const noexcept
Conversion to tuple.
Definition color.hpp:262
C++ wrapper for tpbrt_spectrum_t.
Definition color.hpp:270
constexpr spectrum_type type() const noexcept
Returns type value.
Definition color.hpp:275
constexpr auto reflect() const noexcept
Conversion to tuple.
Definition color.hpp:351
constexpr std::optional< float_t > as_constant() const noexcept
Returns spectrum value as constant.
Definition color.hpp:326
constexpr bool_t is_builtin() const noexcept
Returns true if type is builtin.
Definition color.hpp:290
constexpr bool_t is_rgb() const noexcept
Returns true if type is rgb.
Definition color.hpp:281
constexpr std::optional< string > as_file() const noexcept
Returns spectrum value as file.
Definition color.hpp:314
constexpr std::optional< blackbody > as_blackbody() const noexcept
Returns spectrum value as blackbody.
Definition color.hpp:308
constexpr bool_t is_wavelengths() const noexcept
Returns true if type is wavelengths.
Definition color.hpp:278
constexpr std::optional< rgb > as_rgb() const noexcept
Returns spectrum value as rgb.
Definition color.hpp:302
constexpr bool_t is_file() const noexcept
Returns true if type is file.
Definition color.hpp:287
constexpr std::optional< wavelength_array > as_wavelengths() const noexcept
Returns spectrum value as wavelengths.
Definition color.hpp:296
constexpr std::optional< spectrum_builtin > as_builtin() const noexcept
Returns spectrum value as builtin.
Definition color.hpp:320
constexpr bool_t is_constant() const noexcept
Returns true if type is constant.
Definition color.hpp:293
constexpr bool_t is_blackbody() const noexcept
Returns true if type is blackbody.
Definition color.hpp:284
constexpr variant_type to_variant() const noexcept
Conversion to variant.
Definition color.hpp:332
C++ wrapper for tpbrt_wavelength_t.
Definition color.hpp:101
constexpr auto reflect() const noexcept
Conversion to tuple.
Definition color.hpp:112
constexpr float_t value() const noexcept
Returns value value.
Definition color.hpp:109
constexpr float_t lambda() const noexcept
Returns wavelength value.
Definition color.hpp:106