Problem with volumetric lighting

Hey all

I’m trying to get a volumetric lighting effect to work with the following code:

from direct.directbase.DirectStart import *
from direct.filter.CommonFilters import CommonFilters

class World:
    def __init__(self):
        base.setBackgroundColor(0, 0, 0)
        taskMgr.add(self.timer, "timer")

    def LoadModels(self):
        self.sun2 = loader.loadModel("models/sphere")

        self.filters = None
        self.filters = CommonFilters(,

        self.sun = loader.loadModel("models/sphere")

    def timer(self, task):
        self.sun.setShaderInput("time", task.time)
        return task.cont

World = World()

And the result I’m willing to achieve is the one on the left of this pic. The one I’m getting is the right.

This code was taken from Demomaster’s sun example. When ran via the demomaster’s environment, the result is the one I want (left), and when run as a standalone panda script, I get the right result.

Anyone have any idea on how to fix this?

Try putting “textures-power-2 none” in Config.prc, does that help?

That fixed it, thanks a ton!

Now, is there any way to avoid the rays I circulated in this picture? Like limit the filter to only affect the sun?

You could perhaps create a fullscreen buffer rendering only the sun and then creating your CommonFilters object on that buffer.

In Panda3D 1.8.1 and above, this will be easier; you will be able to render your sun to the stencil buffer or to an auxiliary buffer, and then specify a ‘source = “aux0”’ (or whatever) argument to setVolumetricLighting, or use the output of the bloom stage, like “bloom0”.