renderer_compositor.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /**************************************************************************/
  2. /* renderer_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 RENDERER_COMPOSITOR_H
  31. #define RENDERER_COMPOSITOR_H
  32. #include "servers/rendering/environment/renderer_fog.h"
  33. #include "servers/rendering/environment/renderer_gi.h"
  34. #include "servers/rendering/renderer_canvas_render.h"
  35. #include "servers/rendering/rendering_method.h"
  36. #include "servers/rendering/storage/camera_attributes_storage.h"
  37. #include "servers/rendering/storage/light_storage.h"
  38. #include "servers/rendering/storage/material_storage.h"
  39. #include "servers/rendering/storage/mesh_storage.h"
  40. #include "servers/rendering/storage/particles_storage.h"
  41. #include "servers/rendering/storage/texture_storage.h"
  42. #include "servers/rendering/storage/utilities.h"
  43. #include "servers/rendering_server.h"
  44. class RendererSceneRender;
  45. struct BlitToScreen {
  46. RID render_target;
  47. Rect2 src_rect = Rect2(0.0, 0.0, 1.0, 1.0);
  48. Rect2i dst_rect;
  49. struct {
  50. bool use_layer = false;
  51. uint32_t layer = 0;
  52. } multi_view;
  53. struct {
  54. //lens distorted parameters for VR
  55. bool apply = false;
  56. Vector2 eye_center;
  57. float k1 = 0.0;
  58. float k2 = 0.0;
  59. float upscale = 1.0;
  60. float aspect_ratio = 1.0;
  61. } lens_distortion;
  62. };
  63. class RendererCompositor {
  64. private:
  65. bool xr_enabled = false;
  66. static RendererCompositor *singleton;
  67. protected:
  68. static RendererCompositor *(*_create_func)();
  69. bool back_end = false;
  70. static bool low_end;
  71. public:
  72. static RendererCompositor *create();
  73. virtual RendererUtilities *get_utilities() = 0;
  74. virtual RendererLightStorage *get_light_storage() = 0;
  75. virtual RendererMaterialStorage *get_material_storage() = 0;
  76. virtual RendererMeshStorage *get_mesh_storage() = 0;
  77. virtual RendererParticlesStorage *get_particles_storage() = 0;
  78. virtual RendererTextureStorage *get_texture_storage() = 0;
  79. virtual RendererGI *get_gi() = 0;
  80. virtual RendererFog *get_fog() = 0;
  81. virtual RendererCanvasRender *get_canvas() = 0;
  82. virtual RendererSceneRender *get_scene() = 0;
  83. virtual void set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale, bool p_use_filter = true) = 0;
  84. virtual void initialize() = 0;
  85. virtual void begin_frame(double frame_step) = 0;
  86. virtual void prepare_for_blitting_render_targets() = 0;
  87. virtual void blit_render_targets_to_screen(DisplayServer::WindowID p_screen, const BlitToScreen *p_render_targets, int p_amount) = 0;
  88. virtual void end_frame(bool p_swap_buffers) = 0;
  89. virtual void finalize() = 0;
  90. virtual uint64_t get_frame_number() const = 0;
  91. virtual double get_frame_delta_time() const = 0;
  92. virtual double get_total_time() const = 0;
  93. static bool is_low_end() { return low_end; };
  94. virtual bool is_xr_enabled() const;
  95. static RendererCompositor *get_singleton() { return singleton; }
  96. RendererCompositor();
  97. virtual ~RendererCompositor() {}
  98. };
  99. #endif // RENDERER_COMPOSITOR_H