reflection_probe.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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 blend_distance = 1.0;
  49. float max_distance = 0.0;
  50. Vector3 size = Vector3(20, 20, 20);
  51. Vector3 origin_offset = Vector3(0, 0, 0);
  52. bool box_projection = false;
  53. bool enable_shadows = false;
  54. bool interior = false;
  55. AmbientMode ambient_mode = AMBIENT_ENVIRONMENT;
  56. Color ambient_color = Color(0, 0, 0);
  57. float ambient_color_energy = 1.0;
  58. float mesh_lod_threshold = 1.0;
  59. uint32_t cull_mask = (1 << 20) - 1;
  60. uint32_t reflection_mask = (1 << 20) - 1;
  61. UpdateMode update_mode = UPDATE_ONCE;
  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. public:
  70. void set_intensity(float p_intensity);
  71. float get_intensity() const;
  72. void set_blend_distance(float p_blend_distance);
  73. float get_blend_distance() const;
  74. void set_ambient_mode(AmbientMode p_mode);
  75. AmbientMode get_ambient_mode() const;
  76. void set_ambient_color(Color p_ambient);
  77. Color get_ambient_color() const;
  78. void set_ambient_color_energy(float p_energy);
  79. float get_ambient_color_energy() const;
  80. void set_interior_ambient_probe_contribution(float p_contribution);
  81. float get_interior_ambient_probe_contribution() const;
  82. void set_max_distance(float p_distance);
  83. float get_max_distance() const;
  84. void set_mesh_lod_threshold(float p_pixels);
  85. float get_mesh_lod_threshold() const;
  86. void set_size(const Vector3 &p_size);
  87. Vector3 get_size() const;
  88. void set_origin_offset(const Vector3 &p_offset);
  89. Vector3 get_origin_offset() const;
  90. void set_as_interior(bool p_enable);
  91. bool is_set_as_interior() const;
  92. void set_enable_box_projection(bool p_enable);
  93. bool is_box_projection_enabled() const;
  94. void set_enable_shadows(bool p_enable);
  95. bool are_shadows_enabled() const;
  96. void set_cull_mask(uint32_t p_layers);
  97. uint32_t get_cull_mask() const;
  98. void set_reflection_mask(uint32_t p_layers);
  99. uint32_t get_reflection_mask() const;
  100. void set_update_mode(UpdateMode p_mode);
  101. UpdateMode get_update_mode() const;
  102. virtual AABB get_aabb() const override;
  103. ReflectionProbe();
  104. ~ReflectionProbe();
  105. };
  106. VARIANT_ENUM_CAST(ReflectionProbe::AmbientMode);
  107. VARIANT_ENUM_CAST(ReflectionProbe::UpdateMode);
  108. #endif // REFLECTION_PROBE_H