Blender V5.3
kernel/tables.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5/* clang-format off */
6
7#pragma once
8
9#include "util/defines.h"
10
12 {1.61919106e+03f, -2.05010916e-03f, 5.02995757e+00f},
13 {2.48845471e+03f, -1.11330907e-03f, 3.22621544e+00f},
14 {3.34143193e+03f, -4.86551192e-04f, 1.76486769e+00f},
15 {4.09461742e+03f, -1.27446582e-04f, 7.25731635e-01f},
16 {4.67028036e+03f, 2.91258199e-05f, 1.26703442e-01f},
17 {4.59509185e+03f, 2.87495649e-05f, 1.50345020e-01f},
18 {3.78717450e+03f, 9.35907826e-06f, 3.99075871e-01f}
19};
20
22 {-4.88999748e+02f, 6.04330754e-04f, -7.55807526e-02f},
23 {-7.55994277e+02f, 3.16730098e-04f, 4.78306139e-01f},
24 {-1.02363977e+03f, 1.20223470e-04f, 9.36662319e-01f},
25 {-1.26571316e+03f, 4.87340896e-06f, 1.27054498e+00f},
26 {-1.42529332e+03f, -4.01150431e-05f, 1.43972784e+00f},
27 {-1.17554822e+03f, -2.16378048e-05f, 1.30408023e+00f},
28 {-5.00799571e+02f, -4.59832026e-06f, 1.09098763e+00f}
29};
30
32 {5.96945309e-11f, -4.85742887e-08f, -9.70622247e-05f, -4.07936148e-03f},
33 {2.40430366e-11f, 5.55021075e-08f, -1.98503712e-04f, 2.89312858e-02f},
34 {-1.40949732e-11f, 1.89878968e-07f, -3.56632824e-04f, 9.10767778e-02f},
35 {-3.61460868e-11f, 2.84822009e-07f, -4.93211319e-04f, 1.56723440e-01f},
36 {-1.97075738e-11f, 1.75359352e-07f, -2.50542825e-04f, -2.22783266e-02f},
37 {-1.61997957e-13f, -1.64216008e-08f, 3.86216271e-04f, -7.38077418e-01f},
38 {6.72650283e-13f, -2.73078809e-08f, 4.24098264e-04f, -7.52335691e-01f}
39};
40
41/* CIE1931 visible wavelength range in um. */
42#define WAVELENGTH_CIE_MIN 0.38f
43#define WAVELENGTH_CIE_MAX 0.78f
44/* Wavelength steps in um. */
45#define WAVELENGTH_DLAMBDA 0.005f
46/* Table resolution, (WAVELENGTH_CIE_MAX - WAVELENGTH_CIE_MIN) / WAVELENGTH_DLAMBDA */
47#define WAVELENGTH_RESOLUTION 80
48
49/* CIE 1931 colour-matching functions, 2 degree observer
50 * x, y, and z for wavelengths from 380 to 780 nm, 5 nm wavelength steps.
51 * https://doi.org/10.25039/CIE.DS.xvudnb9b
52 */
54 {0.0014f, 0.0000f, 0.0065f}, {0.0022f, 0.0001f, 0.0105f}, {0.0042f, 0.0001f, 0.0201f},
55 {0.0076f, 0.0002f, 0.0362f}, {0.0143f, 0.0004f, 0.0679f}, {0.0232f, 0.0006f, 0.1102f},
56 {0.0435f, 0.0012f, 0.2074f}, {0.0776f, 0.0022f, 0.3713f}, {0.1344f, 0.0040f, 0.6456f},
57 {0.2148f, 0.0073f, 1.0391f}, {0.2839f, 0.0116f, 1.3856f}, {0.3285f, 0.0168f, 1.6230f},
58 {0.3483f, 0.0230f, 1.7471f}, {0.3481f, 0.0298f, 1.7826f}, {0.3362f, 0.0380f, 1.7721f},
59 {0.3187f, 0.0480f, 1.7441f}, {0.2908f, 0.0600f, 1.6692f}, {0.2511f, 0.0739f, 1.5281f},
60 {0.1954f, 0.0910f, 1.2876f}, {0.1421f, 0.1126f, 1.0419f}, {0.0956f, 0.1390f, 0.8130f},
61 {0.0580f, 0.1693f, 0.6162f}, {0.0320f, 0.2080f, 0.4652f}, {0.0147f, 0.2586f, 0.3533f},
62 {0.0049f, 0.3230f, 0.2720f}, {0.0024f, 0.4073f, 0.2123f}, {0.0093f, 0.5030f, 0.1582f},
63 {0.0291f, 0.6082f, 0.1117f}, {0.0633f, 0.7100f, 0.0782f}, {0.1096f, 0.7932f, 0.0573f},
64 {0.1655f, 0.8620f, 0.0422f}, {0.2257f, 0.9149f, 0.0298f}, {0.2904f, 0.9540f, 0.0203f},
65 {0.3597f, 0.9803f, 0.0134f}, {0.4334f, 0.9950f, 0.0087f}, {0.5121f, 1.0000f, 0.0057f},
66 {0.5945f, 0.9950f, 0.0039f}, {0.6784f, 0.9786f, 0.0027f}, {0.7621f, 0.9520f, 0.0021f},
67 {0.8425f, 0.9154f, 0.0018f}, {0.9163f, 0.8700f, 0.0017f}, {0.9786f, 0.8163f, 0.0014f},
68 {1.0263f, 0.7570f, 0.0011f}, {1.0567f, 0.6949f, 0.0010f}, {1.0622f, 0.6310f, 0.0008f},
69 {1.0456f, 0.5668f, 0.0006f}, {1.0026f, 0.5030f, 0.0003f}, {0.9384f, 0.4412f, 0.0002f},
70 {0.8544f, 0.3810f, 0.0002f}, {0.7514f, 0.3210f, 0.0001f}, {0.6424f, 0.2650f, 0.0000f},
71 {0.5419f, 0.2170f, 0.0000f}, {0.4479f, 0.1750f, 0.0000f}, {0.3608f, 0.1382f, 0.0000f},
72 {0.2835f, 0.1070f, 0.0000f}, {0.2187f, 0.0816f, 0.0000f}, {0.1649f, 0.0610f, 0.0000f},
73 {0.1212f, 0.0446f, 0.0000f}, {0.0874f, 0.0320f, 0.0000f}, {0.0636f, 0.0232f, 0.0000f},
74 {0.0468f, 0.0170f, 0.0000f}, {0.0329f, 0.0119f, 0.0000f}, {0.0227f, 0.0082f, 0.0000f},
75 {0.0158f, 0.0057f, 0.0000f}, {0.0114f, 0.0041f, 0.0000f}, {0.0081f, 0.0029f, 0.0000f},
76 {0.0058f, 0.0021f, 0.0000f}, {0.0041f, 0.0015f, 0.0000f}, {0.0029f, 0.0010f, 0.0000f},
77 {0.0020f, 0.0007f, 0.0000f}, {0.0014f, 0.0005f, 0.0000f}, {0.0010f, 0.0004f, 0.0000f},
78 {0.0007f, 0.0002f, 0.0000f}, {0.0005f, 0.0002f, 0.0000f}, {0.0003f, 0.0001f, 0.0000f},
79 {0.0002f, 0.0001f, 0.0000f}, {0.0002f, 0.0001f, 0.0000f}, {0.0001f, 0.0000f, 0.0000f},
80 {0.0001f, 0.0000f, 0.0000f}, {0.0001f, 0.0000f, 0.0000f}, {0.0000f, 0.0000f, 0.0000f}
81};
82
83/* Normalization factor so that the D65 spectrum integrates to a luminance of 1.0 under
84 * CIE1931 2 degree observer. */
85#define CIE_D65_NORMALIZATION 0.03785528242588043212890625f
86
87/* Spectral power distribution of D65, wavelengths from 380 to 780 nm, 5 nm wavelength steps.
88 * https://doi.org/10.25039/CIE.DS.hjfjmt59
89 */
91 49.9755f, 52.3118f, 54.6482f, 68.7015f, 82.7549f, 87.1204f, 91.486f, 92.4589f, 93.4318f,
92 90.057f, 86.6823f, 95.7736f, 104.865f, 110.936f, 117.008f, 117.41f, 117.812f, 116.336f,
93 114.861f, 115.392f, 115.923f, 112.367f, 108.811f, 109.082f, 109.354f, 108.578f, 107.802f,
94 106.296f, 104.79f, 106.239f, 107.689f, 106.047f, 104.405f, 104.225f, 104.046f, 102.023f,
95 100.0f, 98.1671f, 96.3342f, 96.0611f, 95.788f, 92.2368f, 88.6856f, 89.3459f, 90.0062f,
96 89.8026f, 89.5991f, 88.6489f, 87.6987f, 85.4936f, 83.2886f, 83.4939f, 83.6992f, 81.863f,
97 80.0268f, 80.1207f, 80.2146f, 81.2462f, 82.2778f, 80.281f, 78.2842f, 74.0027f, 69.7213f,
98 70.6652f, 71.6091f, 72.979f, 74.349f, 67.9765f, 61.604f, 65.7448f, 69.8856f, 72.4863f,
99 75.087f, 69.3398f, 63.5927f, 55.0054f, 46.4182f, 56.6118f, 66.8054f, 65.0941f, 63.3828f,
100};
101
102/*
103 * The direction vectors for the first four dimensions of the Sobol
104 * sequence, stored with reversed-order bits.
105 *
106 * This is used in the Sobol-Burley sampler implementation. We don't
107 * need more than four dimensions because we achieve higher dimensions
108 * with padding. They're stored with reversed bits because we need
109 * them reversed for the fast hash-based Owen scrambling anyway, and
110 * this avoids doing that at run time.
111 */
113 {
114 0x00000001, 0x00000002, 0x00000004, 0x00000008,
115 0x00000010, 0x00000020, 0x00000040, 0x00000080,
116 0x00000100, 0x00000200, 0x00000400, 0x00000800,
117 0x00001000, 0x00002000, 0x00004000, 0x00008000,
118 0x00010000, 0x00020000, 0x00040000, 0x00080000,
119 0x00100000, 0x00200000, 0x00400000, 0x00800000,
120 0x01000000, 0x02000000, 0x04000000, 0x08000000,
121 0x10000000, 0x20000000, 0x40000000, 0x80000000,
122 },
123 {
124 0x00000001, 0x00000003, 0x00000005, 0x0000000f,
125 0x00000011, 0x00000033, 0x00000055, 0x000000ff,
126 0x00000101, 0x00000303, 0x00000505, 0x00000f0f,
127 0x00001111, 0x00003333, 0x00005555, 0x0000ffff,
128 0x00010001, 0x00030003, 0x00050005, 0x000f000f,
129 0x00110011, 0x00330033, 0x00550055, 0x00ff00ff,
130 0x01010101, 0x03030303, 0x05050505, 0x0f0f0f0f,
131 0x11111111, 0x33333333, 0x55555555, 0xffffffff,
132 },
133 {
134 0x00000001, 0x00000003, 0x00000006, 0x00000009,
135 0x00000017, 0x0000003a, 0x00000071, 0x000000a3,
136 0x00000116, 0x00000339, 0x00000677, 0x000009aa,
137 0x00001601, 0x00003903, 0x00007706, 0x0000aa09,
138 0x00010117, 0x0003033a, 0x00060671, 0x000909a3,
139 0x00171616, 0x003a3939, 0x00717777, 0x00a3aaaa,
140 0x01170001, 0x033a0003, 0x06710006, 0x09a30009,
141 0x16160017, 0x3939003a, 0x77770071, 0xaaaa00a3,
142 },
143 {
144 0x00000001, 0x00000003, 0x00000004, 0x0000000a,
145 0x0000001f, 0x0000002e, 0x00000045, 0x000000c9,
146 0x0000011b, 0x000002a4, 0x0000079a, 0x00000b67,
147 0x0000101e, 0x0000302d, 0x00004041, 0x0000a0c3,
148 0x0001f104, 0x0002e28a, 0x000457df, 0x000c9bae,
149 0x0011a105, 0x002a7289, 0x0079e7db, 0x00b6dba4,
150 0x0100011a, 0x030002a7, 0x0400079e, 0x0a000b6d,
151 0x1f001001, 0x2e003003, 0x45004004, 0xc900a00a,
152 },
153};
154
155/* clang-format on */
#define ccl_inline_constant
ccl_inline_constant unsigned int sobol_burley_table[4][32]
ccl_inline_constant float blackbody_table_r[][3]
ccl_inline_constant float cie_color_match[][3]
ccl_inline_constant float blackbody_table_g[][3]
ccl_inline_constant float cie_d65_spd[]
ccl_inline_constant float blackbody_table_b[][4]