Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Could tweening potentially be done in shaders?

Discussion in 'Shaders' started by MadeFromPolygons, Apr 20, 2018.

  1. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,877
    Could tweening of position and rotation be done in shaders?

    As in:

    I know I can do the actual tween as in affect the position rotation etc of vertex's, normals, whatever I want.

    What I don't know is, is there a limit to how far from the original position the object could go?

    Trying to think of a high performance way to do tweens and affecting a shader property would be a great way. They don't need collisions when tweening.

    In my mind, it is perfectly possible by getting the world space positions of everything and offsetting that based on the amount needed?
     
  2. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,877
    I wrote this already. Did a matrix transformation per needed transformation type.
     
  3. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    635
    There's a lot of way to do vertex tweening, or animation. A nice one is to use an "animation texture" sampled by vertex to deform them.
    But yes, simple tweening by matrix is possible (imagine also storing a matrix animation in a 16xwhatever px texture). Just keep in mind that the object is still culled by the camera depending of it's bounds, that are not modified by the vertex shader.
    And finally, depending of your target platform, tweening by script is maybe still optimal (no need to deform in the vertex shader) ?
     
  4. Invertex

    Invertex

    Joined:
    Nov 7, 2013
    Posts:
    1,495
  5. andbc

    andbc

    Joined:
    Jan 25, 2014
    Posts:
    18