Skip to content

DecalGeometry: Transform normal with normal matrix#29476

Merged
Mugen87 merged 2 commits into
mrdoob:devfrom
WestLangley:dev-decals
Sep 24, 2024
Merged

DecalGeometry: Transform normal with normal matrix#29476
Mugen87 merged 2 commits into
mrdoob:devfrom
WestLangley:dev-decals

Conversation

@WestLangley
Copy link
Copy Markdown
Collaborator

transformDirection() should not be applied to normal vectors, unless under certain conditions. The normal map should be applied, instead.

@WestLangley WestLangley added this to the r169 milestone Sep 23, 2024
@WestLangley
Copy link
Copy Markdown
Collaborator Author

Related: Is there a reason decals are added to the scene in webgl_decals.html, instead of to the mesh to which they are applied?

Currently, if the mesh is rotated, the decals do not.

@Mugen87
Copy link
Copy Markdown
Collaborator

Mugen87 commented Sep 23, 2024

In webgl_decals, transformDirection() is also used in checkIntersection() to transform normals. Does it make sense to update this code as well?

n.transformDirection( mesh.matrixWorld );

@Mugen87
Copy link
Copy Markdown
Collaborator

Mugen87 commented Sep 23, 2024

Is there a reason decals are added to the scene in webgl_decals.html, instead of to the mesh to which they are applied?

Not that I am aware of. It would seem more natural to add the decals to the logical parent object.

@Mugen87 Mugen87 merged commit 8f765f9 into mrdoob:dev Sep 24, 2024
@WestLangley WestLangley deleted the dev-decals branch September 24, 2024 16:42
@WestLangley
Copy link
Copy Markdown
Collaborator Author

@Mugen87 Doing mesh.attach( decal ) instead of scene.add( decal ) works well, although .attach() only supports a uniformly-scaled parent mesh (the case here). Do you think such a change to the example is worth it?

@Mugen87
Copy link
Copy Markdown
Collaborator

Mugen87 commented Sep 24, 2024

Yes, using attach() looks like a nicer workflow.

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