Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by Nguru · May 10, 2014 at 03:39 AM · shaderterraindepth-bufferdepthmask

Does anyone know how to implement these depth-mask shaders?

I'm trying to create a plane that I can place over-top of the terrain which will hide the terrain but render all other things. For placing a cave under the terrain.

Here is a video of somebody using this technique:
http://www.youtube.com/watch?v=cz7xX8kV7vY

And here are the shader scripts:
http://wiki.unity3d.com/index.php?title=DepthMask

I'm not sure I understand how to apply this for terrain though. Or where to attach the scripts.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
3

Answer by AlucardJay · May 10, 2014 at 09:24 AM

The wiki link you gave has an example project to download.

Disclaimer : Never done this before, but for a quick test just now.

  • Import the SetRenderQueue.cs script

  • Import the DepthMask shader (I changed Tags {"Queue" = "Geometry+200" } as in the video)

  • Create a material, name it MaskMaterial, set the shader to Masked/Mask

now set up the scene :

  • put in terrain and a directional light

  • create a plane, position it just above the terrain

  • drop the MaskMaterial onto the plane

  • drop the SetRenderQueue.cs script onto the plane, set the Queues elements to 1800

  • create a cube, position it just under the terrain (behind the plane!)

  • drop the SetRenderQueue.cs script onto the cube, set the Queues elements to 1500

Done! Hit play and move the camera around.

In both the video and the example project, there was no script on the mask plane, but I couldn't get it to work without adding it and setting the Queues Elements to 1800

So anything you want to render under the terrain behind the mask, add the SetRenderQueue.cs script and set the Queues elements to 1500

As in my disclaimer, I only just tried this for the first time now. Let me know how it goes =]

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image PhilippL · Sep 25, 2015 at 08:44 AM 0
Share

Thank you! It works perfectly. But I had to change the camera option - clear flag to solid color for my application.

avatar image ahmadian · Dec 31, 2015 at 08:46 AM 0
Share

Hi , I tried what you said but it didn't work. I need to Hide part of a mesh so that it appears like a window

avatar image Snipe3000 · Jan 20, 2017 at 08:01 AM 0
Share

This almost works. Is there a reason why the shaders on the objects underneath the plane don't show? The objects show, but not with their shaders.

*Edit, Never $$anonymous$$d, I forgot to increase the Queue size to allow for all of the shaders

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

26 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Making Cave system in Unity 5 0 Answers

problem with custom terrain shader (added holes-functionality, problem with some post effects) 1 Answer

How to change terrain shader 0 Answers

terrain hole shader needs fixing 1 Answer

How to make terrain partially transparent (lower opacity) 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges