I have an inventory system that allows players to choose an item from a list, which then spawns that item as a 3D object suspended close just in front of their camera, which they can then tumble around and examine closely using their mouse.
For the most part it’s working fine, but if the player is close to a wall or looking down at a table or chair, the floating 3D objects can clip inside the nearby world geometry.
I’ve read just about everything I could find on the non-physical sorting of objects, but it seems things like negative values in the Pixel Depth Offset option in materials or Custom Depth passes (for representing the full, colored, shaded object ‘clipping forward’ in the scene depth) either don’t work or aren’t suited for rendering a lit, colored, 3D object in front of everything else.
Because these are just inventory items and not really supposed to be a physicalized part of the world (like say a FPS arm should theoretically be physically in the game’s world), I can’t simply blow up the player’s collision capsule to prevent them from ever getting close to anything. Likewise, disabling the player’s inventory when they’re too close to an object would be terribly arbitrary feeling and confusing to players and an awful solution as well.
For the record, I’m not concerned about accurate shadows being cast either on or from these 3D inventory objects either. If possible, however, I’d like them to receive lighting from the nearby environment, but if that’s unfeasible or multiplies the complexity of a possible solution, then a special lightsource just for these inventory objects would be fine.