Search Unity

Grayscale texture based z-depth testing

Discussion in 'Shaders' started by sewerstyle, Dec 17, 2012.

  1. sewerstyle

    sewerstyle

    Joined:
    Dec 17, 2012
    Posts:
    17
    Hi everyone,

    I'm a bit new to the shader scripting and I have a question according to this. I'm working on a 2D oldscholl-styled isometric RPG game with visuals like you've might seen in Infinity Engine-based games. All the graphics are pre-drawn in one big solid picture. The effect I'd like to achieve is that all the characters might be obscured by the wall partially. I.e. I'm trying to implement z-depth testing based on 2D sprites. I guess I must have another grayscale texture to achieve this, this way I can take "grayness" from that texture and compare it with the desired depth where my character is located. If my character's pixel is located closer to us – we draw it, otherwise – not.

    I'm a bit confused on how to start with this. Should I use z-buffer for that? Or maybe I should use fragment shaders placed on each character and pass the texture into them?

    Any links or directions for the further reading are hugely appreciated.

    Thanks in advance!