Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Question How to distribute a regularly spaced pattern across arbitrary geometry?

Discussion in 'Shaders' started by kittrick, May 31, 2023.

  1. kittrick

    kittrick

    Joined:
    Jul 10, 2019
    Posts:
    3
    Does anyone know how to distribute a regularly spaced pattern across arbitrary geometry in Unity Shadergraph or HLSL?

    Here are the requirements:

    • The geometry will all have the same shader
    • We know world-space vertex position and geometry normals
    • Vertex density is arbitrary
    • Geometry is generative so UVs are not pre-calculated
    • The pattern can be generative or image-based, doesn't matter

    The type of pattern I'm hoping to achieve would be a regularly spaced grid of dots. So far I've tried to take the frac of the world-space coordinates and use that to apply a regular grid of dots, however angled walls will have stretched or dim points, and some surfaces between the points display as totally dark.

    I'm thinking I need to take some kind of 2D planar coordinate and rotate it, essentially on the fly UV creation. Ideally the pattern is fairly regular even on angled surfaces.

    I've thought perhaps there is a way to achieve this with a cube-map?

    I've also tried using tri-planar projection but the pattern has obvious artifacts at the seams.
     
  2. kittrick

    kittrick

    Joined:
    Jul 10, 2019
    Posts:
    3