[SOLVED]Problem didn't fit in the header.

I have a common filter. The filter has a variable. The variable has to grow up or down depending on how big it is.

Here is the code:

### Effects
fltr = CommonFilters(base.win, base.cam)
fltr.setBloom(blend=(0.3, 0.4, 0.3, 0.0), mintrigger=0.6, maxtrigger=7.0, desat=5.6, intensity=10.0, size="big")

def vlght_upd(task):
    up=True
    if up==True:
        dc = +0.01
    else:
            dc = -0.01
    if dc==1.000 and up==True:
        up==False
    if dc==0.900 and up==False:
        up==True
    dc==0.90
    fltr.setVolumetricLighting(sphere, 32, 0.5, dc, 0.05)
    return task.again

upd_vlght = taskMgr.doMethodLater(0.09, vlght_upd, 'woo!')

And nothing… I did this million times before, but in panda it did not work!

EDIT:
OK, it seems that I’ve written it bad, in python it does not work:

up=True
while 1==1:
    dc=0.90

    
    if up==True:
        dc += 0.01
    else:
        dc -= 0.01

    
    if dc>=1.000 and up==True:
        up=False

    
    if dc<=0.900 and up==False:
        up=True

    
    print dc, up

-Cheers.

–Mešča

you are setting
dc=0.90

inside your while loop, so every time it iterates, it gets reset to 0.90, thus never changes

In the first program, I don’t see where dc is set originally, but you are also using :

dc = +0.01 

and similar to decrement. The proper syntax is:

dc += 0.01

your version simply resets it to a value of 0.01

Hope those two items help!

