fog and lightning?

Doesn’t fog color get affected by lightning?

import direct.directbase.DirectStart
from pandac.PandaModules import *
from direct.interval.IntervalGlobal import *


env = loader.loadModel('environment')
env.reparentTo(render)

colour = (0.5,0.8,0.8)
expfog = Fog("Scene-wide exponential Fog object")
expfog.setColor(*colour)
expfog.setExpDensity(0.05)
render.setFog(expfog)
base.setBackgroundColor(*colour)

dlightnode = DirectionalLight('dlight')
dlight = render.attachNewNode(dlightnode)
dlightnode.setColor(Vec4(0.1,0.1,0.2,1))

alightnode = AmbientLight("ambient light")
alight = render.attachNewNode(alightnode)
alightnode.setColor(Vec4(0.1,0.1,0.2,1))

render.setLight(alight)
render.setLight(dlight)

def myFunction(t):
  dlightnode.setColor(t)
 
i = LerpFunc(myFunction,
		fromData= Vec4(0.1,0.1,0.2,1),
		toData= Vec4(1,1,1,1),
		duration= 3)
i.loop()


run()

The issue is, I want blue fog in the game during the day and dark blue during the night.

def myFunction(t): 
  dlightnode.setColor(t)
  alightnode.setColor(t) 
  base.setBackgroundColor(t)

This worked for me

What worked? Did the fog change it’s color? Or is the background color the same as fog color?

i think therefor you need to write your own shader, which wouldnt be that hard btw. i ve never done it before, but it couldnt be that hard. by using the distance to the light as falloff, so you would reach a nice looking illuminated sphere around.

Sorry about the fault in the last reply…I forgot to put the code which change the fog color

The code what I meant is:

def myFunction(t): 
  dlightnode.setColor(t)
  alightnode.setColor(t) 
  base.setBackgroundColor(t) 
  expfog.setColor(t)

wish that is what you want

So your answer is

  1. no, fog doesnt change it’s color based on light
  2. you should change the fog color always when you also change the light color?
  1. Correct.
  2. If you want the fog color to be the same color as the light, then yes.

David

OK