Debian Codegraph @

scene/3d/voxel_gi.h

raw symbols SCIP
1 /**************************************************************************/
2 /* voxel_gi.h */
3 /**************************************************************************/
4 /* This file is part of: */
5 /* GODOT ENGINE */
6 /* https://godotengine.org */
7 /**************************************************************************/
8 /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9 /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10 /* */
11 /* Permission is hereby granted, free of charge, to any person obtaining */
12 /* a copy of this software and associated documentation files (the */
13 /* "Software"), to deal in the Software without restriction, including */
14 /* without limitation the rights to use, copy, modify, merge, publish, */
15 /* distribute, sublicense, and/or sell copies of the Software, and to */
16 /* permit persons to whom the Software is furnished to do so, subject to */
17 /* the following conditions: */
18 /* */
19 /* The above copyright notice and this permission notice shall be */
20 /* included in all copies or substantial portions of the Software. */
21 /* */
22 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29 /**************************************************************************/
30
31 #pragma once
32
33 #include "scene/3d/visual_instance_3d.h"
34
35 class CameraAttributes;
36
37 class VoxelGIData : public Resource {
38 GDCLASS(VoxelGIData, Resource);
39
40 RID probe;
41
42 void _set_data(const Dictionary &p_data);
43 Dictionary _get_data() const;
44
45 Transform3D to_cell_xform;
46 AABB bounds;
47 Vector3 octree_size;
48
49 float dynamic_range = 2.0;
50 float energy = 1.0;
51 float bias = 1.5;
52 float normal_bias = 0.0;
53 float propagation = 0.5;
54 bool interior = false;
55 bool use_two_bounces = true;
56
57 protected:
58 static void _bind_methods();
59
60 public:
61 void allocate(const Transform3D &p_to_cell_xform, const AABB &p_aabb, const Vector3 &p_octree_size, const Vector<uint8_t> &p_octree_cells, const Vector<uint8_t> &p_data_cells, const Vector<uint8_t> &p_distance_field, const Vector<int> &p_level_counts);
62 AABB get_bounds() const;
63 Vector3 get_octree_size() const;
64 Vector<uint8_t> get_octree_cells() const;
65 Vector<uint8_t> get_data_cells() const;
66 Vector<uint8_t> get_distance_field() const;
67 Vector<int> get_level_counts() const;
68 Transform3D get_to_cell_xform() const;
69
70 void set_dynamic_range(float p_range);
71 float get_dynamic_range() const;
72
73 void set_propagation(float p_propagation);
74 float get_propagation() const;
75
76 void set_energy(float p_energy);
77 float get_energy() const;
78
79 void set_bias(float p_bias);
80 float get_bias() const;
81
82 void set_normal_bias(float p_normal_bias);
83 float get_normal_bias() const;
84
85 void set_interior(bool p_enable);
86 bool is_interior() const;
87
88 void set_use_two_bounces(bool p_enable);
89 bool is_using_two_bounces() const;
90
91 virtual RID get_rid() const override;
92
93 VoxelGIData();
94 ~VoxelGIData();
95 };
96
97 class VoxelGI : public VisualInstance3D {
98 GDCLASS(VoxelGI, VisualInstance3D);
99
100 public:
101 enum Subdiv {
102 SUBDIV_64,
103 SUBDIV_128,
104 SUBDIV_256,
105 SUBDIV_512,
106 SUBDIV_MAX
107
108 };
109
110 typedef void (*BakeBeginFunc)();
111 typedef bool (*BakeStepFunc)(int, const String &);
112 typedef void (*BakeEndFunc)();
113
114 private:
115 Ref<VoxelGIData> probe_data;
116
117 RID voxel_gi;
118
119 Subdiv subdiv = SUBDIV_128;
120 Vector3 size = Vector3(20, 20, 20);
121 Ref<CameraAttributes> camera_attributes;
122
123 struct PlotMesh {
124 Ref<Material> override_material;
125 Vector<Ref<Material>> instance_materials;
126 Ref<Mesh> mesh;
127 Transform3D local_xform;
128 };
129
130 void _find_meshes(Node *p_at_node, List<PlotMesh> &plot_meshes);
131 void _debug_bake();
132
133 float _get_camera_exposure_normalization();
134
135 protected:
136 static void _bind_methods();
137 #ifndef DISABLE_DEPRECATED
138 bool _set(const StringName &p_name, const Variant &p_value);
139 bool _get(const StringName &p_name, Variant &r_property) const;
140 #endif // DISABLE_DEPRECATED
141
142 public:
143 static BakeBeginFunc bake_begin_function;
144 static BakeStepFunc bake_step_function;
145 static BakeEndFunc bake_end_function;
146
147 void set_probe_data(const Ref<VoxelGIData> &p_data);
148 Ref<VoxelGIData> get_probe_data() const;
149
150 void set_subdiv(Subdiv p_subdiv);
151 Subdiv get_subdiv() const;
152
153 void set_size(const Vector3 &p_size);
154 Vector3 get_size() const;
155
156 void set_camera_attributes(const Ref<CameraAttributes> &p_camera_attributes);
157 Ref<CameraAttributes> get_camera_attributes() const;
158
159 Vector3i get_estimated_cell_size() const;
160
161 void bake(Node *p_from_node = nullptr, bool p_create_visual_debug = false);
162
163 virtual AABB get_aabb() const override;
164
165 PackedStringArray get_configuration_warnings() const override;
166
167 VoxelGI();
168 ~VoxelGI();
169 };
170
171 VARIANT_ENUM_CAST(VoxelGI::Subdiv)