summaryrefslogtreecommitdiff
path: root/servers/rendering
diff options
context:
space:
mode:
authorHugo Locurcio <hugo.locurcio@hugo.pro>2022-08-10 17:16:02 +0200
committerHugo Locurcio <hugo.locurcio@hugo.pro>2022-08-10 17:16:02 +0200
commitb06890c2b7f142de81a0d6f3623a7538bfc36fd0 (patch)
treea7a8f94b3990aac70f08888ee9ae423d9ccdb961 /servers/rendering
parentcf95056c918b30509c3b181d672e6cfdc971d34f (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.cpp3
-rw-r--r--servers/rendering/renderer_viewport.cpp6
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());
}
}
}