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

Question How to add a world-scale effect to a pixel-sized material?

Discussion in 'Shader Graph' started by Nicksaccount, Aug 6, 2020.

  1. Nicksaccount

    Nicksaccount

    Joined:
    Jan 10, 2013
    Posts:
    24
    Hi there,

    I've got a material that's only a few pixels big and I want to add a procedural dirtying effect to it using shader graph. I've got close, but I need it to apply along the mesh's normals, whereas it looks like it's currently applying from a single, fixed direction.

    My shader graph is:

    shader_graph.png

    The "Normal Vector" and "Screen Position" are left over from failed tests. The closest I've got it working is with "Position" and either "Object" or "World" space. I'm looking at applying this dotted pattern for now, and I can get it looking like the following:

    Annotation 2020-08-06 005129.png

    This shows that on one side of the mesh it's working fine(ish), but on another side it's infinitely stretched.

    Any ideas on how to get it to apply correctly to all sides of the mesh?

    Thanks!
     
  2. melos_han_tani

    melos_han_tani

    Joined:
    Jan 11, 2018
    Posts:
    77
    The texture is stretching on the sides because you're sampling the Voronoi texture using only the XY world coordinates, so it's sort of like how one of the textures in this animation is overlaying.



    You could try using the Triplanar Node to sample the voronoi texture (triplanar refers to how the image above uses three planes to texture an object without UVs: https://docs.unity3d.com/Packages/com.unity.shadergraph@6.9/manual/Triplanar-Node.html

    Or, you could use the object's UV1s to sample the voronoi texture, maybe...? Not sure.
     
    Nicksaccount likes this.
  3. Nicksaccount

    Nicksaccount

    Joined:
    Jan 10, 2013
    Posts:
    24
    Huge thanks for posting this. It easily explains where I was going wrong originally.

    Don't suppose you know how I'd get a Voronoi node into a triplanar node? :) The triplanar node takes an input of Texture and I can only see 1 node with an output of Texture, and that's one where you specify a Texture. There doesn't appear to be any node that can convert that for me.