Shadows and fog do not seem to work correctly together.
A related problem was raised some time ago by Olby in this thread:
problems with shadows and fog
His thread suggests that they worked together until he included a ghosted object (see his sample code).
However, it now seems they don't work together at all (I'm using U7.7RC6).
Here's the code I'm using. Notice how the shadows in the foreground are affected by the fog color. They shouldn't be.
` Spooky's shadow demo plus fog - fog works fine until shadows are enabled
sync on : sync rate 60 : autocam off
fog on
fog color rgb(0,255,0) ` green fog
fog distance 100, 200 ` fog starts at a distance of 100 units
` 0 = use cpu (slow and innaccurate), 1 = gpu shader (fast and accurate)
shader=1
` make a texture
ink rgb(255,0,0),0
box 0,0,16,16
get image 1,0,0,16,16
` hide main light and turn of ambient light
hide light 0
set ambient light 0
` make ground
make matrix 1,1000,1000,64,64
prepare matrix texture 1,1,1,1
position matrix 1,-250,0,-250
` make some objects to cast shadows
o=1
for f=0 to 340 step 20
inc o
make object box o,5,40,5
texture object o,1
set shadow shading on o,-1,1000,shader ` fog works fine if this line is commented
` object, mesh, range, shader
` object=quite obvious really
` mesh=-1 means use objects mesh, but gives option of using lower res mesh
` range=how far to cast shadow - useful as shadows cast on multiple objects through solid objects. Grrrrr
` shader=0=cpu,1=gpu
position object o,100*sin(f),20,100*cos(f)
next f
` make light object to show where light is
inc o
make object sphere o,-10
` make new light and set shadow position
make light 1
set point light 1,0,0,0
set light range 1,1000
lightmode=1
` set shadow mode to 'light' mode,ie shadows will be cast from selected light number
` in this case is 1 (x, y and z values will be ignored)
` you can also use value of -1 which means you can force position of shadows
set shadow position lightmode,0,0,0
position camera -20,8,-150
point camera 0,0,0
ink rgb(255,255,255),0
a#=0
do
control camera using arrowkeys 0,2,2
gosub movelight
text 0,0,"cursors to move around"
text 0,20,"FPS="+str$(screen fps())
sync
loop
movelight:
a#=wrapvalue(a#+0.2)
x#=newxvalue(0,a#,150)
y#=50+(50.0*sin(a#*2.0))
z#=newzvalue(0,a#,150)
position light 1,x#,y#,z#
position object o,x#,y#,z#
return
Edit This seems to be a new problem introduced by a recent update. The code works fine on my version of U7.5. I've noted this on the U7.7 upgrade thread.