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

[3.x] Add a project setting to control the minimum ReflectionProbe roughness #49972

Open
wants to merge 1 commit into
base: 3.x
Choose a base branch
from

Conversation

Calinou
Copy link
Member

@Calinou Calinou commented Jun 28, 2021

This can be used as a form of antialiasing with very little performance cost.

The default value removes almost all aliasing present in ReflectionProbes while still keeping reflections fairly sharp for real world use cases.

I could only get it working in GLES3, so the feature is limited to GLES3. The default value for the minimum roughness is 0.05 and can be changed at run-time.

This closes #49789.

Preview

Reflective materials have Roughness = 0, Metallic = 1.

Before (Min Roughness = 0.0)

Before

After (Min Roughness = 0.05)

After

This can be used as a form of antialiasing with very little performance cost.

The default value removes almost all aliasing present in ReflectionProbes
while still keeping reflections fairly sharp for real world use cases.
@clayjohn
Copy link
Member

How does this compare to just setting the material's roughness to 0.05?

Also, I'm a little confused about why this works, for the top level mipmap, the shader uses "USE_DIRECT_WRITE" and just copies the cubemap without blurring based on roughness

#ifdef USE_DIRECT_WRITE
#ifdef USE_SOURCE_PANORAMA
frag_color = vec4(texturePanorama(N, source_panorama, 0.0).rgb, 1.0);
#endif
#ifdef USE_SOURCE_DUAL_PARABOLOID_ARRAY
frag_color = vec4(textureDualParaboloidArray(N).rgb, 1.0);
#endif
#ifdef USE_SOURCE_DUAL_PARABOLOID
frag_color = vec4(textureDualParaboloid(N).rgb, 1.0);
#endif
#if !defined(USE_SOURCE_DUAL_PARABOLOID_ARRAY) && !defined(USE_SOURCE_PANORAMA) && !defined(USE_SOURCE_DUAL_PARABOLOID)
N.y = -N.y;
frag_color = vec4(texture(N, source_cube).rgb, 1.0);
#endif
#else // USE_DIRECT_WRITE

For the higher levels, roughness should already be greater than 0.05.

@Calinou
Copy link
Member Author

Calinou commented Jun 29, 2021

How does this compare to just setting the material's roughness to 0.05?

You don't need to edit any existing materials, and the rest of roughness calculations (such as light energy conservation) is not affected. While this is physically incorrect, it results in better usability for people who generally just set roughness to 0 on materials they expect to be fully reflective.

Also, I'm a little confused about why this works, for the top level mipmap, the shader uses "USE_DIRECT_WRITE" and just copies the cubemap without blurring based on roughness

I'm also not sure how it's working as intended.

@akien-mga akien-mga modified the milestones: 3.4, 3.5 Nov 8, 2021
@akien-mga akien-mga modified the milestones: 3.5, 3.x Jul 3, 2022
@Calinou Calinou changed the title Add a project setting to control the minimum ReflectionProbe roughness [3.x] Add a project setting to control the minimum ReflectionProbe roughness Jun 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants