Skip to content

Conversation

s-rigaud
Copy link
Contributor

Description

Add more details for the calculation of displacementMap.

@@ -141,7 +141,9 @@ <h3>[property:Float displacementScale]</h3>
<h3>[property:Float displacementBias]</h3>
<p>
The offset of the displacement map's values on the mesh's vertices.
Without a displacement map set, this value is not applied. Default is `0`.
Without a displacement map set, this value is not applied. The formula is
`position * displacementScale + displacementBias` so the bias is added
Copy link
Collaborator

@Mugen87 Mugen87 Feb 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid this isn't correct or at least irritating.

The sampled value from the displacement map is scaled with displacementScale and then displacementBias is added. The (transformed) position vector is then scaled along its object normal with the above offset.

TBH, I'm not sure users must know the process in that detail....

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well I add small trouble in my application because I first set up the bias to match my animation and then I had to find a good value again because I fine tune the scale. Was just a usage warning that could help the user.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about renaming position to displacementMap.x?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe just displacement scale is applied before displacement bias ? This way no formula needs to be displayed 🤔

Copy link
Collaborator

@Mugen87 Mugen87 Feb 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that both properties are applied differently. One is a scaling factor that is multiplied, the other one in some sense an offset that is added.

How about stating the bias is added to the scaled sample of the displacement map.

@s-rigaud s-rigaud force-pushed the doc-material-improve-displacementbias-description branch from 27f9d37 to 4ecd840 Compare February 20, 2025 14:26
@Mugen87 Mugen87 merged commit 09e9894 into mrdoob:dev Feb 20, 2025
3 checks passed
@Mugen87 Mugen87 added this to the r174 milestone Feb 20, 2025
@s-rigaud s-rigaud deleted the doc-material-improve-displacementbias-description branch February 26, 2025 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants