oculus-samples / Unity-DepthAPI

Examples of using Depth API for real-time, dynamic occlusions
Other
192 stars 24 forks source link

OcclusionSubGraph with custom shader #24

Closed clecleath closed 8 months ago

clecleath commented 8 months ago

Hello,

Thanks a lot for this wonderful API.

I got a question regarding the OcclusionSubGraph. I am trying to use it with a custom shader but the occlusion does not work.

I tried the DepthAPI-URP sample and look at the LitOccluded and StylizedOcclusionEffectON shader. But when I built the project and tried it, the occlusion did not work.

So I don't know how to make it work both in the sample scene and in my custom one. Do you have any advice ?

System : Unity 2022.3.16 URP Meta Quest 3

Thanks in advance for your answer

TudorJude commented 8 months ago

Can you share the shadergraph? Also, did you follow all of the steps in setting up Depth API? Do the predefined shadergraph implementations work for you?

clecleath commented 8 months ago

Here is the shadergraph, I am working on.

water_shadergraph

And I followed the setting up Depth API.

I have the Occlusion Lit shader working on materials in my custom scene.

TudorJude commented 8 months ago

Did you enable alpha clipping?

clecleath commented 8 months ago

Yes I have

TudorJude commented 8 months ago

The setup seems correct, so there's some detail that we're missing here.

clecleath commented 8 months ago

Ok, do you have an idea for the fact that the sample scene has the same problem ?

TudorJude commented 8 months ago

Which sample scene, exactly? And what do you mean by the same problem? The default Lit shadergraph isn't working in the sample scene?

clecleath commented 8 months ago

I am talking about the DepthAPI-URP project in the scene OcclusionToggler two object are using custom shaders with OcclusionSubGraph : DodecahedronShadergraph and SphereStylizedOcclusion.

And for both of them, when I put my hand in front, the object is still on top of my hand. But when I put my hand in front of the mug for example (which is using Occlusion Lit) my hand is visible in front of it and the soft occlusion works.

I hope this is clearer

TudorJude commented 8 months ago

That's clear, so the shadergraph solution doesn't work at all for you but occlusions that use materials with shaders do work.

TudorJude commented 8 months ago

Do you get any errors in the console when you start up the project?

clecleath commented 8 months ago

Yes that's the idea. The problem is only related to the shadergraph solution.

When I start the project I have this in console : error_in_console_depthapi_project

And in the project setup tool I have this :

project_setup_tool_depthapi_project

TudorJude commented 8 months ago

The project setup tool issue isn't a problem. I do, however, think that your issue is package manager related somehow. That error is telling me that you aren't properly connected to the package manager server. It's likely related somehow to your issue. Are you logged in to Unity?

clecleath commented 8 months ago

Yes, I am logged into Unity.

Here the three package that I have the error for :

error_package_manager_depthapi_project

TudorJude commented 8 months ago

I'm a bit stumped here, since it seems to be related to the package manager, rather than Depth API itself. I googled your error a bit but couldn't find anything conclusive. There was an old post that I found that mentioned reinstalling a different version of Unity Hub, but I think that's a long shot.

clecleath commented 8 months ago

Ok I see.

I think on saturday (I am currently at school), I will try to launch the sample project using Unity 2022.3.9 on another computer to see if there is any changes.

I will let you know if the change of Unity version and computer change something

Thanks a lot for your help,

TudorJude commented 8 months ago

I'll keep this thread open and we can continue then.

clecleath commented 8 months ago

Hello again,

I did some tests this afternoon and finally discovered that the bug looks related to the Unity version. I was using 2022.3.16 and it was not working. I moved my project to 2022.3.9 and it works.

I will stay on 2022.3.9 for now but let me know if you have any ideas about the 2022.3.16 version bug.

Thanks a lot for your help !

TudorJude commented 8 months ago

I'm glad that it worked out

TudorJude commented 8 months ago

I just tested in 2022.3.16 and I managed to reproduce the issue. It's package manager related, like I assumed. The solution, if anyone else gets this in later versions of Unity, was to exit the editor, sign out of hub, sign back in, start editor. You'll notice that the packages no longer have a big red "!" next to them.

Thanks for pointing this out, we'll flag this to Unity.

clecleath commented 8 months ago

Oh nice, good to know that it can be solved only by signing out and back in.