TripleOneGames wrote:Okay, so this question is probably a bit advanced. I'm looking for a way to rotate a mesh around the object origin's Y axis using vertex offset while preserving normals. I need to preserve normals so that the metallic object reflects the environment accurately.
The reason is for optimized performance. I have quite a few coins in my scene in Unity that are always rotating. I'm not sure if I would get a performance boost by using the shader instead of just rotating the objects transforms. Is there a node for this, or am I going to have to do some trigonometry (I'm only "pretty good" at math at math)? I've searched the internet and found nothing really useful. Any help or tips are appreciated.
Hello TripleOneGames, thank you for getting in touch and for your support!
We don't have a specific node for rotating a mesh, but we're sharing a simple shader sample as an attachment to this post that shows how this can be achieved, for your convenience.
There is a limitation though, when reshaping your mesh using Vertex Offset, the normal direction of the surface will not follow along. This is simply because normals are stored in the mesh, and not computed in real-time.
It's not an easy task to recalculate Normals on a vertex shader because you need to have vertex neighbor information to fully calculate the new normal vector which is something you only have on a geometry shader.
There are a couple of ways to overcome this, you can check
this post which does it by calculating a new binormal and tangent vectors, or our included sample: AmplifyShaderEditor/Examples/Official/VertexNormalReconstruction
Let us know if this information was useful and if you have any further questions, we'll be happy to help!