Blender V5.3
eevee_lightprobe_sphere_bake.bsl.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
11#include "eevee_uniform.bsl.hh"
16
18
19struct Remap {
22
23 [[storage(0, write)]] SphereProbeHarmonic (&out_sh)[];
24 [[storage(1, write)]] SphereProbeSunLight (&out_sun)[];
25
30
33
35
36 [[shared]] float4 local_radiance[SPHERE_PROBE_REMAP_GROUP_SIZE * SPHERE_PROBE_REMAP_GROUP_SIZE];
37};
38
40{
41 return 2.0f * atan(abs(dot(A, cross(B, C))), (1.0f + dot(B, C) + dot(A, C) + dot(A, B)));
42}
43
48
49float octahedral_texel_solid_angle(int2 local_texel, SphereProbePixelArea write_co)
50{
51 if (any(equal(local_texel, int2(write_co.extent - 1)))) {
52 /* Do not weight these border pixels that are redundant. */
53 return 0.0f;
54 }
55 /* Since we are putting texel centers on the edges of the octahedron, the shape of a texel can be
56 * anything from a simple quad (at the Z=0 poles), to a 4 pointed start (at the Z=+-1 poles)
57 * passing by arrow tail shapes (at the X=0 and Y=0 edges).
58 *
59 * But we can leverage the symmetries of the octahedral mapping. Given that all oddly shaped
60 * texels are on the X=0 and Y=0 planes, we first fold all texels to the first quadrant.
61 *
62 * The texel footprint clipped to a quadrant is a well defined spherical quad. We then multiply
63 * by the number of clipped shape the real texel sustains. This number is 2 at the X=0 and Y=0
64 * edges (the arrow shaped pixels) and 4 at the Z=+-1 poles (4 pointed start shaped pixels).
65 *
66 * The sum of all texels solid angle should be 4 PI (area of sphere). */
67
68 /* Wrap to bottom left quadrant. */
69 int half_size = write_co.extent >> 1;
70 int padded_size = write_co.extent - 2;
71 int2 wrapped_texel;
72 wrapped_texel.x = (local_texel.x >= half_size) ? (padded_size - local_texel.x) : local_texel.x;
73 wrapped_texel.y = (local_texel.y >= half_size) ? (padded_size - local_texel.y) : local_texel.y;
74
75 float2 texel_corner_v00 = float2(wrapped_texel) + float2(-0.5f, -0.5f);
76 float2 texel_corner_v10 = float2(wrapped_texel) + float2(+0.5f, -0.5f);
77 float2 texel_corner_v01 = float2(wrapped_texel) + float2(-0.5f, +0.5f);
78 float2 texel_corner_v11 = float2(wrapped_texel) + float2(+0.5f, +0.5f);
79 /* Clamp to well defined shape in spherical domain. */
80 texel_corner_v00 = clamp(texel_corner_v00, float2(0.0f), float2(half_size - 1));
81 texel_corner_v10 = clamp(texel_corner_v10, float2(0.0f), float2(half_size - 1));
82 texel_corner_v01 = clamp(texel_corner_v01, float2(0.0f), float2(half_size - 1));
83 texel_corner_v11 = clamp(texel_corner_v11, float2(0.0f), float2(half_size - 1));
84 /* Convert to point on sphere. */
85 float3 v00 = texel_to_direction(texel_corner_v00, write_co);
86 float3 v10 = texel_to_direction(texel_corner_v10, write_co);
87 float3 v01 = texel_to_direction(texel_corner_v01, write_co);
88 float3 v11 = texel_to_direction(texel_corner_v11, write_co);
89 /* The solid angle functions expect normalized vectors. */
90 v00 = normalize(v00);
91 v10 = normalize(v10);
92 v01 = normalize(v01);
93 v11 = normalize(v11);
94 /* Compute solid angle of the spherical quad. */
95 float texel_clipped_solid_angle = quad_solid_angle(v00, v10, v01, v11);
96 /* Multiply by the symmetric halves that we omitted.
97 * Also important to note that we avoid weighting the same pixel more than it's total sampled
98 * footprint if it is duplicated in another pixel of the map. So border pixels do not require any
99 * special treatment. Only the center cross needs it. */
100 if (wrapped_texel.x == half_size - 1) {
101 texel_clipped_solid_angle *= 2.0f;
102 }
103 if (wrapped_texel.y == half_size - 1) {
104 texel_clipped_solid_angle *= 2.0f;
105 }
106 return texel_clipped_solid_angle;
107}
108
109/* Sample cubemap and remap into an octahedral texture. */
110[[compute, local_size(SPHERE_PROBE_REMAP_GROUP_SIZE, SPHERE_PROBE_REMAP_GROUP_SIZE)]]
112 [[resource_table]] const Uniform &uni,
113 [[global_invocation_id]] const uint3 global_id,
114 [[work_group_id]] const uint3 group_id,
115 [[num_work_groups]] const uint3 num_groups,
116 [[local_invocation_index]] const uint local_index)
117{
118 const uint work_group_index = num_groups.x * group_id.y + group_id.x;
119 constexpr uint group_size = uint(SPHERE_PROBE_REMAP_GROUP_SIZE * SPHERE_PROBE_REMAP_GROUP_SIZE);
120
121 SphereProbeUvArea world_coord = reinterpret_as_atlas_coord(srt.world_coord_packed);
122 SphereProbePixelArea write_coord = reinterpret_as_write_coord(srt.write_coord_packed);
123
124 /* Texel in probe. */
125 int2 local_texel = int2(global_id.xy);
126
127 float2 wrapped_uv;
128 float3 direction = texel_to_direction(float2(local_texel), write_coord, wrapped_uv);
129 float4 radiance_and_transmittance = texture(srt.cubemap_tx, direction);
130 float3 radiance = radiance_and_transmittance.xyz;
131
132 float opacity = 1.0f - radiance_and_transmittance.a;
133
134 /* Composite world into reflection probes. */
135 bool is_world = all(equal(srt.probe_coord_packed, srt.world_coord_packed));
136 if (!is_world && opacity != 1.0f) {
137 float2 biased_uv = miplvl_scale_bias(0.0f, world_coord, saturate(wrapped_uv));
138 float2 world_uv = biased_uv * world_coord.scale + world_coord.offset;
139 float4 world_radiance = textureLod(srt.atlas_tx, float3(world_uv, world_coord.layer), 0.0f);
140 radiance.rgb = mix(world_radiance.rgb, radiance.rgb, opacity);
141 }
142
143 float sun_threshold = uni.uniform_buf.clamp.sun_threshold;
144 float3 radiance_clamped = colorspace::brightness_clamp_max(radiance, sun_threshold);
145 float3 radiance_sun = radiance - radiance_clamped;
146 radiance = radiance_clamped;
147
148 if (srt.do_remap_mip0 && !any(greaterThanEqual(local_texel, int2(write_coord.extent)))) {
149 /* The atlas stores 16-bit floats, avoid storing inf for very bright values like a sun disc.
150 * Note that this can loose quite some energy, but we are fine with that. */
151 float clamp_indirect = min(65504.0f, uni.uniform_buf.clamp.surface_indirect);
152 float3 out_radiance = colorspace::brightness_clamp_max(radiance, clamp_indirect);
153
154 int3 texel = int3(local_texel + write_coord.offset, write_coord.layer);
155 imageStore(srt.atlas_img, texel, float4(out_radiance, 1.0f));
156 }
157
158 float sample_weight = octahedral_texel_solid_angle(local_texel, write_coord);
159
160 if (srt.extract_sun) {
161 /* Parallel sum. Result is stored inside local_radiance[0]. */
162 srt.local_radiance[local_index] = radiance_sun.xyzz * sample_weight;
163 /* OpenGL/Intel drivers have known issues where it isn't able to compile barriers inside for
164 * loops. Unroll is needed as driver might decide to not unroll in shaders with more
165 * complexity. */
166 /* Vulkan validation layers detects a data race on `local_radiance[local_index] +=
167 * local_radiance[local_index + stride]`. This is a false positive. Even when doing a manual
168 * unroll or make the variable `shared coherent` doesn't work around it. */
169 for (uint i = 0; i < 10; i++) [[unroll]] {
170 barrier();
171 uint stride = group_size >> (i + 1u);
172 if (local_index < stride) {
173 srt.local_radiance[local_index] += srt.local_radiance[local_index + stride];
174 }
175 }
176 barrier();
177
178 if (local_index == 0u) {
179 srt.out_sun[work_group_index].radiance = srt.local_radiance[0].xyz;
180 }
181 barrier();
182
183 /* Reusing local_radiance for directions. */
184 auto &local_direction = srt.local_radiance;
185
186 local_direction[local_index] = float4(normalize(direction), 1.0f) * sample_weight *
187 length(radiance_sun.xyz);
188 /* OpenGL/Intel drivers have known issues where it isn't able to compile barriers inside for
189 * loops. Unroll is needed as driver might decide to not unroll in shaders with more
190 * complexity. */
191 /* Vulkan validation layers detects a data race on `local_direction[local_index] +=
192 * local_direction[local_index + stride]`. This is a false positive. Even when doing a manual
193 * unroll or make the variable `shared coherent` doesn't work around it. */
194 for (uint i = 0; i < 10; i++) [[unroll]] {
195 barrier();
196 uint stride = group_size >> (i + 1u);
197 if (local_index < stride) {
198 local_direction[local_index] += local_direction[local_index + stride];
199 }
200 }
201 barrier();
202
203 if (local_index == 0u) {
204 srt.out_sun[work_group_index].direction = local_direction[0];
205 }
206 barrier();
207 }
208
209 if (srt.extract_sh) {
210 /* Parallel sum. Result is stored inside local_radiance[0]. */
211 srt.local_radiance[local_index] = radiance.xyzz * sample_weight;
212 /* OpenGL/Intel drivers have known issues where it isn't able to compile barriers inside for
213 * loops. Unroll is needed as driver might decide to not unroll in shaders with more
214 * complexity. */
215 /* Vulkan validation layers detects a data race on `local_radiance[local_index] +=
216 * local_radiance[local_index + stride]`. This is a false positive. Even when doing a manual
217 * unroll or make the variable `shared coherent` doesn't work around it. */
218 for (uint i = 0; i < 10; i++) [[unroll]] {
219 barrier();
220 uint stride = group_size >> (i + 1u);
221 if (local_index < stride) {
222 srt.local_radiance[local_index] += srt.local_radiance[local_index + stride];
223 }
224 }
225 barrier();
226
227 if (local_index == 0u) {
228 /* Find the middle point of the whole thread-group. Use it as light vector.
229 * Note that this is an approximation since the footprint of a thread-group is not
230 * necessarily a convex polygons (with center of gravity at midpoint).
231 * But the actual error introduce by this approximation is not perceivable. */
232 /* FIXME(fclem): The error IS very perceivable for resolution lower than a quadrant. */
233 int2 max_group_texel = local_texel + int2(SPHERE_PROBE_REMAP_GROUP_SIZE);
234 /* Min direction is the local direction since this is only ran by thread 0. */
235 float3 min_direction = normalize(direction);
236 float3 max_direction = normalize(texel_to_direction(float2(max_group_texel), write_coord));
237 float3 L = normalize(min_direction + max_direction);
238 /* Convert radiance to spherical harmonics. */
240 sh.encode_signal_sample(L, srt.local_radiance[0]);
241 /* Outputs one SH for each thread-group. */
242 srt.out_sh[work_group_index].L0_M0 = sh.L0.M0;
243 srt.out_sh[work_group_index].L1_Mn1 = sh.L1.Mn1;
244 srt.out_sh[work_group_index].L1_M0 = sh.L1.M0;
245 srt.out_sh[work_group_index].L1_Mp1 = sh.L1.Mp1;
246 }
247 }
248}
249
250/* Bypass convolution cascade and projection logic. */
251// #define ALWAYS_SAMPLE_CUBEMAP
252/* Debugging texel alignment. */
253// #define USE_PIXEL_CHECKERBOARD
254
255float roughness_from_relative_mip(float prev_mip_roughness, float curr_mip_roughness)
256{
257#ifdef ALWAYS_SAMPLE_CUBEMAP
258 /* For reference and debugging. */
259 return curr_mip_roughness;
260#else
261 /* The exponent should be 2 but result is a bit less blurry than expected in practice. */
262 constexpr float exponent = 3.0f;
263 /* From linear roughness to GGX roughness input. */
264 float m_prev = pow(prev_mip_roughness, exponent);
265 float m_curr = pow(curr_mip_roughness, exponent);
266 /* Given that spherical gaussians are very close to regular gaussian in 1D,
267 * we reuse the same rule for successive convolution (i.e: `G(x,a) X G(x,b) = G(x,a+b)`).
268 * While this isn't technically correct, this still works quite well in practice. */
269 float m_target = m_curr - m_prev;
270 /* From GGX roughness input to linear roughness. */
271 return pow(m_target, 1.0f / exponent);
272#endif
273}
274
275float cone_cosine_from_roughness(float linear_roughness)
276{
277 /* From linear roughness to GGX roughness input. */
278 float m = square(linear_roughness);
279 /* Chosen so that roughness of 1.0 maps to half pi cone aperture. */
280 float cutoff_value = mix(0.01f, 0.14f, m);
281 /* Inversion of the spherical gaussian. This gives the cutoff for the half angle from N.H. */
282 float half_angle_cos = 1.0f + (log(cutoff_value) * square(m)) / 2.0f;
283 float half_angle_sin = safe_sqrt(1.0f - square(half_angle_cos));
284 /* Use cosine rule to avoid acos. Return cos(2 * half_angle). */
285 return square(half_angle_cos) - square(half_angle_sin);
286}
287
289{
290 /* After experimenting this is likely to be the best value if we keep the max resolution to 2048.
291 * This isn't ideal, but the better solution would be to use multiple steps per mip which would
292 * reduce the number of sample per step (use sum of gaussian per step). */
293 return 196;
294}
295
296float sample_weight(float3 out_direction, float3 in_direction, float linear_roughness)
297{
298 out_direction = normalize(out_direction);
299 in_direction = normalize(in_direction);
300
301 /* From linear roughness to GGX roughness input. */
302 float m = square(linear_roughness);
303 /* Map GGX roughness to spherical gaussian sharpness.
304 * From "SG Series Part 4: Specular Lighting From an SG Light Source" by MJP
305 * https://therealmjp.github.io/posts/sg-series-part-4-specular-lighting-from-an-sg-light-source/
306 */
307 float3 N = out_direction;
308 float3 H = normalize(out_direction + in_direction);
309 float NH = saturate(dot(N, H));
310 /* GGX. */
311 // return exp(-square(acos(NH) / m));
312 /* Spherical Gaussian. */
313 return exp(2.0f * (NH - 1.0f) / square(m));
314}
315
317{
318 /* TODO(fclem): This create a discontinuity at Z=0. */
319 return from_up_axis(N);
320}
321
331
332/* Convolve Mipmap chain recursively using a increasingly large spherical gaussian filters. */
333[[compute, local_size(SPHERE_PROBE_GROUP_SIZE, SPHERE_PROBE_GROUP_SIZE)]]
335{
336 SphereProbeUvArea sample_coord = reinterpret_as_atlas_coord(srt.probe_coord_packed);
337 SphereProbePixelArea out_texel_area = reinterpret_as_write_coord(srt.write_coord_packed);
338
339 /* Texel in probe. */
340 int2 out_local_texel = int2(global_id.xy);
341
342 /* Exit when pixel being written doesn't fit in the area reserved for the probe. */
343 if (any(greaterThanEqual(out_local_texel, int2(out_texel_area.extent)))) {
344 return;
345 }
346
347 /* From mip to linear roughness (same as UI). */
348 float prev_mip_roughness = lod_to_roughness(float(srt.read_lod));
349 float curr_mip_roughness = lod_to_roughness(float(srt.read_lod + 1));
350 /* In order to reduce the sample count, we sample the content of previous mip level.
351 * But this one has already been convolved. So we have to derive the equivalent roughness
352 * that produces the same result. */
353 float mip_roughness = roughness_from_relative_mip(prev_mip_roughness, curr_mip_roughness);
354 /* Clamp to avoid numerical imprecision. */
355 float mip_roughness_clamped = max(mip_roughness, BSDF_ROUGHNESS_THRESHOLD);
356 float cone_cos = cone_cosine_from_roughness(mip_roughness_clamped);
357
358 float3 out_direction = texel_to_direction(float2(out_local_texel), out_texel_area);
359 out_direction = normalize(out_direction);
360
361 float3x3 basis = tangent_basis(out_direction);
362
363 int2 out_texel = out_texel_area.offset + out_local_texel;
364
365 float weight_accum = 0.0f;
366 float4 radiance_accum = float4(0.0f);
367
368 int sample_count = sample_count_get();
369 for (int i = 0; i < sample_count; i++) {
370 float2 rand = random::hammersley_2d(i, sample_count);
371 float3 in_direction = basis * sample_uniform_cone(rand, cone_cos);
372
373 float2 in_uv = direction_to_uv(in_direction, float(srt.read_lod), sample_coord);
374 float4 radiance = texture(srt.in_atlas_mip_tx, float3(in_uv, sample_coord.layer));
375#ifdef ALWAYS_SAMPLE_CUBEMAP /* For reference and debugging. */
376 radiance = texture(srt.cubemap_tx, in_direction);
377#endif
378
379 float weight = sample_weight(out_direction, in_direction, mip_roughness_clamped);
380 radiance_accum += radiance * weight;
381 weight_accum += weight;
382 }
383 float4 out_radiance = radiance_accum * safe_rcp(weight_accum);
384
385#ifdef USE_PIXEL_CHECKERBOARD
386 int2 a = out_texel % 2;
387 out_radiance = float4(a.x == a.y);
388#endif
389
390 imageStore(srt.out_atlas_mip_img, int3(out_texel, out_texel_area.layer), out_radiance);
391}
392
394 [[storage(0, read)]] const SphereProbeHarmonic (&in_sh)[];
395 [[storage(1, write)]] SphereProbeHarmonic &out_sh;
396
398
399 [[shared]] float4 local_sh_coefs[SPHERE_PROBE_SH_GROUP_SIZE][4];
400};
401
402[[compute, local_size(SPHERE_PROBE_SH_GROUP_SIZE)]]
404 [[local_invocation_index]] const uint local_index)
405{
406 constexpr uint group_size = uint(SPHERE_PROBE_SH_GROUP_SIZE);
407
409 sh.L0.M0 = float4(0.0f);
410 sh.L1.Mn1 = float4(0.0f);
411 sh.L1.M0 = float4(0.0f);
412 sh.L1.Mp1 = float4(0.0f);
413
414 /* First sum onto the local memory. */
415 uint valid_data_len = uint(srt.probe_remap_dispatch_size.x * srt.probe_remap_dispatch_size.y);
416 constexpr uint iter_count = uint(SPHERE_PROBE_MAX_HARMONIC) / group_size;
417 for (uint i = 0; i < iter_count; i++) {
418 uint index = SPHERE_PROBE_SH_GROUP_SIZE * i + local_index;
419 if (index >= valid_data_len) {
420 break;
421 }
423 sh_sample.L0.M0 = srt.in_sh[index].L0_M0;
424 sh_sample.L1.Mn1 = srt.in_sh[index].L1_Mn1;
425 sh_sample.L1.M0 = srt.in_sh[index].L1_M0;
426 sh_sample.L1.Mp1 = srt.in_sh[index].L1_Mp1;
427 sh = spherical_harmonics::add(sh, sh_sample);
428 }
429
430 /* Then sum across invocations. */
431 srt.local_sh_coefs[local_index][0] = sh.L0.M0;
432 srt.local_sh_coefs[local_index][1] = sh.L1.Mn1;
433 srt.local_sh_coefs[local_index][2] = sh.L1.M0;
434 srt.local_sh_coefs[local_index][3] = sh.L1.Mp1;
435
436 /* Parallel sum. */
437 uint stride = group_size / 2;
438 for (int i = 0; i < 10; i++) {
439 barrier();
440 if (local_index < stride) {
441 for (int i = 0; i < 4; i++) {
442 srt.local_sh_coefs[local_index][i] += srt.local_sh_coefs[local_index + stride][i];
443 }
444 }
445 stride /= 2;
446 }
447
448 barrier();
449 if (local_index == 0u) {
450 srt.out_sh.L0_M0 = srt.local_sh_coefs[0][0];
451 srt.out_sh.L1_Mn1 = srt.local_sh_coefs[0][1];
452 srt.out_sh.L1_M0 = srt.local_sh_coefs[0][2];
453 srt.out_sh.L1_Mp1 = srt.local_sh_coefs[0][3];
454 }
455}
456
458 [[storage(0, read)]] const SphereProbeSunLight (&in_sun)[];
459 [[storage(1, write)]] LightData (&sunlight_buf)[2];
460 [[push_constant]] const int sun_id;
462
463 [[shared]] float3 local_radiance[SPHERE_PROBE_SH_GROUP_SIZE];
464 [[shared]] float4 local_direction[SPHERE_PROBE_SH_GROUP_SIZE];
465};
466
467[[compute, local_size(SPHERE_PROBE_SH_GROUP_SIZE)]]
469 [[local_invocation_index]] const uint local_index)
470{
471 constexpr uint group_size = uint(SPHERE_PROBE_SH_GROUP_SIZE);
472
473 SphereProbeSunLight sun;
474 sun.radiance = float3(0.0f);
475 sun.direction = float4(0.0f);
476
477 /* First sum onto the local memory. */
478 uint valid_data_len = uint(srt.probe_remap_dispatch_size.x * srt.probe_remap_dispatch_size.y);
479 constexpr uint iter_count = uint(SPHERE_PROBE_MAX_HARMONIC) / group_size;
480 for (uint i = 0; i < iter_count; i++) {
481 uint index = SPHERE_PROBE_SH_GROUP_SIZE * i + local_index;
482 if (index >= valid_data_len) {
483 break;
484 }
485 sun.radiance += srt.in_sun[index].radiance;
486 sun.direction += srt.in_sun[index].direction;
487 }
488
489 /* Then sum across invocations. */
490 srt.local_radiance[local_index] = sun.radiance;
491 srt.local_direction[local_index] = sun.direction;
492
493 /* Parallel sum. */
494 uint stride = group_size / 2;
495 for (int i = 0; i < 10; i++) {
496 barrier();
497 if (local_index < stride) {
498 srt.local_radiance[local_index] += srt.local_radiance[local_index + stride];
499 srt.local_direction[local_index] += srt.local_direction[local_index + stride];
500 }
501 stride /= 2;
502 }
503
504 barrier();
505 if (local_index == 0u) {
506 srt.sunlight_buf[srt.sun_id].color = srt.local_radiance[0];
507
508 /* Normalize the sum to get the mean direction. The length of the vector gives us the size of
509 * the sun light. */
510 float len;
512 srt.local_direction[0].xyz / srt.local_direction[0].w, len);
513
514 float3x3 tx = transpose(from_up_axis(direction));
515 /* Convert to transform. */
516 srt.sunlight_buf[srt.sun_id].object_to_world.x = float4(tx[0], 0.0f);
517 srt.sunlight_buf[srt.sun_id].object_to_world.y = float4(tx[1], 0.0f);
518 srt.sunlight_buf[srt.sun_id].object_to_world.z = float4(tx[2], 0.0f);
519
520 /* Auto sun angle. */
521 float sun_angle_cos = 2.0f * len - 1.0f;
522 /* Compute tangent from cosine. */
523 float sun_angle_tan = sqrt(-1.0f + 1.0f / square(sun_angle_cos));
524 /* Clamp value to avoid float imprecision artifacts. */
525 float sun_radius = clamp(sun_angle_tan, 0.001f, 20.0f);
526
527 /* Convert irradiance to radiance. */
528 float shape_power = M_1_PI * (1.0f + 1.0f / square(sun_radius));
529 float point_power = 1.0f;
530
531 srt.sunlight_buf[srt.sun_id].shape_power = shape_power;
532 srt.sunlight_buf[srt.sun_id].point_power = point_power;
533 srt.sunlight_buf[srt.sun_id].power_factor[LIGHT_DIFFUSE] = 1.0f;
534 srt.sunlight_buf[srt.sun_id].power_factor[LIGHT_SPECULAR] = 1.0f;
535 srt.sunlight_buf[srt.sun_id].power_factor[LIGHT_TRANSMISSION] = 1.0f;
536 srt.sunlight_buf[srt.sun_id].power_factor[LIGHT_VOLUME] = 1.0f;
537
538 /* NOTE: Use the radius from UI instead of auto sun size for now. */
539 }
540}
541
542} // namespace eevee::lightprobe::sphere
543
#define D
#define M_1_PI
#define C
Definition RandGen.cpp:29
#define A
btScalar max
#define SPHERE_PROBE_FORMAT
#define BSDF_ROUGHNESS_THRESHOLD
PipelineCompute eevee_lightprobe_sphere_irradiance(eevee::lightprobe::sphere::irradiance_sum)
PipelineCompute eevee_lightprobe_sphere_remap(eevee::lightprobe::sphere::remap_cubemap_to_octahedral)
PipelineCompute eevee_lightprobe_sphere_convolve(eevee::lightprobe::sphere::mip_convolve)
PipelineCompute eevee_lightprobe_sphere_sunlight(eevee::lightprobe::sphere::sun_extraction)
float3 sample_uniform_cone(float2 rand, float cos_angle)
@ SFLOAT_16_16_16_16
#define shared
#define local_invocation_index
#define storage(slot, qualifiers)
#define image(slot, qualifiers, format)
#define work_group_id
#define index(i)
#define push_constant
#define resource_table
#define sampler(slot)
#define specialization_constant(default_value)
#define global_invocation_id
#define unroll
#define compute
#define num_work_groups
#define local_size(...)
#define atan
VecBase< bool, D > greaterThanEqual(VecOp< T, D >, VecOp< T, D >) RET
#define log
bool any(VecOp< bool, D >) RET
#define pow
#define exp
VecBase< float, D > normalize(VecOp< float, D >) RET
float dot(VecOp< float, D >, VecOp< float, D >) RET
#define abs
bool all(VecOp< bool, D >) RET
#define sqrt
MatBase< R, C > transpose(MatBase< C, R >) RET
VecBase< float, 3 > cross(VecOp< float, 3 >, VecOp< float, 3 >) RET
VecBase< bool, D > equal(VecOp< T, D >, VecOp< T, D >) RET
void barrier()
constexpr T clamp(T, U, U) RET
float length(VecOp< float, D >) RET
ImageBase< float, 2, true > image2DArray
IMG_TEMPLATE void imageStore(T &, IntCoord, DataVec)
TEX_TEMPLATE DataVec texture(T, FltCoord, float=0.0f) RET
TEX_TEMPLATE DataVec textureLod(T, FltCoord, float) RET
SamplerBase< float, 2, false, true > sampler2DArray
SamplerBase< float, 2, true > samplerCube
float square(float v)
float3x3 from_up_axis(float3 up)
float safe_rcp(float a)
float safe_sqrt(float a)
VecT safe_normalize_and_get_length(VecT vector, float &out_length)
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
Definition math_dual.h:263
#define N
#define B
#define L
#define H(x, y, z)
float3 brightness_clamp_max(float3 color, float limit)
float quad_solid_angle(float3 A, float3 B, float3 C, float3 D)
void remap_cubemap_to_octahedral(Remap &srt, const Uniform &uni, const uint3 global_id, const uint3 group_id, const uint3 num_groups, const uint local_index)
void sun_extraction(SunExtraction &srt, const uint local_index)
void irradiance_sum(IrradianceSum &srt, const uint local_index)
float roughness_from_relative_mip(float prev_mip_roughness, float curr_mip_roughness)
float sample_weight(float3 out_direction, float3 in_direction, float linear_roughness)
float3 texel_to_direction(float2 local_texel, SphereProbePixelArea texel_area, float2 &sampling_uv)
float triangle_solid_angle(float3 A, float3 B, float3 C)
float2 miplvl_scale_bias(float mip_lvl, SphereProbeUvArea uv_area, float2 uv)
void mip_convolve(Convolve &srt, const uint3 global_id)
float octahedral_texel_solid_angle(int2 local_texel, SphereProbePixelArea write_co)
void direction_to_uv(float3 L, float lod_min, float lod_max, SphereProbeUvArea uv_area, float2 &altas_uv_min, float2 &altas_uv_max)
float cone_cosine_from_roughness(float linear_roughness)
SphereProbePixelArea reinterpret_as_write_coord(int4 packed_coord)
SphereProbeUvArea reinterpret_as_atlas_coord(int4 packed_coord)
float2 hammersley_2d(T i, T sample_count)
SphericalHarmonicL1< float4 > add(SphericalHarmonicL1< float4 > a, SphericalHarmonicL1< float4 > b)
#define mix
#define saturate(a)
Definition smaa.cc:319
#define min(a, b)
Definition sort.cc:38
spherical_harmonics::BandL1< T > L1
spherical_harmonics::BandL0< T > L0
void encode_signal_sample(float3 direction, T amplitude)
float4 local_radiance[SPHERE_PROBE_REMAP_GROUP_SIZE *SPHERE_PROBE_REMAP_GROUP_SIZE]