How to get instanced mesh local normal in material
I'm trying to get local normal per instanced static mesh in the material.
I've managed to get position, orientation and scale using the Object nodes and passing them through VertexInterpolator, so they're calculated in the vertex shader. The only one that didn't work was the ObjectOrientation node. But I can get the same result by passing a (0,0,1) vector to a TransformVector(Local to World) and then to the VertexInterpolator*.
But no matter what I do, I can't get any vector transformed from World to Local space nor Tangent to Local. See the setup below:
For standard Static Meshes, it works with any of the TransformVector nodes connected. For instanced, though, it doesn't work either way!
Here's an example:
The left cylinder is an instanced mesh and the right one is a standard StaticMeshActor. Both using the same material. The StaticMeshActor (right) correctly displays its local normals, displaying as blue what would be its top side. But the instanced one doesn't, fading to blue on its world space top faces.
How can I do it? I'm almost thinking this is a bug.
asked Sep 16 '17 at 12:49 PM in Rendering
Generally, this behavior of TransformVector material expression is unintended. It should provide proper per-instance transform when used in vertex shader. It can be filed as bug report in a relative section.
For a workaround ou might want to try using custom node like that:
With the following code:
Again, it needs to be passed through vertex interpolator, otherwise compile error will be thrown.
answered Sep 16 '17 at 01:39 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here