summaryrefslogtreecommitdiff
path: root/servers
diff options
context:
space:
mode:
authorHugo Locurcio <hugo.locurcio@hugo.pro>2022-08-10 16:46:26 +0200
committerHugo Locurcio <hugo.locurcio@hugo.pro>2022-08-25 19:38:18 +0200
commit45bc1a379021017a841bc6a2f6afe03c6eb8040f (patch)
treef7984d7bf1578fbf7206f37da8a2262a47aab6ce /servers
parent03ec5d7005067517d608b4f5328675b9a0e17486 (diff)
Automatically use negative mipmap LOD bias when TAA and/or FXAA are enabled
This improves texture sharpness when TAA and/or FXAA are enabled, without requiring manual user intervention.
Diffstat (limited to 'servers')
-rw-r--r--servers/rendering/renderer_rd/renderer_scene_render_rd.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp
index d8499681ad..b8e74683de 100644
--- a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp
+++ b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp
@@ -2459,6 +2459,19 @@ void RendererSceneRenderRD::render_buffers_configure(RID p_render_buffers, RID p
p_internal_width = p_width;
}
+ if (p_use_taa) {
+ // Use negative mipmap LOD bias when TAA is enabled to compensate for loss of sharpness.
+ // This restores sharpness in still images to be roughly at the same level as without TAA,
+ // but moving scenes will still be blurrier.
+ p_texture_mipmap_bias -= 0.5;
+ }
+
+ if (p_screen_space_aa == RS::VIEWPORT_SCREEN_SPACE_AA_FXAA) {
+ // Use negative mipmap LOD bias when FXAA is enabled to compensate for loss of sharpness.
+ // If both TAA and FXAA are enabled, combine their negative LOD biases together.
+ p_texture_mipmap_bias -= 0.25;
+ }
+
material_storage->sampler_rd_configure_custom(p_texture_mipmap_bias);
update_uniform_sets();