Ok, thanks for the advice about desktop composition(?), not knowing of this I`ll look into it shortly.
The problem returns when I add the bloom routine, giving totally black screen in v5 no objects no text onscreen, yet compiles fine in v4. Perhaps it`s rendertoimage() causing zdepth problems:-
width=getdevicewidth()
height=getdeviceheight()
SetVirtualResolution(width,height)
CreateObjectbox(1,10,10,10)
setobjectposition(1,0,0,0)
setcameraposition(1,20,20,20)
SetCameraLookAt( 1, GetObjectX(1),GetObjectY(1), GetObjectZ(1), 0 )
CreateRenderImage( 2, width, height, 0, 0 ) // initial render
CreateRenderImage( 3, (width/2), (height/2), 0, 0 ) // reduction 1
CreateRenderImage( 4, (width/4), (height/4), 0, 0 ) // reduction 2
CreateRenderImage( 5, (width/6), (height/6), 0, 0 ) // reduction 3
CreateRenderImage( 6, (width/8), (height/8), 0, 0 ) // blur 1
// we then blur a second time with image 5 as the output, as it is the right size and we don't need it anymore
// image 5 (blurry) is then blended with image 2 (sharp) to produce the final output shown on the screen
// load the shaders for each stage, Quad.vs does a simply vertex transformation to make the 3D plane perfectly fit the entire screen
LoadShader( 1, "Quad.vs", "Initial.ps" )
LoadShader( 2, "Quad.vs", "Reduction.ps" ) // same shader for all three reduction steps
LoadShader( 3, "Quad.vs", "Blur1.ps" )
LoadShader( 4, "Quad.vs", "Blur2.ps" )
LoadShader( 5, "Quad.vs", "Bloom.ps" ) // combines image 5 and 2 into the final output
vx as float
vy as float
vz as float
vx=0.00
vy=0.00
vz=0.00
CreateLightDirectional( 1, 10,10,10, 200, 200, 250 )
SetLightDirectionalDirection( 1, -1, -1,-1 )
`CreateLightPoint( 2, 25,25, 25, 100, 255, 255, 80 )
`SetLightDirectionalDirection( 2, vx, vy, vz )
// make a plane to display images to the screen so they can be modified by shaders.
// planes used for this purpose are generally called quads, AGK has a special Quad primitive
// that means it can trake some shortcuts in the rendering pipeline, Quads will never be
// rendered to the screen unless you specifically draw it with DrawObject()
CreateObjectQuad( 8 )
x# as float
x#=358
y# as float
y#=0
z# as float
z#=0
amount# as float
amount#=0.05
index as integer
index = 1
x as integer
x = (getdevicewidth()/100)*15
y as integer
y = (getdeviceheight()/100)*85
size as integer
size = (getdevicewidth()/100)*12
AddVirtualJoystick( index, x, y, size )
SetVirtualJoystickActive( index, 1 )
setvirtualjoystickvisible(index,1)
indexa as integer
indexa = 2
xi as integer
xi = (getdevicewidth()/100)*85
yi as integer
yi = (getdeviceheight()/100)*85
sizei as integer
sizei = (getdevicewidth()/100)*12
AddVirtualJoystick( indexa, xi, yi, sizei )
SetVirtualJoystickActive( indexa, 1 )
setvirtualjoystickvisible(indexa,1)
do
RotateObjectLocalz(1,amount#)
Print( ScreenFPS() )
Print( "X#="+str(getobjectanglez(1)) )
Update(0)
// full screen bloom process
// first Render() as normal to image 2
SetRenderToImage( 2, -1 ) // render into image 2, using an internal depth buffer
ClearScreen() // make sure the image is clean
Render() // draw the scene as normal
// do some post processing on our newly rendered image 2
SetObjectImage( 8, 2, 0 ) // apply image 2 to the quad
SetObjectShader( 8, 1 ) // set our first shader to the quad, this does some processing on the image to make it suitable for bloom
SetRenderToImage( 3, 0 ) // we will output to image 3 which is half the size, so this is also a reduction whilst shader 1 does some processing
ClearScreen() // clean image 3
DrawObject( 8 ) // draw the quad and nothing else, this makes it nice and fast
// take our newly rendered image 3 and reduce it further
SetObjectImage( 8, 3, 0 ) // apply image 3 to the quad, this removes image 2 which will remain unchanged from now on
SetObjectShader( 8, 2 ) // set the reduction shader which does nothing but reduce the image size
SetRenderToImage( 4, 0 ) // output to image 4 which is half the size of image 3
ClearScreen() // clean image 4
DrawObject( 8 ) // draw the quad and nothing else
// take our newly rendered image 4 and reduce it further
SetObjectImage( 8, 4, 0 ) // apply image 4 to the quad
SetObjectShader( 8, 2 ) // added for clarity, the quad is already using shader 2
SetRenderToImage( 5, 0 ) // output to image 5 which is half the size of image 4
ClearScreen() // clean image 5
DrawObject( 8 ) // draw the quad and nothing else
// we now have a low quality 128x128 copy of our scene in image 5, lets blur this so it creates a nice bloom effect
SetObjectImage( 8, 5, 0 ) // apply image 5 to the quad
SetObjectShader( 8, 3 ) // set the first blur shader, this does a horizontal blur across the pixels
SetRenderToImage( 6, 0 ) // output to image 6, which is the same size as image 5
ClearScreen() // clean image 6
DrawObject( 8 ) // draw the quad and nothing else
SetObjectImage( 8, 6, 0 ) // apply image 6 to the quad
SetObjectShader( 8, 4 ) // set the second blur shader, this does a vertical blur across the pixels to finish the blur effect
SetRenderToImage( 5, 0 ) // output to image 5 as it is no longer being used and is the right size for this step
ClearScreen() // clean image 5
DrawObject( 8 ) // draw the quad and nothing else
// we now have a very blurry image 5 and a nice sharp image 2 from the very beginning (plus some intermediate
// images 3,4,6 that we don't need anymore), we can combine image 5 and 2 to create a nice bloom effect
SetObjectImage( 8, 2, 0 ) // set image 2 to texture stage 0 on the quad
SetObjectImage( 8, 5, 1 ) // set image 2 to texture stage 1 on the quad
SetObjectShader( 8, 5 ) // apply the bloom shader to the quad, this will do the work of blending image 5 and image 2
SetRenderToScreen() // send this output to the screen, this is the only thing the user will see from the entire process
DrawObject( 8 ) // draw the qaud and nothing else, remember image 2 already contains our original scene so we don't need to draw that again
// don't use Sync() here as it will redraw the entire scene again, we have already drawn the scene and post processed it
Swap()
if GetRawKeyPressed( 27 )=1 then end
loop
This uses the standard shaders that come with the bloom example so I imagine you have them already if you need to test it.