Search Unity

difference between discard vs return in computeshader/fragment shader?

Discussion in 'Shaders' started by mahdiii, Apr 29, 2017.

  1. mahdiii

    mahdiii

    Joined:
    Oct 30, 2014
    Posts:
    856
    I want to know the difference between discard and return in cs/fragment shaders
    Thank you
     
  2. Pode

    Pode

    Joined:
    Nov 13, 2013
    Posts:
    145
    When you discard; you effectively throw away the results of the ongoing calculation. The fragment (and associated pixel on screen) isn't draw on top of whatever was already drawn.
    If you return, you return a value that is combined in one way or another with what is already onscreen.