Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Using object-space coordinate as uv, handle vertical faces

Discussion in 'Shaders' started by bitinn, May 28, 2020.

  1. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    674
    So here is something I am trying to do:

    - Given any object, a Cube for example,
    - Take it's object-space xz as uv coordinate, pass from vertex to fragment,
    - Sample a tiling texture in fragment.

    This works really well for the top face, but not so much for the vertical faces.

    - What I want to do, is to project all these vertical faces (vertices), to as-if they are on the same plane as the top face, so that the UV is continuous, but aligned to the top face.

    Questions:

    - I want to do it in the vertex shader, any tips on how can I make it happen?
    - I can probably hack to make it work on a cube, but how about any primitive shape?

    Thx!
     
unityunity