Id' like to create impression of shaking holographic image of NPC in Unity 2018, but moving it with transform will cause unnecesary transform-rigidbody syncing, and using Rigodbody.position isn't an option for other reasons (too long to explain). I could write custom shader for moving vertices by given vector, but I'd like to keep flexibility of Standard Shader.

Is there any way to properly render object at different position than it's transform.position? I was thinking about passing custom matrix to shader, but not sure which matrix should I overwrite and if it's not gonna complicate things (like break shadows or something).


Yes, you have several options here:

  • Use Graphics.DrawMesh (or one of its variants) to manually submit a drawing call, without a renderer component at all. You can provide your own position & orientation or matrix to control exactly where it's rendered, independent of any transforms. The mesh you draw this way can still cast & receive shadows from the given position & orientation.

  • Use a Surface Shader, or a modified copy of the Standard Shader source (under Downloads -> Built in shaders), make a shader that both has your position offset effect and has the flexibility of the Standard Shader.

  • Place the Renderer into a nested transform, under the Rigidbody, with no Colliders attached to this Renderer object or its children. Then you can move it with impunity without impacting the physics, since it's strictly a display object. I use this trick to animate my dominos' wiggly walk cycles in Last One Standing while their physics stays smooth.

  • \$\begingroup\$ Last option seems to suit my needs, I'll give it a try. I'm not sure about modifying Standard Shader, since AFAIK Unity uses some special optimizations for standard shader (cuting out unused properties or something). \$\endgroup\$
    – dargemir
    Aug 19 '18 at 12:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.