Has anyone added Depth of Field to P3D?

yep, there’s a nice and working example in “Panda3D 1.7 developer’s cookbook”.

I don’t know in which way could it be reproduced…
Anyway… here you found a ZIP with all the cookies in that book, including DOF and blur coded in Cg.

You can get them from here
under Attachment and code downloads.

Unzip and in the folder 05 (DOF is in chapter 5) you find everything. If don’t understand just ask :smiley:

I don’t think that’s a very good one. The blur quality doesn’t seem very good (pixelated), but the main thing is you can see a line on the ground from where blurring starts. I haven’t seen many DOF shaders though, so this might be an issue for all of them.

The shader just caused my entire screen to go blurry instead of geometry in the distance.

def setupPostFx(self):
        self.filterMan = FilterManager(,

        colorTex = Texture()
        blurTex = Texture()
        depthTex = Texture()

        finalQuad = self.filterMan.renderSceneInto(colortex = colorTex, depthtex = depthTex)
        blurQuad = self.filterMan.renderQuadInto(colortex = blurTex, div = 4)
        blurQuad.setShaderInput("color", colorTex)

        finalQuad.setShaderInput("color", colorTex)
        finalQuad.setShaderInput("blur", blurTex)
        finalQuad.setShaderInput("depth", depthTex)