| 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 |
#pragma once |
| 32 |
|
| 33 |
#include "core/templates/paged_allocator.h" |
| 34 |
#include "servers/rendering/multi_uma_buffer.h" |
| 35 |
#include "servers/rendering/renderer_rd/cluster_builder_rd.h" |
| 36 |
#include "servers/rendering/renderer_rd/effects/fsr2.h" |
| 37 |
#ifdef METAL_ENABLED |
| 38 |
#include "servers/rendering/renderer_rd/effects/metal_fx.h" |
| 39 |
#endif |
| 40 |
#include "servers/rendering/renderer_rd/effects/motion_vectors_store.h" |
| 41 |
#include "servers/rendering/renderer_rd/effects/ss_effects.h" |
| 42 |
#include "servers/rendering/renderer_rd/effects/taa.h" |
| 43 |
#include "servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.h" |
| 44 |
#include "servers/rendering/renderer_rd/renderer_scene_render_rd.h" |
| 45 |
#include "servers/rendering/renderer_rd/shaders/forward_clustered/best_fit_normal.glsl.gen.h" |
| 46 |
#include "servers/rendering/renderer_rd/shaders/forward_clustered/integrate_dfg.glsl.gen.h" |
| 47 |
|
| 48 |
#define RB_SCOPE_FORWARD_CLUSTERED SNAME("forward_clustered") |
| 49 |
|
| 50 |
#define RB_TEX_SPECULAR SNAME("specular") |
| 51 |
#define RB_TEX_SPECULAR_MSAA SNAME("specular_msaa") |
| 52 |
#define RB_TEX_NORMAL_ROUGHNESS SNAME("normal_roughness") |
| 53 |
#define RB_TEX_NORMAL_ROUGHNESS_MSAA SNAME("normal_roughness_msaa") |
| 54 |
#define RB_TEX_VOXEL_GI SNAME("voxel_gi") |
| 55 |
#define RB_TEX_VOXEL_GI_MSAA SNAME("voxel_gi_msaa") |
| 56 |
|
| 57 |
namespace RendererSceneRenderImplementation { |
| 58 |
|
| 59 |
class RenderForwardClustered : public RendererSceneRenderRD { |
| 60 |
friend SceneShaderForwardClustered; |
| 61 |
|
| 62 |
enum { |
| 63 |
SCENE_UNIFORM_SET = 0, |
| 64 |
RENDER_PASS_UNIFORM_SET = 1, |
| 65 |
TRANSFORMS_UNIFORM_SET = 2, |
| 66 |
MATERIAL_UNIFORM_SET = 3, |
| 67 |
}; |
| 68 |
|
| 69 |
enum { |
| 70 |
SDFGI_MAX_CASCADES = 8, |
| 71 |
MAX_VOXEL_GI_INSTANCESS = 8, |
| 72 |
MAX_LIGHTMAPS = 8, |
| 73 |
MAX_VOXEL_GI_INSTANCESS_PER_INSTANCE = 2, |
| 74 |
INSTANCE_DATA_BUFFER_MIN_SIZE = 4096 |
| 75 |
}; |
| 76 |
|
| 77 |
enum RenderListType { |
| 78 |
RENDER_LIST_OPAQUE, |
| 79 |
RENDER_LIST_MOTION, |
| 80 |
RENDER_LIST_ALPHA, |
| 81 |
RENDER_LIST_SECONDARY, |
| 82 |
RENDER_LIST_MAX |
| 83 |
}; |
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
SceneShaderForwardClustered scene_shader; |
| 88 |
|
| 89 |
public: |
| 90 |
|
| 91 |
|
| 92 |
class RenderBufferDataForwardClustered : public RenderBufferCustomDataRD { |
| 93 |
GDCLASS(RenderBufferDataForwardClustered, RenderBufferCustomDataRD) |
| 94 |
|
| 95 |
private: |
| 96 |
RenderSceneBuffersRD *render_buffers = nullptr; |
| 97 |
RendererRD::FSR2Context *fsr2_context = nullptr; |
| 98 |
#ifdef METAL_MFXTEMPORAL_ENABLED |
| 99 |
RendererRD::MFXTemporalContext *mfx_temporal_context = nullptr; |
| 100 |
#endif |
| 101 |
|
| 102 |
public: |
| 103 |
ClusterBuilderRD *cluster_builder = nullptr; |
| 104 |
|
| 105 |
struct SSEffectsData { |
| 106 |
Projection ssil_last_frame_projections[RendererSceneRender::MAX_RENDER_VIEWS]; |
| 107 |
Transform3D ssil_last_frame_transform; |
| 108 |
|
| 109 |
Projection ssr_last_frame_projections[RendererSceneRender::MAX_RENDER_VIEWS]; |
| 110 |
Transform3D ssr_last_frame_transform; |
| 111 |
|
| 112 |
RendererRD::SSEffects::SSILRenderBuffers ssil; |
| 113 |
RendererRD::SSEffects::SSAORenderBuffers ssao; |
| 114 |
RendererRD::SSEffects::SSRRenderBuffers ssr; |
| 115 |
} ss_effects_data; |
| 116 |
|
| 117 |
enum DepthFrameBufferType { |
| 118 |
DEPTH_FB, |
| 119 |
DEPTH_FB_ROUGHNESS, |
| 120 |
DEPTH_FB_ROUGHNESS_VOXELGI |
| 121 |
}; |
| 122 |
|
| 123 |
RID render_sdfgi_uniform_set; |
| 124 |
|
| 125 |
void ensure_specular(); |
| 126 |
bool has_specular() const { return render_buffers->has_texture(RB_SCOPE_FORWARD_CLUSTERED, RB_TEX_SPECULAR); } |
| 127 |
RID get_specular() const { return render_buffers->get_texture(RB_SCOPE_FORWARD_CLUSTERED, RB_TEX_SPECULAR); } |
| 128 |
RID get_specular(uint32_t p_layer) { return render_buffers->get_texture_slice(RB_SCOPE_FORWARD_CLUSTERED, RB_TEX_SPECULAR, p_layer, 0); } |
| 129 |
RID get_specular_msaa(uint32_t p_layer) { return render_buffers->get_texture_slice(RB_SCOPE_FORWARD_CLUSTERED, RB_TEX_SPECULAR_MSAA, p_layer, 0); } |
| 130 |
|
| 131 |
void ensure_normal_roughness_texture(); |
| 132 |
bool has_normal_roughness() const { return render_buffers->has_texture(RB_SCOPE_FORWARD_CLUSTERED, RB_TEX_NORMAL_ROUGHNESS); } |
| 133 |
RID get_normal_roughness() const { return render_buffers->get_texture(RB_SCOPE_FORWARD_CLUSTERED, RB_TEX_NORMAL_ROUGHNESS); } |
| 134 |
RID get_normal_roughness(uint32_t p_layer) { return render_buffers->get_texture_slice(RB_SCOPE_FORWARD_CLUSTERED, RB_TEX_NORMAL_ROUGHNESS, p_layer, 0); } |
| 135 |
RID get_normal_roughness_msaa() const { return render_buffers->get_texture(RB_SCOPE_FORWARD_CLUSTERED, RB_TEX_NORMAL_ROUGHNESS_MSAA); } |
| 136 |
RID get_normal_roughness_msaa(uint32_t p_layer) { return render_buffers->get_texture_slice(RB_SCOPE_FORWARD_CLUSTERED, RB_TEX_NORMAL_ROUGHNESS_MSAA, p_layer, 0); } |
| 137 |
|
| 138 |
void ensure_voxelgi(); |
| 139 |
bool has_voxelgi() const { return render_buffers->has_texture(RB_SCOPE_FORWARD_CLUSTERED, RB_TEX_VOXEL_GI); } |
| 140 |
RID get_voxelgi() const { return render_buffers->get_texture(RB_SCOPE_FORWARD_CLUSTERED, RB_TEX_VOXEL_GI); } |
| 141 |
RID get_voxelgi(uint32_t p_layer) { return render_buffers->get_texture_slice(RB_SCOPE_FORWARD_CLUSTERED, RB_TEX_VOXEL_GI, p_layer, 0); } |
| 142 |
RID get_voxelgi_msaa(uint32_t p_layer) { return render_buffers->get_texture_slice(RB_SCOPE_FORWARD_CLUSTERED, RB_TEX_VOXEL_GI_MSAA, p_layer, 0); } |
| 143 |
|
| 144 |
void ensure_fsr2(RendererRD::FSR2Effect *p_effect); |
| 145 |
RendererRD::FSR2Context *get_fsr2_context() const { return fsr2_context; } |
| 146 |
|
| 147 |
#ifdef METAL_MFXTEMPORAL_ENABLED |
| 148 |
bool ensure_mfx_temporal(RendererRD::MFXTemporalEffect *p_effect); |
| 149 |
RendererRD::MFXTemporalContext *get_mfx_temporal_context() const { return mfx_temporal_context; } |
| 150 |
#endif |
| 151 |
|
| 152 |
RID get_color_only_fb(); |
| 153 |
RID get_color_pass_fb(uint32_t p_color_pass_flags); |
| 154 |
RID get_depth_fb(DepthFrameBufferType p_type = DEPTH_FB); |
| 155 |
RID get_specular_only_fb(); |
| 156 |
RID get_velocity_only_fb(); |
| 157 |
|
| 158 |
virtual void configure(RenderSceneBuffersRD *p_render_buffers) override; |
| 159 |
virtual void free_data() override; |
| 160 |
|
| 161 |
static RD::DataFormat get_specular_format(); |
| 162 |
static uint32_t get_specular_usage_bits(bool p_resolve, bool p_msaa, bool p_storage); |
| 163 |
static RD::DataFormat get_normal_roughness_format(); |
| 164 |
static uint32_t get_normal_roughness_usage_bits(bool p_resolve, bool p_msaa, bool p_storage); |
| 165 |
static RD::DataFormat get_voxelgi_format(); |
| 166 |
static uint32_t get_voxelgi_usage_bits(bool p_resolve, bool p_msaa, bool p_storage); |
| 167 |
}; |
| 168 |
|
| 169 |
private: |
| 170 |
virtual void setup_render_buffer_data(Ref<RenderSceneBuffersRD> p_render_buffers) override; |
| 171 |
|
| 172 |
RID render_base_uniform_set; |
| 173 |
|
| 174 |
uint64_t lightmap_texture_array_version = 0xFFFFFFFF; |
| 175 |
|
| 176 |
void _update_render_base_uniform_set(); |
| 177 |
RID _setup_sdfgi_render_pass_uniform_set(RID p_albedo_texture, RID p_emission_texture, RID p_emission_aniso_texture, RID p_geom_facing_texture, const RendererRD::MaterialStorage::Samplers &p_samplers); |
| 178 |
RID _setup_render_pass_uniform_set(RenderListType p_render_list, const RenderDataRD *p_render_data, RID p_radiance_texture, const RendererRD::MaterialStorage::Samplers &p_samplers, bool p_use_directional_shadow_atlas = false, int p_index = 0); |
| 179 |
|
| 180 |
struct BestFitNormal { |
| 181 |
BestFitNormalShaderRD shader; |
| 182 |
RID shader_version; |
| 183 |
RID pipeline; |
| 184 |
RID texture; |
| 185 |
} best_fit_normal; |
| 186 |
|
| 187 |
struct IntegrateDFG { |
| 188 |
IntegrateDfgShaderRD shader; |
| 189 |
RID shader_version; |
| 190 |
RID pipeline; |
| 191 |
RID texture; |
| 192 |
} dfg_lut; |
| 193 |
|
| 194 |
enum PassMode { |
| 195 |
PASS_MODE_COLOR, |
| 196 |
PASS_MODE_SHADOW, |
| 197 |
PASS_MODE_SHADOW_DP, |
| 198 |
PASS_MODE_DEPTH, |
| 199 |
PASS_MODE_DEPTH_NORMAL_ROUGHNESS, |
| 200 |
PASS_MODE_DEPTH_NORMAL_ROUGHNESS_VOXEL_GI, |
| 201 |
PASS_MODE_DEPTH_MATERIAL, |
| 202 |
PASS_MODE_SDF, |
| 203 |
PASS_MODE_MAX |
| 204 |
}; |
| 205 |
|
| 206 |
enum ColorPassFlags { |
| 207 |
COLOR_PASS_FLAG_TRANSPARENT = 1 << 0, |
| 208 |
COLOR_PASS_FLAG_SEPARATE_SPECULAR = 1 << 1, |
| 209 |
COLOR_PASS_FLAG_MULTIVIEW = 1 << 2, |
| 210 |
COLOR_PASS_FLAG_MOTION_VECTORS = 1 << 3, |
| 211 |
}; |
| 212 |
|
| 213 |
struct GeometryInstanceSurfaceDataCache; |
| 214 |
struct RenderElementInfo; |
| 215 |
|
| 216 |
struct RenderListParameters { |
| 217 |
GeometryInstanceSurfaceDataCache **elements = nullptr; |
| 218 |
RenderElementInfo *element_info = nullptr; |
| 219 |
int element_count = 0; |
| 220 |
bool reverse_cull = false; |
| 221 |
PassMode pass_mode = PASS_MODE_COLOR; |
| 222 |
uint32_t color_pass_flags = 0; |
| 223 |
bool no_gi = false; |
| 224 |
uint32_t view_count = 1; |
| 225 |
RID render_pass_uniform_set; |
| 226 |
bool force_wireframe = false; |
| 227 |
Vector2 uv_offset; |
| 228 |
float lod_distance_multiplier = 0.0; |
| 229 |
float screen_mesh_lod_threshold = 0.0; |
| 230 |
RD::FramebufferFormatID framebuffer_format = 0; |
| 231 |
uint32_t element_offset = 0; |
| 232 |
bool use_directional_soft_shadow = false; |
| 233 |
SceneShaderForwardClustered::ShaderSpecialization base_specialization = {}; |
| 234 |
|
| 235 |
RenderListParameters(GeometryInstanceSurfaceDataCache **p_elements, RenderElementInfo *p_element_info, int p_element_count, bool p_reverse_cull, PassMode p_pass_mode, uint32_t p_color_pass_flags, bool p_no_gi, bool p_use_directional_soft_shadows, RID p_render_pass_uniform_set, bool p_force_wireframe = false, const Vector2 &p_uv_offset = Vector2(), float p_lod_distance_multiplier = 0.0, float p_screen_mesh_lod_threshold = 0.0, uint32_t p_view_count = 1, uint32_t p_element_offset = 0, SceneShaderForwardClustered::ShaderSpecialization p_base_specialization = {}) { |
| 236 |
elements = p_elements; |
| 237 |
element_info = p_element_info; |
| 238 |
element_count = p_element_count; |
| 239 |
reverse_cull = p_reverse_cull; |
| 240 |
pass_mode = p_pass_mode; |
| 241 |
color_pass_flags = p_color_pass_flags; |
| 242 |
no_gi = p_no_gi; |
| 243 |
view_count = p_view_count; |
| 244 |
render_pass_uniform_set = p_render_pass_uniform_set; |
| 245 |
force_wireframe = p_force_wireframe; |
| 246 |
uv_offset = p_uv_offset; |
| 247 |
lod_distance_multiplier = p_lod_distance_multiplier; |
| 248 |
screen_mesh_lod_threshold = p_screen_mesh_lod_threshold; |
| 249 |
element_offset = p_element_offset; |
| 250 |
use_directional_soft_shadow = p_use_directional_soft_shadows; |
| 251 |
base_specialization = p_base_specialization; |
| 252 |
} |
| 253 |
}; |
| 254 |
|
| 255 |
struct LightmapData { |
| 256 |
float normal_xform[12]; |
| 257 |
float texture_size[2]; |
| 258 |
float exposure_normalization; |
| 259 |
uint32_t flags; |
| 260 |
}; |
| 261 |
|
| 262 |
struct LightmapCaptureData { |
| 263 |
float sh[9 * 4]; |
| 264 |
}; |
| 265 |
|
| 266 |
|
| 267 |
enum { |
| 268 |
INSTANCE_DATA_FLAG_MULTIMESH_INDIRECT = 1 << 2, |
| 269 |
INSTANCE_DATA_FLAGS_DYNAMIC = 1 << 3, |
| 270 |
INSTANCE_DATA_FLAGS_NON_UNIFORM_SCALE = 1 << 4, |
| 271 |
INSTANCE_DATA_FLAG_USE_GI_BUFFERS = 1 << 5, |
| 272 |
INSTANCE_DATA_FLAG_USE_SDFGI = 1 << 6, |
| 273 |
INSTANCE_DATA_FLAG_USE_LIGHTMAP_CAPTURE = 1 << 7, |
| 274 |
INSTANCE_DATA_FLAG_USE_LIGHTMAP = 1 << 8, |
| 275 |
INSTANCE_DATA_FLAG_USE_SH_LIGHTMAP = 1 << 9, |
| 276 |
INSTANCE_DATA_FLAG_USE_VOXEL_GI = 1 << 10, |
| 277 |
INSTANCE_DATA_FLAG_PARTICLES = 1 << 11, |
| 278 |
INSTANCE_DATA_FLAG_MULTIMESH = 1 << 12, |
| 279 |
INSTANCE_DATA_FLAG_MULTIMESH_FORMAT_2D = 1 << 13, |
| 280 |
INSTANCE_DATA_FLAG_MULTIMESH_HAS_COLOR = 1 << 14, |
| 281 |
INSTANCE_DATA_FLAG_MULTIMESH_HAS_CUSTOM_DATA = 1 << 15, |
| 282 |
INSTANCE_DATA_FLAGS_PARTICLE_TRAIL_SHIFT = 16, |
| 283 |
INSTANCE_DATA_FLAGS_PARTICLE_TRAIL_MASK = 0xFF, |
| 284 |
INSTANCE_DATA_FLAGS_FADE_SHIFT = 24, |
| 285 |
INSTANCE_DATA_FLAGS_FADE_MASK = 0xFFUL << INSTANCE_DATA_FLAGS_FADE_SHIFT |
| 286 |
}; |
| 287 |
|
| 288 |
struct SceneState { |
| 289 |
|
| 290 |
struct UBO { |
| 291 |
uint32_t cluster_shift; |
| 292 |
uint32_t cluster_width; |
| 293 |
uint32_t cluster_type_size; |
| 294 |
uint32_t max_cluster_element_count_div_32; |
| 295 |
|
| 296 |
uint32_t ss_effects_flags; |
| 297 |
float ssao_light_affect; |
| 298 |
float ssao_ao_affect; |
| 299 |
uint32_t pad1; |
| 300 |
|
| 301 |
float sdf_to_bounds[16]; |
| 302 |
|
| 303 |
int32_t sdf_offset[3]; |
| 304 |
uint32_t pad2; |
| 305 |
|
| 306 |
int32_t sdf_size[3]; |
| 307 |
uint32_t gi_upscale_for_msaa; |
| 308 |
|
| 309 |
uint32_t volumetric_fog_enabled; |
| 310 |
float volumetric_fog_inv_length; |
| 311 |
float volumetric_fog_detail_spread; |
| 312 |
uint32_t volumetric_fog_pad; |
| 313 |
}; |
| 314 |
|
| 315 |
struct PushConstantUbershader { |
| 316 |
SceneShaderForwardClustered::ShaderSpecialization specialization; |
| 317 |
SceneShaderForwardClustered::UbershaderConstants constants; |
| 318 |
}; |
| 319 |
|
| 320 |
struct PushConstant { |
| 321 |
uint32_t base_index; |
| 322 |
uint32_t uv_offset; |
| 323 |
uint32_t multimesh_motion_vectors_current_offset; |
| 324 |
uint32_t multimesh_motion_vectors_previous_offset; |
| 325 |
PushConstantUbershader ubershader; |
| 326 |
}; |
| 327 |
|
| 328 |
struct InstanceData { |
| 329 |
float transform[12]; |
| 330 |
float compressed_aabb_position[4]; |
| 331 |
float compressed_aabb_size[4]; |
| 332 |
float uv_scale[4]; |
| 333 |
uint32_t flags; |
| 334 |
uint32_t instance_uniforms_ofs; |
| 335 |
uint32_t gi_offset; |
| 336 |
uint32_t layer_mask; |
| 337 |
float prev_transform[12]; |
| 338 |
float lightmap_uv_scale[4]; |
| 339 |
#ifdef REAL_T_IS_DOUBLE |
| 340 |
float model_precision[4]; |
| 341 |
float prev_model_precision[4]; |
| 342 |
#endif |
| 343 |
|
| 344 |
|
| 345 |
inline void set_lightmap_uv_scale(const Rect2 &p_rect) { |
| 346 |
#ifdef REAL_T_IS_DOUBLE |
| 347 |
lightmap_uv_scale[0] = p_rect.position.x; |
| 348 |
lightmap_uv_scale[1] = p_rect.position.y; |
| 349 |
lightmap_uv_scale[2] = p_rect.size.x; |
| 350 |
lightmap_uv_scale[3] = p_rect.size.y; |
| 351 |
#else |
| 352 |
Rect2 *rect = reinterpret_cast<Rect2 *>(lightmap_uv_scale); |
| 353 |
*rect = p_rect; |
| 354 |
#endif |
| 355 |
} |
| 356 |
|
| 357 |
inline void set_compressed_aabb(const AABB &p_aabb) { |
| 358 |
#ifdef REAL_T_IS_DOUBLE |
| 359 |
compressed_aabb_position[0] = p_aabb.position.x; |
| 360 |
compressed_aabb_position[1] = p_aabb.position.y; |
| 361 |
compressed_aabb_position[2] = p_aabb.position.z; |
| 362 |
|
| 363 |
compressed_aabb_size[0] = p_aabb.size.x; |
| 364 |
compressed_aabb_size[1] = p_aabb.size.y; |
| 365 |
compressed_aabb_size[2] = p_aabb.size.z; |
| 366 |
#else |
| 367 |
Vector3 *compressed_aabb_position_vec3 = reinterpret_cast<Vector3 *>(compressed_aabb_position); |
| 368 |
Vector3 *compressed_aabb_size_vec3 = reinterpret_cast<Vector3 *>(compressed_aabb_size); |
| 369 |
*compressed_aabb_position_vec3 = p_aabb.position; |
| 370 |
*compressed_aabb_size_vec3 = p_aabb.size; |
| 371 |
#endif |
| 372 |
} |
| 373 |
|
| 374 |
inline void set_uv_scale(const Vector4 &p_uv_scale) { |
| 375 |
#ifdef REAL_T_IS_DOUBLE |
| 376 |
uv_scale[0] = p_uv_scale.x; |
| 377 |
uv_scale[1] = p_uv_scale.y; |
| 378 |
uv_scale[2] = p_uv_scale.z; |
| 379 |
uv_scale[3] = p_uv_scale.w; |
| 380 |
#else |
| 381 |
Vector4 *uv_scale_vec4 = reinterpret_cast<Vector4 *>(uv_scale); |
| 382 |
*uv_scale_vec4 = p_uv_scale; |
| 383 |
#endif |
| 384 |
} |
| 385 |
}; |
| 386 |
|
| 387 |
static_assert(std::is_trivially_destructible_v<InstanceData>); |
| 388 |
static_assert(std::is_trivially_constructible_v<InstanceData>); |
| 389 |
|
| 390 |
UBO ubo; |
| 391 |
|
| 392 |
LocalVector<RID> uniform_buffers; |
| 393 |
LocalVector<RID> implementation_uniform_buffers; |
| 394 |
|
| 395 |
LightmapData lightmaps[MAX_LIGHTMAPS]; |
| 396 |
RID lightmap_ids[MAX_LIGHTMAPS]; |
| 397 |
bool lightmap_has_sh[MAX_LIGHTMAPS]; |
| 398 |
uint32_t lightmaps_used = 0; |
| 399 |
uint32_t max_lightmaps; |
| 400 |
RID lightmap_buffer; |
| 401 |
|
| 402 |
MultiUmaBuffer<1u> instance_buffer[RENDER_LIST_MAX] = { MultiUmaBuffer<1u>("RENDER_LIST_OPAQUE"), MultiUmaBuffer<1u>("RENDER_LIST_MOTION"), MultiUmaBuffer<1u>("RENDER_LIST_ALPHA"), MultiUmaBuffer<1u>("RENDER_LIST_SECONDARY") }; |
| 403 |
InstanceData *curr_gpu_ptr[RENDER_LIST_MAX] = {}; |
| 404 |
|
| 405 |
LightmapCaptureData *lightmap_captures = nullptr; |
| 406 |
uint32_t max_lightmap_captures; |
| 407 |
RID lightmap_capture_buffer; |
| 408 |
|
| 409 |
RID voxelgi_ids[MAX_VOXEL_GI_INSTANCESS]; |
| 410 |
uint32_t voxelgis_used = 0; |
| 411 |
|
| 412 |
bool used_screen_texture = false; |
| 413 |
bool used_normal_texture = false; |
| 414 |
bool used_depth_texture = false; |
| 415 |
bool used_sss = false; |
| 416 |
bool used_lightmap = false; |
| 417 |
bool used_opaque_stencil = false; |
| 418 |
|
| 419 |
struct ShadowPass { |
| 420 |
uint32_t element_from; |
| 421 |
uint32_t element_count; |
| 422 |
PassMode pass_mode; |
| 423 |
|
| 424 |
RID rp_uniform_set; |
| 425 |
float lod_distance_multiplier; |
| 426 |
float screen_mesh_lod_threshold; |
| 427 |
|
| 428 |
RID framebuffer; |
| 429 |
Rect2i rect; |
| 430 |
bool clear_depth; |
| 431 |
bool flip_cull; |
| 432 |
}; |
| 433 |
|
| 434 |
LocalVector<ShadowPass> shadow_passes; |
| 435 |
|
| 436 |
void grow_instance_buffer(RenderListType p_render_list, uint32_t p_req_element_count, bool p_append); |
| 437 |
} scene_state; |
| 438 |
|
| 439 |
static RenderForwardClustered *singleton; |
| 440 |
|
| 441 |
void _setup_environment(const RenderDataRD *p_render_data, bool p_no_fog, const Size2i &p_screen_size, const Size2 &p_viewport_size, const Color &p_default_bg_color, bool p_opaque_render_buffers = false, bool p_apply_alpha_multiplier = false, bool p_pancake_shadows = false, int p_index = 0); |
| 442 |
void _setup_voxelgis(const PagedArray<RID> &p_voxelgis); |
| 443 |
void _setup_lightmaps(const RenderDataRD *p_render_data, const PagedArray<RID> &p_lightmaps, const Transform3D &p_cam_transform); |
| 444 |
|
| 445 |
struct RenderElementInfo { |
| 446 |
enum { MAX_REPEATS = (1 << 20) - 1 }; |
| 447 |
union { |
| 448 |
struct { |
| 449 |
uint32_t lod_index : 8; |
| 450 |
uint32_t uses_softshadow : 1; |
| 451 |
uint32_t uses_projector : 1; |
| 452 |
uint32_t uses_forward_gi : 1; |
| 453 |
uint32_t uses_lightmap : 1; |
| 454 |
}; |
| 455 |
uint32_t value; |
| 456 |
}; |
| 457 |
uint32_t repeat; |
| 458 |
}; |
| 459 |
|
| 460 |
static_assert(std::is_trivially_destructible_v<RenderElementInfo>); |
| 461 |
static_assert(std::is_trivially_constructible_v<RenderElementInfo>); |
| 462 |
|
| 463 |
template <PassMode p_pass_mode, uint32_t p_color_pass_flags = 0> |
| 464 |
_FORCE_INLINE_ void _render_list_template(RenderingDevice::DrawListID p_draw_list, RenderingDevice::FramebufferFormatID p_framebuffer_Format, RenderListParameters *p_params, uint32_t p_from_element, uint32_t p_to_element); |
| 465 |
void _render_list(RenderingDevice::DrawListID p_draw_list, RenderingDevice::FramebufferFormatID p_framebuffer_Format, RenderListParameters *p_params, uint32_t p_from_element, uint32_t p_to_element); |
| 466 |
void _render_list_with_draw_list(RenderListParameters *p_params, RID p_framebuffer, BitField<RD::DrawFlags> p_draw_flags = RD::DRAW_DEFAULT_ALL, const Vector<Color> &p_clear_color_values = Vector<Color>(), float p_clear_depth_value = 0.0, uint32_t p_clear_stencil_value = 0, const Rect2 &p_region = Rect2()); |
| 467 |
|
| 468 |
void _fill_instance_data(RenderListType p_render_list, int *p_render_info = nullptr, uint32_t p_offset = 0, int32_t p_max_elements = -1, bool p_update_buffer = true); |
| 469 |
void _fill_render_list(RenderListType p_render_list, const RenderDataRD *p_render_data, PassMode p_pass_mode, bool p_using_sdfgi = false, bool p_using_opaque_gi = false, bool p_using_motion_pass = false, bool p_append = false); |
| 470 |
|
| 471 |
HashMap<Size2i, RID> sdfgi_framebuffer_size_cache; |
| 472 |
|
| 473 |
struct GeometryInstanceData; |
| 474 |
class GeometryInstanceForwardClustered; |
| 475 |
|
| 476 |
struct GeometryInstanceLightmapSH { |
| 477 |
Color sh[9]; |
| 478 |
}; |
| 479 |
|
| 480 |
|
| 481 |
struct GeometryInstanceSurfaceDataCache { |
| 482 |
enum { |
| 483 |
FLAG_PASS_DEPTH = 1, |
| 484 |
FLAG_PASS_OPAQUE = 2, |
| 485 |
FLAG_PASS_ALPHA = 4, |
| 486 |
FLAG_PASS_SHADOW = 8, |
| 487 |
FLAG_USES_SHARED_SHADOW_MATERIAL = 128, |
| 488 |
FLAG_USES_SUBSURFACE_SCATTERING = 2048, |
| 489 |
FLAG_USES_SCREEN_TEXTURE = 4096, |
| 490 |
FLAG_USES_DEPTH_TEXTURE = 8192, |
| 491 |
FLAG_USES_NORMAL_TEXTURE = 16384, |
| 492 |
FLAG_USES_DOUBLE_SIDED_SHADOWS = 32768, |
| 493 |
FLAG_USES_PARTICLE_TRAILS = 65536, |
| 494 |
FLAG_USES_MOTION_VECTOR = 131072, |
| 495 |
FLAG_USES_STENCIL = 262144, |
| 496 |
}; |
| 497 |
|
| 498 |
union { |
| 499 |
struct { |
| 500 |
uint64_t sort_key1; |
| 501 |
uint64_t sort_key2; |
| 502 |
}; |
| 503 |
struct { |
| 504 |
|
| 505 |
uint64_t lod_index : 8; |
| 506 |
uint64_t uses_softshadow : 1; |
| 507 |
uint64_t uses_projector : 1; |
| 508 |
uint64_t uses_forward_gi : 1; |
| 509 |
uint64_t uses_lightmap : 1; |
| 510 |
|
| 511 |
|
| 512 |
|
| 513 |
|
| 514 |
uint64_t depth_layer : 4; |
| 515 |
uint64_t surface_index : 8; |
| 516 |
uint64_t geometry_id : 32; |
| 517 |
uint64_t material_id_hi : 8; |
| 518 |
|
| 519 |
uint64_t material_id_lo : 24; |
| 520 |
uint64_t shader_id : 32; |
| 521 |
uint64_t priority : 8; |
| 522 |
}; |
| 523 |
} sort; |
| 524 |
|
| 525 |
RS::PrimitiveType primitive = RS::PRIMITIVE_MAX; |
| 526 |
uint32_t flags = 0; |
| 527 |
uint32_t surface_index = 0; |
| 528 |
uint32_t color_pass_inclusion_mask = 0; |
| 529 |
|
| 530 |
void *surface = nullptr; |
| 531 |
RID material_uniform_set; |
| 532 |
SceneShaderForwardClustered::ShaderData *shader = nullptr; |
| 533 |
SceneShaderForwardClustered::MaterialData *material = nullptr; |
| 534 |
|
| 535 |
void *surface_shadow = nullptr; |
| 536 |
RID material_uniform_set_shadow; |
| 537 |
SceneShaderForwardClustered::ShaderData *shader_shadow = nullptr; |
| 538 |
|
| 539 |
GeometryInstanceSurfaceDataCache *next = nullptr; |
| 540 |
GeometryInstanceForwardClustered *owner = nullptr; |
| 541 |
SelfList<GeometryInstanceSurfaceDataCache> compilation_dirty_element; |
| 542 |
SelfList<GeometryInstanceSurfaceDataCache> compilation_all_element; |
| 543 |
|
| 544 |
GeometryInstanceSurfaceDataCache() : |
| 545 |
compilation_dirty_element(this), compilation_all_element(this) {} |
| 546 |
}; |
| 547 |
|
| 548 |
class GeometryInstanceForwardClustered : public RenderGeometryInstanceBase { |
| 549 |
public: |
| 550 |
|
| 551 |
RID lightmap_instance; |
| 552 |
Rect2 lightmap_uv_scale; |
| 553 |
uint32_t lightmap_slice_index; |
| 554 |
GeometryInstanceLightmapSH *lightmap_sh = nullptr; |
| 555 |
|
| 556 |
|
| 557 |
|
| 558 |
uint32_t gi_offset_cache = 0; |
| 559 |
bool store_transform_cache = true; |
| 560 |
RID transforms_uniform_set; |
| 561 |
uint32_t instance_count = 0; |
| 562 |
uint32_t trail_steps = 1; |
| 563 |
bool can_sdfgi = false; |
| 564 |
bool using_projectors = false; |
| 565 |
bool using_softshadows = false; |
| 566 |
|
| 567 |
|
| 568 |
uint64_t prev_transform_change_frame = 0xFFFFFFFF; |
| 569 |
enum TransformStatus { |
| 570 |
NONE, |
| 571 |
MOVED, |
| 572 |
TELEPORTED, |
| 573 |
} transform_status = TransformStatus::MOVED; |
| 574 |
Transform3D prev_transform; |
| 575 |
RID voxel_gi_instances[MAX_VOXEL_GI_INSTANCESS_PER_INSTANCE]; |
| 576 |
GeometryInstanceSurfaceDataCache *surface_caches = nullptr; |
| 577 |
SelfList<GeometryInstanceForwardClustered> dirty_list_element; |
| 578 |
|
| 579 |
GeometryInstanceForwardClustered() : |
| 580 |
dirty_list_element(this) {} |
| 581 |
|
| 582 |
virtual void _mark_dirty() override; |
| 583 |
|
| 584 |
virtual void set_transform(const Transform3D &p_transform, const AABB &p_aabb, const AABB &p_transformed_aabb) override; |
| 585 |
virtual void reset_motion_vectors() override; |
| 586 |
virtual void set_use_lightmap(RID p_lightmap_instance, const Rect2 &p_lightmap_uv_scale, int p_lightmap_slice_index) override; |
| 587 |
virtual void set_lightmap_capture(const Color *p_sh9) override; |
| 588 |
|
| 589 |
virtual void clear_light_instances() override {} |
| 590 |
virtual void pair_light_instance(const RID p_light_instance, RS::LightType light_type, uint32_t placement_idx) override {} |
| 591 |
virtual void pair_reflection_probe_instances(const RID *p_reflection_probe_instances, uint32_t p_reflection_probe_instance_count) override {} |
| 592 |
virtual void pair_decal_instances(const RID *p_decal_instances, uint32_t p_decal_instance_count) override {} |
| 593 |
virtual void pair_voxel_gi_instances(const RID *p_voxel_gi_instances, uint32_t p_voxel_gi_instance_count) override; |
| 594 |
|
| 595 |
virtual void set_softshadow_projector_pairing(bool p_softshadow, bool p_projector) override; |
| 596 |
}; |
| 597 |
|
| 598 |
|
| 599 |
virtual uint32_t get_max_lights_total() override { return 0; } |
| 600 |
virtual uint32_t get_max_lights_per_mesh() override { return 0; } |
| 601 |
|
| 602 |
static void _geometry_instance_dependency_changed(Dependency::DependencyChangedNotification p_notification, DependencyTracker *p_tracker); |
| 603 |
static void _geometry_instance_dependency_deleted(const RID &p_dependency, DependencyTracker *p_tracker); |
| 604 |
|
| 605 |
SelfList<GeometryInstanceForwardClustered>::List geometry_instance_dirty_list; |
| 606 |
SelfList<GeometryInstanceSurfaceDataCache>::List geometry_surface_compilation_dirty_list; |
| 607 |
SelfList<GeometryInstanceSurfaceDataCache>::List geometry_surface_compilation_all_list; |
| 608 |
|
| 609 |
PagedAllocator<GeometryInstanceForwardClustered> geometry_instance_alloc; |
| 610 |
PagedAllocator<GeometryInstanceSurfaceDataCache> geometry_instance_surface_alloc; |
| 611 |
PagedAllocator<GeometryInstanceLightmapSH> geometry_instance_lightmap_sh; |
| 612 |
|
| 613 |
struct SurfacePipelineData { |
| 614 |
void *mesh_surface = nullptr; |
| 615 |
void *mesh_surface_shadow = nullptr; |
| 616 |
SceneShaderForwardClustered::ShaderData *shader = nullptr; |
| 617 |
SceneShaderForwardClustered::ShaderData *shader_shadow = nullptr; |
| 618 |
bool instanced = false; |
| 619 |
bool uses_opaque = false; |
| 620 |
bool uses_transparent = false; |
| 621 |
bool uses_depth = false; |
| 622 |
bool can_use_lightmap = false; |
| 623 |
}; |
| 624 |
|
| 625 |
struct GlobalPipelineData { |
| 626 |
union { |
| 627 |
uint32_t key; |
| 628 |
|
| 629 |
struct { |
| 630 |
uint32_t texture_samples : 3; |
| 631 |
uint32_t use_reflection_probes : 1; |
| 632 |
uint32_t use_separate_specular : 1; |
| 633 |
uint32_t use_motion_vectors : 1; |
| 634 |
uint32_t use_normal_and_roughness : 1; |
| 635 |
uint32_t use_lightmaps : 1; |
| 636 |
uint32_t use_voxelgi : 1; |
| 637 |
uint32_t use_sdfgi : 1; |
| 638 |
uint32_t use_multiview : 1; |
| 639 |
uint32_t use_16_bit_shadows : 1; |
| 640 |
uint32_t use_32_bit_shadows : 1; |
| 641 |
uint32_t use_shadow_cubemaps : 1; |
| 642 |
uint32_t use_shadow_dual_paraboloid : 1; |
| 643 |
}; |
| 644 |
}; |
| 645 |
}; |
| 646 |
|
| 647 |
GlobalPipelineData global_pipeline_data_compiled = {}; |
| 648 |
GlobalPipelineData global_pipeline_data_required = {}; |
| 649 |
|
| 650 |
typedef Pair<SceneShaderForwardClustered::ShaderData *, SceneShaderForwardClustered::ShaderData::PipelineKey> ShaderPipelinePair; |
| 651 |
|
| 652 |
void _update_global_pipeline_data_requirements_from_project(); |
| 653 |
void _update_global_pipeline_data_requirements_from_light_storage(); |
| 654 |
void _geometry_instance_add_surface_with_material(GeometryInstanceForwardClustered *ginstance, uint32_t p_surface, SceneShaderForwardClustered::MaterialData *p_material, uint32_t p_material_id, uint32_t p_shader_id, RID p_mesh); |
| 655 |
void _geometry_instance_add_surface_with_material_chain(GeometryInstanceForwardClustered *ginstance, uint32_t p_surface, SceneShaderForwardClustered::MaterialData *p_material, RID p_mat_src, RID p_mesh); |
| 656 |
void _geometry_instance_add_surface(GeometryInstanceForwardClustered *ginstance, uint32_t p_surface, RID p_material, RID p_mesh); |
| 657 |
void _geometry_instance_update(RenderGeometryInstance *p_geometry_instance); |
| 658 |
void _mesh_compile_pipeline_for_surface(SceneShaderForwardClustered::ShaderData *p_shader, void *p_mesh_surface, bool p_ubershader, bool p_instanced_surface, RS::PipelineSource p_source, SceneShaderForwardClustered::ShaderData::PipelineKey &r_pipeline_key, Vector<ShaderPipelinePair> *r_pipeline_pairs = nullptr); |
| 659 |
void _mesh_compile_pipelines_for_surface(const SurfacePipelineData &p_surface, const GlobalPipelineData &p_global, RS::PipelineSource p_source, Vector<ShaderPipelinePair> *r_pipeline_pairs = nullptr); |
| 660 |
void _mesh_generate_all_pipelines_for_surface_cache(GeometryInstanceSurfaceDataCache *p_surface_cache, const GlobalPipelineData &p_global); |
| 661 |
void _update_dirty_geometry_instances(); |
| 662 |
void _update_dirty_geometry_pipelines(); |
| 663 |
|
| 664 |
|
| 665 |
struct GlobalSurfaceData { |
| 666 |
bool screen_texture_used = false; |
| 667 |
bool normal_texture_used = false; |
| 668 |
bool depth_texture_used = false; |
| 669 |
bool sss_used = false; |
| 670 |
} global_surface_data; |
| 671 |
|
| 672 |
|
| 673 |
|
| 674 |
struct RenderList { |
| 675 |
LocalVector<GeometryInstanceSurfaceDataCache *> elements; |
| 676 |
LocalVector<RenderElementInfo> element_info; |
| 677 |
|
| 678 |
void clear() { |
| 679 |
elements.clear(); |
| 680 |
element_info.clear(); |
| 681 |
} |
| 682 |
|
| 683 |
|
| 684 |
|
| 685 |
struct SortByKey { |
| 686 |
_FORCE_INLINE_ bool operator()(const GeometryInstanceSurfaceDataCache *A, const GeometryInstanceSurfaceDataCache *B) const { |
| 687 |
return (A->sort.sort_key2 == B->sort.sort_key2) ? (A->sort.sort_key1 < B->sort.sort_key1) : (A->sort.sort_key2 < B->sort.sort_key2); |
| 688 |
} |
| 689 |
}; |
| 690 |
|
| 691 |
void sort_by_key() { |
| 692 |
SortArray<GeometryInstanceSurfaceDataCache *, SortByKey> sorter; |
| 693 |
sorter.sort(elements.ptr(), elements.size()); |
| 694 |
} |
| 695 |
|
| 696 |
void sort_by_key_range(uint32_t p_from, uint32_t p_size) { |
| 697 |
SortArray<GeometryInstanceSurfaceDataCache *, SortByKey> sorter; |
| 698 |
sorter.sort(elements.ptr() + p_from, p_size); |
| 699 |
} |
| 700 |
|
| 701 |
struct SortByDepth { |
| 702 |
_FORCE_INLINE_ bool operator()(const GeometryInstanceSurfaceDataCache *A, const GeometryInstanceSurfaceDataCache *B) const { |
| 703 |
return (A->owner->depth < B->owner->depth); |
| 704 |
} |
| 705 |
}; |
| 706 |
|
| 707 |
void sort_by_depth() { |
| 708 |
|
| 709 |
SortArray<GeometryInstanceSurfaceDataCache *, SortByDepth> sorter; |
| 710 |
sorter.sort(elements.ptr(), elements.size()); |
| 711 |
} |
| 712 |
|
| 713 |
struct SortByReverseDepthAndPriority { |
| 714 |
_FORCE_INLINE_ bool operator()(const GeometryInstanceSurfaceDataCache *A, const GeometryInstanceSurfaceDataCache *B) const { |
| 715 |
return (A->sort.priority == B->sort.priority) ? (A->owner->depth > B->owner->depth) : (A->sort.priority < B->sort.priority); |
| 716 |
} |
| 717 |
}; |
| 718 |
|
| 719 |
void sort_by_reverse_depth_and_priority() { |
| 720 |
|
| 721 |
SortArray<GeometryInstanceSurfaceDataCache *, SortByReverseDepthAndPriority> sorter; |
| 722 |
sorter.sort(elements.ptr(), elements.size()); |
| 723 |
} |
| 724 |
|
| 725 |
_FORCE_INLINE_ void add_element(GeometryInstanceSurfaceDataCache *p_element) { |
| 726 |
elements.push_back(p_element); |
| 727 |
} |
| 728 |
}; |
| 729 |
|
| 730 |
RenderList render_list[RENDER_LIST_MAX]; |
| 731 |
|
| 732 |
virtual void _update_shader_quality_settings() override; |
| 733 |
|
| 734 |
|
| 735 |
|
| 736 |
RendererRD::TAA *taa = nullptr; |
| 737 |
RendererRD::FSR2Effect *fsr2_effect = nullptr; |
| 738 |
RendererRD::SSEffects *ss_effects = nullptr; |
| 739 |
|
| 740 |
#ifdef METAL_MFXTEMPORAL_ENABLED |
| 741 |
RendererRD::MFXTemporalEffect *mfx_temporal_effect = nullptr; |
| 742 |
#endif |
| 743 |
RendererRD::MotionVectorsStore *motion_vectors_store = nullptr; |
| 744 |
|
| 745 |
|
| 746 |
|
| 747 |
ClusterBuilderSharedDataRD cluster_builder_shared; |
| 748 |
ClusterBuilderRD *current_cluster_builder = nullptr; |
| 749 |
|
| 750 |
|
| 751 |
void _update_sdfgi(RenderDataRD *p_render_data); |
| 752 |
|
| 753 |
|
| 754 |
RID shadow_sampler; |
| 755 |
|
| 756 |
void _update_volumetric_fog(Ref<RenderSceneBuffersRD> p_render_buffers, RID p_environment, const Projection &p_cam_projection, const Transform3D &p_cam_transform, const Transform3D &p_prev_cam_inv_transform, RID p_shadow_atlas, int p_directional_light_count, bool p_use_directional_shadows, int p_positional_light_count, int p_voxel_gi_count, const PagedArray<RID> &p_fog_volumes); |
| 757 |
|
| 758 |
|
| 759 |
|
| 760 |
void _render_shadow_pass(RID p_light, RID p_shadow_atlas, int p_pass, const PagedArray<RenderGeometryInstance *> &p_instances, float p_lod_distance_multiplier = 0, float p_screen_mesh_lod_threshold = 0.0, bool p_open_pass = true, bool p_close_pass = true, bool p_clear_region = true, RenderingMethod::RenderInfo *p_render_info = nullptr, const Size2i &p_viewport_size = Size2i(1, 1), const Transform3D &p_main_cam_transform = Transform3D()); |
| 761 |
void _render_shadow_begin(); |
| 762 |
void _render_shadow_append(RID p_framebuffer, const PagedArray<RenderGeometryInstance *> &p_instances, const Projection &p_projection, const Transform3D &p_transform, float p_zfar, float p_bias, float p_normal_bias, bool p_reverse_cull_face, bool p_use_dp, bool p_use_dp_flip, bool p_use_pancake, float p_lod_distance_multiplier = 0.0, float p_screen_mesh_lod_threshold = 0.0, const Rect2i &p_rect = Rect2i(), bool p_flip_y = false, bool p_clear_region = true, bool p_begin = true, bool p_end = true, RenderingMethod::RenderInfo *p_render_info = nullptr, const Size2i &p_viewport_size = Size2i(1, 1), const Transform3D &p_main_cam_transform = Transform3D()); |
| 763 |
void _render_shadow_process(); |
| 764 |
void _render_shadow_end(); |
| 765 |
|
| 766 |
|
| 767 |
void _process_ssao(Ref<RenderSceneBuffersRD> p_render_buffers, RID p_environment, const RID *p_normal_buffers, const Projection *p_projections); |
| 768 |
void _process_ssil(Ref<RenderSceneBuffersRD> p_render_buffers, RID p_environment, const RID *p_normal_buffers, const Projection *p_projections, const Transform3D &p_transform); |
| 769 |
void _process_ssr(Ref<RenderSceneBuffersRD> p_render_buffers, RID p_environment, const RID *p_normal_slices, const Projection *p_projections, const Vector3 *p_eye_offsets, const Transform3D &p_transform); |
| 770 |
void _copy_framebuffer_to_ss_effects(Ref<RenderSceneBuffersRD> p_render_buffers, bool p_use_ssil, bool p_use_ssr); |
| 771 |
void _pre_opaque_render(RenderDataRD *p_render_data, bool p_use_ssao, bool p_use_ssil, bool p_use_ssr, bool p_use_gi, const RID *p_normal_roughness_slices, RID p_voxel_gi_buffer); |
| 772 |
void _process_sss(Ref<RenderSceneBuffersRD> p_render_buffers, const Projection &p_camera); |
| 773 |
|
| 774 |
|
| 775 |
void _debug_draw_cluster(Ref<RenderSceneBuffersRD> p_render_buffers); |
| 776 |
|
| 777 |
protected: |
| 778 |
|
| 779 |
|
| 780 |
virtual RID _render_buffers_get_normal_texture(Ref<RenderSceneBuffersRD> p_render_buffers) override; |
| 781 |
virtual RID _render_buffers_get_velocity_texture(Ref<RenderSceneBuffersRD> p_render_buffers) override; |
| 782 |
|
| 783 |
virtual void environment_set_ssao_quality(RS::EnvironmentSSAOQuality p_quality, bool p_half_size, float p_adaptive_target, int p_blur_passes, float p_fadeout_from, float p_fadeout_to) override; |
| 784 |
virtual void environment_set_ssil_quality(RS::EnvironmentSSILQuality p_quality, bool p_half_size, float p_adaptive_target, int p_blur_passes, float p_fadeout_from, float p_fadeout_to) override; |
| 785 |
virtual void environment_set_ssr_half_size(bool p_half_size) override; |
| 786 |
virtual void environment_set_ssr_roughness_quality(RS::EnvironmentSSRRoughnessQuality p_quality) override; |
| 787 |
|
| 788 |
virtual void sub_surface_scattering_set_quality(RS::SubSurfaceScatteringQuality p_quality) override; |
| 789 |
virtual void sub_surface_scattering_set_scale(float p_scale, float p_depth_scale) override; |
| 790 |
|
| 791 |
|
| 792 |
|
| 793 |
virtual void _render_scene(RenderDataRD *p_render_data, const Color &p_default_bg_color) override; |
| 794 |
virtual void _render_buffers_debug_draw(const RenderDataRD *p_render_data) override; |
| 795 |
|
| 796 |
virtual void _render_material(const Transform3D &p_cam_transform, const Projection &p_cam_projection, bool p_cam_orthogonal, const PagedArray<RenderGeometryInstance *> &p_instances, RID p_framebuffer, const Rect2i &p_region, float p_exposure_normalization) override; |
| 797 |
virtual void _render_uv2(const PagedArray<RenderGeometryInstance *> &p_instances, RID p_framebuffer, const Rect2i &p_region) override; |
| 798 |
virtual void _render_sdfgi(Ref<RenderSceneBuffersRD> p_render_buffers, const Vector3i &p_from, const Vector3i &p_size, const AABB &p_bounds, const PagedArray<RenderGeometryInstance *> &p_instances, const RID &p_albedo_texture, const RID &p_emission_texture, const RID &p_emission_aniso_texture, const RID &p_geom_facing_texture, float p_exposure_normalization) override; |
| 799 |
virtual void _render_particle_collider_heightfield(RID p_fb, const Transform3D &p_cam_transform, const Projection &p_cam_projection, const PagedArray<RenderGeometryInstance *> &p_instances) override; |
| 800 |
|
| 801 |
public: |
| 802 |
static RenderForwardClustered *get_singleton() { return singleton; } |
| 803 |
|
| 804 |
ClusterBuilderSharedDataRD *get_cluster_builder_shared() { return &cluster_builder_shared; } |
| 805 |
RendererRD::SSEffects *get_ss_effects() { return ss_effects; } |
| 806 |
|
| 807 |
|
| 808 |
virtual void setup_added_reflection_probe(const Transform3D &p_transform, const Vector3 &p_half_size) override; |
| 809 |
virtual void setup_added_light(const RS::LightType p_type, const Transform3D &p_transform, float p_radius, float p_spot_aperture) override; |
| 810 |
virtual void setup_added_decal(const Transform3D &p_transform, const Vector3 &p_half_size) override; |
| 811 |
|
| 812 |
virtual void base_uniforms_changed() override; |
| 813 |
|
| 814 |
|
| 815 |
|
| 816 |
virtual void sdfgi_update(const Ref<RenderSceneBuffers> &p_render_buffers, RID p_environment, const Vector3 &p_world_position) override; |
| 817 |
virtual int sdfgi_get_pending_region_count(const Ref<RenderSceneBuffers> &p_render_buffers) const override; |
| 818 |
virtual AABB sdfgi_get_pending_region_bounds(const Ref<RenderSceneBuffers> &p_render_buffers, int p_region) const override; |
| 819 |
virtual uint32_t sdfgi_get_pending_region_cascade(const Ref<RenderSceneBuffers> &p_render_buffers, int p_region) const override; |
| 820 |
RID sdfgi_get_ubo() const { return gi.sdfgi_ubo; } |
| 821 |
|
| 822 |
|
| 823 |
|
| 824 |
virtual RenderGeometryInstance *geometry_instance_create(RID p_base) override; |
| 825 |
virtual void geometry_instance_free(RenderGeometryInstance *p_geometry_instance) override; |
| 826 |
|
| 827 |
virtual uint32_t geometry_instance_get_pair_mask() override; |
| 828 |
|
| 829 |
|
| 830 |
|
| 831 |
virtual void mesh_generate_pipelines(RID p_mesh, bool p_background_compilation) override; |
| 832 |
virtual uint32_t get_pipeline_compilations(RS::PipelineSource p_source) override; |
| 833 |
|
| 834 |
|
| 835 |
|
| 836 |
virtual void enable_features(BitField<FeatureBits> p_feature_bits) override; |
| 837 |
virtual String get_name() const override; |
| 838 |
|
| 839 |
virtual bool free(RID p_rid) override; |
| 840 |
|
| 841 |
virtual void update() override; |
| 842 |
|
| 843 |
RenderForwardClustered(); |
| 844 |
~RenderForwardClustered(); |
| 845 |
}; |
| 846 |
} |