diff options
author | Hugo Locurcio <hugo.locurcio@hugo.pro> | 2022-08-10 17:16:02 +0200 |
---|---|---|
committer | Hugo Locurcio <hugo.locurcio@hugo.pro> | 2022-08-10 17:16:02 +0200 |
commit | b06890c2b7f142de81a0d6f3623a7538bfc36fd0 (patch) | |
tree | a7a8f94b3990aac70f08888ee9ae423d9ccdb961 /servers/rendering | |
parent | cf95056c918b30509c3b181d672e6cfdc971d34f (diff) |
Use negative mipmap LOD bias for sub-native bilinear 3D scale
This provides a benefit similar to FSR 1.0 (greater texture sharpness
at the cost of some graininess at sub-native resolution scales), but
without the added performance cost of FSR 1.0.
Diffstat (limited to 'servers/rendering')
-rw-r--r-- | servers/rendering/renderer_rd/renderer_scene_render_rd.cpp | 3 | ||||
-rw-r--r-- | servers/rendering/renderer_viewport.cpp | 6 |
2 files changed, 6 insertions, 3 deletions
diff --git a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp index 13f8d1ab75..6c219933b0 100644 --- a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp @@ -2459,8 +2459,7 @@ void RendererSceneRenderRD::render_buffers_configure(RID p_render_buffers, RID p p_internal_width = p_width; } - const float texture_mipmap_bias = -log2f(p_width / p_internal_width) + p_texture_mipmap_bias; - material_storage->sampler_rd_configure_custom(texture_mipmap_bias); + material_storage->sampler_rd_configure_custom(p_texture_mipmap_bias); update_uniform_sets(); RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers); diff --git a/servers/rendering/renderer_viewport.cpp b/servers/rendering/renderer_viewport.cpp index 118bf532b3..73b03966c5 100644 --- a/servers/rendering/renderer_viewport.cpp +++ b/servers/rendering/renderer_viewport.cpp @@ -138,7 +138,11 @@ void RendererViewport::_configure_3d_render_buffers(Viewport *p_viewport) { p_viewport->internal_size = Size2(render_width, render_height); - RSG::scene->render_buffers_configure(p_viewport->render_buffers, p_viewport->render_target, render_width, render_height, width, height, p_viewport->fsr_sharpness, p_viewport->texture_mipmap_bias, p_viewport->msaa, p_viewport->screen_space_aa, p_viewport->use_taa, p_viewport->use_debanding, p_viewport->get_view_count()); + // At resolution scales lower than 1.0, use negative texture mipmap bias + // to compensate for the loss of sharpness. + const float texture_mipmap_bias = log2f(MIN(scaling_3d_scale, 1.0)) + p_viewport->texture_mipmap_bias; + + RSG::scene->render_buffers_configure(p_viewport->render_buffers, p_viewport->render_target, render_width, render_height, width, height, p_viewport->fsr_sharpness, texture_mipmap_bias, p_viewport->msaa, p_viewport->screen_space_aa, p_viewport->use_taa, p_viewport->use_debanding, p_viewport->get_view_count()); } } } |