Hello, I have been playing around with the basic bloom shader included with darkshader, and also bond1's bloom shader. You may have seen my question in a the "Adaptive bloom shader by Bond1!!" thread. Rather than hijacking an info thread as such I though I would post this up, to see if any shader boffins out there can help.
Rem Project: SpaceTrader
Rem Created: Wednesday, November 10, 2010
Rem ***** Main Source File *****
x=desktop width()
y=desktop height()
set display mode x,y,32,1
sync on
color backdrop 0
sync
gosub setup_universe
set camera range 0,20,1000000000
`set camera range 1,10,1000000000
rot as float
radius as float
moonrot as float
radius=38440.03+moon
if music exist(1)=1
loop music 1
endif
dim distance(20,1)
do
gosub orbit
gosub distance
gosub control
rem Render scene camera (which produces our bloom)
if bloom=1
hide object 2000
for n=1 to 20
if object exist(n)
show object n
endif
next n
sync camera 1
endif
text 0,0,"polygons "+str$(statistic(1))
text 0,16,"Speed "+str$(speed)
text 0,32,"Current X,Y,Z "+str$(playerx#)+","+str$(playery#)+","+str$(playerz#)
text 0,48,"FPS "+str$(screen fps())
text 0,64,"Sun X,Y,Z "+str$(planet(1,1))+","+str$(planet(1,2))+","+str$(planet(1,3))+" Distance "+str$(planet(1,4)-planet(1,5))
text 0,80,"Mercury X,Y,Z "+str$(planet(2,1))+","+str$(planet(2,2))+","+str$(planet(2,3))+" Distance "+str$(planet(2,4)-planet(2,5))
text 0,96,"Venus X,Y,Z "+str$(planet(3,1))+","+str$(planet(3,2))+","+str$(planet(3,3))+" Distance "+str$(planet(3,4)-planet(3,5))
text 0,112,"Earth X,Y,Z "+str$(planet(4,1))+","+str$(planet(4,2))+","+str$(planet(4,3))+" Distance "+str$(planet(4,4)-planet(4,5))
text 0,128,"Mars X,Y,Z "+str$(planet(5,1))+","+str$(planet(5,2))+","+str$(planet(5,3))+" Distance "+str$(planet(5,4)-planet(5,5))
text 0,144,"Jupiter X,Y,Z "+str$(planet(6,1))+","+str$(planet(6,2))+","+str$(planet(6,3))+" Distance "+str$(planet(6,4)-planet(6,5))
text 0,160,"Saturn X,Y,Z "+str$(planet(7,1))+","+str$(planet(7,2))+","+str$(planet(7,3))+" Distance "+str$(planet(7,4)-planet(7,5))
text 0,176,"Uranus X,Y,Z "+str$(planet(8,1))+","+str$(planet(8,2))+","+str$(planet(8,3))+" Distance "+str$(planet(8,4)-planet(8,5))
text 0,192,"Neptune X,Y,Z "+str$(planet(9,1))+","+str$(planet(9,2))+","+str$(planet(9,3))+" Distance "+str$(planet(9,4)-planet(9,5))
text 0,208,"Pluto X,Y,Z "+str$(planet(10,1))+","+str$(planet(10,2))+","+str$(planet(10,3))+" Distance "+str$(planet(10,4)-planet(10,5))
text 0,224,"Moon X,Y,Z "+str$(planet(11,1))+","+str$(planet(11,2))+","+str$(planet(11,3))+" Distance "+str$(planet(11,4)-planet(11,5))
rem Render our main screen camera zero
if bloom=1
show object 2000
for n=1 to 20
if object exist(n)
hide object n
endif
next n
sync mask %01:sync
endif
sync
LOOP
distance:
for n= 1 to 20
x1#=planet(n,1)
y1#=planet(n,2)
z1#=planet(n,3)
x2#=camera position x(0)
y2#=camera position y(0)
z2#=camera position z(0)
x#=x2#-x1#
y#=y2#-y1#
z#=z2#=z1#
planet(n,4)=sqrt((x#^2)+(y#^2)+(z#^2))
next n
return
orbit:
inc rot,.1
inc moonrot,.1
yrotate object 1,wrapvalue(rot/10)
yrotate object 2,wrapvalue(rot/10)
yrotate object 3,wrapvalue(rot/10)
yrotate object 4,wrapvalue(rot/5)
yrotate object 5,wrapvalue(rot)
yrotate object 6,wrapvalue(rot/10)
yrotate object 7,wrapvalue(rot/10)
yrotate object 8,wrapvalue(rot/5)
yrotate object 9,wrapvalue(rot)
yrotate object 10,wrapvalue(rot)
yrotate object 11,wrapvalue(rot)
`SET OBJECT TO CAMERA ORIENTATION 1000
`yrotate object 300,object orientation
for n=300 to 310
SET OBJECT TO CAMERA ORIENTATION n
next n
xpos=radius*cos(moonrot)
zpos=radius*sin(moonrot)
position object 11,xpos+(sun/2)+14960000,0,zpos
for n= 1 to 20
if object exist(n)
planet(n,1)=object position x(n)
planet(n,2)=object position y(n)
planet(n,3)=object position z(n)
endif
next n
return
control:
if keystate(44)=1
if speed<100000
inc speed
endif
endif
if keystate(45)=1
if speed>0
dec speed
endif
endif
if keystate(44)=1 and keystate(29)=1
if speed<100000
inc speed,10
if speed>100000
speed=100000
endif
endif
endif
if keystate(45)=1 and keystate(29)=1
if speed>20
dec speed,20
if speed<0
speed=0
endif
endif
endif
if upkey()=1
inc bank#,.2
ENDIF
if downkey()=1
dec bank#,.2
ENDIF
if leftkey()=1
dec turn#,.2
ENDIF
if rightkey()=1
inc turn#,.2
ENDIF
yrotate camera 0,turn#
xrotate camera 0,bank#
move camera 0,speed
playerx#=camera position x(0)
playery#=camera position y(0)
playerz#=camera position z(0)
`yrotate object 1000,turn#
`xrotate object 1000,bank#
`move object 1000,speed
return
setup_universe:
if file exist("sun4.png")=1
load image "sun.png",1
load image "mercury.jpg",2 `57.91 million km distance from sun
load image "venus.jpg",3 `108.2 million km
load image "earth.jpg",4 `149.6 million km
load image "mars.jpg",5 `227.94
load image "jupiter.png",6 `778.33
load image "saturn.png",7 `1426.94
load image "uranus.png",8 `2870.99
load image "neptune.jpg",9 `497.07
load image "pluto.jpg",10 `5913.52
load image "moon.jpg",11
load image "sky.bmp",30
load image "target.bmp",300
load music "docking.mp3",1
else
for n=1 to 11
cls rgb(rnd(255),rnd(255),rnd(255))
get image n,0,0,256,256,1
NEXT n
cls rgb(rnd(255),rnd(255),rnd(255))
get image 11,0,0,256,256,1
cls 0
blue=rgb(0,0,200)
black=rgb(0,0,0)
box 0,0,256,256,blue,blue,blue,blue
box 32,0,224,256,black,black,black,black
box 0,32,256,224,black,black,black,black
box 4,4,252,252,black,black,black,black
get image 300,0,0,256,256,1
endif
`load effect "post-bloom.fx",1,0
`type galaxy
`name as string
`stars as integer
`planets as integer
`moons as integer
`endtype
`dim galaxy(10,10,10) as galaxy
remstart
for x= 0 to 10
for y=0 to 10
for z= 0 to 10
inc tempname
galaxy(x,y,z).name=str$(tempname)
galaxy(x,y,z).stars=rnd(2)+1
galaxy(x,y,z).planets=rnd(20)+1
galaxy(x,y,z).moons=rnd(galaxy(x,y,z).planets)+1
`print "Name: "+galaxy(x,y,z).name
`print "Stars: "+str$(galaxy(x,y,z).stars)
`print "Planets: "+str$(galaxy(x,y,z).planets)
`print "Moons"+str$(galaxy(x,y,z).moons)
next z
NEXT y
`sync
NEXT x
remend
sun=6378000
moon=15940
spheredetail=64
mercury=24390
venus=60520
earth=63780
mars=33970
jupiter=714920
saturn=602680
uranus=255590
neptune=247640
pluto=11600
` suns
make object sphere 1,sun,16,16
texture object 1,1
position object 1,0,0,0
`set object 1,1,1,0,1,0
set object light 1,0
`set effect on 1,"post-bloom.fx",1
`planets
make object sphere 2,mercury,spheredetail,spheredetail
texture object 2,2
position object 2,5791000+(sun/2),0,0
make object sphere 3,venus,spheredetail,spheredetail
texture object 3,3
position object 3,10820000+(sun/2),0,0
make object sphere 4,earth,spheredetail,spheredetail
texture object 4,4
position object 4,14960000+(sun/2),0,0
make object sphere 5,mars,spheredetail,spheredetail
texture object 5,5
position object 5,22794000+(sun/2),0,0
make object sphere 6,jupiter,spheredetail,spheredetail
texture object 6,6
position object 6,77833000+(sun/2),0,0
make object sphere 7,saturn,spheredetail,spheredetail
texture object 7,7
position object 7,142694000+(sun/2),0,0
make object sphere 8,uranus,spheredetail,spheredetail
texture object 8,8
position object 8,287099000+(sun/2),0,0
make object sphere 9,neptune,spheredetail,spheredetail
texture object 9,9
position object 9,449707000+(sun/2),0,0
make object sphere 10,pluto,spheredetail,spheredetail
texture object 10,10
position object 10,591352000+(sun/2),0,0
`moons
make object sphere 11,moon,spheredetail,spheredetail
texture object 11,11
position object 11,14960000+(sun/2)+3844.03,0,0
dim planets(20,9)
for n= 1 to 20
planets(n,1)=256
planets(n,2)=128
planets(n,3)=64
planets(n,4)=32
planets(n,5)=16
planets(n,6)=8
planets(n,7)=4
planets(n,8)=2
planets(n,9)=1
next n
dim planet(20,5)
for n= 1 to 20
if object exist(n)
a#=object position x(n)
b#=object position y(n)
c#=object position z(n)
planet(n,1)=a#
planet(n,2)=b#
planet(n,3)=c#
planet(n,5)=object size(n,1)
endif
next n
`target icons
make object plain 300,sun*2,sun*2
texture object 300,300
position object 300,planet(1,1),planet(1,2),planet(1,3)
`set object 300,1,1,0,1,0
set object light 300,0
set object transparency 300,6
make object plain 301,mercury*planets(2,1),mercury*planets(2,1)
texture object 301,300
position object 301,planet(2,1),planet(2,2),planet(2,3)
`set object 301,1,1,0,1,0
set object light 301,0
set object transparency 301,6
make object plain 302,venus*planets(3,1),venus*planets(3,1)
texture object 302,300
position object 302,planet(3,1),planet(3,2),planet(3,3)
`set object 302,1,1,0,1,0
set object light 302,0
set object transparency 302,6
make object plain 303,earth*planets(1,1),earth*planets(1,1)
texture object 303,300
position object 303,planet(4,1),planet(4,2),planet(4,3)
`set object 303,1,1,0,1,0
set object light 303,0
set object transparency 303,6
make object plain 304,mars*planets(1,1),mars*planets(1,1)
texture object 304,300
position object 304,planet(5,1),planet(5,2),planet(5,3)
`set object 304,1,1,0,1,0
set object light 304,0
set object transparency 304,6
make object plain 305,jupiter*planets(1,1),jupiter*planets(1,1)
texture object 305,300
position object 305,planet(6,1),planet(6,2),planet(6,3)
`set object 305,1,1,0,1,0
set object light 305,0
set object transparency 305,6
make object plain 306,saturn*planets(1,1),saturn*planets(1,1)
texture object 306,300
position object 306,planet(7,1),planet(7,2),planet(7,3)
`set object 306,1,1,0,1,0
set object light 306,0
set object transparency 306,6
make object plain 307,urnaus*planets(1,1),urnaus*planets(1,1)
texture object 307,300
position object 307,planet(8,1),planet(8,2),planet(8,3)
`set object 307,1,1,0,1,0
set object light 307,0
set object transparency 307,6
make object plain 308,neptune*planets(1,1),neptune*planets(1,1)
texture object 308,300
position object 308,planet(9,1),planet(9,2),planet(9,3)
`set object 308,1,1,0,1,0
set object light 308,0
set object transparency 308,6
make object plain 309,pluto*planets(1,1),pluto*planets(1,1)
texture object 309,300
position object 309,planet(10,1),planet(10,2),planet(10,3)
`set object 309,1,1,0,1,0
set object light 309,0
set object transparency 309,6
make object plain 310,moon*planets(1,1),moon*planets(1,1)
texture object 310,300
position object 310,planet(11,1),planet(11,2),planet(11,3)
`set object 310,1,1,0,1,0
set object light 310,0
set object transparency 310,6
`make object cube 1000,30
`position object 1000,500000,0,-4500
`make object box 30,19000000,19000000,19000000
`texture object 30,30
`position object 30,0,0,0
`set object 30,1,1,0,1,0
`load object "shuttle1.x",100
`position object 100,6000+(sun/2),0,0
make light 1
set light range 1,1000000000
position light 1,0,0,0
position camera 0,5000000,0,-4500
`point camera 0,0,0,0
set ambient light 10
`hide light 0
planet=2
` planet,x,y,z,distance to ship,size,
`cls 0
bloom=0 `1/0 change to enable/diable bloom effect
if bloom=1
rem Make camera one our new 3D scene camera
make camera 1 : color backdrop 1,rgb(255,64,0)
rem Load and apply fullscreen shader to scene camera (using DarkSHADER commands and file format)
load camera effect "bloom.dbs",1,0 : set camera effect 1,1,1
rem Place scene camera
`position camera 1,500000,0,-4500
position camera 1,0,50,-200
point camera 1,0,0,0
rem Create a quad with quad shader for our main screen camera zero
make object plain 2000,2,2,1
load effect "quad.fx",2,0
set object effect 2000,2
null = make vector4(1)
set vector4 1,x,y,0,0
set effect constant vector 2,"ViewSize",1
null = delete vector4(1)
texture object 2000,0,1
endif
return
That is the code in it's entirety, rather than the snippet I put in the aforementioned post. Turn off/on bloom by changing bloom=0 to bloom=1 at line 455.
Basically I am either getting a black screen or as I have now discovered since altering the media code a little for posting, I see the last thing that was drawn to screen before the 3d objects were made( the target graphic). If I turn off the bloom obviously it all works fine. It seems as if it is texturing the plain with the last image grabbed rather than the camera image? I cannot see where the shader gets it's image from as it seems to use image 1 which should be the suns image.
I'd love to get this working nice and early on before things start really getting more complicated. I think it s a camera/image problem somehow, but am unable to work out what's happening.
I also lose all my info text when attempting to use the shader which I also can't see why as I place it in the correct place according to the demo. It just seems the image is static and is not updating.
Edit - accelerate and decelerate using z and x keys arrow keys control direction. Hold ctrl and z or x to increase boost. Just in case you don't want to work out the keystates
http://s6.bitefight.org/c.php?uid=103081