Blender V4.3
eevee_lightprobe.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
13#pragma once
14
15#include "BLI_bit_vector.hh"
16#include "BLI_map.hh"
17
18#include "eevee_defines.hh"
19#include "eevee_sync.hh"
20
21namespace blender::eevee {
22
23class Instance;
24class VolumeProbeModule;
25
26/* -------------------------------------------------------------------- */
32 int atlas_layer = -1;
36 int area_index = -1;
37
39 void free()
40 {
41 atlas_layer = -1;
42 }
43
44 /* Return the area extent in pixel. */
45 int area_extent(int mip_lvl = 0) const
46 {
47 return SPHERE_PROBE_ATLAS_RES >> (subdivision_lvl + mip_lvl);
48 }
49
50 /* Coordinate of the area in [0..area_count_per_dimension[ range. */
52 {
53 const int area_count_per_dimension = 1 << subdivision_lvl;
54 return int2(area_index % area_count_per_dimension, area_index / area_count_per_dimension);
55 }
56
57 /* Coordinate of the bottom left corner of the area in [0..SPHERE_PROBE_ATLAS_RES[ range. */
58 int2 area_offset(int mip_lvl = 0) const
59 {
60 return area_location() * area_extent(mip_lvl);
61 }
62
71
73 {
75 coord.extent = area_extent(mip_lvl);
76 coord.offset = area_offset(mip_lvl);
77 coord.layer = atlas_layer;
78 return coord;
79 }
80
92 BitVector<> areas_occupancy_;
93 int subdivision_level_;
94 /* Area count for the given subdivision level. */
95 int areas_per_dimension_;
96 int areas_per_layer_;
97
98 public:
99 LocationFinder(int allocated_layer_count, int subdivision_level);
100
101 /* Mark space to be occupied by the given probe_data. */
102 void mark_space_used(const SphereProbeAtlasCoord &coord);
103
105
106 void print_debug() const;
107 };
108};
109
113 bool used = false;
114 bool initialized = false;
115 /* NOTE: Might be not needed if depsgraph updates work as intended. */
116 bool updated = false;
118 bool viewport_display = false;
120};
121
148
161
163 /* Copy of object matrices. */
166 /* Offset to the clipping plane in the normal direction. */
168 /* Index in the resource array. */
170
171 public:
176 void set_view(const draw::View &view, int layer_id);
177
188
189 private:
194 float4x4 reflection_matrix_get()
195 {
197 }
198};
199
201 friend class IrradianceBake;
202 friend class VolumeProbeModule;
203 friend class PlanarProbeModule;
204 friend class SphereProbeModule;
205 friend class BackgroundPipeline;
206
207 private:
208 Instance &inst_;
209
211 Map<ObjectKey, VolumeProbe> volume_map_;
212 Map<ObjectKey, SphereProbe> sphere_map_;
213 Map<ObjectKey, PlanarProbe> planar_map_;
214 /* World probe is stored separately. */
215 SphereProbe world_sphere_;
217 bool volume_update_;
218 bool sphere_update_;
219 bool planar_update_;
221 bool auto_bake_enabled_;
222
223 eLightProbeResolution sphere_object_resolution_ = LIGHT_PROBE_RESOLUTION_128;
224
225 public:
228
229 void init();
230
231 void begin_sync();
232 void sync_probe(const Object *ob, ObjectHandle &handle);
233 void sync_world(const ::World *world, bool has_update);
234 void end_sync();
235
236 private:
237 void sync_sphere(const Object *ob, ObjectHandle &handle);
238 void sync_volume(const Object *ob, ObjectHandle &handle);
239 void sync_planar(const Object *ob, ObjectHandle &handle);
240
242 int sphere_layer_count() const;
243
245 SphereProbeAtlasCoord find_empty_atlas_region(int subdivision_level) const;
246};
247
248} // namespace blender::eevee
eLightProbeResolution
@ LIGHT_PROBE_RESOLUTION_128
A running instance of the engine.
void sync_world(const ::World *world, bool has_update)
void sync_probe(const Object *ob, ObjectHandle &handle)
void mark_space_used(const SphereProbeAtlasCoord &coord)
LocationFinder(int allocated_layer_count, int subdivision_level)
#define SPHERE_PROBE_ATLAS_RES
draw_view in_light_buf[] float
T dot(const QuaternionBase< T > &a, const QuaternionBase< T > &b)
MatT from_scale(const VecBase< typename MatT::base_type, ScaleDim > &scale)
VecBase< float, 4 > float4
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
VecBase< float, 3 > float3
void set_view(const draw::View &view, int layer_id)
SphereProbePixelArea as_write_coord(int mip_lvl) const
int2 area_offset(int mip_lvl=0) const
SphereProbeUvArea as_sampling_coord() const
SphereProbeAtlasCoord atlas_coord
Vector< IrradianceBrickPacked > bricks
const LightProbeObjectCache * cache