Near plane clipping in unity

I am experiencing some issues with clipping in Unity (URP) where the character disappears when the camera is placed too close. I have set the camera to 0.01, but it still cuts out when positioned farther away. This is as close as I can get the camera to the character:

@Yonatan It sounds like you’re having the same issue as described in this thread about Unity’s camera looking past the default bounding box (centered on the sensor origin) of the Depthkit asset. Try the solution provided there, and let us know if it doesn’t fix it.

1 Like

Thanks! @CoryAllen it works when editing the meradata file. no clipping.

gif

looks cool, but I’m trying to get smoother edges, particularly on the characters’ heads. Is there a way to achieve this? Any tips or suggestions would be appreciated
I also noticed that when I use a lower aperture setting while shooting, the image appears less shaky. Does this make sense?

@Yonatan Glad to see your main issue is resolved.

I am not clear on how the aperture is affecting the result. Do you have a side-by-side comparison which demonstrates the difference you are seeing?

The instability of the edges is somewhat inherent to data captured with depth sensors, and the more off-axis the virtual camera is from the origin of the real sensor, the more you will see that artifact. That said, there are a couple of things you can try to reduce it:

  • In the Depthkit Editor’s Refinement tools, try increasing the Color Contribution value.
  • This is more experimental, but after exporting your Combined-per-Pixel video, import it into DaVinci Resolve (or other compositing software) and apply Spatial and Temporal Noise Reduction (as in this tutorial). Be sure to mask the effect to only the depth map. Once you export a new version with these effects applied (keeping the same resolution and framerate), compare it to the original to see if it the edges are more stable. You may need to try versions with different noise reduction values. Also, subtle manipulation of the hue-encoded depth map may result in small changes to scale, position, or other distortions, so keep an eye out for those as well.
  • For any captures going forward, make sure there’s no stray infrared light in your scene. This includes turning off or blocking out any hot lights (tungsten/halogen) or sunlight, and try to get your sensor as close to the subject as possible.
1 Like

@Yonatan Another idea from our team is to use some of the edge blending tools available in our Unity Expansion package - specifically the Dither Edge option in the Depthkit Core Mesh Source component.
image

1 Like

Thanks, that’s great. but for some reason in all the generation settings i can only set it on during play mode, if i change it during edit it doesn’t work on play.
do i need to change anything in order for it to work?

@Yonatan Yes, Unity unfortunately doesn’t save changes made within Play Mode, however you can work around this by doing the following:

  • Enter play mode
  • Make your adjustments
  • BEFORE exiting Play Mode, right-click the component you have edited, and select Copy Component.
  • Exit Play Mode
  • Right-click the component, and select Paste Component Values.

@CoryAllen Sorry if i wasn’t clear… I know how play mode works:). I ment that once i enter play mode it clears the effect and setts it off.

@Yonatan Apologies for the misunderstanding - Can you take a screen recording of this so we can see how the effect is being disabled?

@CoryAllen Thanks! Link for the recording: DEPTHKIT - SampleScene - Android - Unity 2021.3.mp4 - Google Drive

@Yonatan At first glance, I noticed this project is built in Unity v2021 - Have you tried these in v2020.3 (which is the version that the Depthkit Studio Expansion packages are tested and verified in)?

@CoryAllen I haven’t tried v2020, for my project I’ll be using v2021 for its new URP input system

@Yonatan We haven’t exhaustively tested these packages in Unity v2021, and rather maintain full support in Unity v2020. Are you able to create a quick test project in v2020.3, starting with just the Depthkit packages and asset, and then adding other elements from your project to see if any of those create the issue you’re seeing?

@Yonatan Quick update: I tried to recreate the issue in Unity v2020, and was unable to reproduce the behavior you are seeing where the Edge Masking settings in the Core Mesh Source component are reset once you enter Play mode. Have you been able to do any more testing in the different versions?