0.2.0-dev Download ZIP
575 lines ·17.7 KB Raw
| 1 | /**************************************************************************/ |
| 2 | /* ss_effects.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 | #pragma once |
| 32 | |
| 33 | #include "servers/rendering/renderer_rd/pipeline_deferred_rd.h" |
| 34 | #include "servers/rendering/renderer_rd/shaders/effects/screen_space_contact_shadows.glsl.gen.h" |
| 35 | #include "servers/rendering/renderer_rd/shaders/effects/screen_space_reflection.glsl.gen.h" |
| 36 | #include "servers/rendering/renderer_rd/shaders/effects/screen_space_reflection_downsample.glsl.gen.h" |
| 37 | #include "servers/rendering/renderer_rd/shaders/effects/screen_space_reflection_filter.glsl.gen.h" |
| 38 | #include "servers/rendering/renderer_rd/shaders/effects/screen_space_reflection_hiz.glsl.gen.h" |
| 39 | #include "servers/rendering/renderer_rd/shaders/effects/screen_space_reflection_resolve.glsl.gen.h" |
| 40 | #include "servers/rendering/renderer_rd/shaders/effects/ss_effects_downsample.glsl.gen.h" |
| 41 | #include "servers/rendering/renderer_rd/shaders/effects/ssao.glsl.gen.h" |
| 42 | #include "servers/rendering/renderer_rd/shaders/effects/ssao_blur.glsl.gen.h" |
| 43 | #include "servers/rendering/renderer_rd/shaders/effects/ssao_importance_map.glsl.gen.h" |
| 44 | #include "servers/rendering/renderer_rd/shaders/effects/ssao_interleave.glsl.gen.h" |
| 45 | #include "servers/rendering/renderer_rd/shaders/effects/ssil.glsl.gen.h" |
| 46 | #include "servers/rendering/renderer_rd/shaders/effects/ssil_blur.glsl.gen.h" |
| 47 | #include "servers/rendering/renderer_rd/shaders/effects/ssil_importance_map.glsl.gen.h" |
| 48 | #include "servers/rendering/renderer_rd/shaders/effects/ssil_interleave.glsl.gen.h" |
| 49 | #include "servers/rendering/renderer_rd/shaders/effects/subsurface_scattering.glsl.gen.h" |
| 50 | |
| 51 | #define RB_SCOPE_SSLF SNAME("rb_sslf") |
| 52 | #define RB_SCOPE_SSDS SNAME("rb_ssds") |
| 53 | #define RB_SCOPE_SSIL SNAME("rb_ssil") |
| 54 | #define RB_SCOPE_SSAO SNAME("rb_ssao") |
| 55 | #define RB_SCOPE_SSR SNAME("rb_ssr") |
| 56 | #define RB_SCOPE_SSCS SNAME("rb_sscs") |
| 57 | |
| 58 | #define RB_LINEAR_DEPTH SNAME("linear_depth") |
| 59 | #define RB_FINAL SNAME("final") |
| 60 | #define RB_LAST_FRAME SNAME("last_frame") |
| 61 | #define RB_DEINTERLEAVED SNAME("deinterleaved") |
| 62 | #define RB_DEINTERLEAVED_PONG SNAME("deinterleaved_pong") |
| 63 | #define RB_EDGES SNAME("edges") |
| 64 | #define RB_IMPORTANCE_MAP SNAME("importance_map") |
| 65 | #define RB_IMPORTANCE_PONG SNAME("importance_pong") |
| 66 | |
| 67 | #define RB_NORMAL_ROUGHNESS SNAME("normal_roughness") |
| 68 | #define RB_HIZ SNAME("hiz") |
| 69 | #define RB_SSR SNAME("ssr") |
| 70 | #define RB_MIP_LEVEL SNAME("mip_level") |
| 71 | |
| 72 | #define RB_SSCS SNAME("sscs") |
| 73 | |
| 74 | class RenderSceneBuffersRD; |
| 75 | |
| 76 | namespace RendererRD { |
| 77 | |
| 78 | class CopyEffects; |
| 79 | |
| 80 | class SSEffects { |
| 81 | private: |
| 82 | static SSEffects *singleton; |
| 83 | |
| 84 | public: |
| 85 | static SSEffects *get_singleton() { return singleton; } |
| 86 | |
| 87 | SSEffects(); |
| 88 | ~SSEffects(); |
| 89 | |
| 90 | /* Last Frame */ |
| 91 | |
| 92 | void allocate_last_frame_buffer(Ref<RenderSceneBuffersRD> p_render_buffers, bool p_use_ssil, bool p_use_ssr); |
| 93 | void copy_internal_texture_to_last_frame(Ref<RenderSceneBuffersRD> p_render_buffers, CopyEffects &p_copy_effects); |
| 94 | |
| 95 | /* SS Downsampler */ |
| 96 | |
| 97 | void downsample_depth(Ref<RenderSceneBuffersRD> p_render_buffers, uint32_t p_view, const Projection &p_projection); |
| 98 | |
| 99 | /* SSIL */ |
| 100 | void ssil_set_quality(RSE::EnvironmentSSILQuality p_quality, bool p_half_size, float p_adaptive_target, int p_blur_passes, float p_fadeout_from, float p_fadeout_to); |
| 101 | |
| 102 | struct SSILRenderBuffers { |
| 103 | bool half_size = false; |
| 104 | int buffer_width; |
| 105 | int buffer_height; |
| 106 | int half_buffer_width; |
| 107 | int half_buffer_height; |
| 108 | }; |
| 109 | |
| 110 | struct SSILSettings { |
| 111 | float radius = 1.0; |
| 112 | float intensity = 2.0; |
| 113 | float sharpness = 0.98; |
| 114 | float normal_rejection = 1.0; |
| 115 | |
| 116 | Size2i full_screen_size; |
| 117 | }; |
| 118 | |
| 119 | void ssil_allocate_buffers(Ref<RenderSceneBuffersRD> p_render_buffers, SSILRenderBuffers &p_ssil_buffers, const SSILSettings &p_settings); |
| 120 | void screen_space_indirect_lighting(Ref<RenderSceneBuffersRD> p_render_buffers, SSILRenderBuffers &p_ssil_buffers, uint32_t p_view, RID p_normal_buffer, const Projection &p_projection, const Projection &p_last_projection, const SSILSettings &p_settings); |
| 121 | |
| 122 | /* SSAO */ |
| 123 | void ssao_set_quality(RSE::EnvironmentSSAOQuality p_quality, bool p_half_size, float p_adaptive_target, int p_blur_passes, float p_fadeout_from, float p_fadeout_to); |
| 124 | |
| 125 | struct SSAORenderBuffers { |
| 126 | bool half_size = false; |
| 127 | int buffer_width; |
| 128 | int buffer_height; |
| 129 | int half_buffer_width; |
| 130 | int half_buffer_height; |
| 131 | }; |
| 132 | |
| 133 | struct SSAOSettings { |
| 134 | float radius = 1.0; |
| 135 | float intensity = 2.0; |
| 136 | float power = 1.5; |
| 137 | float detail = 0.5; |
| 138 | float horizon = 0.06; |
| 139 | float sharpness = 0.98; |
| 140 | |
| 141 | Size2i full_screen_size; |
| 142 | }; |
| 143 | |
| 144 | void ssao_allocate_buffers(Ref<RenderSceneBuffersRD> p_render_buffers, SSAORenderBuffers &p_ssao_buffers, const SSAOSettings &p_settings); |
| 145 | void generate_ssao(Ref<RenderSceneBuffersRD> p_render_buffers, SSAORenderBuffers &p_ssao_buffers, uint32_t p_view, RID p_normal_buffer, const Projection &p_projection, const SSAOSettings &p_settings); |
| 146 | |
| 147 | /* Screen Space Reflection */ |
| 148 | void ssr_set_half_size(bool p_half_size); |
| 149 | |
| 150 | struct SSRRenderBuffers { |
| 151 | Size2i size; |
| 152 | uint32_t mipmaps = 1; |
| 153 | bool half_size = false; |
| 154 | }; |
| 155 | |
| 156 | void ssr_allocate_buffers(Ref<RenderSceneBuffersRD> p_render_buffers, SSRRenderBuffers &p_ssr_buffers, const RD::DataFormat p_color_format); |
| 157 | void screen_space_reflection(Ref<RenderSceneBuffersRD> p_render_buffers, SSRRenderBuffers &p_ssr_buffers, const RID *p_normal_roughness_slices, int p_max_steps, float p_fade_in, float p_fade_out, float p_tolerance, const Projection *p_projections, const Projection *p_reprojections, const Vector3 *p_eye_offsets, RendererRD::CopyEffects &p_copy_effects); |
| 158 | |
| 159 | /* subsurface scattering */ |
| 160 | void sss_set_quality(RSE::SubSurfaceScatteringQuality p_quality); |
| 161 | RSE::SubSurfaceScatteringQuality sss_get_quality() const; |
| 162 | void sss_set_scale(float p_scale, float p_depth_scale); |
| 163 | |
| 164 | void sub_surface_scattering(Ref<RenderSceneBuffersRD> p_render_buffers, RID p_diffuse, RID p_depth, const Projection &p_camera, const Size2i &p_screen_size); |
| 165 | |
| 166 | /* Screen Space Shadows */ |
| 167 | struct SSCSRenderBuffers { |
| 168 | Size2i size; |
| 169 | uint32_t light_count = 0; |
| 170 | }; |
| 171 | |
| 172 | struct SSCSSettings { |
| 173 | RSE::ScreenSpaceContactShadowsLength quality = RSE::SCREEN_SPACE_CONTACT_SHADOWS_LENGTH_MEDIUM; |
| 174 | float surface_thickness = 0.01f; |
| 175 | }; |
| 176 | |
| 177 | void sscs_allocate_buffers(Ref<RenderSceneBuffersRD> p_render_buffers, SSCSRenderBuffers &p_sscs_buffers, uint32_t p_contact_shadow_count); |
| 178 | void screen_space_contact_shadows(Ref<RenderSceneBuffersRD> p_render_buffers, SSCSRenderBuffers &p_sscs_buffers, const SSCSSettings &p_settings, const Projection *p_projections, Vector3 p_light_direction, uint32_t p_light_index, float p_blur, float p_taa_frame_count); |
| 179 | |
| 180 | private: |
| 181 | /* Settings */ |
| 182 | |
| 183 | RSE::EnvironmentSSAOQuality ssao_quality = RSE::ENV_SSAO_QUALITY_MEDIUM; |
| 184 | bool ssao_half_size = false; |
| 185 | float ssao_adaptive_target = 0.5; |
| 186 | int ssao_blur_passes = 2; |
| 187 | float ssao_fadeout_from = 50.0; |
| 188 | float ssao_fadeout_to = 300.0; |
| 189 | |
| 190 | RSE::EnvironmentSSILQuality ssil_quality = RSE::ENV_SSIL_QUALITY_MEDIUM; |
| 191 | bool ssil_half_size = false; |
| 192 | float ssil_adaptive_target = 0.5; |
| 193 | int ssil_blur_passes = 4; |
| 194 | float ssil_fadeout_from = 50.0; |
| 195 | float ssil_fadeout_to = 300.0; |
| 196 | |
| 197 | bool ssr_half_size = false; |
| 198 | |
| 199 | RSE::SubSurfaceScatteringQuality sss_quality = RSE::SUB_SURFACE_SCATTERING_QUALITY_MEDIUM; |
| 200 | float sss_scale = 0.05; |
| 201 | float sss_depth_scale = 0.01; |
| 202 | |
| 203 | /* SS Downsampler */ |
| 204 | |
| 205 | struct SSEffectsDownsamplePushConstant { |
| 206 | float pixel_size[2]; |
| 207 | float z_far; |
| 208 | float z_near; |
| 209 | uint32_t orthogonal; |
| 210 | float radius_sq; |
| 211 | uint32_t pad[2]; |
| 212 | }; |
| 213 | |
| 214 | enum SSEffectsMode { |
| 215 | SS_EFFECTS_DOWNSAMPLE, |
| 216 | SS_EFFECTS_DOWNSAMPLE_HALF_RES, |
| 217 | SS_EFFECTS_DOWNSAMPLE_MIPMAP, |
| 218 | SS_EFFECTS_DOWNSAMPLE_MIPMAP_HALF_RES, |
| 219 | SS_EFFECTS_DOWNSAMPLE_HALF, |
| 220 | SS_EFFECTS_DOWNSAMPLE_HALF_RES_HALF, |
| 221 | SS_EFFECTS_DOWNSAMPLE_FULL_MIPS, |
| 222 | SS_EFFECTS_MAX |
| 223 | }; |
| 224 | |
| 225 | struct SSEffectsGatherConstants { |
| 226 | float rotation_matrices[80]; //5 vec4s * 4 |
| 227 | }; |
| 228 | |
| 229 | struct SSEffectsShader { |
| 230 | SSEffectsDownsamplePushConstant downsample_push_constant; |
| 231 | SsEffectsDownsampleShaderRD downsample_shader; |
| 232 | RID downsample_shader_version; |
| 233 | bool used_half_size_last_frame = false; |
| 234 | bool used_mips_last_frame = false; |
| 235 | bool used_full_mips_last_frame = false; |
| 236 | |
| 237 | RID gather_constants_buffer; |
| 238 | |
| 239 | RID mirror_sampler; |
| 240 | |
| 241 | PipelineDeferredRD pipelines[SS_EFFECTS_MAX]; |
| 242 | } ss_effects; |
| 243 | |
| 244 | /* SSIL */ |
| 245 | |
| 246 | enum SSILMode { |
| 247 | SSIL_GATHER, |
| 248 | SSIL_GATHER_BASE, |
| 249 | SSIL_GATHER_ADAPTIVE, |
| 250 | SSIL_GENERATE_IMPORTANCE_MAP, |
| 251 | SSIL_PROCESS_IMPORTANCE_MAPA, |
| 252 | SSIL_PROCESS_IMPORTANCE_MAPB, |
| 253 | SSIL_BLUR_PASS, |
| 254 | SSIL_BLUR_PASS_SMART, |
| 255 | SSIL_BLUR_PASS_WIDE, |
| 256 | SSIL_INTERLEAVE, |
| 257 | SSIL_INTERLEAVE_SMART, |
| 258 | SSIL_INTERLEAVE_HALF, |
| 259 | SSIL_MAX |
| 260 | }; |
| 261 | |
| 262 | struct SSILGatherPushConstant { |
| 263 | int32_t screen_size[2]; |
| 264 | int pass; |
| 265 | int quality; |
| 266 | |
| 267 | float half_screen_pixel_size[2]; |
| 268 | float half_screen_pixel_size_x025[2]; |
| 269 | |
| 270 | float NDC_to_view_mul[2]; |
| 271 | float NDC_to_view_add[2]; |
| 272 | |
| 273 | float pad2[2]; |
| 274 | float z_near; |
| 275 | float z_far; |
| 276 | |
| 277 | float radius; |
| 278 | float intensity; |
| 279 | int size_multiplier; |
| 280 | int pad; |
| 281 | |
| 282 | float fade_out_mul; |
| 283 | float fade_out_add; |
| 284 | float normal_rejection_amount; |
| 285 | float inv_radius_near_limit; |
| 286 | |
| 287 | uint32_t is_orthogonal; |
| 288 | float neg_inv_radius; |
| 289 | float load_counter_avg_div; |
| 290 | float adaptive_sample_limit; |
| 291 | |
| 292 | int32_t pass_coord_offset[2]; |
| 293 | float pass_uv_offset[2]; |
| 294 | }; |
| 295 | |
| 296 | struct SSILImportanceMapPushConstant { |
| 297 | float half_screen_pixel_size[2]; |
| 298 | float intensity; |
| 299 | float pad; |
| 300 | }; |
| 301 | |
| 302 | struct SSILBlurPushConstant { |
| 303 | float edge_sharpness; |
| 304 | float pad; |
| 305 | float half_screen_pixel_size[2]; |
| 306 | }; |
| 307 | |
| 308 | struct SSILInterleavePushConstant { |
| 309 | float inv_sharpness; |
| 310 | uint32_t size_modifier; |
| 311 | float pixel_size[2]; |
| 312 | }; |
| 313 | |
| 314 | struct SSILProjectionUniforms { |
| 315 | float inv_last_frame_projection_matrix[16]; |
| 316 | }; |
| 317 | |
| 318 | struct SSIL { |
| 319 | SSILGatherPushConstant gather_push_constant; |
| 320 | SsilShaderRD gather_shader; |
| 321 | RID gather_shader_version; |
| 322 | RID projection_uniform_buffer; |
| 323 | |
| 324 | SSILImportanceMapPushConstant importance_map_push_constant; |
| 325 | SsilImportanceMapShaderRD importance_map_shader; |
| 326 | RID importance_map_shader_version; |
| 327 | RID importance_map_load_counter; |
| 328 | RID counter_uniform_set; |
| 329 | |
| 330 | SSILBlurPushConstant blur_push_constant; |
| 331 | SsilBlurShaderRD blur_shader; |
| 332 | RID blur_shader_version; |
| 333 | |
| 334 | SSILInterleavePushConstant interleave_push_constant; |
| 335 | SsilInterleaveShaderRD interleave_shader; |
| 336 | RID interleave_shader_version; |
| 337 | |
| 338 | PipelineDeferredRD pipelines[SSIL_MAX]; |
| 339 | } ssil; |
| 340 | |
| 341 | void gather_ssil(RD::ComputeListID p_compute_list, const RID *p_ssil_slices, const RID *p_edges_slices, const SSILSettings &p_settings, bool p_adaptive_base_pass, RID p_gather_uniform_set, RID p_importance_map_uniform_set, RID p_projection_uniform_set); |
| 342 | |
| 343 | /* SSAO */ |
| 344 | |
| 345 | enum SSAOMode { |
| 346 | SSAO_GATHER, |
| 347 | SSAO_GATHER_BASE, |
| 348 | SSAO_GATHER_ADAPTIVE, |
| 349 | SSAO_GENERATE_IMPORTANCE_MAP, |
| 350 | SSAO_PROCESS_IMPORTANCE_MAPA, |
| 351 | SSAO_PROCESS_IMPORTANCE_MAPB, |
| 352 | SSAO_BLUR_PASS, |
| 353 | SSAO_BLUR_PASS_SMART, |
| 354 | SSAO_BLUR_PASS_WIDE, |
| 355 | SSAO_INTERLEAVE, |
| 356 | SSAO_INTERLEAVE_SMART, |
| 357 | SSAO_INTERLEAVE_HALF, |
| 358 | SSAO_MAX |
| 359 | }; |
| 360 | |
| 361 | struct SSAOGatherPushConstant { |
| 362 | int32_t screen_size[2]; |
| 363 | int pass; |
| 364 | int quality; |
| 365 | |
| 366 | float half_screen_pixel_size[2]; |
| 367 | int size_multiplier; |
| 368 | float detail_intensity; |
| 369 | |
| 370 | float NDC_to_view_mul[2]; |
| 371 | float NDC_to_view_add[2]; |
| 372 | |
| 373 | float pad[2]; |
| 374 | float half_screen_pixel_size_x025[2]; |
| 375 | |
| 376 | float radius; |
| 377 | float intensity; |
| 378 | float shadow_power; |
| 379 | float shadow_clamp; |
| 380 | |
| 381 | float fade_out_mul; |
| 382 | float fade_out_add; |
| 383 | float horizon_angle_threshold; |
| 384 | float inv_radius_near_limit; |
| 385 | |
| 386 | uint32_t is_orthogonal; |
| 387 | float neg_inv_radius; |
| 388 | float load_counter_avg_div; |
| 389 | float adaptive_sample_limit; |
| 390 | |
| 391 | int32_t pass_coord_offset[2]; |
| 392 | float pass_uv_offset[2]; |
| 393 | }; |
| 394 | |
| 395 | struct SSAOImportanceMapPushConstant { |
| 396 | float half_screen_pixel_size[2]; |
| 397 | float intensity; |
| 398 | float power; |
| 399 | }; |
| 400 | |
| 401 | struct SSAOBlurPushConstant { |
| 402 | float edge_sharpness; |
| 403 | float pad; |
| 404 | float half_screen_pixel_size[2]; |
| 405 | }; |
| 406 | |
| 407 | struct SSAOInterleavePushConstant { |
| 408 | float inv_sharpness; |
| 409 | uint32_t size_modifier; |
| 410 | float pixel_size[2]; |
| 411 | }; |
| 412 | |
| 413 | struct SSAO { |
| 414 | SSAOGatherPushConstant gather_push_constant; |
| 415 | SsaoShaderRD gather_shader; |
| 416 | RID gather_shader_version; |
| 417 | |
| 418 | SSAOImportanceMapPushConstant importance_map_push_constant; |
| 419 | SsaoImportanceMapShaderRD importance_map_shader; |
| 420 | RID importance_map_shader_version; |
| 421 | RID importance_map_load_counter; |
| 422 | RID counter_uniform_set; |
| 423 | |
| 424 | SSAOBlurPushConstant blur_push_constant; |
| 425 | SsaoBlurShaderRD blur_shader; |
| 426 | RID blur_shader_version; |
| 427 | |
| 428 | SSAOInterleavePushConstant interleave_push_constant; |
| 429 | SsaoInterleaveShaderRD interleave_shader; |
| 430 | RID interleave_shader_version; |
| 431 | |
| 432 | PipelineDeferredRD pipelines[SSAO_MAX]; |
| 433 | } ssao; |
| 434 | |
| 435 | void gather_ssao(RD::ComputeListID p_compute_list, const RID *p_ao_slices, const SSAOSettings &p_settings, bool p_adaptive_base_pass, RID p_gather_uniform_set, RID p_importance_map_uniform_set); |
| 436 | |
| 437 | /* Screen Space Reflection */ |
| 438 | |
| 439 | enum ScreenSpaceReflectionDownsampleMode { |
| 440 | SCREEN_SPACE_REFLECTION_DOWNSAMPLE_DEFAULT, |
| 441 | SCREEN_SPACE_REFLECTION_DOWNSAMPLE_ODD_WIDTH, |
| 442 | SCREEN_SPACE_REFLECTION_DOWNSAMPLE_ODD_HEIGHT, |
| 443 | SCREEN_SPACE_REFLECTION_DOWNSAMPLE_ODD_WIDTH_AND_HEIGHT, |
| 444 | SCREEN_SPACE_REFLECTION_DOWNSAMPLE_MAX |
| 445 | }; |
| 446 | |
| 447 | struct ScreenSpaceReflectionDownsamplePushConstant { |
| 448 | int32_t screen_size[2]; |
| 449 | int32_t pad[2]; |
| 450 | }; |
| 451 | |
| 452 | enum ScreenSpaceReflectionHizMode { |
| 453 | SCREEN_SPACE_REFLECTION_HIZ_DEFAULT, |
| 454 | SCREEN_SPACE_REFLECTION_HIZ_ODD_WIDTH, |
| 455 | SCREEN_SPACE_REFLECTION_HIZ_ODD_HEIGHT, |
| 456 | SCREEN_SPACE_REFLECTION_HIZ_ODD_WIDTH_AND_HEIGHT, |
| 457 | SCREEN_SPACE_REFLECTION_HIZ_MAX |
| 458 | }; |
| 459 | |
| 460 | struct ScreenSpaceReflectionHizPushConstant { |
| 461 | int32_t screen_size[2]; |
| 462 | int32_t pad[2]; |
| 463 | }; |
| 464 | |
| 465 | struct ScreenSpaceReflectionSceneData { |
| 466 | float projection[2][16]; |
| 467 | float inv_projection[2][16]; |
| 468 | float reprojection[2][16]; |
| 469 | float eye_offset[2][4]; |
| 470 | }; |
| 471 | |
| 472 | struct ScreenSpaceReflectionPushConstant { |
| 473 | int32_t screen_size[2]; |
| 474 | int32_t mipmaps; |
| 475 | int32_t num_steps; |
| 476 | float distance_fade; |
| 477 | float curve_fade_in; |
| 478 | float depth_tolerance; |
| 479 | int32_t orthogonal; |
| 480 | uint32_t view_index; |
| 481 | int32_t pad[3]; |
| 482 | }; |
| 483 | |
| 484 | struct ScreenSpaceReflectionFilterPushConstant { |
| 485 | int32_t screen_size[2]; |
| 486 | uint32_t mip_level; |
| 487 | int32_t pad; |
| 488 | }; |
| 489 | |
| 490 | struct ScreenSpaceReflectionResolvePushConstant { |
| 491 | int32_t screen_size[2]; |
| 492 | int32_t pad[2]; |
| 493 | }; |
| 494 | |
| 495 | struct ScreenSpaceReflection { |
| 496 | ScreenSpaceReflectionDownsampleShaderRD downsample_shader; |
| 497 | RID downsample_shader_version; |
| 498 | PipelineDeferredRD downsample_pipelines[SCREEN_SPACE_REFLECTION_DOWNSAMPLE_MAX]; |
| 499 | |
| 500 | ScreenSpaceReflectionHizShaderRD hiz_shader; |
| 501 | RID hiz_shader_version; |
| 502 | PipelineDeferredRD hiz_pipelines[SCREEN_SPACE_REFLECTION_HIZ_MAX]; |
| 503 | |
| 504 | ScreenSpaceReflectionShaderRD ssr_shader; |
| 505 | RID ssr_shader_version; |
| 506 | PipelineDeferredRD ssr_pipeline; |
| 507 | RID ubo; |
| 508 | |
| 509 | ScreenSpaceReflectionFilterShaderRD filter_shader; |
| 510 | RID filter_shader_version; |
| 511 | PipelineDeferredRD filter_pipeline; |
| 512 | |
| 513 | ScreenSpaceReflectionResolveShaderRD resolve_shader; |
| 514 | RID resolve_shader_version; |
| 515 | PipelineDeferredRD resolve_pipeline; |
| 516 | } ssr; |
| 517 | |
| 518 | /* Screen Space Shadows */ |
| 519 | |
| 520 | enum ScreenSpaceContactShadowsMode { |
| 521 | SCREEN_SPACE_CONTACT_SHADOWS_LOW_QUALITY, |
| 522 | SCREEN_SPACE_CONTACT_SHADOWS_MEDIUM_QUALITY, |
| 523 | SCREEN_SPACE_CONTACT_SHADOWS_HIGH_QUALITY, |
| 524 | SCREEN_SPACE_CONTACT_SHADOWS_MAX |
| 525 | }; |
| 526 | |
| 527 | struct ScreenSpaceContactShadows { |
| 528 | ScreenSpaceContactShadowsShaderRD sscs_shader; |
| 529 | RID sscs_shader_version; |
| 530 | PipelineDeferredRD sscs_pipelines[SCREEN_SPACE_CONTACT_SHADOWS_MAX]; |
| 531 | RID border_sampler; |
| 532 | |
| 533 | } sscs; |
| 534 | |
| 535 | struct ScreenSpaceContactShadowsPushConstant { |
| 536 | int32_t screen_size[2]; |
| 537 | int32_t light_offset[2]; |
| 538 | float light_coordinates[4]; |
| 539 | float surface_thickness; |
| 540 | float blur; |
| 541 | float taa_frame_count; |
| 542 | }; |
| 543 | |
| 544 | /* Subsurface scattering */ |
| 545 | |
| 546 | enum SSSMode { |
| 547 | SUBSURFACE_SCATTERING_MODE_LOW_QUALITY, |
| 548 | SUBSURFACE_SCATTERING_MODE_MEDIUM_QUALITY, |
| 549 | SUBSURFACE_SCATTERING_MODE_HIGH_QUALITY, |
| 550 | SUBSURFACE_SCATTERING_MODE_MAX |
| 551 | }; |
| 552 | |
| 553 | struct SubSurfaceScatteringPushConstant { |
| 554 | int32_t screen_size[2]; |
| 555 | float camera_z_far; |
| 556 | float camera_z_near; |
| 557 | |
| 558 | uint32_t vertical; |
| 559 | uint32_t orthogonal; |
| 560 | float unit_size; |
| 561 | float scale; |
| 562 | |
| 563 | float depth_scale; |
| 564 | uint32_t pad[3]; |
| 565 | }; |
| 566 | |
| 567 | struct SubSurfaceScattering { |
| 568 | SubSurfaceScatteringPushConstant push_constant; |
| 569 | SubsurfaceScatteringShaderRD shader; |
| 570 | RID shader_version; |
| 571 | PipelineDeferredRD pipelines[SUBSURFACE_SCATTERING_MODE_MAX]; |
| 572 | } sss; |
| 573 | }; |
| 574 | |
| 575 | } // namespace RendererRD |