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 mircbone · Oct 27, 2016 at 12:40 PM · distancedepth-bufferdepth buffer

Depth values from a scene

Hi!

I have created a depth map in Maya 2016 from a certain scene. I want to get the distance values of the pixels from the scene and use it in Unity to create another scene, knowing those values. I am not sure, if I should work with it only in Unity, or get help from Maya's renderer.

How can I get the depth values? Thanks a lot!

Mark alt text

depth-map.jpg (40.2 kB)
Comment
Add comment · Show 3
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 Oliver-Bogdan · Oct 27, 2016 at 03:05 PM 0
Share

Take a look at https://docs.unity3d.com/$$anonymous$$anual/SL-DepthTextures.html and https://docs.unity3d.com/$$anonymous$$anual/SL-CameraDepthTexture.html.

avatar image Glurth · Oct 27, 2016 at 03:24 PM 0
Share

Is this an exercise in computer vision? Try to build a set of shapes from a depth map? If so, that's pretty darn cool! If not, why mess with the depth-map, can't you just pull those objects into unity as 3D-meshes? (not familiar enough with $$anonymous$$aya to know, but I thought I remember seeing/reading about that as a feature.) Question about the depth map image: Is the rear wall tilted towards the camera? It looks like the whole wall is at the same distance/depth, and so shouldn't it be a solid color, rather than a gradient?

avatar image mircbone Glurth · Oct 27, 2016 at 03:31 PM 0
Share

Is Computer Graphics. $$anonymous$$ainly this is what I have to do for my current academic project: I have a scene. I have to make a depth map of that scene, to get all the values of the distance of each pixel. $$anonymous$$nowing that, I have to re-project the pixels at that distance with their previous color (from the scene), inside Unity. Now, I thought of two ways: one involves that I do everything in Unity, but I can't seem to find much about this subject; second, to use $$anonymous$$aya to get the depth values and then come back to Unity to create the scene, with those values.

Thx for the reply :)

PS. I'm new to CG :(

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Glurth · Oct 27, 2016 at 04:08 PM

Cool Project!
Since I don't know Maya that well, and it might help, here is how I would do that entirely in unity:

I would use RAYCASTING to generate the depth-map: (https://docs.unity3d.com/ScriptReference/Physics.Raycast.html) in the direction the scene camera is pointing, to determine the distance from the camera plane to the closest mesh object. This would be done in a nested loop to raycast from a plane of points. I would use WorldToScreenPoint to find the detected scene point's screen position pixel, and get it's color. https://docs.unity3d.com/ScriptReference/Camera.WorldToScreenPoint.html , https://docs.unity3d.com/ScriptReference/Texture2D.GetPixel.html

I would then use this gathered data to create a custom output MESH: (https://docs.unity3d.com/ScriptReference/Mesh.html) Starting with a simple x/y-plane mesh, I would deform each vertex's z-coordinate value by the depth-map value of it's rayast. Rather than use the UV values of the mesh to reference a texture, I would simply the process a bit by using a vertex-shader to display the mesh. This allow us to colorize each vertex of the mesh with the color detect at the end of the raycast (https://docs.unity3d.com/ScriptReference/Mesh-colors.html).

Since the result is a single mesh, I would be interested to see the imperfect results as the resolution of the output mesh (and number of raycasts) changes. Best results would be, I suspect, 1 raycast per pixel of the original scene image.

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
avatar image
0

Answer by mircbone · Oct 27, 2016 at 06:48 PM

Thanks for the reply!

The thing is, my input is pictures that I can populate a skybox with. That means either I bring in Unity the 6 pictures with their 6 depth maps and I work from here somehow or I have to make depth maps from these 6 pictures directly in Unity if there is a way.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Intersection Highlight Shader -1 Answers

re-use depth for shadows on stereo render 0 Answers

Homing Missile, get two different targets? 0 Answers

Sorting Javascript array by Distance 0 Answers

Move an object to a specific distance 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