compositor.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /**************************************************************************/
  2. /* compositor.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 COMPOSITOR_H
  31. #define COMPOSITOR_H
  32. #include "core/io/resource.h"
  33. #include "core/object/gdvirtual.gen.inc"
  34. #include "servers/rendering/storage/render_data.h"
  35. /* Compositor Effect */
  36. class CompositorEffect : public Resource {
  37. GDCLASS(CompositorEffect, Resource);
  38. public:
  39. enum EffectCallbackType {
  40. EFFECT_CALLBACK_TYPE_PRE_OPAQUE,
  41. EFFECT_CALLBACK_TYPE_POST_OPAQUE,
  42. EFFECT_CALLBACK_TYPE_POST_SKY,
  43. EFFECT_CALLBACK_TYPE_PRE_TRANSPARENT,
  44. EFFECT_CALLBACK_TYPE_POST_TRANSPARENT,
  45. EFFECT_CALLBACK_TYPE_MAX
  46. };
  47. private:
  48. RID rid;
  49. bool enabled = true;
  50. EffectCallbackType effect_callback_type = EFFECT_CALLBACK_TYPE_POST_TRANSPARENT;
  51. bool access_resolved_color = false;
  52. bool access_resolved_depth = false;
  53. bool needs_motion_vectors = false;
  54. bool needs_normal_roughness = false;
  55. bool needs_separate_specular = false;
  56. protected:
  57. static void _bind_methods();
  58. void _validate_property(PropertyInfo &p_property) const;
  59. GDVIRTUAL2(_render_callback, int, const RenderData *)
  60. public:
  61. virtual RID get_rid() const override { return rid; }
  62. void set_enabled(bool p_enabled);
  63. bool get_enabled() const;
  64. void set_effect_callback_type(EffectCallbackType p_callback_type);
  65. EffectCallbackType get_effect_callback_type() const;
  66. void set_access_resolved_color(bool p_enabled);
  67. bool get_access_resolved_color() const;
  68. void set_access_resolved_depth(bool p_enabled);
  69. bool get_access_resolved_depth() const;
  70. void set_needs_motion_vectors(bool p_enabled);
  71. bool get_needs_motion_vectors() const;
  72. void set_needs_normal_roughness(bool p_enabled);
  73. bool get_needs_normal_roughness() const;
  74. void set_needs_separate_specular(bool p_enabled);
  75. bool get_needs_separate_specular() const;
  76. CompositorEffect();
  77. ~CompositorEffect();
  78. };
  79. VARIANT_ENUM_CAST(CompositorEffect::EffectCallbackType)
  80. /* Compositor */
  81. class Compositor : public Resource {
  82. GDCLASS(Compositor, Resource);
  83. private:
  84. RID compositor;
  85. // Compositor effects
  86. LocalVector<Ref<CompositorEffect>> effects;
  87. protected:
  88. static void _bind_methods();
  89. public:
  90. virtual RID get_rid() const override { return compositor; }
  91. Compositor();
  92. ~Compositor();
  93. // Compositor effects
  94. void set_compositor_effects(const TypedArray<CompositorEffect> &p_compositor_effects);
  95. TypedArray<CompositorEffect> get_compositor_effects() const;
  96. };
  97. #endif // COMPOSITOR_H