Skip to content

Conversation

@Calinou
Copy link
Member

@Calinou Calinou commented Mar 25, 2025

This improves the realism of reflections when box projection is enabled. This works by scaling the roughness according to the hit distance between the bounds of the reflection and the fragment being shaded.

Additionally, this makes reflection sampling in Compatibility use the same perceptual roughness formula (sqrt(roughness)) as Forward+/Mobile for better visual consistency.

Testing project: test_improved_box_projected_reflections.zip
Press B to toggle box projection.

Preview

Forward+

Before After
Image Image

Videos with varying roughness:

Before

roughness_before_forward_plus.mp4

After

There's a stretching effect that occurs (also without this PR) and becomes more noticeable at higher roughness values. It does not occur when using Compatibility, despite the code changes between both renderers being the same. I don't know why this is happening. (Is this an approximation of anisotropy that's not present in Compatibility?)

roughness_after_forward_plus.mp4

Mobile

Before After
Image Image

Compatibility

Roughness before this PR wasn't using the perceptual roughness formula (sqrt(roughness)), so it appeared to be too low compared to other renderers. Was this intentional? cc @BastiaanOlij

Before After
Image Image

Videos with varying roughness:

Before

roughness_before_compatibility.mp4

After

roughness_after_compatibility.mp4

…ojection is used

This improves the realism of reflections when box projection is enabled.
This works by scaling the roughness according to the hit distance
between the bounds of the reflection and the fragment being shaded.
@Calinou Calinou added this to the 4.x milestone Mar 25, 2025
@Calinou Calinou requested a review from a team as a code owner March 25, 2025 00:09
@michaelharmonart

This comment was marked as outdated.

@Calinou

This comment was marked as resolved.

@lander-vr
Copy link
Contributor

lander-vr commented May 9, 2025

Nice! I'm really happy to see this!

There is an issue that makes materials look less rough than they should appear.

Master This PR
image image
SSR Ground truth (Cycles)
image image

@lander-vr
Copy link
Contributor

lander-vr commented May 10, 2025

Apologies for my many substantial edits, in case you've read this comment before.

I removed my previous concerns, because my assumptions there were incorrect. However, there are definitely a few issues with the approach.

The calculation of distance_to_hit_point seems incorrect:

Reflections are relative to the viewer, but the mipmap selection is done based on the world position distance between the reflection surface and reflected pixel. This creates an effect of the mip selection being "glued" to surfaces. In the following comparison to Cycles we see that reflection roughness is relative to the viewer. I'm not sure if this is just the effect of reducing roughness based on fresnel, or if there's something more complex happening.

PR + reflection probe stretching fix:

25_05_10_16_29__godot.windows.editor.x86_64_ldqEkxNBsz.mp4

Cycles:

25_05_10_16_30__blender_3oRiyR4p72.mp4
PR + stretching fix Cycles
image image
image image

The result of not taking in account the viewer distance is too sharp reflections nearby, and too rough reflections when far away.

I'm unsure that we're applying fresnel correctly from refprobes. We seem to have way too strong reflections at perpendicular viewing angles:

PR + reflection probe stretching fix:

image

Cycles:

image

It also doesn't seem to handle fully rough surfaces entirely correctly:

image image

I also think it would be worth considering a different sampler if possible, the linear sampling makes pixels in reflections very obvious. I suspect cubic would work/look much much better for reflections, especially with this contact hardening.

@Calinou
Copy link
Member Author

Calinou commented Nov 4, 2025

@Calinou Calinou closed this Nov 4, 2025
@Calinou Calinou removed this from the 4.x milestone Nov 4, 2025
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.

Improve ReflectionProbe sampling on semi-rough materials to use realistic falloff according to object <-> reflection distance

3 participants