Drawing into the depth buffer

I’ve got a 2d image and a matching 2d depth map. What I want to do is draw these into the frame and depth buffers, so that when I render 3d models they are draw in front/behind the respective areas of the 2d image … faking 3d.

In raw OpenGL I should be able to achieve this through use of glDrawPixels; but how do I do it in Panda3d?

I suspect theres a solution using shaders (I’ve no idea how) but it really feels like that would be overcomplicating the problem; all I want to do is sidestep the whole rendering from 3d to 2d bit and just supply the data directly.


shaders fragment shaders can draw to the depth buffer just like they do to the color buffer, nothing special really. Just output “float o_Depth : DEPTH” from your fragment shader.