decal.h 4.3 KB

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