Blender V5.3
eevee_lightprobe.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
13#include "gpu_shader_codegen_lib.glsl"
15
16namespace eevee {
17
22
27 LightProbeSample load(float2 screen_texel, float3 P, float3 Ng, float3 V) const
28 {
29 float noise = random::interleaved_gradient(screen_texel, 0.0f, 0.0f);
30 noise = fract(noise + sampling.rng_1D_get(SAMPLING_LIGHTPROBE));
31
32 LightProbeSample result;
33 result.volume_irradiance = volumes.sample_probe(sampling, P, V, Ng);
34 result.spherical_id = spheres.select_probe(P, noise);
35 return result;
36 }
37
39 float3 P,
40 float3 L,
41 float perceptual_roughness) const
42 {
43 /* Avoid over-blurring diffuse. */
44 perceptual_roughness = min(0.6f, perceptual_roughness);
45 float lod = lightprobe::sphere::roughness_to_lod(perceptual_roughness);
47 return radiance_sh;
48 }
49
50 /* TODO: Port that inside a BSSDF file. */
51 float3 eval(const UtilityTexture &util_tx,
53 ClosureSubsurface cl,
54 float3 /*P*/,
55 float3 /*V*/,
56 Thickness thickness) const
57 {
58 float3 sss_profile = subsurface_transmission(util_tx, cl.sss_radius, thickness.value());
59 float3 radiance_sh = samp.volume_irradiance.evaluate_lambert(cl.N).rgb;
60 radiance_sh += samp.volume_irradiance.evaluate_lambert(-cl.N).rgb * sss_profile;
61 return radiance_sh;
62 }
63
65 LightProbeSample samp, ClosureUndetermined cl, float3 P, float3 V, Thickness thickness) const
66 {
68
71
73 samp, P, ray.dominant_direction, lod);
75 return mix(radiance_cube, radiance_sh, fac);
76 }
77};
78
79} // namespace eevee
LightProbeRay bxdf_lightprobe_ray(ClosureUndetermined cl, float3, float3 V, Thickness thickness)
float3 subsurface_transmission(const UtilityTexture &util, float3 sss_radii, float thickness)
#define resource_table
T fract(T) RET
float noise(float p)
#define L
float roughness_to_mix_fac(float roughness)
float interleaved_gradient(float2 pixel, float seed, float offset)
#define mix
#define min(a, b)
Definition sort.cc:38
packed_float3 dominant_direction
SphericalHarmonicL1< float4 > volume_irradiance
float3 eval_direction(LightProbeSample samp, float3 P, float3 L, float perceptual_roughness) const
LightprobeVolumeRenderData volumes
LightprobeSphereRenderData spheres
float3 eval(LightProbeSample samp, ClosureUndetermined cl, float3 P, float3 V, Thickness thickness) const
float3 eval(const UtilityTexture &util_tx, LightProbeSample samp, ClosureSubsurface cl, float3, float3, Thickness thickness) const
LightProbeSample load(float2 screen_texel, float3 P, float3 Ng, float3 V) const
float3 spherical_sample_normalized_with_parallax(LightProbeSample samp, float3 P, float3 L, float lod) const
int select_probe(float3 P, float random_probe) const
SphericalHarmonicL1< float4 > sample_probe(const Sampling &sampling, float3 P, float3 V, float3 Ng) const
float rng_1D_get(const eSamplingDimension dim) const
CCL_NAMESPACE_BEGIN struct Window V