reflection_probe.h 4.7 KB

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