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 spraycanmansam · Jul 13, 2013 at 11:58 AM · shaderrendertexturenormalsdepth

Normals from Depth texture distorted

Hi all,

I've been writing some image effects using the cameras generated depth and normals texture. One thing that I've noticed is that the cameras field of view seems to distort the depth values at the sides of the screen... If anyone wants to see what I mean, load up Unity's builtin global fog shader and with some random geometry look at the left and right sides of the screen as you turn left and right... It's a bit frustrating as my world space positions which are based off the depth texture change, which is screwing up my lighting calculations...

I've included a little demo scene with a plane to highlight the problem. It's particularly noticeable on the right corner.. as you rotate the camera around slowly you'll see the corner get more 'red' instead of staying the same color. And like I mentioned, seeing as my world space postions are based of this... it screws things up! I'm inclined to think it's a problem on my end, but Unity's builtin global fog shader has the same problem, so I don't know...

alt text link text

depth problem.zip (13.3 kB)
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 Benproductions1 · Jul 13, 2013 at 11:59 AM 2
Share

distortion is a general problem with perspective based cameras. Usually lowering the field of view avoids this, however it still exists and can't be completely avoided

2 Replies

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

Answer by Owen-Reynolds · Jul 13, 2013 at 03:08 PM

To expand on BenProd, Depth is not distance. It's faster to convert the screen to local coords and use Z for depth. This means that a duck 30 meters to your left and 40 meters away, has a depth of 40. Rotate to face that same duck and it's depth magically increases to 50. Of course, the distance was always 50, but no-one was computing that.

You see this issues in lots of game with depth-culling. Walk back until a tree has a LOD change (vanishes, etc...) then turn sideways and the tree will pop back on the edge of the screen, since the depth has gotten lower.

Comment
Add comment · Show 4 · 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 spraycanmansam · Jul 14, 2013 at 08:45 AM 0
Share

Thanks Owen. So there's no effective method around it?

avatar image Bunny83 · Jul 14, 2013 at 09:13 AM 0
Share

No, our real eye has a curved retina. The field of view represents an angle and should therefore result in a curved surface as well (actually a spherical sector). But since our monitor is flat we use a viewing frustum ins$$anonymous$$d.

avatar image spraycanmansam · Jul 14, 2013 at 11:08 AM 0
Share

Ok, I had suspected as much. Thanks guys :)

avatar image Owen-Reynolds · Jul 14, 2013 at 03:21 PM 0
Share

Optics aside, the graphics card is wired to use "local-Z = depth" for speed. So, we could do all the math in the CPU, using real distance. I assume overnight renders do this (and one of the reasons they take overnight to render 30 seconds.)

avatar image
0

Answer by spraycanmansam · Mar 12, 2014 at 07:37 AM

Just to follow up on this -- I mentioned my lighting calculations were being stuffed up in my original post. I had attibuted this to my world space calculations from the depth texture. It actually turned out to be from my decoded normals from the _CameraDepthNormals texture. They were still in view space! I had forgotten to convert my normals to world space the same as the depth values I was working with.

Just wanted to clarify that point :)

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

Render depth seperately 0 Answers

RenderTexture behaviour inconsistent to Cameras, Rendering two times to a RenderTexture respecting depth, Rendering object visibility 0 Answers

sampler2d object has no methods 1 Answer

Read depth buffer on the cpu 1 Answer

Complex Depth 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