-
-
Notifications
You must be signed in to change notification settings - Fork 36.1k
NodeMaterial - Fix DoubleSided and BackSided NormalMap flipped #17584
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
Conversation
|
When opening your live link, the normal map still looks flipped. However, if I switched to |
|
@Mugen87 I forgot to define the default side, the default side is DoubleSided and not FrontSided. |
|
My issue is that apparently in non NodeMaterial too DoubleSided and FrontSided have different results rendering the front face only? |
|
I think that it should be
|
|
Seems that @bhouston explained better the cause here: |
|
@arobertson0 @Mugen87 Seems correct now? |
|
To test, remove the lid and bottom like so: teapot = new TeapotBufferGeometry( 15, 18, false, false );so you can see what is happening.
/ping @donmccurdy |
|
Hmm @WestLangley seems that BackSide issue in NodeMaterial is related with this: three.js/src/renderers/WebGLRenderer.js Line 2264 in 2d7c0b4
|
|
Maybe should be we move this to the shader? |
|
Anyway, this seems to fix DoubleSided fliped normal in front-face in core shader? |
|
Double-sided materials with a normal map are broken in the core shader. Breakage occurred in #17158 (confirmed). The breakage is easily-seen in var material = decalMaterial.clone();
material.side = THREE.DoubleSide; // add this/ping @JordyvanDortmont |
|
@sunag Whether the triangle is front-facing is a separate issue from whether the geometry and or UVs are mirrored. All we need is a test to replace |
I think it's better to have a single PR and use a uniform solution in @mrdoob Which one do you prefer? I suggest to update this PR with your desired solution and close #17586. |
|
I liked the PR of @WestLangley, I suggest merge the PR of @WestLangley first and after I fix any conflicts of this PR for NodeMaterial. |
|
@sunag Done! |
|
The approach used currently to BackSided is incompatible with NodeMaterial and a bit more hard to implement. I think in leave this fix to another PR. three.js/src/renderers/WebGLRenderer.js Line 2264 in 2d7c0b4
|
|
I'm sorry for breaking the normals for double-sided materials! I tested both PRs on a GTX 1070 and I see differences between the two PRs suggested. One is related to the While I was writing this, this PR has changed, so I'll describe the current behaviour of this PR. The normals are flipped for The normals flip when When the |
|
I was thinking of fix BackSided using shader, but with node seems easier... I will commit this fix. |
My live example is only for nodematerial, the core was fixed in WestLangley PR #17586. |
|
I think it is ready to merge? |
Looks great. As you said, this matches #17586. Thanks for the fix. |
|
Thanks! |
https://raw.githack.com/sunag/three.js/dev-node-sides/examples/webgl_materials_nodes.html
Fixes #17383