Search Unity

Question How do I randomize the entire mesh by a single value, instead of multiple places on the mesh?

Discussion in 'Shader Graph' started by bunp, Jun 16, 2019.

  1. bunp

    bunp

    Joined:
    Feb 21, 2019
    Posts:
    70
    I have a 6x6 tile texture I want to grab random tiles from and apply to my mesh. My problem is all the methods to introduce randomness do it on a per-pixel basis, I want a per-object basis.

    How do I randomize my object's UV based on its position in space, but the position of the whole entire mesh, not trying to cause weird marbleizing patterns on the mesh.
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    You need some unique per mesh value to work from. As long as the mesh isn’t batched, you can use the world pivot position for the mesh.

    float3 objectPos = unity_ObjectToWorld._m30_m31_m32;

    Note, this is the Object node’s position value.
     
    Last edited: Jun 17, 2019