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

Resolved Different ZTest for each pass?

Discussion in 'Shader Graph' started by zhuchun, Aug 1, 2019.

  1. zhuchun

    zhuchun

    Joined:
    Aug 11, 2012
    Posts:
    433
    Hi, It's great to see the ZTest option is available, but I'm wondering how to set them differently in shader graph, say I want to display one color for the LEqual part and another color for the Greater part of the object?
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,329
    Shader Graph shaders are always only a single pass (for the main forward pass at least), and GPUs cannot change the ZTest mid-shader execution. If you want to have different ZTest settings, you'd need to have two separate shaders and materials applied to your object.
     
    iSinner and zhuchun like this.
  3. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,193
    I'd like to understand what you mean by two separate materials. Let's say the mesh is just a single triangle. That single triangle can't have two materials, can it, rendered on different passes?
     
  4. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,329
    Yes, just add two materials to your object and it’ll render twice. Once with each material. It’ll also pop up a big warning on the renderer component about this that you can ignore.
     
    euivtui4h likes this.
  5. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,193
    Interesting. I didn't know that. However, I assume there's no way to fake a multi-pass shader using this approach, where the output of one shader gets passed into the second shader as input?