Search Unity

[Unsolved] Different stencil shaders per object.

Discussion in 'Shaders' started by LukeAJones, Jan 25, 2020.

  1. LukeAJones

    LukeAJones

    Joined:
    May 7, 2017
    Posts:
    15
    I'm new to shaders and having a really hard time figuring out how to make this work. I think it's possible but seems like it'd be really hacky to make work. I'm trying to apply see through clothes to enemies as a combat feature. Basicly the whole game is built around that.

    The idea is whatever is under said clothing, like a torso under a shirt, is teleported to 'The NULL', which is a seperate area the camera can switch to. For that it's pretty simple (at least it seems to be), I just need a duplicate of the enemy and an overlap stencil for what's been hidden in the normal world so it appears here. The other part though, it's giving me a lot of trouble.

    I can't figure out how to limit a stencil to just one object. I was trying to have every object get assigned a different stencil value and mask them with a matching value, but I couldn't get it working from several problems. One of the main ones being getting masks to see through other masks. When looking through the mask of one enemy, I need it to still show other enemies with their respective masks applied. At least without bitwise comparisons I don't know how it'd be done.

    Any help would be appriciated. I don't have long to try get this working and the alternatives to get the same effect aren't ideal. I don't need this to be a shader but I don't know of another solution without significant drawbacks, though my knoweldge about rendering techniques is pretty limited so feel free to suggest options. :)