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