Skip to content

Add an import option to correct a heightmap texture's baseline or normalize it#100226

Open
Calinou wants to merge 1 commit into
godotengine:masterfrom
Calinou:import-detect-heightmap-textures
Open

Add an import option to correct a heightmap texture's baseline or normalize it#100226
Calinou wants to merge 1 commit into
godotengine:masterfrom
Calinou:import-detect-heightmap-textures

Conversation

@Calinou
Copy link
Copy Markdown
Member

@Calinou Calinou commented Dec 9, 2024

Automatic detection is implemented in the BaseMaterial3D shader. It can be integrated in custom shaders by adding hint_height to the relevant sampler uniforms or setting the texture mode to Height Map in VisualShaderNodeTextureParameter.

When a texture is detected to be used as a heightmap, it'll switch to the Correct Baseline mode automatically, which reduces parallax issues without requiring manual adjustments to the heightmap scale.

If you want to further improve quality (or reduce the number of deep parallax steps without impacting quality), you can use the Normalized mode which requires adjusting the heightmap scale used in the material. When doing so, the required heightmap scale multiplier is printed on import so you can get the same effective heightmap scale as before.

Testing project: test_texture_heightmap.zip

Preview

Watch in fullscreen to better spot the differences.

Disabled vs Correct Baseline

Left: Disabled, Right: Correct Baseline

Notice how there's less visible "warping" on the right as the camera moves.

disabled_vs_correct_baseline.mp4

Correct Baseline vs Normalized

Left: Correct Baseline, Right: Normalized

Pause the video in front of the bricks; notice how there are fewer stairstepping artifacts on the right.

correct_baseline_vs_normalized.mp4

@Calinou Calinou added this to the 4.x milestone Dec 9, 2024
@Calinou Calinou requested review from a team as code owners December 9, 2024 23:51
@Calinou Calinou force-pushed the import-detect-heightmap-textures branch 4 times, most recently from 5bf47cd to 57bbd9f Compare December 12, 2024 22:02
@Calinou Calinou force-pushed the import-detect-heightmap-textures branch from 57bbd9f to 480dc44 Compare July 1, 2025 18:09
@Repiteo Repiteo requested a review from a team as a code owner February 17, 2026 20:10
@Nintorch Nintorch removed request for a team March 5, 2026 16:13
@Calinou Calinou force-pushed the import-detect-heightmap-textures branch from 480dc44 to 861eb4a Compare May 20, 2026 23:13
@Calinou Calinou requested a review from a team as a code owner May 20, 2026 23:13
@fire
Copy link
Copy Markdown
Member

fire commented May 21, 2026

Do you need asset pipeline team approval or rendering team for this?

@akien-mga
Copy link
Copy Markdown
Member

Both.

Comment thread doc/classes/ResourceImporterTexture.xml Outdated
@QbieShay
Copy link
Copy Markdown
Contributor

While I can understand the rationale behind this, I'm concerned this touches a lot of the rendering, and ti adds an hint, hint height, which does operations on a texture and changes a texture type.

The most common usage for height maps imo is not parallax but generic heightmaps to displace mesh vertices. If this feature is specifically for parallax, it should be called parallax and not generic height.

I would like to understand a bit more the demand for the feature. I know it's common for engine devs to talk to devs behind the scenes and bring forth their proposal, but I don't see this as a common usecase to warrant the added complexity. Of course what I see is partial and I'm happy to be corrected :)

I wonder whether fixing textures from polyheaven is what we should be looking at. We should probably look into quixel's library and talk with rodzilla, material maker's author, and see how this work with substance painter textures. Chances are polyheaven is not our largest userbase.

…malize it

Automatic detection is implemented in the BaseMaterial3D shader.
It can be integrated in custom shaders by adding `hint_height` to the relevant
sampler uniforms or setting the texture mode to Height Map
in VisualShaderNodeTextureParameter.

When a texture is detected to be used as a heightmap, it'll switch to
the Correct Baseline mode automatically, which reduces parallax issues
without requiring manual adjustments to the heightmap scale.

If you want to further improve quality (or reduce the number of deep
parallax steps without impacting quality), you can use the Normalized
mode which requires adjusting the heightmap scale used in the material.
When doing so, the required heightmap scale multiplier is printed
on import so you can get the same effective heightmap scale as before.
@Calinou Calinou force-pushed the import-detect-heightmap-textures branch from 861eb4a to 1ef48c8 Compare June 4, 2026 01:18
@Calinou
Copy link
Copy Markdown
Member Author

Calinou commented Jun 4, 2026

The most common usage for height maps imo is not parallax but generic heightmaps to displace mesh vertices. If this feature is specifically for parallax, it should be called parallax and not generic height.

This feature is meant to work with Godot's own parallax mapping specifically, rather than terrain textures imported as heightmaps. I suppose I could rename the hint to hint_parallax to make this clearer. That said, Godot's height mapping functionality is called height in BaseMaterial3D, and the feature is still relevant and improves visuals even if you have height_deep_parallax disabled.

I wonder whether fixing textures from polyheaven is what we should be looking at. We should probably look into quixel's library and talk with rodzilla, material maker's author, and see how this work with substance painter textures. Chances are polyheaven is not our largest userbase.

This PR works with any texture source, but some sources are more impacted by this issue than others.

However, like many things in 3D art, the problem this PR resolves is a difficult thing to initially become aware of. I've seen many reports of poor parallax mapping quality with users not knowing why their POM materials don't look as good as it could, or users increasing the deep parallax layer count to 64 (which is very expensive), while they could just have modified the heightmap texture instead to improve quality.

Speaking of experience, it took me several years to realize that stretching the range of the heightmap texture improves parallax quality and ensures the material doesn't distort more than needed when the camera moves.

While the documentation already mentions this subject briefly, we could further improve the documentation to show some examples of good parallax maps. We could also document how to correct existing suboptimal parallax maps (possibly using an ImageMagick command - I couldn't figure out a one-stop way to do it in GIMP).

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.

Add an import option that corrects material heightmaps to reduce visible distortion without affecting their scale

5 participants