Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vulkan Clustered: ReflectionProbe roughness is affected by global Texture Mipmap Bias #65690

Closed
Tracked by #66628 ...
BraqueDown opened this issue Sep 12, 2022 · 8 comments · Fixed by #84637
Closed
Tracked by #66628 ...

Comments

@BraqueDown
Copy link

Godot version

v4.0.alpha.custom_build [baded9f]

System information

Windows 10, Vulkan Clustered, Ryzen R5 3600, RTX 3070 (512.15)

Issue description

Enabling FXAA or TAA, or lowering the viewport's resolution scale causes reflections created by ReflectionProbes to reduce in apparent roughness. The size of the viewport itself doesn't affect anything. Also, raising resolution scaling above 1.0 doesn't affect it either.

ReflectionProbe.Scaling.mp4

This does not affect the size of the specular lobe, nor does it affect reflections from VoxelGI, SDFGI, or the sky cubemap.

This issue does not occur on the Vulkan Mobile backend.

Steps to reproduce

  1. Add a mesh and apply a metallic material, and raise it's roughness.
  2. Open the project settings and toggle either FXAA or TAA, and reduce resolution scaling below 1.0.

or download attached MRP and hit Play (F5).

Minimal reproduction project

ReflectionProbe Scaling Roughness Bug.zip

@Chaosus
Copy link
Member

Chaosus commented Sep 12, 2022

сс @Calinou

@Calinou
Copy link
Member

Calinou commented Sep 12, 2022

It looks like FXAA and TAA affect rendering within the reflection probes, but this may be intended to improve reflection smoothness. It does look strange on higher roughness values, but that's the price to pay to avoid aliasing in low-roughness reflections. See also #49789.

On the other hand, not using FXAA/TAA within reflection probe rendering should speed up their rendering noticeably, with only a small decrease in quality in low-roughness reflections. This also applies to some other tonemapping effects, such as debanding. Disabling them within reflections may be a better tradeoff if possible.

The resolution scale issue may not be caused by resolution scale itself, but by very low 3D buffer resolutions instead. See also #64683.

This issue does not occur on the Vulkan Mobile backend.

Vulkan Mobile doesn't support TAA, and FXAA may not be working either.

@BraqueDown
Copy link
Author

It looks like FXAA and TAA affect rendering within the reflection probes, but this may be intended to improve reflection smoothness. It does look strange on higher roughness values, but that's the price to pay to avoid aliasing in low-roughness reflections.

I think you may be misunderstanding my issue. Toggling FXAA and TAA does not (to my knowledge) cause ReflectionProbes to rebuild, and that should only affect in-cubemap aliasing (and of course texture aliasing as a result of how cubemapped surfaces are rendered).

The problem here is that these effects are changing the way that the roughness mipmaps are being blended. When the effects are on (or the res-scale is reduced), ReflectionProbe reflections act as though the surfaces they are rendering on have decreased in roughness.

image
Metallic surface with 0.5 roughness, Post-AA disabled

image
Same surface, Post-AA enabled. The previous mipmap level is clearly fading out to the next one up.


The resolution scale issue may not be caused by resolution scale itself, but by very low 3D buffer resolutions instead.

I'm not sure what you mean by this?

Vulkan Mobile doesn't support TAA, and FXAA may not be working either.

I'm aware TAA isn't supported on mobile, and indeed FXAA doesn't seem to be working either. But the res-scale slider still works just fine on the mobile backend (on my desktop at least), and this issue still doesn't occur there.

@Calinou
Copy link
Member

Calinou commented Sep 12, 2022

I'm not sure what you mean by this?

When using a low resolution scale on a low-resolution viewport (e.g. in a small window), the final 3D buffer size will be very small (around 240p). It's difficult to properly generate reflection probe mipmaps at such a low size.

@BraqueDown
Copy link
Author

BraqueDown commented Sep 12, 2022

Why would ReflectionProbe resolution depend on the viewport resolution? ReflectionProbes have their own project setting that determines their resolution.

EDIT: I did a quick test, and building the cubemaps at 0.25 viewport scaling in project settings indeed has no effect on the cubemap resolution, but does have a minor effect on the appearance of the ground texture (mipmapping? AF?)

image
Scene reloaded with scaling at 0.25

image
Scene reloaded with scaling at 1.00

@Calinou Calinou changed the title [Vulkan Clustered] Resolution Scale and Post-AA affect ReflectionProbe roughness Vulkan Clustered: Resolution Scale and FXAA or TAA affect ReflectionProbe roughness Dec 2, 2022
@BraqueDown
Copy link
Author

By happenstance, I messed with the Texture Mipmap Bias setting in another project and noticed that it also affects the mips of ReflectionProbes.

Lo and behold the tooltip flat out states that this is the cause of the problem:
image

These auto-offsets for FXAA/TAA and viewport scaling were implemented in #64223 and #64225, both by @Calinou, so it's very funny that they didn't realise.

@BraqueDown BraqueDown changed the title Vulkan Clustered: Resolution Scale and FXAA or TAA affect ReflectionProbe roughness Vulkan Clustered: ReflectionProbe roughness is affected by global Texture Mipmap Bias Dec 5, 2022
@Calinou
Copy link
Member

Calinou commented Dec 5, 2022

@BraqueDown Good catch 🙂

I think this can be fixed by using a different sampler for radiance cubemaps, one that does not take the mipmap LOD bias override into account:

specular_light = texture(samplerCubeArray(radiance_cubemap, material_samplers[SAMPLER_LINEAR_WITH_MIPMAPS_CLAMP]), vec4(ref_vec, lod)).rgb;
specular_light = mix(specular_light, texture(samplerCubeArray(radiance_cubemap, material_samplers[SAMPLER_LINEAR_WITH_MIPMAPS_CLAMP]), vec4(ref_vec, lod + 1)).rgb, blend);
#else
specular_light = textureLod(samplerCube(radiance_cubemap, material_samplers[SAMPLER_LINEAR_WITH_MIPMAPS_CLAMP]), ref_vec, sqrt(roughness) * MAX_ROUGHNESS_LOD).rgb;

The same change should be carried over elsewhere in the shader (e.g. for fog rendering), and in scene_forward_mobile.glsl.

@BraqueDown
Copy link
Author

On the subject of the mobile renderer, the bias slider doesn't seem to work when it's enabled, which would explain why this issue didn't occur there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants