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