World Position Offset Mesh Face Rotation?

materials
unreal-engine
world-position-offse

#1

world%20position%20offset

In unreal engine i am using world position offset for this effect and i am facing 2 problems one is faces of mesh are stretching and second is i want to rotation each face on its pivot randomly.


#2

You’re gonna have loads of problem with that. In shader, unless you baked some info on your mesh somewhere position are vertex positions. Not faces. And since vertex shader typically execute on a vert per vert basis, they won’t know about the 2 other verts for a given triangle.

Your options are to bake some fake per face pivots on vertex data (like uvs or very color or something) and operate logic on that fake pivot. Basically need to compute a transform matrix, apply said matrix to fake pivot, then use baked vert data to follow newly transformed fake pivot.

Or to bake your animation using some vertex texture animal pipeline.

Otherwise you’ll just hit a wall trying to keep faces together and uniform.

Also a side note, world position offset is in world space, but position in the shader stack are local. So the stretching is likely because you are missing a space conversion.


#3

What Mederic said. You’ll want to bake the centroids to the vertex colors or UV channels.
See http://tech-artists.org/t/gdc-2019-tech-art-bootcamp-presentations/11094 (Ryan Brucks’ presentation) and https://docs.unrealengine.com/en-US/Engine/Content/Tools/PivotPainter/PivotPainter2
Those links won’t solve your problem specifically, but they’re related so it might shed some light on how to approach this