Skip to content

Fix stray pixel artifacts when BaseMaterial3D Deep Parallax is enabled#101551

Open
Calinou wants to merge 1 commit into
godotengine:masterfrom
Calinou:basematerial3d-height-deep-parallax-fix-stray-pixels
Open

Fix stray pixel artifacts when BaseMaterial3D Deep Parallax is enabled#101551
Calinou wants to merge 1 commit into
godotengine:masterfrom
Calinou:basematerial3d-height-deep-parallax-fix-stray-pixels

Conversation

@Calinou
Copy link
Copy Markdown
Member

@Calinou Calinou commented Jan 14, 2025

Mipmaps for the heightmap seem to cause issues with the parallax occlusion mapping algorithm used. This is most noticeable with steep height changes where surrounding pixels will occasionally appear depending on the view angle. This occurs regardless of the Min Layers and Max Layers values.

Note that there may be a better solution to this, such as sampling the heightmap texture differently (e.g. textureGrad()). This could result in better performance as mipmaps allow the GPU to sample a lower-resolution texture in the distance – however, for this to be beneficial, the different texture sampling method must not be more expensive than disabling mipmaps.

I found this issue (and the way to fix it) using https://github.com/Calinou/godot-rendering-tests' texture sampling test.

Edit: Xtarsia mentioned on the Godot VFX Discord that this could resolved in a more optimized way in Forward+/Mobile:

textureLod() for the heightmap read, rather than disabling mipmaps entirely?
1 call to textureQueryLod() before the loop should be sufficient. This is likley to be faster than no mipmaps at all?

Can fall back to textureLod(height_sampler, uv, 0.0) for Compatibility

Testing project: https://github.com/Calinou/godot-parallax-test-4.0

Preview

Before

parallax_before.mp4

After

parallax_after.mp4

@Calinou Calinou added this to the 4.4 milestone Jan 14, 2025
@Repiteo Repiteo modified the milestones: 4.4, 4.5 Feb 24, 2025
@Repiteo Repiteo modified the milestones: 4.5, 4.6 Sep 8, 2025
Mipmaps for the heightmap seem to cause issues with the parallax
occlusion mapping algorithm used.
@Calinou Calinou force-pushed the basematerial3d-height-deep-parallax-fix-stray-pixels branch from e9fe197 to 1702a12 Compare December 18, 2025 01:05
@akien-mga akien-mga modified the milestones: 4.6, 4.x Jan 13, 2026
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.

3 participants