Search Unity

Feature Request Pass vertex data from vertex to fragment shader

Discussion in 'Shader Graph' started by Elecman, Aug 21, 2019.

  1. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,374
    It would be really useful to be able to transfer arbitrary data from the vertex to the fragment shader so that certain fragment calculations can be done on a per vertex basis, improving performance a lot.
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    While it would be nice to be able to specify data that gets transferred from the vertex to the fragment, doing calculations in the vertex shader isn’t usually the performance improvement people think it is. Most of the time it’s actually slower.

    Modern GPUs, both mobile and desktop, are generally far more limited by memory bandwidth than their computational power. Over a decade ago removing a single float4 value from needing to be interpolated was equivalent to being able to do somewhere between 6 and 10 instructions in the fragment shader. Today it’s even more. This is actually even more true on mobile today than desktop where the memory bandwidth is severely constrained compared to the ALU.

    So while it feels “dirty” to do all that extra work per pixel, it is usually in fact the optimal way of doing it.
     
  3. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,374
    Thanks, I didn't know that. Will profile it.