Problem with volumetric lighting

Return to Scripting Issues

Problem with volumetric lighting

Postby Gormo » Fri Jun 22, 2012 3:15 pm

Hey all

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

Code: Select all

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

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

    def LoadModels(self):
        self.sun2 = loader.loadModel("models/sphere")
        self.sun2.reparentTo(render)
        self.sun2.setScale(0.9)

        self.filters = None
        self.filters = CommonFilters(base.win, base.cam)
        self.filters.setVolumetricLighting(self.sun2,32,0.7,0.99,0.05)

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

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

World = World()
run()


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.
Image

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?
Gormo
 
Posts: 4
Joined: Fri Jun 22, 2012 12:59 pm

Postby rdb » Sat Jun 30, 2012 1:29 pm

Try putting "textures-power-2 none" in Config.prc, does that help?
I prefer e-mail over PM
rdb
 
Posts: 8547
Joined: Mon Dec 04, 2006 5:58 am
Location: Netherlands

Postby Gormo » Tue Jul 03, 2012 7:39 pm

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?
Image
Gormo
 
Posts: 4
Joined: Fri Jun 22, 2012 12:59 pm

Postby rdb » Wed Jul 04, 2012 12:21 pm

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".
rdb
 
Posts: 8547
Joined: Mon Dec 04, 2006 5:58 am
Location: Netherlands


Return to Scripting Issues

Who is online

Users browsing this forum: No registered users and 0 guests