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 /
  • Help Room /
avatar image
0
Question by aur8l · Feb 24, 2017 at 12:32 AM · camerarenderingeffects

DoF with transparent shaders in Unity 5

Heya,

so I know this question has been asked heaps, and I tried every single shader tweaks to make it work, but the fact is UNITY 5 CANNOT HANDLE DOF WITH TRANSPARENT CUSTOM SHADERS. This is as simple as that.

So now, workarounds... Anyone has a good idea on how the following could be achieved? I have a 3D model of a planet that is the center of "the world". The main (and only) camera is revolving around this object. I want the planet to be blurred if an object is between the camera and the planet, but only while the object is within a certain range. So I just described DOF, I know, but since it is not working (my planet has a transparent object around it to simulate the atmosphere) I need to find a workaround. My idea so far is to render the planet and the skybox using one camera (A), other objects with another camera (B), and blur camera A if oject is within the defined range. Old PS2 style DOF.

Thing is I have no clue how to implement this. I don't know how to overlay camera - but I do know how to assign objects to layers. Can please someone point me towards something that would be helpful to solve this problem?

Thanks so much.

Aurelien

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 aur8l · Feb 27, 2017 at 01:06 AM

Solved it. If anyone is interested in the solution, shout out.

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 KensonTsang · Feb 27, 2017 at 10:43 AM

@aur8l

YES!!!! I'm facing this problem too!!

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 aur8l · Mar 02, 2017 at 01:13 AM 0
Share

Hey @$$anonymous$$ensonTsang,

Pretty easy actually. You need 2 cameras. One will render everything except the objects in the foreground and the other nothing but the objects in the foreground. Of course, this has to be adapted to your situation but: camera that renders the foreground will need to have a child (I used a cube mesh with no mesh renderer - just to get the collider which is a trigger) that will serve as the DoF detection zone. On this is a script attached that call a function in the root object (see below) to blur the background camera, using OnTrigger events.

All my camera are themselves children of a master object, that will control the blur of the camera rendering the background.

Voila. Let me know if you want even more details. It is not ideal of course as I need to have this dummy cube being a Rigidbody for nothing (except throwing the OnTrigger events).

edit: forgot to mention that if an object enters the detection zone it should change layers to be rendered by the foreground camera, and vice-versa.

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

120 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 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 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 avatar image avatar image avatar image

Related Questions

URP Camera.RenderWithShader(..) doesn't seem to work? 0 Answers

Rendering viewmodel over everything WITHOUT dual camera 1 Answer

Stop Post-Processing Effects on UI? 3 Answers

Why does everything render in the scene editor, but not after I build it? 0 Answers

How to hide and show level based on player/camera position? 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