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
1
Question by stephero · Feb 06, 2016 at 02:38 PM · shadertexture2drendertexturepngdepth buffer

16 bits Depth Map to file using a RenderTexture

Hello guys,

I want to capture the depth map of my camera and export it to a file.

I managed to do that using a custom shader to show the depth map, a RenderTexture, and Texture2D.ReadPixels.

But my depth map precision is 16 bits, and I don't want to loose this precision. Since the PNG format supports grayscale images with 16 bits channel, it would be perfect to use this format to store my depth map.

The problem is I don't manage to convert my RenderTexture to a Texture2D (and then a file) without losing my 16 bits precision. With my current implementation, because of Texture2D.ReadPixels, the exported file has a 8 bits precision. I tried several TextureFormat, but Texture2D.ReadPixels doesn't support many of them. For example TextureFormat.R16 is not supported.

Do you have any idea? Thanks.

Comment
Add comment · Show 5
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 Predator4Ksu · Mar 08, 2018 at 10:09 AM 0
Share

Hi!, did you find any answer to your problem?

avatar image sergiobd · May 05, 2019 at 09:27 AM 0
Share

I have a very similar problem now. I want to bake pointcloud data into a texture. $$anonymous$$y depth data (from kinect) has 13 bits. I have not been able to save the data to disk without losing precision. $$anonymous$$aybe try .EXR file? Please notify us if you managed to solve the problem.

avatar image stephero sergiobd · May 05, 2019 at 09:47 AM 0
Share

sorry guys, I never managed to solve this issue...

avatar image sergiobd stephero · Jul 08, 2019 at 04:35 AM 0
Share

Someone suggested me to try "AssetDatabase.CreateAsset(blah...)". I haven't tried it. It would only work in the Editor.

avatar image andrew-lukasik · May 05, 2019 at 10:08 AM 0
Share

Graphics.CopyTexture (or Graphics.Blit etc) maybe? Texture2D can be saved then to a file in 16 bit precision using PNGCS. Or you can just grab Texture2D's raw bytes and do whatever needs to be done from there

0 Replies

· Add your reply
  • Sort: 

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

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Save rendertexture to image in file 2 Answers

How to save a RenderTexture as a 1-channel 8-bit grayscale PNG? 0 Answers

Grab texture from Vertex Shader 0 Answers

Most Efficient way to save shader result as texture and feed it back in next frame (Ping Pong Buffer) 1 Answer

Use RenderTexture as ShaderResource in DX11 native plug-in 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