Open Robpayot opened 1 month ago
Sorry I reopened it because I found a fix for InstancedMesh using normalLocal.assign()
but not for BatchedMesh it still doesn't work
I added a jsfiddle example here, I hope this can help: https://jsfiddle.net/dfw7hroL/
You can see here the lighting is broken when I use my custom vertexNode (I used a directionnal light), if I comment this line : material.vertexNode = customVertexNode
the light is fixed
I found a fix using const varNormalLocal = varying(vec3(0))
, then I assign the normalLocal
to it in the vertexNode, and just apply it to the material.normalNode = transformNormalToView(varNormalLocal)
. It seems to work now, here is an example:
When adding a point light to the scene, the lights seems totally broken again : https://jsfiddle.net/oc0gkyqa/8/
@Makio64 To handle lights you also need to update the positionView accodingly: positionView.assign(transformed)
.
@Makio64 To handle lights you also need to update the positionView accodingly:
positionView.assign(transformed)
.
@RenaudRohlinger Merci! This was bugging me so hard! 🙇♂️
Description
I'm using TSL with a MeshStandardNodeMaterial on a BatchedMesh. I have a custom vertexNode reusing the logic of BatchNode so I can apply custom bending effect on it later on.
However when doing that the lights of my BatchedMesh are broken (not in the correct direction). When I remove the vertexNode (using the default shader) it fixes it.
Does it mean the vertexNode is overwriting the normalLocal so the fragment doesn't have the correct vNormals anymore? but weirdly I have the normalLocal assigned.
Does it also mean if I want to customise the fragment part I will have to rewrite the whole StandardNodeMaterial fragment shader in the outputNode to get the lights right?
Thank you
Reproduction steps
Code
Version
0.168.0