- Home /
Depth Mask shader with a depth range/bias
We're sitting with quite a dilemma. The root of our problem is creating holes in terrains.
We cannot use a lowered terrain with mesh blending (we have complicated tunnel systems, cliff systems and basements as well as underwater areas) or model our entire terrain in Maya, neither are valid options.
So we turned to the Terrain Hole System from TRI (available on the asset store). Which uses a fourth black detail terrain texture (that you just paint on the areas you want transparent) to identify the black colour ceated on the splat map as transparent areas and then an additional script (that is placed on objects that have to interact with the hole) allows an object to pass through the hole by detecting when the object is on the black area of the splat map and then temporarily turning off collision.
This worked well except when it came to actually applying a proper terrain shader (ats colormap Ultra 1.6c) to the terrain, we got troubles merging the two terrain shaders (plus the Terrain Hole System is still a bit buggy and doesn't want to always get rid of the black artifacts it creates in the transparent hole areas you paint).
So now we have turned to depth masks to solve the problem as we can create the transparent areas with primitive meshes not a terrain shader and then just solve passing through the hole with a trigger collider that temporarily disables collision.
We are currently using the modified Unify Wiki Depth Mask shader that allows shadows that can be found here:
http://answers.unity3d.com/questions/243371/depthmask-shader-receive-shadows.html
The only little problem we have with depth masks is we cant seem to find a way to set the range or bias on what the depth mask cuts out. Currently it just cuts out the terrain in an infinite range. So when you look through the depth mask on, either side, not just the little area covered by the primitive mesh is cut out, the whole terrain within view of that depth mask's perspective is cut out.
Is there anyway of limiting the range that the depth mask cuts out of a specific render que/object so that not the whole object(s) is cut out just the area covered by the mesh using the depth mask shader?
If this isn't possible is there any other way of solving this problem?
Please any help or advice would be appreciated as this problem is starting to cut into our level construction deadline.
Thanks so much in advance everyone.