Hello Guest

Author Topic: Depth Bias for Depth Mask Shader  (Read 6185 times)

wtg

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 22
    • View Profile
Depth Bias for Depth Mask Shader
« on: May 06, 2013, 05:21:54 pm »
I was wondering if there's a way to set the Render Que or perhaps a Depth Bias on objects utilizing the Depth Mask shader. I want to assign the shader to an object and then tell that object/shader to only mask out other objects that sit within a certain range behind it. Right the Deth Mask clips everything behind it, unless I assign the non-clipped objects to another camera. Depth masking is a technique I utilized a lot with the OGRE engine and now that I'm in Unity, I want to apply the same technique. Previously in OGRE, I had control over what objects got masked out based on a Depth Bias. So if I had the shader applied to a masking object with a Depth Bias of 10, any other objects that sat within 10 units behind it would be clipped. Any other objects outside of the range was unaffected. I would prefer a Depth Bias solution rather than a multiple camera based solution. I have too many objects that require they're own depth masks, so having multiple cameras would get messy. Any help in this problem would be greatly appreciated.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Depth Bias for Depth Mask Shader
« Reply #1 on: May 06, 2013, 08:45:14 pm »
Thats an interesting way to do it.

I had a quick go and this is certainly doable, but I thought of a much nicer way to do this compared to how I've done it now (as a shader hack). Also it needs some editor tools to help visualise the "clip window".

In any case here is a replacement shader to the built in depth mask one. This can be done without a shader to work on even fixed function hardware.
Use it as shown in the image below.


unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Depth Bias for Depth Mask Shader
« Reply #2 on: May 06, 2013, 08:46:32 pm »
The shader itself is posted in your private forum post.