Panda3D SimplePBR
Panda3D SimplePBR (version 0.13.1) is a lightweight, drop-in Physically Based Rendering (PBR) shader system for Panda3D. It provides a visual upgrade over Panda3D's default auto shader with minimal code changes, making it easy to integrate PBR workflows. The project is actively maintained with a steady release cadence addressing bug fixes and feature enhancements.
Common errors
-
AttributeError: module 'simplepbr' has no attribute 'get_shader'
cause Attempting to call `simplepbr.get_shader()` in SimplePBR versions 0.12.0 or newer.fixRemove the call to `get_shader()`. Instead, call `simplepbr.init()` once after initializing `ShowBase`. SimplePBR will automatically apply its shader to `base.render`. -
TypeError: 'NodePath' object is not callable
cause This often occurs if `simplepbr.init()` is called before the Panda3D `ShowBase` instance (usually `base`) is fully set up, or if `base` is not accessible.fixEnsure `base = ShowBase()` is executed and `base` is in scope before calling `simplepbr.init()`. -
Shader compilation error: GLSL: '...' : undeclared identifier
cause A generic shader error indicating an issue with the GLSL code. This can be due to an outdated Panda3D version, unsupported graphics drivers, or incorrect shader inputs.fixUpdate your Panda3D installation (`pip install --upgrade panda3d`). Ensure your graphics drivers are up to date. Verify that any custom `setShaderInput` calls use the correct input names as expected by SimplePBR (refer to documentation for specific versions). -
KeyError: 'metallic_map' (or 'roughness_map', 'normal_map', etc.)
cause You are using old shader input names (snake_case) with SimplePBR versions 0.8.0 or newer, which expect camelCase input names.fixChange the shader input names from snake_case to camelCase. For example, `setShaderInput('metallic_map', texture)` should become `setShaderInput('metallicMap', texture)`.
Warnings
- breaking The `simplepbr.get_shader()` function was removed. The shader is now applied globally to `base.render` by `simplepbr.init()`.
- breaking Shader input names for PBR textures changed from snake_case to camelCase (e.g., `metallic_map` became `metallicMap`).
- gotcha SimplePBR requires Python 3.9 or newer and Panda3D 1.10.13 or newer. Using older versions will lead to installation errors or runtime issues.
- gotcha Applying other shaders to `base.render` or its ancestors after `simplepbr.init()` can lead to conflicts or unexpected rendering results, as SimplePBR sets a global shader.
Install
-
pip install panda3d-simplepbr
Imports
- simplepbr
from panda3d.simplepbr import init
import simplepbr
- init
from simplepbr import create_simplepbr
simplepbr.init()
Quickstart
from direct.showbase.ShowBase import ShowBase
from panda3d.core import DirectionalLight, AmbientLight, VBase4
import simplepbr
# Standard Panda3D ShowBase setup
base = ShowBase()
base.camLens.setNearFar(0.1, 1000.0)
# Initialize SimplePBR - this is the core step
simplepbr.init()
# Load a test model (Panda3D's default smiley)
smiley = base.loader.loadModel('smiley')
smiley.reparentTo(base.render)
smiley.setPos(0, 5, 0)
smiley.setHpr(0, 90, 0)
# Add a directional light
dlight = DirectionalLight('dlight')
dlight.setColor(VBase4(0.8, 0.8, 0.8, 1))
dlnp = base.render.attachNewNode(dlight)
dlnp.setHpr(0, -60, 0)
base.render.setLight(dlnp)
# Add some ambient light
alight = AmbientLight('alight')
alight.setColor(VBase4(0.2, 0.2, 0.2, 1))
alnp = base.render.attachNewNode(alight)
base.render.setLight(alnp)
base.run()