-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Raycasting onto the Depth map #16
Comments
Hey dogadogan, We will add that feature sometime in the near future. |
Hi @TudorJude, thank you so much for your reply! I'm a bit confused, the Meta Depth API for Unity website says this is already available: And I have definitely already seen some demos utilizing this. Would you be able to point me to the right API documentation? If this has not been implemented yet, might you be able to share an estimated time for when this will be available? Thank you so much for your time and help! :) |
Hi @dogadogan, |
Yes, it would be great if you can share the example code for raycasting here! Thank you so much in advance! |
Hey dogadogan, Here's the solution, but as @vasylbo mentioned, this is not production ready nor is it very performant but you can can use it to play around with. Firstly you will need to create a new compute shader that computes the raycasts. Here's the code for it :
Next, you will need a script to access this data in your C# code, let's call it
Now, you can simply call one of the two public functions to get the DepthRaycastResult and work with it. Here's a simple example of placing
Note: if you look at the code you should notice that this is only supported by 3DOF implementation. What this means is that you need to set 3DOF to true in the depth texture provider: |
Hi, first of all thanks for sharing the example code! Sadly the raycast position is not working correctly for me, so i changed the shader to only compute the depth. The benefit of this is that it also works with BiRP. I uploaded the project if any one else wants to try out raycasting on the depth api. |
@dogadogan You can see a video of it here: (Only works with URP I think, but it shouldn't be too hard to get working with BiRP if you need...) |
Starting with v71, we've released our official solution for depth raycasting and is part of MRUK. You can find more information on it here. There's also a sample within MRUK that showcases its usage here. We strongly recommend using the official solution over the solutions mentioned in this thread moving forward. |
Firstly, thank you so much for this great repo.
I was wondering how I can raycast toward the depth map generated by Depth API - so I can make use of the hit 3D point. Is there a specific method/script for doing this?
This page mentions "Raycasting: using rays to point at physical surfaces. Supports use cases like content placement" - but I couldn't find information on how to do this in the context of Depth API.
Thank you!
EDIT (for visibility):
The text was updated successfully, but these errors were encountered: