Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
3
Question by Wolfdog · Feb 19, 2016 at 11:38 AM · renderingscript.collider2dinvisiblevisible

Only render part of object inside a circle

I would like to only render the part of objects in circle colliders. Below is what I mean. alt text

Context: I want to have a full scene where only the background is rendered. Then I would like to spawn circle colliders in certain areas to and show what is there. (I'm open to other suggestions beside circle colliders).

my-awesome-explanation.png (8.0 kB)
Comment
Add comment · Show 2
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 Cherno · Feb 19, 2016 at 01:14 PM 0
Share

$$anonymous$$aybe you could use a shader that supports masking, give it a circle mask, then make the camera RenderToTexture using this shader as a replacement shader (and make the camera render no background), and display the resulting RenderTexture in your main camera view. It won't be the circle collider, but at least a circle :)

avatar image Dougi42094 · Jul 10, 2016 at 05:27 PM 1
Share

Did you ever get this problem solved @wolfdog ? this is the only post in the internet ive been able to fine that even comes close to the issue i need a soloution for? i thought/tried Camera.layercull.spherical but just wouldnt work

1 Reply

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

Answer by Bunny83 · Feb 19, 2016 at 04:08 PM

Unity seems to finally support stencil operations in custom shaders. This simplifies the implementation of such fancy things.

One approach would be:

  • render your background

  • render your mask geometry to the stencil buffer and increase the buffer value

  • use a custom depthmask shader which only renders where the stencil buffer is 0. Render a fullscreen quad to mask everything out except the area that the mask geometry occupies.

  • render your second camera which should render everything that should be masked.

The advantage of this approach is, that you don't need to use special shaders for everything else. You probably want to use 3 cameras. One for the background which actually clears the buffers, one for the masking geometry and one for everything else. You would need at least 3 layers. The fullscreen quad can be rendered manually with the GL class.

You can simply disable all cameras except the first camera which renders the background. On that camera use a script that has a OnPostRender method. In that method you would simply render the masking geometry camera manually followed by the fullscreen rect, followed by the main camera.

This is just an idea how it could be done.

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

39 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 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

Converting C# to JS: rendering a mesh 1 Answer

Instantiated GameObject Not Rendering 1 Answer

OnBecameInvisible in the Editor? 3 Answers

How can i use a script to automatic place invisible walls around the terrain edges ? 1 Answer

Occluding rendering with an invisible wall. 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