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
0
Question by BmB23 · Jul 15, 2017 at 11:37 AM · normalsdepth-bufferuv coordinates

Camera DepthNormals Issues

I am making an SSAO shader, my approach requires comparing the angle of a vector that points to the sample and the surface normal vector in screen space. Like so:

Using the _CameraDepthTexture, and reconstructing the normal from the depth, gives good results. But creates an artifact around the outlines of objects due to the high difference in depth there. Reconstructing the depth also requires additional samples and is expensive.

Using _CameraDepthNormalsTexture gives a depth value with severe precision issues, and a normal that is not relative to the view, causing massive artifacts toward the side of the screen. Combining just the normals from this texture with the regular depth texture gives completely unexpected results. The two don't appear to be in the same space at all.

This thread gives a way to convert screen space coordinates into whatever space the normals are in. From some Takahashi fellow at Unity Japan. Since I'm not well versed in projection matrices and the documentation is silent on this matter, there's absolutely no way I'd ever have figured something like this by myself, just to do a basic task. What an oversight! Using this works but just adds more precision issues, presumably because the normals are also packed.

I could render my own normals pass and make sure they are in the space I need, but that seems potentially expensive. I'm presuming DepthNormals does both in one pass efficiently. I'd like it to work in forward rendering so fetching stuff off the G-buffer is a no go. Assuming the G-buffer normals are more well behaved in the first place that is.

What do?

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
0

Answer by BmB23 · Jul 18, 2017 at 01:35 AM

Okay so basically the problem is that the UV coordinates and screen depth are in screen space, but the COMPUTE_VIEW_NORMAL function only rotates the normals into view space. I tried multiple approaches I found to de-projecting the screen space coordinates back into view space but none of them were any good. So I gave up and rendered a fullscreen buffer containing the view space position of that pixel and used that value directly instead of trying to de-project anything. The extra pass for generating that clocks in at under a millisecond for a basic scene so that seems alright. Really not optimal but it works and I can set the render target to any precision I need.

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

68 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

Related Questions

Rendering to DepthTextureMode.Depth 0 Answers

facing an object 1 Answer

Intersection Highlight Shader -1 Answers

How to assign depth texture to camera? 0 Answers

How do I write a cutout sprite shader to depth depthtexture ? 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