Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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 joyuseon · Jul 31, 2015 at 09:40 AM · c#gameobjectrenderingcoordinatesdepthmask

Rendering depending on world coordinates

Hi,

I am looking for a method to able/disable rendering GameObjects depending on the world coordinate of the objects (or their parts). For example, assuming that I have many objects in the scene, I want to show only objects (or their parts) whose x-coordinates are less than 100. So basically think of putting a cross-section-plane in the middle of the scene.

In order to implement this, I tried to use DepthMask, however it only blocks the camera's sight and does not necessarily disable the rendering. This causes a problem when the movable-camera goes passed the 'DepthMasking' plane or cube, and the camera is still able to see the objects inside the 'DepthMask'. To sum up, I want to turn on/off GameObjects and possibly their parts depending on their coordinates, regardless of the camera's position.

Will Stencil help? I looked into it, but I felt like it's very similar to DepthMask in that it's dependent on the camera's position. (For example, if the camera goes into the cube from the example below, the Stencil magic will stop. Am I correct? Link: https://www.youtube.com/watch?v=5DKIP9N-OB4 )

Again, what I want to do is Cross-sectioning the whole scene like the picture below, without having to care about the camera's position or angle.

alt text

Thank you very much!

Best,

Comment
Add comment · Show 1
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 _dns_ · Jul 31, 2015 at 01:33 PM 0
Share

Hi, is what you want something like this http://forum.unity3d.com/threads/simple-cross-section-shader.34508/ but with a cube cuting the objects ? It's possible to have the world position of the current rendered pixel in the pixel/surface shader so it's quite easy to "clip" it if it's inside a cube.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by SilentSin · Jul 31, 2015 at 11:55 AM

Keep a list of all GameObjects you want to turn on/off. Each frame, loop through the entire list, check their position, and turn on/off as appropriate.

That's the simplest way to do it.

For a more efficient (and more complicated) solution, you could look into Quad Trees or Binary Space Partitioning.

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

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Instantiated GameObject Not Rendering 1 Answer

How would I attached a gameobject to a prefab that is spawned at a specific time? 1 Answer

Multiple Cars not working 1 Answer

How to mask 3D game object or 2D sprite? 1 Answer

change the alpha of a gameobject with multiple childs 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