Nodes/ComfyUI-Panda3d/Panda3dLoadDepthModel
ComfyUI Node

Panda3dLoadDepthModel

Turn a depth map into real 3D geometry in your scene

By chaojie·Created 3 years ago·Updated 2 years ago· 17
Panda3dLoadDepthModel
  • base
  • loader
  • parent
  • depthimg
  • textureimg
  • base
  • model
x0.00
y0.00
z0.00
h0.00
p90.00
r0.00
sx1.00
sy1.00
sz1.00

Depth estimation in the ComfyUI world usually means one of two things: a ControlNet preprocessor, or the raw data for a "living photo" parallax effect. Panda3dLoadDepthModel is squarely in the second camp, and it takes a more literal route than most. Instead of just warping pixels, it builds an actual 3D mesh from your depth map and drops it into the Panda3D scene graph as real geometry you can move, rotate, and render from the engine's camera. When the pack was posted to r/StableDiffusion in early 2024, the top comment was someone asking for exactly this: a depth-pass render option. So this is the node the community asked for.

How it works

The mechanism is old-school but effective. Feed it two images - a texture and a depth map - and it does this:

  1. Converts both tensors to PNGs and writes them to custom_nodes/ComfyUI-Panda3d/models/output/ with a timestamped name.
  2. Reads the depth image as grayscale and treats each pixel's brightness as height, generating a per-pixel grid of vertices - a classic heightfield.
  3. Writes that grid out as a Wavefront .obj file, plus an .mtl material file that references the texture image.
  4. Loads the OBJ with loader.loadModel() and parents it into the scene at the position you set.

The p (pitch) input defaults to 90, which rotates the flat mesh to face the camera - that's the parallax trick in a single default. Feed it the output of a DepthAnythingPreprocessor (the pack's own workflow_depth.json chains exactly that way) and you get a gently displaceable surface instead of a flat card.

The inputs that matter

  • depthimg (IMAGE) - the grayscale depth map. Whiter = closer, which is the standard convention.
  • textureimg (IMAGE) - the color image that gets mapped onto the mesh. This is the one you'll recognize in the output.
  • parent (Panda3dModel) - the scene-graph parent; render from Panda3dBase for world space.
  • x / y / z, h / p / r, sx / sy / sz - same position/orientation/scale controls as the other transform nodes. p defaults to 90 for a reason.

It also requires base and loader from Panda3dBase, like every loader in the pack. Outputs are base (passthrough) and model, which you wire into Panda3dTest to render.

Installing it

One pack, all nodes. ComfyUI Manager, search ComfyUI-Panda3d, or:

cd ComfyUI/custom_nodes
git clone https://github.com/chaojie/ComfyUI-Panda3d
cd ComfyUI-Panda3d
pip install -r requirements.txt

Restart ComfyUI. You'll also want a depth preprocessor - DepthAnythingPreprocessor works out of the box and pairs naturally.

Gotchas

  • Mesh size scales with image resolution. The node creates a vertex per pixel, then two triangles per pixel cell. A 512×512 depth map is ~260k vertices and half a million triangles - fine for a one-off, but don't feed it a 4K image and expect speed.
  • It writes files. Every run dumps PNGs, an OBJ and an MTL into models/output/. It cleans up nothing, so that folder accumulates junk over time. Deleting it is safe.
  • There's a built-in one-second sleep after writing the mesh - presumably to let the files flush before the engine reads them. It makes runs feel laggy, but it's intentional.
  • Depth inversion. The node passes depthInvert=True to its mesh builder, so dark-near/bright-far maps still work - just be aware that the inversion is hardcoded, not a toggle.

It's the most interesting node in the pack, and the one that actually does something no other ComfyUI node does out of the box: real geometry from a depth map, inside a real engine, rendered to frames.

CategoryPanda3d

Inputs (14)

NameTypeDefaultDescription
basePanda3dBase
loaderPanda3dLoader
parentPanda3dModel
depthimgIMAGE
textureimgIMAGE
xFLOAT0.00
yFLOAT0.00
zFLOAT0.00
hFLOAT0.00
pFLOAT90.00
rFLOAT0.00
sxFLOAT1.00
syFLOAT1.00
szFLOAT1.00

Outputs (2)

NameTypeDescription
basePanda3dBase
modelPanda3dModel