Blender V4.5
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 "eevee_defines.hh"
21#include "eevee_sync.hh"
22
23namespace blender::eevee {
24
25class Instance;
27
28/* -------------------------------------------------------------------- */
31
34 int atlas_layer = -1;
38 int area_index = -1;
39
41 void free()
42 {
43 atlas_layer = -1;
44 }
45
46 /* Return the area extent in pixel. */
47 int area_extent(int mip_lvl = 0) const
48 {
49 return SPHERE_PROBE_ATLAS_RES >> (subdivision_lvl + mip_lvl);
50 }
51
52 /* Coordinate of the area in [0..area_count_per_dimension[ range. */
54 {
55 const int area_count_per_dimension = 1 << subdivision_lvl;
56 return int2(area_index % area_count_per_dimension, area_index / area_count_per_dimension);
57 }
58
59 /* Coordinate of the bottom left corner of the area in [0..SPHERE_PROBE_ATLAS_RES[ range. */
60 int2 area_offset(int mip_lvl = 0) const
61 {
62 return area_location() * area_extent(mip_lvl);
63 }
64
66 {
68 coord.scale = float(area_extent()) / SPHERE_PROBE_ATLAS_RES;
70 coord.layer = atlas_layer;
71 return coord;
72 }
73
75 {
77 coord.extent = area_extent(mip_lvl);
78 coord.offset = area_offset(mip_lvl);
79 coord.layer = atlas_layer;
80 return coord;
81 }
82
94 BitVector<> areas_occupancy_;
95 int subdivision_level_;
96 /* Area count for the given subdivision level. */
97 int areas_per_dimension_;
98 int areas_per_layer_;
99
100 public:
101 LocationFinder(int allocated_layer_count, int subdivision_level);
102
103 /* Mark space to be occupied by the given probe_data. */
104 void mark_space_used(const SphereProbeAtlasCoord &coord);
105
107
108 void print_debug() const;
109 };
110};
111
113
115 bool used = false;
116 bool initialized = false;
117 /* NOTE: Might be not needed if depsgraph updates work as intended. */
118 bool updated = false;
120 bool viewport_display = false;
122};
123
150
163
165 /* Copy of object matrices. */
168 /* Offset to the clipping plane in the normal direction. */
170 /* Index in the resource array. */
172
173 public:
178 void set_view(const draw::View &view, int layer_id);
179
190
191 private:
196 float4x4 reflection_matrix_get()
197 {
199 }
200};
201
203 friend class IrradianceBake;
204 friend class VolumeProbeModule;
205 friend class PlanarProbeModule;
206 friend class SphereProbeModule;
207 friend class BackgroundPipeline;
208
209 private:
210 Instance &inst_;
211
213 Map<ObjectKey, VolumeProbe> volume_map_;
214 Map<ObjectKey, SphereProbe> sphere_map_;
215 Map<ObjectKey, PlanarProbe> planar_map_;
216 /* World probe is stored separately. */
217 SphereProbe world_sphere_;
219 bool volume_update_;
220 bool sphere_update_;
221 bool planar_update_;
223 bool auto_bake_enabled_;
224
225 eLightProbeResolution sphere_object_resolution_ = LIGHT_PROBE_RESOLUTION_128;
226
227 public:
230
231 void init();
232
233 void begin_sync();
234 void sync_probe(const Object *ob, ObjectHandle &handle);
235 void sync_world(const ::World *world, bool has_update);
236 void end_sync();
237
238 private:
239 void sync_sphere(const Object *ob, ObjectHandle &handle);
240 void sync_volume(const Object *ob, ObjectHandle &handle);
241 void sync_planar(const Object *ob, ObjectHandle &handle);
242
244 int sphere_layer_count() const;
245
247 SphereProbeAtlasCoord find_empty_atlas_region(int subdivision_level) const;
248};
249
250} // 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)
#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