1 | /**************************************************************************/ |
2 | /* reflection_probe.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 | #ifndef REFLECTION_PROBE_H |
32 | #define REFLECTION_PROBE_H |
33 | |
34 | #include "scene/3d/visual_instance_3d.h" |
35 | |
36 | class ReflectionProbe : public VisualInstance3D { |
37 | GDCLASS(ReflectionProbe, VisualInstance3D); |
38 | |
39 | public: |
40 | enum UpdateMode { |
41 | UPDATE_ONCE, |
42 | UPDATE_ALWAYS, |
43 | }; |
44 | |
45 | enum AmbientMode { |
46 | AMBIENT_DISABLED, |
47 | AMBIENT_ENVIRONMENT, |
48 | AMBIENT_COLOR |
49 | }; |
50 | |
51 | private: |
52 | RID probe; |
53 | float intensity = 1.0; |
54 | float max_distance = 0.0; |
55 | Vector3 size = Vector3(20, 20, 20); |
56 | Vector3 origin_offset = Vector3(0, 0, 0); |
57 | bool box_projection = false; |
58 | bool enable_shadows = false; |
59 | bool interior = false; |
60 | AmbientMode ambient_mode = AMBIENT_ENVIRONMENT; |
61 | Color ambient_color = Color(0, 0, 0); |
62 | float ambient_color_energy = 1.0; |
63 | float mesh_lod_threshold = 1.0; |
64 | |
65 | uint32_t cull_mask = (1 << 20) - 1; |
66 | UpdateMode update_mode = UPDATE_ONCE; |
67 | |
68 | protected: |
69 | static void _bind_methods(); |
70 | void _validate_property(PropertyInfo &p_property) const; |
71 | #ifndef DISABLE_DEPRECATED |
72 | bool _set(const StringName &p_name, const Variant &p_value); |
73 | bool _get(const StringName &p_name, Variant &r_property) const; |
74 | #endif // DISABLE_DEPRECATED |
75 | |
76 | public: |
77 | void set_intensity(float p_intensity); |
78 | float get_intensity() const; |
79 | |
80 | void set_ambient_mode(AmbientMode p_mode); |
81 | AmbientMode get_ambient_mode() const; |
82 | |
83 | void set_ambient_color(Color p_ambient); |
84 | Color get_ambient_color() const; |
85 | |
86 | void set_ambient_color_energy(float p_energy); |
87 | float get_ambient_color_energy() const; |
88 | |
89 | void set_interior_ambient_probe_contribution(float p_contribution); |
90 | float get_interior_ambient_probe_contribution() const; |
91 | |
92 | void set_max_distance(float p_distance); |
93 | float get_max_distance() const; |
94 | |
95 | void set_mesh_lod_threshold(float p_pixels); |
96 | float get_mesh_lod_threshold() const; |
97 | |
98 | void set_size(const Vector3 &p_size); |
99 | Vector3 get_size() const; |
100 | |
101 | void set_origin_offset(const Vector3 &p_offset); |
102 | Vector3 get_origin_offset() const; |
103 | |
104 | void set_as_interior(bool p_enable); |
105 | bool is_set_as_interior() const; |
106 | |
107 | void set_enable_box_projection(bool p_enable); |
108 | bool is_box_projection_enabled() const; |
109 | |
110 | void set_enable_shadows(bool p_enable); |
111 | bool are_shadows_enabled() const; |
112 | |
113 | void set_cull_mask(uint32_t p_layers); |
114 | uint32_t get_cull_mask() const; |
115 | |
116 | void set_update_mode(UpdateMode p_mode); |
117 | UpdateMode get_update_mode() const; |
118 | |
119 | virtual AABB get_aabb() const override; |
120 | |
121 | virtual PackedStringArray get_configuration_warnings() const override; |
122 | |
123 | ReflectionProbe(); |
124 | ~ReflectionProbe(); |
125 | }; |
126 | |
127 | VARIANT_ENUM_CAST(ReflectionProbe::AmbientMode); |
128 | VARIANT_ENUM_CAST(ReflectionProbe::UpdateMode); |
129 | |
130 | #endif // REFLECTION_PROBE_H |
131 | |