Blender V5.3
eevee_surfel_light.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
8
9#pragma once
10
11#include "eevee_closure.bsl.hh"
13#include "eevee_surfel.bsl.hh"
14
15namespace eevee::surfel {
16
17struct EvalLight {
18 /* WORKAROUND: Disables culling in lighting evaluation function. */
20};
21
25 [[resource_table]] const Uniform &uni,
26 [[resource_table]] const UtilityTexture &util_tx,
27 [[resource_table]] SurfelData &surfels,
28 [[global_invocation_id]] const uint3 global_id)
29{
30 const int index = int(global_id.x);
31 if (index >= int(surfels.capture_info_buf.surfel_len)) {
32 return;
33 }
34
35 Surfel surfel = surfels.surfel_buf[index];
36
37 /* There is no view dependent effect as we evaluate everything using diffuse. */
38 float3 V = surfel.normal;
39 float3 Ng = surfel.normal;
40 float3 P = surfel.position;
41
43 ctx.P = P;
44 ctx.Ng = Ng;
45 /* Note: This shader disables light culling and shadow jitter. */
46 ctx.texel = float2(0.0);
48 ctx.receiver_light_set = surfel.receiver_light_set;
49 ctx.terminator_normal_offset = 0.0f;
51 ctx.ray_count = uni.uniform_buf.shadow.ray_count;
52 ctx.ray_step_count = uni.uniform_buf.shadow.step_count;
53
54 ClosureUndetermined cl_reflect;
55 cl_reflect.N = surfel.normal;
56 cl_reflect.type = CLOSURE_BSDF_DIFFUSE_ID;
57 ctx.stack.cl[0] = closure_light_new(util_tx, cl_reflect, V);
58 lights.eval_reflection(ctx, 1.0f);
59
60 if (surfels.capture_info_buf.capture_indirect) {
61 surfels.surfel_buf[index].radiance_direct.front.rgb += ctx.stack.cl[0].light_shadowed *
62 surfel.albedo_front;
63 }
64
65 ClosureUndetermined cl_transmit;
66 cl_transmit.N = -surfel.normal;
67 cl_transmit.type = CLOSURE_BSDF_DIFFUSE_ID;
68 ctx.stack.cl[0] = closure_light_new(util_tx, cl_transmit, -V);
69
70 ctx.Ng = -Ng;
71 lights.eval_reflection(ctx, 1.0f);
72
73 if (surfels.capture_info_buf.capture_indirect) {
74 surfels.surfel_buf[index].radiance_direct.back.rgb += ctx.stack.cl[0].light_shadowed *
75 surfel.albedo_back;
76 }
77}
78
79} // namespace eevee::surfel
80
83 .light_iter_force_no_culling = true,
84 },
86 .shadow_random = false,
87 },
89 .light_closure_eval_count_reflect = 1,
90 .light_closure_eval_count_transmit = 0,
91 .light_closure_count_reflect = 1,
92 .light_closure_count_transmit = 1,
93 });
static Thickness zero()
ClosureLight closure_light_new(const UtilityTexture &util_tx, ClosureUndetermined cl, float3 V, Thickness thickness)
#define SURFEL_GROUP_SIZE
PipelineCompute eevee_surfel_light(eevee::surfel::eval_light, eevee::surfel::EvalLight{ .light_iter_force_no_culling=true, }, eevee::ShadowRenderConstants{ .shadow_random=false, }, eevee::LightEvalConstants{ .light_closure_eval_count_reflect=1,.light_closure_eval_count_transmit=0,.light_closure_count_reflect=1,.light_closure_count_transmit=1, })
#define index(i)
#define compilation_constant
#define resource_table
#define global_invocation_id
#define compute
#define local_size(...)
@ CLOSURE_BSDF_DIFFUSE_ID
void eval_light(EvalLight &, LightEvalIterator &lights, const Uniform &uni, const UtilityTexture &util_tx, SurfelData &surfels, const uint3 global_id)
ClosureStack< is_transmission > stack
CCL_NAMESPACE_BEGIN struct Window V