render_scene_buffers.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /**************************************************************************/
  2. /* render_scene_buffers.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 RENDER_SCENE_BUFFERS_H
  31. #define RENDER_SCENE_BUFFERS_H
  32. #include "core/object/ref_counted.h"
  33. #include "servers/rendering_server.h"
  34. class RenderSceneBuffersConfiguration : public RefCounted {
  35. GDCLASS(RenderSceneBuffersConfiguration, RefCounted);
  36. private:
  37. RID render_target;
  38. Size2i internal_size;
  39. Size2i target_size;
  40. uint32_t view_count = 1;
  41. RS::ViewportScaling3DMode scaling_3d_mode = RS::VIEWPORT_SCALING_3D_MODE_OFF;
  42. RS::ViewportMSAA msaa_3d = RS::VIEWPORT_MSAA_DISABLED;
  43. RS::ViewportScreenSpaceAA screen_space_aa = RS::VIEWPORT_SCREEN_SPACE_AA_DISABLED;
  44. float fsr_sharpness = 0.0;
  45. float texture_mipmap_bias = 0.0;
  46. bool use_taa = false;
  47. bool use_debanding = false;
  48. protected:
  49. static void _bind_methods();
  50. public:
  51. RID get_render_target() const { return render_target; }
  52. void set_render_target(RID p_render_target) { render_target = p_render_target; }
  53. Size2i get_internal_size() const { return internal_size; }
  54. void set_internal_size(Size2i p_internal_size) { internal_size = p_internal_size; }
  55. Size2i get_target_size() const { return target_size; }
  56. void set_target_size(Size2i p_target_size) { target_size = p_target_size; }
  57. uint32_t get_view_count() const { return view_count; }
  58. void set_view_count(uint32_t p_view_count) { view_count = p_view_count; }
  59. RS::ViewportScaling3DMode get_scaling_3d_mode() const { return scaling_3d_mode; }
  60. void set_scaling_3d_mode(RS::ViewportScaling3DMode p_scaling_3d_mode) { scaling_3d_mode = p_scaling_3d_mode; }
  61. RS::ViewportMSAA get_msaa_3d() const { return msaa_3d; }
  62. void set_msaa_3d(RS::ViewportMSAA p_msaa_3d) { msaa_3d = p_msaa_3d; }
  63. RS::ViewportScreenSpaceAA get_screen_space_aa() const { return screen_space_aa; }
  64. void set_screen_space_aa(RS::ViewportScreenSpaceAA p_screen_space_aa) { screen_space_aa = p_screen_space_aa; }
  65. float get_fsr_sharpness() const { return fsr_sharpness; }
  66. void set_fsr_sharpness(float p_fsr_sharpness) { fsr_sharpness = p_fsr_sharpness; }
  67. float get_texture_mipmap_bias() const { return texture_mipmap_bias; }
  68. void set_texture_mipmap_bias(float p_texture_mipmap_bias) { texture_mipmap_bias = p_texture_mipmap_bias; }
  69. bool get_use_taa() const { return use_taa; }
  70. void set_use_taa(bool p_use_taa) { use_taa = p_use_taa; }
  71. bool get_use_debanding() const { return use_debanding; }
  72. void set_use_debanding(bool p_use_debanding) { use_debanding = p_use_debanding; }
  73. RenderSceneBuffersConfiguration() {}
  74. virtual ~RenderSceneBuffersConfiguration(){};
  75. };
  76. class RenderSceneBuffers : public RefCounted {
  77. GDCLASS(RenderSceneBuffers, RefCounted);
  78. protected:
  79. static void _bind_methods();
  80. public:
  81. RenderSceneBuffers(){};
  82. virtual ~RenderSceneBuffers(){};
  83. virtual void configure(const RenderSceneBuffersConfiguration *p_config) = 0;
  84. // for those settings that are unlikely to require buffers to be recreated, we'll add setters
  85. virtual void set_fsr_sharpness(float p_fsr_sharpness) = 0;
  86. virtual void set_texture_mipmap_bias(float p_texture_mipmap_bias) = 0;
  87. virtual void set_use_debanding(bool p_use_debanding) = 0;
  88. };
  89. class RenderSceneBuffersExtension : public RenderSceneBuffers {
  90. GDCLASS(RenderSceneBuffersExtension, RenderSceneBuffers);
  91. protected:
  92. static void _bind_methods();
  93. GDVIRTUAL1(_configure, const RenderSceneBuffersConfiguration *)
  94. GDVIRTUAL1(_set_fsr_sharpness, float)
  95. GDVIRTUAL1(_set_texture_mipmap_bias, float)
  96. GDVIRTUAL1(_set_use_debanding, bool)
  97. public:
  98. virtual ~RenderSceneBuffersExtension(){};
  99. virtual void configure(const RenderSceneBuffersConfiguration *p_config) override;
  100. virtual void set_fsr_sharpness(float p_fsr_sharpness) override;
  101. virtual void set_texture_mipmap_bias(float p_texture_mipmap_bias) override;
  102. virtual void set_use_debanding(bool p_use_debanding) override;
  103. };
  104. #endif // RENDER_SCENE_BUFFERS_H