Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
2 captures
12 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
0
Question by Rapickt · Feb 24, 2017 at 11:23 AM · camerashaderrenderingdepthpost-process-effect

Rendering different shader when camera get near object

Hello,

My goal is to create the same effect that I have in this video

When the camera get near the material change and become colored and transparent.

So, I already have this effect in a shader someone helped me to make in ShaderForge.

Graph

Problem is, I don't know how I should process to apply this effect to my whole scene, and not to every material one by one, this would be way too complicated because I would have to get all the information of the old shader, then mix those information with the new shader.

In my mind I should probably try to do some kind of post process to apply this effect to the whole scene, but I don't know how to do it.

Is there any other way to do this than writing a post process? Am I on the right track or should I think of another way to do it?

Thanks for taking the time to read me,

Cheers

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
2

Answer by hrgchris · Feb 24, 2017 at 11:56 AM

Hi There

There are various approaches to this issue, though there won't be a trivial post-processing effect you can apply just to one camera. This is because a post-process can only modify pixels that have been rendered, so you couldn't take solid pixels then realise you actually wanted them transparent!

If your goal is to find a solution that doesn't require modifying lots of materials (a perfectly valid desire!) then I would:

  • render all objects that you don't want the clipping effect on as normal

  • render objects that you do want the clipping effect on into a render texture (that includes depth)

  • now in a post process you can combine these 2 separate renders into 1, using the depth values to calculate how transparent the clipped versions should be

This would require you to work out which objects you wanted rendered into which textures, though you might be able to do this with a trick as simple as having 2 cameras with different front/back view planes. i.e:

  • normal camera has view planes 1m->1000m

  • clipped object camera has view planes 0.1m->1m

If that works it'll be nice, as unity will do the job of separating out clipped from none-clipped objects for you.

Hope that gets you in the right direction. I would start by just seeing if you can use the above technique with cameras to separate normal from clipped, then see if you can make a post processing effect that makes any clipped object semi transparent. Once you have that working, you can start looking at nicer effects that go more transparent/change colour when they get close to the camera.

-Chris

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

112 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

Related Questions

Post Effect to certain objects? 1 Answer

"Motion vectors" and "depth with normals" from camera's target texture 1 Answer

Shader based camera compositing. 2 Answers

Dividng clip space by "w" warps the output? 1 Answer

Wrong Depth texture being passed into the shader. 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