I’m trying to set up a prerendered background game and having trouble figuring out how to use shaders to control when a 3D character is and is not visible.
I have rendered a scene from Blender and the corresponding depth map. In Godot I have a 3D camera and a couple placeholder 3D meshes scattered across the scene.
My goal was to use the baked depth map as a way to control mesh visibility, somewhat similar to what this doc describes, except using the baked depth map texture instead of accessing the depth buffer. Does anyone know what modifications would need to be made in order to make it so that the depth map can control visibility of the 3D scene?
I’d just draw it to the depth buffer. Not sure what it takes to match the depth values from Blender with the ones you’ll get in Godot though. It might be easier to get a lowpoly mesh from blender and render that to depthbuffer, instead of dealing with maps.
Is it possible for a mesh to occlude other meshes but not be visible to the camera? That seems preferable to trying to rig up some depth buffer trick that I don’t really know how to pull off yet.
This looks like it’ll work well - I saw this before but I didn’t realize I could crack open my 3D scenery and reassign all the meshes to have that depth-only material.
I tried rendering in Godot first actually. I wasn’t able to get the lighting, rendering quality, and post processing effects how I wanted it (it probably didn’t help that I already had a render I liked from Blender). I don’t know much about lighting in Godot, it’s probably possible to get really close recreating the Blender output but I’d rather put my time towards building the game. I did just run into some weird issues translation camera settings from Blender to Godot, so maybe I’ll end up having to do everything in Godot anyway.
The depth trick is doable but probably not worth the effort. You need to export floating point depth data from Blender using a file format that supports it and that Godot can read. Exr is likely the best (and maybe the only) option.
If your scenes are static, you could just bake the complete look into textures in Blender and go with full 3D instead. It’ll look exactly like Blender render.
Yeah I’m not exporting depth maps anymore. The link earlier in the thread shows a super easy way to have meshes occlude objects behind them but not actually appear in the scene, so I can use a render as a backdrop and then have characters or whatever walk around on the image and get occluded by the scenery meshes.