Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GLTFLoader: Flip normalScale without tangents. #18112

Merged
merged 3 commits into from
Dec 20, 2019
Merged

Conversation

elalish
Copy link
Contributor

@elalish elalish commented Dec 10, 2019

Fixes #11438

After reading this comment I applied this change to model-viewer. It appears to be the right change, given all the models I've seen. I think it also makes sense given the chain rule explanation given in that thread as well.

@mrdoob mrdoob requested a review from donmccurdy December 10, 2019 01:27
@mrdoob mrdoob added this to the r112 milestone Dec 10, 2019
@WestLangley
Copy link
Collaborator

I think it also makes sense given the chain rule explanation given in that thread as well.

I assume you are referring to this?

@elalish
Copy link
Contributor Author

elalish commented Dec 10, 2019

@WestLangley Indeed, much appreciated!

@Mugen87 Mugen87 changed the title flip normalScale without tangents GLTFLoader: Flip normalScale without tangents. Dec 16, 2019
@@ -2262,6 +2262,14 @@ THREE.GLTFLoader = ( function () {

if ( materialDef.name !== undefined ) material.name = materialDef.name;

// Normal map textures use OpenGL conventions:
// https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#materialnormaltexture
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am not sure that comment explains the ensuing code block...

Maybe referencing #11438 (comment) would be OK?

@mrdoob
Copy link
Owner

mrdoob commented Dec 17, 2019

/ping @donmccurdy


material.normalScale.y = - material.normalScale.y;

}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you check that this is OK on a model with vertexTangents? Note that we're in the loadMaterial method here, and .vertexTangents wouldn't be set until later, in the assignFinalMaterial method, when we have access to the mesh and can confirm whether it has tangents. I think the change will need to be moved there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed, found the repro with your shoe.glb. Moved and verified the fix. Thanks!

@mrdoob mrdoob merged commit b4d2be0 into mrdoob:dev Dec 20, 2019
@mrdoob
Copy link
Owner

mrdoob commented Dec 20, 2019

Thanks!

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.

GLTFLoader: Normal-Tangent Test model result is incorrect
4 participants