Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Discard fragment doesn't discard Z/Depth?

Discussion in 'Shaders' started by emilmeiton, Sep 19, 2015.

  1. emilmeiton

    emilmeiton

    Joined:
    Apr 8, 2014
    Posts:
    15
    Just a quick question.., why does the discard command not discard the writing to the depth buffer also?.., I just made a shader with discard at the top of the fragment function and I still get depth information from the objects using the shader...

    Maybe I'm doing something silly? Thanks in advance!
     
  2. emilmeiton

    emilmeiton

    Joined:
    Apr 8, 2014
    Posts:
    15
    ok.., I'm not understanding this completely.., but it seems like it does the depth comparison before the first line in the fragment shader (where I use discard)

    Any obvious way to solve this? I'm basically trying to do a cutout based on an alpha texture