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 ikelaiah · Aug 23, 2013 at 02:49 AM · shadershader-replacement

How do I correctly invert depth values from an active camera?

After reading Unity's documentation on getting depth value, I get a display where far away objects are shown whiter then closer object.

My question

how do I correctly invert the depth values so that far away objects can be displayed darker?

Comment
Add comment · Show 4
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 MaT227 · Aug 23, 2013 at 09:07 AM 0
Share

It seems to be some kind of fog, no ? You can play with the diffuse color of your object according to the depth value.

avatar image ikelaiah · Aug 23, 2013 at 11:38 AM 0
Share

A fog is what I got from Unity's documentation. Well, what I want is to get a inverse of a fog. Close whiter, further, more black.

avatar image meat5000 ♦ · Aug 23, 2013 at 11:44 AM 0
Share

To literally 'invert' the depth

camera.depth = -camera.depth;

But I'm guessing it's not what you want and will maybe throw up error everywhere. Urg...messy!

If you are using multiple cameras you can iterate them all into an array and swap all the values.

Somehow I think you are asking about Rendering order ins$$anonymous$$d?

avatar image OP_toss · Jan 06, 2014 at 11:50 PM 0
Share

$$anonymous$$ool! I'll convert to answer so u can close the ticket. Thanks!

1 Reply

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

Answer by OP_toss · Jan 06, 2014 at 11:03 PM

Camera.depth has nothing to do with depth passes, nor with fog.

Either make your fog black, and your objects white, or write a custom shader. Once you're in shader land, you can simply 1-depth to invert it, and you have full control of how it is rendered. But a simple fix would be to use black fog.

EDIT: Looks like you are in shaderland! Just 1.0-depth to do a simple invert. You may want to remap it to make the effect more or less intense. You can also raise to an exponent to create exponential falloff. Options are endless!

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

18 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

Related Questions

FunkyGlowingThingsEffect fix for inverted y on Windows 1 Answer

I'am new to shaders and I'am making games for mobile devices should I switch over to LWRP? 0 Answers

Fog of War overlay for overhead map. 1 Answer

Encoding Float to RG/RGBA and Blending 0 Answers

Setting up a simple depth-based Shader Replacement material? 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