1/**************************************************************************/
2/* decal.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 DECAL_H
32#define DECAL_H
33
34#include "scene/3d/visual_instance_3d.h"
35
36class Decal : public VisualInstance3D {
37 GDCLASS(Decal, VisualInstance3D);
38
39public:
40 enum DecalTexture {
41 TEXTURE_ALBEDO,
42 TEXTURE_NORMAL,
43 TEXTURE_ORM,
44 TEXTURE_EMISSION,
45 TEXTURE_MAX
46 };
47
48private:
49 RID decal;
50 Vector3 size = Vector3(2, 2, 2);
51 Ref<Texture2D> textures[TEXTURE_MAX];
52 real_t emission_energy = 1.0;
53 real_t albedo_mix = 1.0;
54 Color modulate = Color(1, 1, 1, 1);
55 uint32_t cull_mask = (1 << 20) - 1;
56 real_t normal_fade = 0.0;
57 real_t upper_fade = 0.3;
58 real_t lower_fade = 0.3;
59 bool distance_fade_enabled = false;
60 real_t distance_fade_begin = 40.0;
61 real_t distance_fade_length = 10.0;
62
63protected:
64 static void _bind_methods();
65 void _validate_property(PropertyInfo &p_property) const;
66#ifndef DISABLE_DEPRECATED
67 bool _set(const StringName &p_name, const Variant &p_value);
68 bool _get(const StringName &p_name, Variant &r_property) const;
69#endif // DISABLE_DEPRECATED
70
71public:
72 virtual PackedStringArray get_configuration_warnings() const override;
73
74 void set_size(const Vector3 &p_size);
75 Vector3 get_size() const;
76
77 void set_texture(DecalTexture p_type, const Ref<Texture2D> &p_texture);
78 Ref<Texture2D> get_texture(DecalTexture p_type) const;
79
80 void set_emission_energy(real_t p_energy);
81 real_t get_emission_energy() const;
82
83 void set_albedo_mix(real_t p_mix);
84 real_t get_albedo_mix() const;
85
86 void set_modulate(Color p_modulate);
87 Color get_modulate() const;
88
89 void set_upper_fade(real_t p_energy);
90 real_t get_upper_fade() const;
91
92 void set_lower_fade(real_t p_fade);
93 real_t get_lower_fade() const;
94
95 void set_normal_fade(real_t p_fade);
96 real_t get_normal_fade() const;
97
98 void set_enable_distance_fade(bool p_enable);
99 bool is_distance_fade_enabled() const;
100
101 void set_distance_fade_begin(real_t p_distance);
102 real_t get_distance_fade_begin() const;
103
104 void set_distance_fade_length(real_t p_length);
105 real_t get_distance_fade_length() const;
106
107 void set_cull_mask(uint32_t p_layers);
108 uint32_t get_cull_mask() const;
109
110 virtual AABB get_aabb() const override;
111
112 Decal();
113 ~Decal();
114};
115
116VARIANT_ENUM_CAST(Decal::DecalTexture);
117
118#endif // DECAL_H
119