-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
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
Support vertex tangents #15692
Comments
Please see if you can get the OP to provide an example with a plane only. |
OP here. |
threejs does compute tangents in the shader, ignoring custom tangents in the model, yes. I'm not sure how to isolate whether that is the cause... omitting the tangents, will babylonjs still render correctly? |
When I delete the tangent attribute, it introduces some color variance on the cube faces but the result still looks much "flatter" compared to three.js (see image below). Looking at the three.js code, it doesn't look like the algorithm for generating tangents corresponds to the Mikktspace algorithm prescribed by GLTF spec (in case tangents are not present). Specifically, in Three.js, tangents seem to be completely independent on vertex normals which would explain the results from above. If that's the case, the best solution would be to add support for tangent attribute to Three.js otherwise it would be rather challenging to use GLTF normal mapping. |
Yes. three.js ignores attribute tangents. |
Related: #15428 |
Yeah, seems to be the same issues (tangents nor propagated to Three.js from GLTF and Three.js not using tangents attached to the geometry). It would be nice if this could get fixed to make three.js GLTF compliant. |
I have a branch (dev...donmccurdy:feat-attribute-tangents-v2) that appears to be working. The DamagedHelmet example (it had similar issues in the past, which we solved differently) looks fine as well. But it will take some time to test this change more thoroughly, and at the moment I don't have much bandwidth, so it could be a while before I can get to a PR.
|
Vertex tangents are 4-component, no? It appears you are treating them as 3-component. |
@WestLangley see the table under the glTF • Meshes section – the |
I would say the matrix depends on Since your However it is typically done is fine... And thanks for this! :-) |
Thanks Don and everyone else for adding this feature so quickly! |
via @ondys –
A simple cube mode with normal map that simulates flat shading:
normal_map_flat-20190201T224012Z-001.zip
The cube has smooth geometry normals (no normal seams on cube edges) + a normal map that simulates flat shading.
Babylon.js rendering seems to work correctly but three.js produces a weird looking result (cesium viewer also seem to work correctly)
For comparison, if normal map is set to a constant value (128, 128, 255), the resulting geometry is smooth for both three.js and babylon.js:
Cube with constant normal map is here:
normal_map_smooth-20190201T224029Z-001.zip
The text was updated successfully, but these errors were encountered: