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