Use default samplers in base uniform set when rendering to reflection probes
This commit is contained in:
parent
3e7f638d7b
commit
a74cfc2629
5 changed files with 78 additions and 38 deletions
|
@ -2694,7 +2694,6 @@
|
|||
Affects the final texture sharpness by reading from a lower or higher mipmap (also called "texture LOD bias"). Negative values make mipmapped textures sharper but grainier when viewed at a distance, while positive values make mipmapped textures blurrier (even when up close).
|
||||
Enabling temporal antialiasing ([member rendering/anti_aliasing/quality/use_taa]) will automatically apply a [code]-0.5[/code] offset to this value, while enabling FXAA ([member rendering/anti_aliasing/quality/screen_space_aa]) will automatically apply a [code]-0.25[/code] offset to this value. If both TAA and FXAA are enabled at the same time, an offset of [code]-0.75[/code] is applied to this value.
|
||||
[b]Note:[/b] If [member rendering/scaling_3d/scale] is lower than [code]1.0[/code] (exclusive), [member rendering/textures/default_filters/texture_mipmap_bias] is used to adjust the automatic mipmap bias which is calculated internally based on the scale factor. The formula for this is [code]log2(scaling_3d_scale) + mipmap_bias[/code].
|
||||
[b]Note:[/b] This property is only read when the project starts. To change the mipmap LOD bias at run-time, set [member Viewport.texture_mipmap_bias] instead.
|
||||
</member>
|
||||
<member name="rendering/textures/default_filters/use_nearest_mipmap_filter" type="bool" setter="" getter="" default="false">
|
||||
If [code]true[/code], uses nearest-neighbor mipmap filtering when using mipmaps (also called "bilinear filtering"), which will result in visible seams appearing between mipmap stages. This may increase performance in mobile as less memory bandwidth is used. If [code]false[/code], linear mipmap filtering (also called "trilinear filtering") is used.
|
||||
|
|
|
@ -1739,7 +1739,12 @@ void RenderForwardClustered::_render_scene(RenderDataRD *p_render_data, const Co
|
|||
_setup_voxelgis(*p_render_data->voxel_gi_instances);
|
||||
_setup_environment(p_render_data, is_reflection_probe, screen_size, !is_reflection_probe, p_default_bg_color, false);
|
||||
|
||||
_update_render_base_uniform_set(rb->get_samplers()); // May have changed due to the above (light buffer enlarged, as an example).
|
||||
// May have changed due to the above (light buffer enlarged, as an example).
|
||||
if (is_reflection_probe) {
|
||||
_update_render_base_uniform_set(RendererRD::MaterialStorage::get_singleton()->samplers_rd_get_default(), BASE_UNIFORM_SET_CACHE_DEFAULT);
|
||||
} else {
|
||||
_update_render_base_uniform_set(rb->get_samplers(), BASE_UNIFORM_SET_CACHE_VIEWPORT);
|
||||
}
|
||||
|
||||
_fill_render_list(RENDER_LIST_OPAQUE, p_render_data, PASS_MODE_COLOR, using_sdfgi, using_sdfgi || using_voxelgi, using_motion_pass);
|
||||
render_list[RENDER_LIST_OPAQUE].sort_by_key();
|
||||
|
@ -1970,7 +1975,11 @@ void RenderForwardClustered::_render_scene(RenderDataRD *p_render_data, const Co
|
|||
p_render_data->scene_data->opaque_prepass_threshold = 0.0f;
|
||||
|
||||
// Shadow pass can change the base uniform set samplers.
|
||||
_update_render_base_uniform_set(rb->get_samplers());
|
||||
if (is_reflection_probe) {
|
||||
_update_render_base_uniform_set(RendererRD::MaterialStorage::get_singleton()->samplers_rd_get_default(), BASE_UNIFORM_SET_CACHE_DEFAULT);
|
||||
} else {
|
||||
_update_render_base_uniform_set(rb->get_samplers(), BASE_UNIFORM_SET_CACHE_VIEWPORT);
|
||||
}
|
||||
|
||||
_setup_environment(p_render_data, is_reflection_probe, screen_size, !is_reflection_probe, p_default_bg_color, true, using_motion_pass);
|
||||
|
||||
|
@ -2495,7 +2504,7 @@ void RenderForwardClustered::_render_shadow_pass(RID p_light, RID p_shadow_atlas
|
|||
void RenderForwardClustered::_render_shadow_begin() {
|
||||
scene_state.shadow_passes.clear();
|
||||
RD::get_singleton()->draw_command_begin_label("Shadow Setup");
|
||||
_update_render_base_uniform_set(RendererRD::MaterialStorage::get_singleton()->samplers_rd_get_default());
|
||||
_update_render_base_uniform_set(RendererRD::MaterialStorage::get_singleton()->samplers_rd_get_default(), BASE_UNIFORM_SET_CACHE_DEFAULT);
|
||||
|
||||
render_list[RENDER_LIST_SECONDARY].clear();
|
||||
scene_state.instance_data[RENDER_LIST_SECONDARY].clear();
|
||||
|
@ -2619,7 +2628,7 @@ void RenderForwardClustered::_render_particle_collider_heightfield(RID p_fb, con
|
|||
render_data.cluster_max_elements = 32;
|
||||
render_data.instances = &p_instances;
|
||||
|
||||
_update_render_base_uniform_set(RendererRD::MaterialStorage::get_singleton()->samplers_rd_get_default());
|
||||
_update_render_base_uniform_set(RendererRD::MaterialStorage::get_singleton()->samplers_rd_get_default(), BASE_UNIFORM_SET_CACHE_DEFAULT);
|
||||
|
||||
_setup_environment(&render_data, true, Vector2(1, 1), true, Color(), false, false, false);
|
||||
|
||||
|
@ -2665,7 +2674,7 @@ void RenderForwardClustered::_render_material(const Transform3D &p_cam_transform
|
|||
|
||||
scene_shader.enable_advanced_shader_group();
|
||||
|
||||
_update_render_base_uniform_set(RendererRD::MaterialStorage::get_singleton()->samplers_rd_get_default());
|
||||
_update_render_base_uniform_set(RendererRD::MaterialStorage::get_singleton()->samplers_rd_get_default(), BASE_UNIFORM_SET_CACHE_DEFAULT);
|
||||
|
||||
_setup_environment(&render_data, true, Vector2(1, 1), false, Color());
|
||||
|
||||
|
@ -2716,7 +2725,7 @@ void RenderForwardClustered::_render_uv2(const PagedArray<RenderGeometryInstance
|
|||
|
||||
scene_shader.enable_advanced_shader_group();
|
||||
|
||||
_update_render_base_uniform_set(RendererRD::MaterialStorage::get_singleton()->samplers_rd_get_default());
|
||||
_update_render_base_uniform_set(RendererRD::MaterialStorage::get_singleton()->samplers_rd_get_default(), BASE_UNIFORM_SET_CACHE_DEFAULT);
|
||||
|
||||
_setup_environment(&render_data, true, Vector2(1, 1), false, Color());
|
||||
|
||||
|
@ -2785,7 +2794,7 @@ void RenderForwardClustered::_render_sdfgi(Ref<RenderSceneBuffersRD> p_render_bu
|
|||
render_data.cluster_max_elements = 32;
|
||||
render_data.instances = &p_instances;
|
||||
|
||||
_update_render_base_uniform_set(RendererRD::MaterialStorage::get_singleton()->samplers_rd_get_default());
|
||||
_update_render_base_uniform_set(RendererRD::MaterialStorage::get_singleton()->samplers_rd_get_default(), BASE_UNIFORM_SET_CACHE_DEFAULT);
|
||||
|
||||
PassMode pass_mode = PASS_MODE_SDF;
|
||||
_fill_render_list(RENDER_LIST_SECONDARY, &render_data, pass_mode);
|
||||
|
@ -2859,21 +2868,23 @@ void RenderForwardClustered::_render_sdfgi(Ref<RenderSceneBuffersRD> p_render_bu
|
|||
}
|
||||
|
||||
void RenderForwardClustered::base_uniforms_changed() {
|
||||
if (!render_base_uniform_set.is_null() && RD::get_singleton()->uniform_set_is_valid(render_base_uniform_set)) {
|
||||
RD::get_singleton()->free(render_base_uniform_set);
|
||||
for (int i = 0; i < BASE_UNIFORM_SET_CACHE_MAX; i++) {
|
||||
if (!render_base_uniform_set_cache[i].is_null() && RD::get_singleton()->uniform_set_is_valid(render_base_uniform_set_cache[i])) {
|
||||
RD::get_singleton()->free(render_base_uniform_set_cache[i]);
|
||||
}
|
||||
render_base_uniform_set_cache[i] = RID();
|
||||
}
|
||||
render_base_uniform_set = RID();
|
||||
}
|
||||
|
||||
void RenderForwardClustered::_update_render_base_uniform_set(const RendererRD::MaterialStorage::Samplers &p_samplers) {
|
||||
void RenderForwardClustered::_update_render_base_uniform_set(const RendererRD::MaterialStorage::Samplers &p_samplers, BaseUniformSetCache p_cache_index) {
|
||||
RendererRD::LightStorage *light_storage = RendererRD::LightStorage::get_singleton();
|
||||
|
||||
if (render_base_uniform_set.is_null() || !RD::get_singleton()->uniform_set_is_valid(render_base_uniform_set) || (lightmap_texture_array_version != light_storage->lightmap_array_get_version())) {
|
||||
if (render_base_uniform_set.is_valid() && RD::get_singleton()->uniform_set_is_valid(render_base_uniform_set)) {
|
||||
RD::get_singleton()->free(render_base_uniform_set);
|
||||
if (render_base_uniform_set_cache[p_cache_index].is_null() || !RD::get_singleton()->uniform_set_is_valid(render_base_uniform_set_cache[p_cache_index]) || (lightmap_texture_array_version_cache[p_cache_index] != light_storage->lightmap_array_get_version())) {
|
||||
if (render_base_uniform_set_cache[p_cache_index].is_valid() && RD::get_singleton()->uniform_set_is_valid(render_base_uniform_set_cache[p_cache_index])) {
|
||||
RD::get_singleton()->free(render_base_uniform_set_cache[p_cache_index]);
|
||||
}
|
||||
|
||||
lightmap_texture_array_version = light_storage->lightmap_array_get_version();
|
||||
lightmap_texture_array_version_cache[p_cache_index] = light_storage->lightmap_array_get_version();
|
||||
|
||||
Vector<RD::Uniform> uniforms;
|
||||
|
||||
|
@ -3030,8 +3041,9 @@ void RenderForwardClustered::_update_render_base_uniform_set(const RendererRD::M
|
|||
|
||||
uniforms.append_array(p_samplers.get_uniforms(SAMPLERS_BINDING_FIRST_INDEX));
|
||||
|
||||
render_base_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, scene_shader.default_shader_rd, SCENE_UNIFORM_SET);
|
||||
render_base_uniform_set_cache[p_cache_index] = RD::get_singleton()->uniform_set_create(uniforms, scene_shader.default_shader_rd, SCENE_UNIFORM_SET);
|
||||
}
|
||||
render_base_uniform_set = render_base_uniform_set_cache[p_cache_index];
|
||||
}
|
||||
|
||||
RID RenderForwardClustered::_setup_render_pass_uniform_set(RenderListType p_render_list, const RenderDataRD *p_render_data, RID p_radiance_texture, bool p_use_directional_shadow_atlas, int p_index) {
|
||||
|
|
|
@ -158,11 +158,20 @@ class RenderForwardClustered : public RendererSceneRenderRD {
|
|||
|
||||
virtual void setup_render_buffer_data(Ref<RenderSceneBuffersRD> p_render_buffers) override;
|
||||
|
||||
enum BaseUniformSetCache {
|
||||
BASE_UNIFORM_SET_CACHE_VIEWPORT,
|
||||
BASE_UNIFORM_SET_CACHE_DEFAULT,
|
||||
BASE_UNIFORM_SET_CACHE_MAX
|
||||
};
|
||||
|
||||
RID render_base_uniform_set;
|
||||
// One for custom samplers, one for default samplers.
|
||||
// Need to switch between them as default is needed for probes, shadows, materials, etc.
|
||||
RID render_base_uniform_set_cache[BASE_UNIFORM_SET_CACHE_MAX];
|
||||
|
||||
uint64_t lightmap_texture_array_version = 0xFFFFFFFF;
|
||||
uint64_t lightmap_texture_array_version_cache[BASE_UNIFORM_SET_CACHE_MAX] = { 0xFFFFFFFF, 0xFFFFFFFF };
|
||||
|
||||
void _update_render_base_uniform_set(const RendererRD::MaterialStorage::Samplers &p_samplers);
|
||||
void _update_render_base_uniform_set(const RendererRD::MaterialStorage::Samplers &p_samplers, BaseUniformSetCache p_cache_index);
|
||||
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);
|
||||
RID _setup_render_pass_uniform_set(RenderListType p_render_list, const RenderDataRD *p_render_data, RID p_radiance_texture, bool p_use_directional_shadow_atlas = false, int p_index = 0);
|
||||
|
||||
|
|
|
@ -763,7 +763,12 @@ void RenderForwardMobile::_render_scene(RenderDataRD *p_render_data, const Color
|
|||
_setup_lightmaps(p_render_data, *p_render_data->lightmaps, p_render_data->scene_data->cam_transform);
|
||||
_setup_environment(p_render_data, is_reflection_probe, screen_size, !is_reflection_probe, p_default_bg_color, false);
|
||||
|
||||
_update_render_base_uniform_set(rb->get_samplers()); //may have changed due to the above (light buffer enlarged, as an example)
|
||||
// May have changed due to the above (light buffer enlarged, as an example).
|
||||
if (is_reflection_probe) {
|
||||
_update_render_base_uniform_set(RendererRD::MaterialStorage::get_singleton()->samplers_rd_get_default(), BASE_UNIFORM_SET_CACHE_DEFAULT);
|
||||
} else {
|
||||
_update_render_base_uniform_set(rb->get_samplers(), BASE_UNIFORM_SET_CACHE_VIEWPORT);
|
||||
}
|
||||
|
||||
RD::get_singleton()->draw_command_end_label(); // Render Setup
|
||||
|
||||
|
@ -902,7 +907,11 @@ void RenderForwardMobile::_render_scene(RenderDataRD *p_render_data, const Color
|
|||
p_render_data->scene_data->directional_light_count = p_render_data->directional_light_count;
|
||||
|
||||
// Shadow pass can change the base uniform set samplers.
|
||||
_update_render_base_uniform_set(rb->get_samplers());
|
||||
if (is_reflection_probe) {
|
||||
_update_render_base_uniform_set(RendererRD::MaterialStorage::get_singleton()->samplers_rd_get_default(), BASE_UNIFORM_SET_CACHE_DEFAULT);
|
||||
} else {
|
||||
_update_render_base_uniform_set(rb->get_samplers(), BASE_UNIFORM_SET_CACHE_VIEWPORT);
|
||||
}
|
||||
|
||||
_setup_environment(p_render_data, is_reflection_probe, screen_size, !is_reflection_probe, p_default_bg_color, p_render_data->render_buffers.is_valid());
|
||||
|
||||
|
@ -1264,7 +1273,7 @@ void RenderForwardMobile::_render_shadow_pass(RID p_light, RID p_shadow_atlas, i
|
|||
void RenderForwardMobile::_render_shadow_begin() {
|
||||
scene_state.shadow_passes.clear();
|
||||
RD::get_singleton()->draw_command_begin_label("Shadow Setup");
|
||||
_update_render_base_uniform_set(RendererRD::MaterialStorage::get_singleton()->samplers_rd_get_default());
|
||||
_update_render_base_uniform_set(RendererRD::MaterialStorage::get_singleton()->samplers_rd_get_default(), BASE_UNIFORM_SET_CACHE_DEFAULT);
|
||||
|
||||
render_list[RENDER_LIST_SECONDARY].clear();
|
||||
}
|
||||
|
@ -1371,7 +1380,7 @@ void RenderForwardMobile::_render_material(const Transform3D &p_cam_transform, c
|
|||
|
||||
RD::get_singleton()->draw_command_begin_label("Render 3D Material");
|
||||
|
||||
_update_render_base_uniform_set(RendererRD::MaterialStorage::get_singleton()->samplers_rd_get_default());
|
||||
_update_render_base_uniform_set(RendererRD::MaterialStorage::get_singleton()->samplers_rd_get_default(), BASE_UNIFORM_SET_CACHE_DEFAULT);
|
||||
|
||||
RenderSceneDataRD scene_data;
|
||||
scene_data.cam_projection = p_cam_projection;
|
||||
|
@ -1422,7 +1431,7 @@ void RenderForwardMobile::_render_uv2(const PagedArray<RenderGeometryInstance *>
|
|||
|
||||
RD::get_singleton()->draw_command_begin_label("Render UV2");
|
||||
|
||||
_update_render_base_uniform_set(RendererRD::MaterialStorage::get_singleton()->samplers_rd_get_default());
|
||||
_update_render_base_uniform_set(RendererRD::MaterialStorage::get_singleton()->samplers_rd_get_default(), BASE_UNIFORM_SET_CACHE_DEFAULT);
|
||||
|
||||
RenderSceneDataRD scene_data;
|
||||
scene_data.dual_paraboloid_side = 0;
|
||||
|
@ -1496,7 +1505,7 @@ void RenderForwardMobile::_render_particle_collider_heightfield(RID p_fb, const
|
|||
|
||||
RD::get_singleton()->draw_command_begin_label("Render Collider Heightfield");
|
||||
|
||||
_update_render_base_uniform_set(RendererRD::MaterialStorage::get_singleton()->samplers_rd_get_default());
|
||||
_update_render_base_uniform_set(RendererRD::MaterialStorage::get_singleton()->samplers_rd_get_default(), BASE_UNIFORM_SET_CACHE_DEFAULT);
|
||||
|
||||
RenderSceneDataRD scene_data;
|
||||
scene_data.cam_projection = p_cam_projection;
|
||||
|
@ -1534,23 +1543,23 @@ void RenderForwardMobile::_render_particle_collider_heightfield(RID p_fb, const
|
|||
}
|
||||
|
||||
void RenderForwardMobile::base_uniforms_changed() {
|
||||
if (!render_base_uniform_set.is_null() && RD::get_singleton()->uniform_set_is_valid(render_base_uniform_set)) {
|
||||
RD::get_singleton()->free(render_base_uniform_set);
|
||||
for (int i = 0; i < BASE_UNIFORM_SET_CACHE_MAX; i++) {
|
||||
if (!render_base_uniform_set_cache[i].is_null() && RD::get_singleton()->uniform_set_is_valid(render_base_uniform_set_cache[i])) {
|
||||
RD::get_singleton()->free(render_base_uniform_set_cache[i]);
|
||||
}
|
||||
render_base_uniform_set_cache[i] = RID();
|
||||
}
|
||||
render_base_uniform_set = RID();
|
||||
}
|
||||
|
||||
void RenderForwardMobile::_update_render_base_uniform_set(const RendererRD::MaterialStorage::Samplers &p_samplers) {
|
||||
void RenderForwardMobile::_update_render_base_uniform_set(const RendererRD::MaterialStorage::Samplers &p_samplers, BaseUniformSetCache p_cache_index) {
|
||||
RendererRD::LightStorage *light_storage = RendererRD::LightStorage::get_singleton();
|
||||
|
||||
if (render_base_uniform_set.is_null() || !RD::get_singleton()->uniform_set_is_valid(render_base_uniform_set) || (lightmap_texture_array_version != light_storage->lightmap_array_get_version())) {
|
||||
if (render_base_uniform_set.is_valid() && RD::get_singleton()->uniform_set_is_valid(render_base_uniform_set)) {
|
||||
RD::get_singleton()->free(render_base_uniform_set);
|
||||
if (render_base_uniform_set_cache[p_cache_index].is_null() || !RD::get_singleton()->uniform_set_is_valid(render_base_uniform_set_cache[p_cache_index]) || (lightmap_texture_array_version_cache[p_cache_index] != light_storage->lightmap_array_get_version())) {
|
||||
if (render_base_uniform_set_cache[p_cache_index].is_valid() && RD::get_singleton()->uniform_set_is_valid(render_base_uniform_set_cache[p_cache_index])) {
|
||||
RD::get_singleton()->free(render_base_uniform_set_cache[p_cache_index]);
|
||||
}
|
||||
|
||||
// This is all loaded into set 0
|
||||
|
||||
lightmap_texture_array_version = light_storage->lightmap_array_get_version();
|
||||
lightmap_texture_array_version_cache[p_cache_index] = light_storage->lightmap_array_get_version();
|
||||
|
||||
Vector<RD::Uniform> uniforms;
|
||||
|
||||
|
@ -1699,8 +1708,9 @@ void RenderForwardMobile::_update_render_base_uniform_set(const RendererRD::Mate
|
|||
|
||||
uniforms.append_array(p_samplers.get_uniforms(SAMPLERS_BINDING_FIRST_INDEX));
|
||||
|
||||
render_base_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, scene_shader.default_shader_rd, SCENE_UNIFORM_SET);
|
||||
render_base_uniform_set_cache[p_cache_index] = RD::get_singleton()->uniform_set_create(uniforms, scene_shader.default_shader_rd, SCENE_UNIFORM_SET);
|
||||
}
|
||||
render_base_uniform_set = render_base_uniform_set_cache[p_cache_index];
|
||||
}
|
||||
|
||||
RID RenderForwardMobile::_render_buffers_get_normal_texture(Ref<RenderSceneBuffersRD> p_render_buffers) {
|
||||
|
|
|
@ -198,9 +198,19 @@ private:
|
|||
RID _setup_render_pass_uniform_set(RenderListType p_render_list, const RenderDataRD *p_render_data, RID p_radiance_texture, bool p_use_directional_shadow_atlas = false, int p_index = 0);
|
||||
void _pre_opaque_render(RenderDataRD *p_render_data);
|
||||
|
||||
uint64_t lightmap_texture_array_version = 0xFFFFFFFF;
|
||||
enum BaseUniformSetCache {
|
||||
BASE_UNIFORM_SET_CACHE_VIEWPORT,
|
||||
BASE_UNIFORM_SET_CACHE_DEFAULT,
|
||||
BASE_UNIFORM_SET_CACHE_MAX
|
||||
};
|
||||
|
||||
void _update_render_base_uniform_set(const RendererRD::MaterialStorage::Samplers &p_samplers);
|
||||
// One for custom samplers, one for default samplers.
|
||||
// Need to switch between them as default is needed for probes, shadows, materials, etc.
|
||||
RID render_base_uniform_set_cache[BASE_UNIFORM_SET_CACHE_MAX];
|
||||
|
||||
uint64_t lightmap_texture_array_version_cache[BASE_UNIFORM_SET_CACHE_MAX] = { 0xFFFFFFFF, 0xFFFFFFFF };
|
||||
|
||||
void _update_render_base_uniform_set(const RendererRD::MaterialStorage::Samplers &p_samplers, BaseUniformSetCache p_cache_index);
|
||||
|
||||
void _update_instance_data_buffer(RenderListType p_render_list);
|
||||
void _fill_instance_data(RenderListType p_render_list, uint32_t p_offset = 0, int32_t p_max_elements = -1, bool p_update_buffer = true);
|
||||
|
|
Loading…
Reference in a new issue