render_scene_buffers.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. #pragma once
  31. #include "core/object/ref_counted.h"
  32. #include "servers/rendering_server.h"
  33. class RenderSceneBuffersConfiguration : public RefCounted {
  34. GDCLASS(RenderSceneBuffersConfiguration, RefCounted);
  35. private:
  36. RID render_target;
  37. Size2i internal_size;
  38. Size2i target_size;
  39. uint32_t view_count = 1;
  40. RS::ViewportScaling3DMode scaling_3d_mode = RS::VIEWPORT_SCALING_3D_MODE_OFF;
  41. RS::ViewportMSAA msaa_3d = RS::VIEWPORT_MSAA_DISABLED;
  42. RS::ViewportScreenSpaceAA screen_space_aa = RS::VIEWPORT_SCREEN_SPACE_AA_DISABLED;
  43. RS::ViewportAnisotropicFiltering anisotropic_filtering_level = RS::VIEWPORT_ANISOTROPY_4X;
  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. RS::ViewportAnisotropicFiltering get_anisotropic_filtering_level() const { return anisotropic_filtering_level; }
  70. void set_anisotropic_filtering_level(RS::ViewportAnisotropicFiltering p_anisotropic_filtering_level) { anisotropic_filtering_level = p_anisotropic_filtering_level; }
  71. bool get_use_taa() const { return use_taa; }
  72. void set_use_taa(bool p_use_taa) { use_taa = p_use_taa; }
  73. bool get_use_debanding() const { return use_debanding; }
  74. void set_use_debanding(bool p_use_debanding) { use_debanding = p_use_debanding; }
  75. RenderSceneBuffersConfiguration() {}
  76. virtual ~RenderSceneBuffersConfiguration() {}
  77. };
  78. class RenderSceneBuffers : public RefCounted {
  79. GDCLASS(RenderSceneBuffers, RefCounted);
  80. protected:
  81. static void _bind_methods();
  82. public:
  83. RenderSceneBuffers() {}
  84. virtual ~RenderSceneBuffers() {}
  85. virtual void configure(const RenderSceneBuffersConfiguration *p_config) = 0;
  86. // for those settings that are unlikely to require buffers to be recreated, we'll add setters
  87. virtual void set_fsr_sharpness(float p_fsr_sharpness) = 0;
  88. virtual void set_texture_mipmap_bias(float p_texture_mipmap_bias) = 0;
  89. virtual void set_anisotropic_filtering_level(RS::ViewportAnisotropicFiltering p_anisotropic_filtering_level) = 0;
  90. virtual void set_use_debanding(bool p_use_debanding) = 0;
  91. };
  92. class RenderSceneBuffersExtension : public RenderSceneBuffers {
  93. GDCLASS(RenderSceneBuffersExtension, RenderSceneBuffers);
  94. protected:
  95. static void _bind_methods();
  96. GDVIRTUAL1(_configure, const RenderSceneBuffersConfiguration *)
  97. GDVIRTUAL1(_set_fsr_sharpness, float)
  98. GDVIRTUAL1(_set_texture_mipmap_bias, float)
  99. GDVIRTUAL1(_set_anisotropic_filtering_level, int)
  100. GDVIRTUAL1(_set_use_debanding, bool)
  101. public:
  102. virtual ~RenderSceneBuffersExtension() {}
  103. virtual void configure(const RenderSceneBuffersConfiguration *p_config) override;
  104. virtual void set_fsr_sharpness(float p_fsr_sharpness) override;
  105. virtual void set_texture_mipmap_bias(float p_texture_mipmap_bias) override;
  106. virtual void set_anisotropic_filtering_level(RS::ViewportAnisotropicFiltering p_anisotropic_filtering_level) override;
  107. virtual void set_use_debanding(bool p_use_debanding) override;
  108. };