Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
0
Question by Questjon · Mar 25, 2014 at 11:32 AM · shadereffectdepthcutout

How do I achieve this effect?

alt text

I originally thought I could do it with a depth shader and render queues but I couldn't get the back room to occlude the front room (but it turns out render queues don't work like that). The I tried rendering the active room on a different camera, this worked but then the player couldn't enter the room (as it was rendered on top) or would appear in front of inactive walls (if I rendered the player with the active room). Also using a second camera resulted in a very hard and ugly cutoff of the front room and I'd prefer a semi transparent result (similar to project zomboid).

I'm not looking for anyone to write a complete solution but some guidance would be great. I'm fairly new to Unity and very new to shaders but wanting to learn. Any help would be appreciated.

Thank you for your time.

how.png (74.3 kB)
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

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Bunny83 · Mar 25, 2014 at 12:42 PM

Well, to het this exact effect you need a few things. First of all you need a well designed order in which the different objects are drawn. This could be done by using custom shaders with a custom renderqueue value.

The objects should be rendered in that order:

  • First you only draw the active room and only draw the front faces as usual.

  • Now you draw all items / players which should be visible through the transparent areas.

  • Now you draw the active room again but this time only the backfaces and you only write to the z buffer and keep the color buffer. The shader also should offset the geometry towards the camera position to make sure it covers the whole area of the active room.

  • Finally draw the remaining rooms.

This would carve the active room from the others. The overlapping areas will simply be invisible. You could draw the remaining rooms again with a transparent shader that doesn't do a depth test, but the result might look strange and of course causes a lot of overdraw which is bad for performance.

There are certainly other ways to accomplish this, maybe by using the alpha channel and alpha tests in the shaders, but this is what i just had in mind ;)

ps: If your rooms don't use a double sided shader but have actual geometry for both sides it's getting a bit tricky. In this case you need some other hint to know what is in front of what.

Comment
Add comment · 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
0

Answer by Bartalo · Mar 25, 2014 at 11:42 AM

I really have no idea for the other situations, but for the first two perhaps you could alternatively use for the room a shader that do, and one that don't, cull back. When the little orange guy is in a particular room you would assign to that room a material that has the shader that culls back faces (in your 3d modeling application you would want to have all the faces targeting with their normals the inside of the room).

I hope this could be of some help. sorry for bad english

Comment
Add comment · Show 1 · 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 Questjon · Mar 25, 2014 at 12:32 PM 0
Share

I just tried this and room 2 still blocks out room. alt text

fail.png (44.2 kB)

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

22 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

Related Questions

Multiple Cars not working 1 Answer

Shader Depth Mask - Shadows with cutouts 2 Answers

SSAO shader problem 0 Answers

Trying to achieve this color effect 0 Answers

Cut out shader with geometry depth and alpha 0 Answers


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