Search Unity

Transparent Shader that clips effects underneath

Discussion in 'Shaders' started by Mr-Brent, Nov 5, 2013.

  1. Mr-Brent

    Mr-Brent

    Joined:
    Aug 20, 2013
    Posts:
    19
    This may be a bit hard to explain, but here's a picture of what I have:

    $Screen Shot 2013-11-05 at 3.31.13 PM.png

    The grey and yellow ships, with the larger black circles are intended to be the player's ships, and their vision merges. That works just fine, and I'm using the merge shader detailed here: http://forum.unity3d.com/threads/146173-Merge-shader

    I've also included a blue "fog" so that the non-visible areas of the screen are obvious. My problem is the red vision circles of the enemies. I can hide the enemies model when they aren't visible, that's not the issue, but their vision circles, especially when they're at the edge of the player's vision, also go into the "fog" area. I'd like you to only see the portion of the enemy vision circle that overlaps the player's vision.

    I've attempted to do all kinds of Zwrite options on the fog shader, hoping that it would overwrite what's below it, but anything that does work, also turns it into a solid color, and I'd still like to see the stars behind there, or other large structures that would not be affected by player vision.

    Any clue as to how I can clip those red circles to the bigger grey circles of the player's vision? Is there any way to only overwrite what's the in Transparent render queue, or a specific layer?