Page 1 of 1

Help using vertex offset

PostPosted: Wed Jan 09, 2019 3:07 pm
by noeinz
Hello Amplify,

I have a shader here that is supposed to collapse towards a reference point, like a worm hole. So far I have the vertex offset pulling towards the point properly and the collapse happens but the numbers go beyond 1 and it starts inverting the collapse of the mesh. I cannot figure out how to collapse towards the object and stay collapsed without inverting.

Here is my node setup

Image

Image

I am trying to recreate this shader from this post:
https://deepspacebanana.github.io/deeps ... der-Effect

Image

Re: Help using vertex offset

PostPosted: Thu Jan 10, 2019 10:18 am
by Amplify_Borba
Hello, thank you for getting in touch and for your support!

The example you posted roughly translates to this:

Image

The float values will have to be tweaked specifically for Unity, and the _Position global variable is receiving the transform position of the orbiting sphere through a script that is attached to it:

Code: Select all
[ExecuteInEditMode]
public class Test : MonoBehaviour
{
    public Renderer Renderer = null;

    private Material m_instancedMaterial;
    private Material InstancedMaterial
    {
        get { return m_instancedMaterial; }
        set { m_instancedMaterial = value; }
    }

    private void Awake()
    {
        InstancedMaterial = Renderer.material;
    }

    // Update is called once per frame
    void Update()
    {
        InstancedMaterial.SetVector("_Position", transform.position);
    }
}


On the Renderer parameter in the inspector of this script you'll have to drag the other sphere, which has the shader assigned to it.

Image

Please let me know if this helps!

Re: Help using vertex offset

PostPosted: Thu Jan 10, 2019 2:11 pm
by noeinz
Thank you so much. It works! :mrgreen:

I feel like I had this answer but I missed some combination in my setup. Maybe I had the nodes hooked up wrong in the lerp.

Re: Help using vertex offset

PostPosted: Thu Jan 10, 2019 3:56 pm
by Amplify_Borba
No worries, glad I was able to help!

Have you had the chance to rate and review Amplify Shader Editor? It would be awesome if you could share your experience with the Unity community, every bit helps and your feedback is extremely valuable to us.

Feel free to get back in touch if you have further issues or questions, thanks!