Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Triangle position in vertex/fragment shader

Discussion in 'Shaders' started by Charken, Jun 24, 2015.

  1. Charken

    Charken

    Joined:
    Jun 11, 2015
    Posts:
    14
    Hello,

    I'm writing a custom shader for procedural terrain generation and I'm wondering if there is a way to access all three vertex positions of a triangle in the fragment function? This can be done by using uvs to gain access to the triangle vertices but that seems kinda cumbersome and there should be an easier way.
     
    Last edited: Jun 24, 2015
  2. VIC20

    VIC20

    Joined:
    Jan 19, 2008
    Posts:
    2,687
    How shall that be possible? The fragment is part of a face and each fragment receives interpolated data from the vertices.
     
  3. Charken

    Charken

    Joined:
    Jun 11, 2015
    Posts:
    14
    instead of passing uvs you pass vertice positions again so that you have access to them. This works as long as you don't need the uvs for something else.

    yes, and the only data you have access to is the final position of the fragment and not the original vertex positions i'm trying to get access to. I was just wondering if there was a quick and easy way of accessing the original vertex positions, instead of using the uvs.
     
    Last edited: Jul 1, 2015