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
3
Question by Quentin 3 · Apr 22, 2011 at 08:43 AM · cameradepthbuffer

Retrieving depth buffer of a frame

Hello everyone,

Im new to Unity3D, but I can already say that this is an amazing tool. Im currently working on a personal project on unity, and I have a question.

Is it possible to create a camera that would retrieve the depth buffer of the current frame when I send a request to it?

As I said before, I'm totally new to unity and even if I have already done a bunch of tutos I can't really see were to begin with this pb.

Im French and my English is far from perfect, if my question is not clear, feel free to say it ^^.

Thanks !

Quentin

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
5
Best Answer

Answer by taoa · Apr 22, 2011 at 09:35 AM

Yes it's totally possible.

One thing to know is that the depth texture must be 'drawn' by Unity before you can use it as a texture in your shaders/post processes/whatever.

However, as you might know, Unity has two modes of rendering : forward and deferred. If you choose deferred rendering, Unity already needs this depth texture for it's own internal use so it's already available.

In forward rendering though, you'll have to tell Unity to drawn this texture or it won't be available. You can use this to tell your main camera to draw it. You'll notice that here you can ask Unity to render the Normals texture as well. The same goes with the Normals texture concerning deferred rendering.

Once your texture is drawn, you can use it as a global shader property: _CameraDepthTexture

Et te biles pas pour ton anglais, il est des annes-lumires de bien des gens ici! ^^

EDIT: Eric's link to the Documentation is full of good stuff, covering what I just said ^_^ Go read it now!

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 Quentin 3 · Apr 22, 2011 at 02:00 PM 0
Share

I'll read it right now. Thank you for your answer ! Et merci pour le compliment =)

avatar image Quentin 3 · Apr 28, 2011 at 10:04 AM 0
Share

I still don't have the pro version so I can't use depth texture for the moment...

I'll have it soon and I just wanted to be sure : - Firstly I must create a shader which will render depth - Secondly I have to create a camera and use the depth texture mode - The returned texture will be screen wide and will contain the information I need ie. the "depth buffer"

Am I right ?

Do I have to create the shader or can I find it somewhere ?

avatar image taoa · Apr 28, 2011 at 12:26 PM 0
Share

The depth texture will be rendered with all objects that write in the depth buffer (ZWrite On - default). You don't need to make a special shader for this, just use Unity's own shaders. If your project is set to use deferred rendering you don't need to tell your game camera to render the depth texture, but you DO if you're using forward rendering.

avatar image Quentin 3 · May 09, 2011 at 09:04 PM 0
Share

Hello taoa, I'm sorry to ask for your help ... again, but I'm a little bit lost. I believe you are french (or speak french), is it possible to ask you some questions in french by mail ?

avatar image
1
Best Answer

Answer by Eric5h5 · Apr 22, 2011 at 09:28 AM

You need rendertextures for that; see here. Your English is in fact quite good.

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 Quentin 3 · Apr 22, 2011 at 01:59 PM 0
Share

Thank you Eric, I'll read it right now ! =)

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

No one has followed this question yet.

Related Questions

Shader works on Android but it is black on iOS 1 Answer

Problem with render order using 3 cameras! 2 Answers

Rendering different cameras with the same depth? 1 Answer

Face tracking using Intel RealSense Depth Camera D435 in Unity 0 Answers

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


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