Blender V5.0
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
12
13#pragma once
14
15#include "BLI_bit_vector.hh"
16#include "BLI_map.hh"
17
18#include "DNA_world_types.h"
19
20#include "draw_view.hh"
21
22#include "eevee_defines.hh"
24#include "eevee_sync.hh"
25
26namespace blender::eevee {
27
28using namespace draw;
29
30class Instance;
32
33/* -------------------------------------------------------------------- */
36
39 int atlas_layer = -1;
43 int area_index = -1;
44
46 void free()
47 {
48 atlas_layer = -1;
49 }
50
51 /* Return the area extent in pixel. */
52 int area_extent(int mip_lvl = 0) const
53 {
54 return SPHERE_PROBE_ATLAS_RES >> (subdivision_lvl + mip_lvl);
55 }
56
57 /* Coordinate of the area in [0..area_count_per_dimension[ range. */
59 {
60 const int area_count_per_dimension = 1 << subdivision_lvl;
61 return int2(area_index % area_count_per_dimension, area_index / area_count_per_dimension);
62 }
63
64 /* Coordinate of the bottom left corner of the area in [0..SPHERE_PROBE_ATLAS_RES[ range. */
65 int2 area_offset(int mip_lvl = 0) const
66 {
67 return area_location() * area_extent(mip_lvl);
68 }
69
78
80 {
82 coord.extent = area_extent(mip_lvl);
83 coord.offset = area_offset(mip_lvl);
84 coord.layer = atlas_layer;
85 return coord;
86 }
87
99 BitVector<> areas_occupancy_;
100 int subdivision_level_;
101 /* Area count for the given subdivision level. */
102 int areas_per_dimension_;
103 int areas_per_layer_;
104
105 public:
106 LocationFinder(int allocated_layer_count, int subdivision_level);
107
108 /* Mark space to be occupied by the given probe_data. */
109 void mark_space_used(const SphereProbeAtlasCoord &coord);
110
112
113 void print_debug() const;
114 };
115};
116
118
120 bool used = false;
121 bool initialized = false;
122 /* NOTE: Might be not needed if depsgraph updates work as intended. */
123 bool updated = false;
125 bool viewport_display = false;
127};
128
155
168
170 /* Copy of object matrices. */
173 /* Offset to the clipping plane in the normal direction. */
175 /* Index in the resource array. */
177
178 public:
183 void set_view(const draw::View &view, int layer_id);
184
195
196 private:
201 float4x4 reflection_matrix_get()
202 {
204 }
205};
206
208 friend class IrradianceBake;
209 friend class VolumeProbeModule;
210 friend class PlanarProbeModule;
211 friend class SphereProbeModule;
212 friend class BackgroundPipeline;
213
214 private:
215 Instance &inst_;
216
218 Map<ObjectKey, VolumeProbe> volume_map_;
219 Map<ObjectKey, SphereProbe> sphere_map_;
220 Map<ObjectKey, PlanarProbe> planar_map_;
221 /* World probe is stored separately. */
222 SphereProbe world_sphere_;
224 bool volume_update_;
225 bool sphere_update_;
226 bool planar_update_;
228 bool auto_bake_enabled_;
229
230 eLightProbeResolution sphere_object_resolution_ = LIGHT_PROBE_RESOLUTION_128;
231
232 public:
235
236 void init();
237
238 void begin_sync();
239 void sync_probe(const Object *ob, ObjectHandle &handle);
240 void sync_world(const ::World *world, bool has_update);
241 void end_sync();
242
243 private:
244 void sync_sphere(const Object *ob, ObjectHandle &handle);
245 void sync_volume(const Object *ob, ObjectHandle &handle);
246 void sync_planar(const Object *ob, ObjectHandle &handle);
247
249 int sphere_layer_count() const;
250
252 SphereProbeAtlasCoord find_empty_atlas_region(int subdivision_level) const;
253};
254
255} // namespace blender::eevee
eLightProbeResolution
@ LIGHT_PROBE_RESOLUTION_128
static AppView * view
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)
nullptr float
#define SPHERE_PROBE_ATLAS_RES
T dot(const QuaternionBase< T > &a, const QuaternionBase< T > &b)
MatT from_scale(const VecBase< typename MatT::base_type, ScaleDim > &scale)
MatBase< float, 4, 4 > float4x4
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