1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
|
/*************************************************************************/
/* effects_rd.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef EFFECTS_RD_H
#define EFFECTS_RD_H
#include "core/math/camera_matrix.h"
#include "servers/rendering/renderer_rd/pipeline_cache_rd.h"
#include "servers/rendering/renderer_rd/shaders/cube_to_dp.glsl.gen.h"
#include "servers/rendering/renderer_rd/shaders/cubemap_downsampler.glsl.gen.h"
#include "servers/rendering/renderer_rd/shaders/cubemap_downsampler_raster.glsl.gen.h"
#include "servers/rendering/renderer_rd/shaders/cubemap_filter.glsl.gen.h"
#include "servers/rendering/renderer_rd/shaders/cubemap_filter_raster.glsl.gen.h"
#include "servers/rendering/renderer_rd/shaders/cubemap_roughness.glsl.gen.h"
#include "servers/rendering/renderer_rd/shaders/cubemap_roughness_raster.glsl.gen.h"
#include "servers/rendering/renderer_rd/shaders/fsr_upscale.glsl.gen.h"
#include "servers/rendering/renderer_rd/shaders/luminance_reduce.glsl.gen.h"
#include "servers/rendering/renderer_rd/shaders/luminance_reduce_raster.glsl.gen.h"
#include "servers/rendering/renderer_rd/shaders/resolve.glsl.gen.h"
#include "servers/rendering/renderer_rd/shaders/roughness_limiter.glsl.gen.h"
#include "servers/rendering/renderer_rd/shaders/screen_space_reflection.glsl.gen.h"
#include "servers/rendering/renderer_rd/shaders/screen_space_reflection_filter.glsl.gen.h"
#include "servers/rendering/renderer_rd/shaders/screen_space_reflection_scale.glsl.gen.h"
#include "servers/rendering/renderer_rd/shaders/sort.glsl.gen.h"
#include "servers/rendering/renderer_rd/shaders/specular_merge.glsl.gen.h"
#include "servers/rendering/renderer_rd/shaders/ss_effects_downsample.glsl.gen.h"
#include "servers/rendering/renderer_rd/shaders/ssao.glsl.gen.h"
#include "servers/rendering/renderer_rd/shaders/ssao_blur.glsl.gen.h"
#include "servers/rendering/renderer_rd/shaders/ssao_importance_map.glsl.gen.h"
#include "servers/rendering/renderer_rd/shaders/ssao_interleave.glsl.gen.h"
#include "servers/rendering/renderer_rd/shaders/ssil.glsl.gen.h"
#include "servers/rendering/renderer_rd/shaders/ssil_blur.glsl.gen.h"
#include "servers/rendering/renderer_rd/shaders/ssil_importance_map.glsl.gen.h"
#include "servers/rendering/renderer_rd/shaders/ssil_interleave.glsl.gen.h"
#include "servers/rendering/renderer_rd/shaders/subsurface_scattering.glsl.gen.h"
#include "servers/rendering/renderer_rd/shaders/taa_resolve.glsl.gen.h"
#include "servers/rendering/renderer_scene_render.h"
#include "servers/rendering_server.h"
class EffectsRD {
private:
bool prefer_raster_effects;
enum FSRUpscalePass {
FSR_UPSCALE_PASS_EASU = 0,
FSR_UPSCALE_PASS_RCAS = 1
};
struct FSRUpscalePushConstant {
float resolution_width;
float resolution_height;
float upscaled_width;
float upscaled_height;
float sharpness;
int pass;
int _unused0, _unused1;
};
struct FSRUpscale {
FSRUpscalePushConstant push_constant;
FsrUpscaleShaderRD shader;
RID shader_version;
RID pipeline;
} FSR_upscale;
struct TAAResolvePushConstant {
float resolution_width;
float resolution_height;
float disocclusion_threshold;
float disocclusion_scale;
};
struct TAAResolve {
TAAResolvePushConstant push_constant;
TaaResolveShaderRD shader;
RID shader_version;
RID pipeline;
} TAA_resolve;
struct CubemapRoughnessPushConstant {
uint32_t face_id;
uint32_t sample_count;
float roughness;
uint32_t use_direct_write;
float face_size;
float pad[3];
};
struct CubemapRoughness {
CubemapRoughnessPushConstant push_constant;
CubemapRoughnessShaderRD compute_shader;
CubemapRoughnessRasterShaderRD raster_shader;
RID shader_version;
RID compute_pipeline;
PipelineCacheRD raster_pipeline;
} roughness;
enum LuminanceReduceMode {
LUMINANCE_REDUCE_READ,
LUMINANCE_REDUCE,
LUMINANCE_REDUCE_WRITE,
LUMINANCE_REDUCE_MAX
};
struct LuminanceReducePushConstant {
int32_t source_size[2];
float max_luminance;
float min_luminance;
float exposure_adjust;
float pad[3];
};
struct LuminanceReduce {
LuminanceReducePushConstant push_constant;
LuminanceReduceShaderRD shader;
RID shader_version;
RID pipelines[LUMINANCE_REDUCE_MAX];
} luminance_reduce;
enum LuminanceReduceRasterMode {
LUMINANCE_REDUCE_FRAGMENT_FIRST,
LUMINANCE_REDUCE_FRAGMENT,
LUMINANCE_REDUCE_FRAGMENT_FINAL,
LUMINANCE_REDUCE_FRAGMENT_MAX
};
struct LuminanceReduceRasterPushConstant {
int32_t source_size[2];
int32_t dest_size[2];
float exposure_adjust;
float min_luminance;
float max_luminance;
uint32_t pad1;
};
struct LuminanceReduceFragment {
LuminanceReduceRasterPushConstant push_constant;
LuminanceReduceRasterShaderRD shader;
RID shader_version;
PipelineCacheRD pipelines[LUMINANCE_REDUCE_FRAGMENT_MAX];
} luminance_reduce_raster;
struct CopyToDPPushConstant {
float z_far;
float z_near;
float texel_size[2];
float screen_rect[4];
};
struct CoptToDP {
CubeToDpShaderRD shader;
RID shader_version;
PipelineCacheRD pipeline;
} cube_to_dp;
struct SSEffectsDownsamplePushConstant {
float pixel_size[2];
float z_far;
float z_near;
uint32_t orthogonal;
float radius_sq;
uint32_t pad[2];
};
enum SSEffectsMode {
SS_EFFECTS_DOWNSAMPLE,
SS_EFFECTS_DOWNSAMPLE_HALF_RES,
SS_EFFECTS_DOWNSAMPLE_MIPMAP,
SS_EFFECTS_DOWNSAMPLE_MIPMAP_HALF_RES,
SS_EFFECTS_DOWNSAMPLE_HALF,
SS_EFFECTS_DOWNSAMPLE_HALF_RES_HALF,
SS_EFFECTS_DOWNSAMPLE_FULL_MIPS,
SS_EFFECTS_MAX
};
struct SSEffectsGatherConstants {
float rotation_matrices[80]; //5 vec4s * 4
};
struct SSEffects {
SSEffectsDownsamplePushConstant downsample_push_constant;
SsEffectsDownsampleShaderRD downsample_shader;
RID downsample_shader_version;
RID downsample_uniform_set;
bool used_half_size_last_frame = false;
bool used_mips_last_frame = false;
bool used_full_mips_last_frame = false;
RID gather_constants_buffer;
RID mirror_sampler;
RID pipelines[SS_EFFECTS_MAX];
} ss_effects;
enum SSAOMode {
SSAO_GATHER,
SSAO_GATHER_BASE,
SSAO_GATHER_ADAPTIVE,
SSAO_GENERATE_IMPORTANCE_MAP,
SSAO_PROCESS_IMPORTANCE_MAPA,
SSAO_PROCESS_IMPORTANCE_MAPB,
SSAO_BLUR_PASS,
SSAO_BLUR_PASS_SMART,
SSAO_BLUR_PASS_WIDE,
SSAO_INTERLEAVE,
SSAO_INTERLEAVE_SMART,
SSAO_INTERLEAVE_HALF,
SSAO_MAX
};
struct SSAOGatherPushConstant {
int32_t screen_size[2];
int pass;
int quality;
float half_screen_pixel_size[2];
int size_multiplier;
float detail_intensity;
float NDC_to_view_mul[2];
float NDC_to_view_add[2];
float pad[2];
float half_screen_pixel_size_x025[2];
float radius;
float intensity;
float shadow_power;
float shadow_clamp;
float fade_out_mul;
float fade_out_add;
float horizon_angle_threshold;
float inv_radius_near_limit;
uint32_t is_orthogonal;
float neg_inv_radius;
float load_counter_avg_div;
float adaptive_sample_limit;
int32_t pass_coord_offset[2];
float pass_uv_offset[2];
};
struct SSAOImportanceMapPushConstant {
float half_screen_pixel_size[2];
float intensity;
float power;
};
struct SSAOBlurPushConstant {
float edge_sharpness;
float pad;
float half_screen_pixel_size[2];
};
struct SSAOInterleavePushConstant {
float inv_sharpness;
uint32_t size_modifier;
float pixel_size[2];
};
struct SSAO {
SSAOGatherPushConstant gather_push_constant;
SsaoShaderRD gather_shader;
RID gather_shader_version;
SSAOImportanceMapPushConstant importance_map_push_constant;
SsaoImportanceMapShaderRD importance_map_shader;
RID importance_map_shader_version;
RID importance_map_load_counter;
RID counter_uniform_set;
SSAOBlurPushConstant blur_push_constant;
SsaoBlurShaderRD blur_shader;
RID blur_shader_version;
SSAOInterleavePushConstant interleave_push_constant;
SsaoInterleaveShaderRD interleave_shader;
RID interleave_shader_version;
RID pipelines[SSAO_MAX];
} ssao;
enum SSILMode {
SSIL_GATHER,
SSIL_GATHER_BASE,
SSIL_GATHER_ADAPTIVE,
SSIL_GENERATE_IMPORTANCE_MAP,
SSIL_PROCESS_IMPORTANCE_MAPA,
SSIL_PROCESS_IMPORTANCE_MAPB,
SSIL_BLUR_PASS,
SSIL_BLUR_PASS_SMART,
SSIL_BLUR_PASS_WIDE,
SSIL_INTERLEAVE,
SSIL_INTERLEAVE_SMART,
SSIL_INTERLEAVE_HALF,
SSIL_MAX
};
struct SSILGatherPushConstant {
int32_t screen_size[2];
int pass;
int quality;
float half_screen_pixel_size[2];
float half_screen_pixel_size_x025[2];
float NDC_to_view_mul[2];
float NDC_to_view_add[2];
float pad2[2];
float z_near;
float z_far;
float radius;
float intensity;
int size_multiplier;
int pad;
float fade_out_mul;
float fade_out_add;
float normal_rejection_amount;
float inv_radius_near_limit;
uint32_t is_orthogonal;
float neg_inv_radius;
float load_counter_avg_div;
float adaptive_sample_limit;
int32_t pass_coord_offset[2];
float pass_uv_offset[2];
};
struct SSILImportanceMapPushConstant {
float half_screen_pixel_size[2];
float intensity;
float pad;
};
struct SSILBlurPushConstant {
float edge_sharpness;
float pad;
float half_screen_pixel_size[2];
};
struct SSILInterleavePushConstant {
float inv_sharpness;
uint32_t size_modifier;
float pixel_size[2];
};
struct SSILProjectionUniforms {
float inv_last_frame_projection_matrix[16];
};
struct SSIL {
SSILGatherPushConstant gather_push_constant;
SsilShaderRD gather_shader;
RID gather_shader_version;
RID projection_uniform_buffer;
SSILImportanceMapPushConstant importance_map_push_constant;
SsilImportanceMapShaderRD importance_map_shader;
RID importance_map_shader_version;
RID importance_map_load_counter;
RID counter_uniform_set;
SSILBlurPushConstant blur_push_constant;
SsilBlurShaderRD blur_shader;
RID blur_shader_version;
SSILInterleavePushConstant interleave_push_constant;
SsilInterleaveShaderRD interleave_shader;
RID interleave_shader_version;
RID pipelines[SSIL_MAX];
} ssil;
struct RoughnessLimiterPushConstant {
int32_t screen_size[2];
float curve;
uint32_t pad;
};
struct RoughnessLimiter {
RoughnessLimiterPushConstant push_constant;
RoughnessLimiterShaderRD shader;
RID shader_version;
RID pipeline;
} roughness_limiter;
struct CubemapDownsamplerPushConstant {
uint32_t face_size;
uint32_t face_id;
float pad[2];
};
struct CubemapDownsampler {
CubemapDownsamplerPushConstant push_constant;
CubemapDownsamplerShaderRD compute_shader;
CubemapDownsamplerRasterShaderRD raster_shader;
RID shader_version;
RID compute_pipeline;
PipelineCacheRD raster_pipeline;
} cubemap_downsampler;
enum CubemapFilterMode {
FILTER_MODE_HIGH_QUALITY,
FILTER_MODE_LOW_QUALITY,
FILTER_MODE_HIGH_QUALITY_ARRAY,
FILTER_MODE_LOW_QUALITY_ARRAY,
FILTER_MODE_MAX,
};
struct CubemapFilterRasterPushConstant {
uint32_t mip_level;
uint32_t face_id;
float pad[2];
};
struct CubemapFilter {
CubemapFilterShaderRD compute_shader;
CubemapFilterRasterShaderRD raster_shader;
RID shader_version;
RID compute_pipelines[FILTER_MODE_MAX];
PipelineCacheRD raster_pipelines[FILTER_MODE_MAX];
RID uniform_set;
RID image_uniform_set;
RID coefficient_buffer;
bool use_high_quality;
} filter;
enum SpecularMergeMode {
SPECULAR_MERGE_ADD,
SPECULAR_MERGE_SSR,
SPECULAR_MERGE_ADDITIVE_ADD,
SPECULAR_MERGE_ADDITIVE_SSR,
SPECULAR_MERGE_MAX
};
/* Specular merge must be done using raster, rather than compute
* because it must continue the existing color buffer
*/
struct SpecularMerge {
SpecularMergeShaderRD shader;
RID shader_version;
PipelineCacheRD pipelines[SPECULAR_MERGE_MAX];
} specular_merge;
enum ScreenSpaceReflectionMode {
SCREEN_SPACE_REFLECTION_NORMAL,
SCREEN_SPACE_REFLECTION_ROUGH,
SCREEN_SPACE_REFLECTION_MAX,
};
struct ScreenSpaceReflectionPushConstant {
float proj_info[4];
int32_t screen_size[2];
float camera_z_near;
float camera_z_far;
int32_t num_steps;
float depth_tolerance;
float distance_fade;
float curve_fade_in;
uint32_t orthogonal;
float filter_mipmap_levels;
uint32_t use_half_res;
uint8_t metallic_mask[4];
float projection[16];
};
struct ScreenSpaceReflection {
ScreenSpaceReflectionPushConstant push_constant;
ScreenSpaceReflectionShaderRD shader;
RID shader_version;
RID pipelines[SCREEN_SPACE_REFLECTION_MAX];
} ssr;
struct ScreenSpaceReflectionFilterPushConstant {
float proj_info[4];
uint32_t orthogonal;
float edge_tolerance;
int32_t increment;
uint32_t pad;
int32_t screen_size[2];
uint32_t vertical;
uint32_t steps;
};
enum {
SCREEN_SPACE_REFLECTION_FILTER_HORIZONTAL,
SCREEN_SPACE_REFLECTION_FILTER_VERTICAL,
SCREEN_SPACE_REFLECTION_FILTER_MAX,
};
struct ScreenSpaceReflectionFilter {
ScreenSpaceReflectionFilterPushConstant push_constant;
ScreenSpaceReflectionFilterShaderRD shader;
RID shader_version;
RID pipelines[SCREEN_SPACE_REFLECTION_FILTER_MAX];
} ssr_filter;
struct ScreenSpaceReflectionScalePushConstant {
int32_t screen_size[2];
float camera_z_near;
float camera_z_far;
uint32_t orthogonal;
uint32_t filter;
uint32_t pad[2];
};
struct ScreenSpaceReflectionScale {
ScreenSpaceReflectionScalePushConstant push_constant;
ScreenSpaceReflectionScaleShaderRD shader;
RID shader_version;
RID pipeline;
} ssr_scale;
struct SubSurfaceScatteringPushConstant {
int32_t screen_size[2];
float camera_z_far;
float camera_z_near;
uint32_t vertical;
uint32_t orthogonal;
float unit_size;
float scale;
float depth_scale;
uint32_t pad[3];
};
struct SubSurfaceScattering {
SubSurfaceScatteringPushConstant push_constant;
SubsurfaceScatteringShaderRD shader;
RID shader_version;
RID pipelines[3]; //3 quality levels
} sss;
struct ResolvePushConstant {
int32_t screen_size[2];
int32_t samples;
uint32_t pad;
};
enum ResolveMode {
RESOLVE_MODE_GI,
RESOLVE_MODE_GI_VOXEL_GI,
RESOLVE_MODE_DEPTH,
RESOLVE_MODE_MAX
};
struct Resolve {
ResolvePushConstant push_constant;
ResolveShaderRD shader;
RID shader_version;
RID pipelines[RESOLVE_MODE_MAX]; //3 quality levels
} resolve;
enum SortMode {
SORT_MODE_BLOCK,
SORT_MODE_STEP,
SORT_MODE_INNER,
SORT_MODE_MAX
};
struct Sort {
struct PushConstant {
uint32_t total_elements;
uint32_t pad[3];
int32_t job_params[4];
};
SortShaderRD shader;
RID shader_version;
RID pipelines[SORT_MODE_MAX];
} sort;
RID default_sampler;
RID default_mipmap_sampler;
RID index_buffer;
RID index_array;
HashMap<RID, RID> texture_to_uniform_set_cache;
HashMap<RID, RID> input_to_uniform_set_cache;
HashMap<RID, RID> image_to_uniform_set_cache;
struct TexturePair {
RID texture1;
RID texture2;
_FORCE_INLINE_ bool operator<(const TexturePair &p_pair) const {
if (texture1 == p_pair.texture1) {
return texture2 < p_pair.texture2;
} else {
return texture1 < p_pair.texture1;
}
}
};
struct TextureSamplerPair {
RID texture;
RID sampler;
_FORCE_INLINE_ bool operator<(const TextureSamplerPair &p_pair) const {
if (texture == p_pair.texture) {
return sampler < p_pair.sampler;
} else {
return texture < p_pair.texture;
}
}
};
RBMap<TexturePair, RID> texture_pair_to_uniform_set_cache;
RBMap<RID, RID> texture_to_compute_uniform_set_cache;
RBMap<TexturePair, RID> texture_pair_to_compute_uniform_set_cache;
RBMap<TexturePair, RID> image_pair_to_compute_uniform_set_cache;
RBMap<TextureSamplerPair, RID> texture_sampler_to_compute_uniform_set_cache;
RID _get_uniform_set_from_image(RID p_texture);
RID _get_uniform_set_from_texture(RID p_texture, bool p_use_mipmaps = false);
RID _get_compute_uniform_set_from_texture(RID p_texture, bool p_use_mipmaps = false);
RID _get_compute_uniform_set_from_texture_and_sampler(RID p_texture, RID p_sampler);
RID _get_compute_uniform_set_from_texture_pair(RID p_texture, RID p_texture2, bool p_use_mipmaps = false);
RID _get_compute_uniform_set_from_image_pair(RID p_texture, RID p_texture2);
public:
bool get_prefer_raster_effects();
void fsr_upscale(RID p_source_rd_texture, RID p_secondary_texture, RID p_destination_texture, const Size2i &p_internal_size, const Size2i &p_size, float p_fsr_upscale_sharpness);
void taa_resolve(RID p_frame, RID p_temp, RID p_depth, RID p_velocity, RID p_prev_velocity, RID p_history, Size2 p_resolution, float p_z_near, float p_z_far);
void cubemap_roughness(RID p_source_rd_texture, RID p_dest_texture, uint32_t p_face_id, uint32_t p_sample_count, float p_roughness, float p_size);
void cubemap_roughness_raster(RID p_source_rd_texture, RID p_dest_framebuffer, uint32_t p_face_id, uint32_t p_sample_count, float p_roughness, float p_size);
void copy_cubemap_to_dp(RID p_source_rd_texture, RID p_dst_framebuffer, const Rect2 &p_rect, const Vector2 &p_dst_size, float p_z_near, float p_z_far, bool p_dp_flip);
void luminance_reduction(RID p_source_texture, const Size2i p_source_size, const Vector<RID> p_reduce, RID p_prev_luminance, float p_min_luminance, float p_max_luminance, float p_adjust, bool p_set = false);
void luminance_reduction_raster(RID p_source_texture, const Size2i p_source_size, const Vector<RID> p_reduce, Vector<RID> p_fb, RID p_prev_luminance, float p_min_luminance, float p_max_luminance, float p_adjust, bool p_set = false);
struct SSAOSettings {
float radius = 1.0;
float intensity = 2.0;
float power = 1.5;
float detail = 0.5;
float horizon = 0.06;
float sharpness = 0.98;
RS::EnvironmentSSAOQuality quality = RS::ENV_SSAO_QUALITY_MEDIUM;
bool half_size = false;
float adaptive_target = 0.5;
int blur_passes = 2;
float fadeout_from = 50.0;
float fadeout_to = 300.0;
Size2i full_screen_size = Size2i();
Size2i half_screen_size = Size2i();
Size2i quarter_screen_size = Size2i();
};
struct SSILSettings {
float radius = 1.0;
float intensity = 2.0;
float sharpness = 0.98;
float normal_rejection = 1.0;
RS::EnvironmentSSILQuality quality = RS::ENV_SSIL_QUALITY_MEDIUM;
bool half_size = true;
float adaptive_target = 0.5;
int blur_passes = 4;
float fadeout_from = 50.0;
float fadeout_to = 300.0;
Size2i full_screen_size = Size2i();
Size2i half_screen_size = Size2i();
Size2i quarter_screen_size = Size2i();
};
void downsample_depth(RID p_depth_buffer, const Vector<RID> &p_depth_mipmaps, RS::EnvironmentSSAOQuality p_ssao_quality, RS::EnvironmentSSILQuality p_ssil_quality, bool p_invalidate_uniform_set, bool p_ssao_half_size, bool p_ssil_half_size, Size2i p_full_screen_size, const CameraMatrix &p_projection);
void gather_ssao(RD::ComputeListID p_compute_list, const Vector<RID> p_ao_slices, const SSAOSettings &p_settings, bool p_adaptive_base_pass, RID p_gather_uniform_set, RID p_importance_map_uniform_set);
void generate_ssao(RID p_normal_buffer, RID p_depth_mipmaps_texture, RID p_ao, const Vector<RID> p_ao_slices, RID p_ao_pong, const Vector<RID> p_ao_pong_slices, RID p_upscale_buffer, RID p_importance_map, RID p_importance_map_pong, const CameraMatrix &p_projection, const SSAOSettings &p_settings, bool p_invalidate_uniform_sets, RID &r_gather_uniform_set, RID &r_importance_map_uniform_set);
void gather_ssil(RD::ComputeListID p_compute_list, const Vector<RID> p_ssil_slices, const Vector<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);
void screen_space_indirect_lighting(RID p_diffuse, RID p_destination, RID p_normal_buffer, RID p_depth_mipmaps_texture, RID p_ao, const Vector<RID> p_ao_slices, RID p_ao_pong, const Vector<RID> p_ao_pong_slices, RID p_importance_map, RID p_importance_map_pong, RID p_edges, const Vector<RID> p_edges_slices, const CameraMatrix &p_projection, const CameraMatrix &p_last_projection, const SSILSettings &p_settings, bool p_invalidate_uniform_sets, RID &r_gather_uniform_set, RID &r_importance_map_uniform_set, RID &r_projection_uniform_set);
void roughness_limit(RID p_source_normal, RID p_roughness, const Size2i &p_size, float p_curve);
void cubemap_downsample(RID p_source_cubemap, RID p_dest_cubemap, const Size2i &p_size);
void cubemap_downsample_raster(RID p_source_cubemap, RID p_dest_framebuffer, uint32_t p_face_id, const Size2i &p_size);
void cubemap_filter(RID p_source_cubemap, Vector<RID> p_dest_cubemap, bool p_use_array);
void cubemap_filter_raster(RID p_source_cubemap, RID p_dest_framebuffer, uint32_t p_face_id, uint32_t p_mip_level);
void screen_space_reflection(RID p_diffuse, RID p_normal_roughness, RS::EnvironmentSSRRoughnessQuality p_roughness_quality, RID p_blur_radius, RID p_blur_radius2, RID p_metallic, const Color &p_metallic_mask, RID p_depth, RID p_scale_depth, RID p_scale_normal, RID p_output, RID p_output_blur, const Size2i &p_screen_size, int p_max_steps, float p_fade_in, float p_fade_out, float p_tolerance, const CameraMatrix &p_camera);
void merge_specular(RID p_dest_framebuffer, RID p_specular, RID p_base, RID p_reflection);
void sub_surface_scattering(RID p_diffuse, RID p_diffuse2, RID p_depth, const CameraMatrix &p_camera, const Size2i &p_screen_size, float p_scale, float p_depth_scale, RS::SubSurfaceScatteringQuality p_quality);
void resolve_gi(RID p_source_depth, RID p_source_normal_roughness, RID p_source_voxel_gi, RID p_dest_depth, RID p_dest_normal_roughness, RID p_dest_voxel_gi, Vector2i p_screen_size, int p_samples, uint32_t p_barrier = RD::BARRIER_MASK_ALL);
void resolve_depth(RID p_source_depth, RID p_dest_depth, Vector2i p_screen_size, int p_samples, uint32_t p_barrier = RD::BARRIER_MASK_ALL);
void sort_buffer(RID p_uniform_set, int p_size);
EffectsRD(bool p_prefer_raster_effects);
~EffectsRD();
};
#endif // !RASTERIZER_EFFECTS_RD_H
|