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 Nullspace · Feb 25, 2013 at 11:49 PM · shaderaugmented realitycg

Rendering virtual objects within a real scene

I have depth maps and color images (both of them are from a camera), and I create some virtual objects to interact with real objects in the scene. How to render both of them (in Unity)? Maybe a shader will work. But I am relatively new to Cg. In a pixel shader, how to compare depth values of different objects which are projected to one same pixel? Thanks.

So what in my mind is this: A color image with depth data at each pixel (get from a camera), and several virtual objects in Unity. I want to overlay them. I want a pixel shader to check depth buffer for every pixel. If the depth value of the pixel from color image is smaller, rendering that pixel. Or if the virtual object is closer, rendering the virtual object.

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 DaveA · Feb 26, 2013 at 12:17 AM 0
Share

Any chance this is $$anonymous$$inect related? Or OpenNI in any case? ZigFu's stuff does what you ask, but only if you're doing $$anonymous$$inect.

avatar image Nullspace · Feb 26, 2013 at 12:19 AM 0
Share

I am not using $$anonymous$$inect & OpenNI for now. Thanks.

avatar image numberkruncher · Feb 26, 2013 at 12:42 AM 0
Share

I am not sure what you are asking, but if you are talking about procedurally generating objects dynamically at runtime then you should take a look at the `$$anonymous$$esh` class.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by spalmer · Jun 30, 2015 at 04:09 PM

I haven't seen any code from you yet, not going to write a shader for you, but your idea seems reasonable. Would be easy as a post-processing effect, just plug in all four images and select based on the depths. Doing this will require Unity Pro. You can use the Depth of Field image effect as an example of how to obtain the camera depth texture from script and access the depth buffer from an image effect shader. A depth texture appears to the shader as a texture of single unorm value in the red channel. Simple comparing the depths to see which is smaller should be simple enough if that's all you need.

http://docs.unity3d.com/Manual/SL-CameraDepthTexture.html

http://docs.unity3d.com/Manual/script-DepthOfField.html

Comment
Add comment · Show 2 · 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 tanoshimi · Jun 30, 2015 at 04:12 PM 0
Share

Unity 5 has barely any difference in features between Pro and Personal edition... you don't require Pro to do this.

avatar image spalmer · Jun 30, 2015 at 04:25 PM 0
Share

Good to know!

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

12 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

Related Questions

How to force the compilation of a shader in Unity? 5 Answers

Cg Language incompatibility Desktop VS GLSL Android 0 Answers

Can anyone help me with reflective shader with fall off property? 0 Answers

Sprite deformation in shader? 0 Answers

Shader: get nearest point light's color, direction and general custom lighting questions 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