OK, but(I used the sphere from normal mapping example, and the ecm.jpg you can find here: http://planetpixelemporium.com/download/download.php?earthcloudmap.jpg):

from pandac.PandaModules import *
loadPrcFileData("", "textures-power-2 none")
import direct.directbase.DirectStart
from direct.filter.CommonFilters import CommonFilters
alight = AmbientLight('amibent') 
alight.setColor(VBase4(3, 3, 3, 1)) 
alnp = render.attachNewNode(alight)
plight = PointLight('point')
plight.setColor(VBase4(10, 10, 10, 1))
plnp = render.attachNewNode(plight)
plnp.setPos(0, 0, 1)
render.setLight(alnp)
render.setLight(plnp)
sphere = loader.loadModel("sphere")
sphere.reparentTo(plnp)
sphere.setScale(4, 4 ,4)
tex = loader.loadTexture("ecm.jpg")
sphere.setTexture(tex, 1)
### Effects 
fltr = CommonFilters(base.win, base.cam) 
fltr.setBloom(blend=(0.3, 0.4, 0.3, 0.0), mintrigger=0.6, maxtrigger=7.0, desat=5.6, intensity=10.0, size="big") 

def vlght_upd(task):
    dc==0.90 
    up=True 
    if up==True: 
        dc = +0.01 
    else: 
            dc = -0.01 
    if dc==1.000 and up==True: 
        up==False 
    if dc==0.900 and up==False: 
        up==True 
    fltr.setVolumetricLighting(sphere, 32, 0.5, dc, 0.05) 
    return task.again 

upd_vlght = taskMgr.doMethodLater(0.09, vlght_upd, 'woo!')

run()

And it does not run(I don’t know what exception did occur because IDLE isn’t working for me fine right now)

OK. For the record, I am still using 1.5.4

the line:

    dc==0.90 

should be:

    dc=0.90 

The == is a comparison operator, so you were getting a “variable referenced before it is assigned” error.

I fixed that, and now you are getting, once again:

[code]

Traceback (most recent call last):

File “something.py”, line 39, in
run()
File “C:\Panda3D-1.5.4\direct\src\showbase\ShowBase.py”, line 2266, in run
self.taskMgr.run()
File “C:\Panda3D-1.5.4\direct\src\task\Task.py”, line 965, in run
self.step()
File “C:\Panda3D-1.5.4\direct\src\task\Task.py”, line 903, in step
self.__stepThroughList(taskPriList)
File “C:\Panda3D-1.5.4\direct\src\task\Task.py”, line 802, in __stepThroughLis
t
ret = self.__executeTask(task)
File “C:\Panda3D-1.5.4\direct\src\task\Task.py”, line 721, in __executeTask
ret = task(*task.extraArgs)
File “something.py”, line 34, in vlght_upd
fltr.setVolumetricLighting(sphere, 32, 0.5, dc, 0.05)
AttributeError: CommonFilters instance has no attribute ‘setVolumetricLighting’
[\code]

I don’t know why it claims not to have the setVolumetricLighting attribute…

Note that there are still errors in your logic. the = + vs. += stuff for one, plus, you assign dc = 90 at the beginning of the function, so any assignment that happens in the function is eliminated the next time it is called.

In any event, I once again defer questions regarding CommonFilters to those that are more informed than I…

volumelights are only supported in 1.6.1 and up
i changed the logic a bit, fixed some = - to -= and the likes. and changed the sphere and smiley model as well as preventing panda to use basic-shaders only.
to make it run change the input-texture to point to an existing file.
nice sample btw. never seen volumetric lights in action before :smiley: neat stuff… the earth-at-night textures are looking nice.

from pandac.PandaModules import *
loadPrcFileData("", "textures-power-2 none")

loadPrcFileData("", "basic-shaders-only f") 
import direct.directbase.DirectStart
from direct.filter.CommonFilters import CommonFilters
alight = AmbientLight('amibent')
alight.setColor(VBase4(3, 3, 3, 1))
alnp = render.attachNewNode(alight)
plight = PointLight('point')
plight.setColor(VBase4(10, 10, 10, 1))
plnp = render.attachNewNode(plight)
plnp.setPos(0, 0, 1)
render.setLight(alnp)
render.setLight(plnp)
sphere = loader.loadModel("smiley")
sphere.reparentTo(plnp)
sphere.setScale(4, 4 ,4)
tex = loader.loadTexture("earthlights1k.jpg")
sphere.setTexture(tex, 1)
### Effects
fltr = CommonFilters(base.win, base.cam)
fltr.setBloom(blend=(0.3, 0.4, 0.3, 0.0), mintrigger=0.6, maxtrigger=7.0, desat=5.6, intensity=10.0, size="big")

dc=0.90
up=True
def vlght_upd(task):
    global dc
    global up

    if dc>=1.100 and up==True:
        up=False
    elif dc<=.9 and up ==False:
        up=True
    
    if up==True:
        dc += 0.01
    else:
        dc -= 0.01
    
    
    fltr.setVolumetricLighting(sphere, 32, 0.5, dc, 0.05)
    print dc
    return task.again

upd_vlght = taskMgr.doMethodLater(0.09, vlght_upd, 'woo!')

run()

wow! :open_mouth: even I did not except this! nice!

Thank you.

–Mešča

EDIT: If you like to taste it’s almost full power. Try to add this to the solar system example:

-Header

# tutorial uses the same base code from the solar system tutorial.
from pandac.PandaModules import * 
loadPrcFileData("", "textures-power-2 none") 

loadPrcFileData("", "basic-shaders-only f") 
import direct.directbase.DirectStart
from direct.showbase import DirectObject
from pandac.PandaModules import TextNode, Vec3, Vec4
from direct.interval.IntervalGlobal import *
from direct.gui.DirectGui import *
from direct.showbase.DirectObject import DirectObject
import sys
from direct.filter.CommonFilters import CommonFilters

#We start this tutorial with the standard class. However, the class is a

-End

#end class world
fltr = CommonFilters(base.win, base.cam)     
dc=0.95 
up=True 
def vlght_upd(task): 
    global dc 
    global up 

    if dc>=1.000 and up==True: 
        up=False 
    elif dc<=.95 and up ==False: 
        up=True 
    
    if up==True: 
        dc += 0.001 
    else: 
        dc -= 0.001 
    
    
    fltr.setVolumetricLighting(w.sun, 32, 0.7, dc, 0.05) 
    ###Uncomment if you have a fast GPU
    ###Outputs very nice effect
    ###fltr.setVolumetricLighting(w.sun, 64, 0.7, dc, 0.05)
    ###Uncomment if you have a really fast GPU
    ###Outputs AMAZING effects
    ###fltr.setVolumetricLighting(w.sun, 128, 0.7, dc, 0.05)
    return task.again 

upd_vlght = taskMgr.doMethodLater(0.03, vlght_upd, 'woo!')

w = World()

run()

to correct myself. its 1.6.0 and up. thx pro-rsoft for pointing it out

why you didn’t use the edit button?

cause people get confused when the folowing posts refer to information your changed/deleted.
aside from that it’s easier for people to keep track of things if changes are made in a chronological order. and not jumping forth and back and getting confused etc.

the edit button is very useful to fix typos, change the topic to add things like [SOLVED] , to update broken links,to announce updates, make additions (such as yours) and simmilar.

usually it should not be used to edit your post in order to change/manipulate/delete already existing content since it makes the whole thread unreadable,confusing,irritating and very difficult to understand.

well, that’s your opinion.

That just convinced me that you are the next reincarnation of Dany0.

while this is indeed my humble opinion.but think i share this opinion with most of the other people here.
it’s not like avoiding unnecessary edits is a big deal. it wont hurt anyone and it doesn’t cost a penny either. just try to avoid it if possible.thx