Hi,
I would like to render the output of several camera shaders at the same time.
In this case, it is the Sixty Squares' heat haze:
[Shader] Heat Haze / Distortion (Easy to Use)
And the DarkShader fullscreen Bloom shader.
The problem is that when the Bloom shader renders, it overwrittes the output of the heat haze shader.
The output of the Heat haze shader must be passed as input of the Bloom shader, but I don't know exactly how to do this
Here is the DBPro source code:
Rem Project: Bloom and HeatHaze
Rem Created: 17/10/2010 18:00:15
Rem ***** Main Source File *****
Rem variables
Global HeatFX as integer
Global HeatCam as integer
Global HeatCamIMG as integer
Global HeatXScroll,HeatYScroll as float
Global MainCam as integer
Global FXVector as integer
MainCam = 0 Rem This is your main camera (the camera you use for your game). Change it if you're using another camera.
FXVector = 1
Rem --heat haze
HeatFX = 1
HeatCam = 1
HeatCamIMG = 3
HeatQuad = 2
Rem --Bloom
BloomFX = 2
BloomCam = 2
BloomCamIMG = 4
BloomQuad = 3
BloomQuadFX = 3
Rem Setup the camera variables (unrelated to heat haze)
CamAngX#=25
CamAngY#=0
CamDist#=250
mmx# = 0
mmy# = 0
mmz# = 0
Set Display Mode Desktop Width(), Desktop Height(),32
Sync On
Sync Rate 0
AutoCam Off
Set Window On
Maximize Window
Set Window Layout 0, 0, 0
Rem Make the vector
Make Vector4 FXVector
Rem Load the level object
Load Object "Level/Level.dbo", 1
Rem Rem Rem /HEAT HAZE SETUP:
Rem Load the heat haze effect and make the camera
Load Effect "FX/HeatHaze.fx", HeatFX, 0
Make Camera HeatCam
Set Camera To Image HeatCam, HeatCamIMG, 512, 512
Rem Load the heat haze textures.
Rem NormalMap: Defines the bumpiness of the heat haze. This texture will scroll along the heat haze to create the distortion effect.
Rem Mask: Defines the alpha of the heat haze. Black=0 alpha invisible and White=100% alpha completely visible.
Load Image "Textures/HeatHazeNormalMap.bmp", 1
Load Image "Textures/HeatHazeMask.bmp", 2
Rem Make a heat haze object and position it this object can be whatever shape you want. I just chose a plain.
Make Object Plain HeatQuad, 130, 130
Position Object HeatQuad, 0, 70, 0
Rem Turn the heat haze effect on. [ Syntax is: SetHeatHazeOn object , effect , Normal Map Image, Mask Image ]. Specifying an effect number less than or equal to 0 will use the default effect.
SetHeatHazeOn(HeatQuad,HeatFX,1,2)
Rem Rem Rem /BLOOM SETUP:
REMSTART
REm ShaderDataStart
Color Backdrop 0, 0
Make Camera BloomCam
Color Backdrop BloomCam, 0
Load Camera Effect "FX/Bloom.dbs", BloomFX, 0
Set Camera Effect BloomCam, BloomFX, BloomCamIMG
Rem Make second quad
Make Object Plain BloomQuad, 2, 2
Load Effect "FX/quad.fx", BloomQuadFX, 0
Set Object Effect BloomQuad, BloomQuadFX
Set Vector4 FXVector, 1.0/Screen Width(), 1.0/Screen Height(), 0 , 0
Set Effect Constant Vector BloomQuadFX, "InvViewSize", FXVector
Texture Object BloomQuad, 0, BloomCamIMG
Rem To do not depend on hide/show
REM Set Object Mask BloomQuad, 1 << MainCam
Set Camera Effect Constant Float BloomFX, "BloomPower", 1.0
Set Camera Effect Constant Float BloomFX, "BloomScale", 1.0
REMEND
do
`Print the FPS (unrelated to heat haze)
set cursor 0,0
print "FPS: ",screen fps()
`Control the camera (unrelated to heat haze)
mmx#=mousemovex()/8.0
mmy#=mousemovey()/8.0
mmz#=mousemovez()/-4.0
inc CamAngX#,mmy#
inc CamAngY#,mmx#
inc CamDist#,mmz#
position camera 0,20,0
rotate camera CamAngX#,CamAngY#,0
move camera -CamDist#
if camera position y()<20 then position camera camera position x(MainCam),20,camera position z(MainCam)
Rem Rem Rem /HEAT HAZE:
Rem Point the heat haze object at the camera (not needed, I just did this because I thought it might look better)
Point Object HeatQuad, Camera Position X(MainCam), Camera Position Y(MainCam), Camera Position Z(MainCam)
Rem Update the heat haze, scrolling the texture by 0 on the X axis and 0.005 on the Y axis. (Works just like SCROLL OBJECT TEXTURE.)
UpdateHeatHaze( 0.0, 0.005 )
Rem Rem Rem /BLOOM
REMSTART
Position Camera BloomCam, Camera Position X(MainCam),Camera Position Y(MainCam),Camera Position Z(MainCam)
Rotate Camera BloomCam, Camera Angle X(MainCam) ,Camera Angle Y(MainCam), Camera Angle Z(MainCam)
Rem Sync Bloom Cam
Hide Object BloomQuad
Show Object 1
Sync Camera BloomCam
Show Object BloomQuad
Hide Object 1
Sync Mask %01
if ShiftKey()
Hide Object BloomQuad
else
Show Object BloomQuad
endif
REMEND
Sync
loop
`Turns the heat haze effect on for an object. Specifying an effect number less than or equal to zero will cause the object to use the default effect.
`If you want to use a non-default effect, then you should load it yourself and specify its effect number here.
Function SetHeatHazeOn(obj,effect,NormalMapIMG,MaskIMG)
set object effect obj,effect
texture object obj,0,HeatCamIMG
texture object obj,1,NormalMapIMG
texture object obj,2,MaskIMG
set object mask obj,2^MainCam
set object transparency obj,1
Endfunction
`Updates the heat haze camera and scrolls the default heat haze effect by the amount you specify. If you don't want to scroll the default effect, then set this to 0. Works just like SCROLL OBJECT TEXTURE.
Function UpdateHeatHaze(ScrollU#,ScrollV#)
inc HeatXScroll,ScrollU#
inc HeatYScroll,ScrollV#
set effect constant float HeatFX,"OffsetX",HeatXScroll
set effect constant float HeatFX,"OffsetY",HeatYScroll
position camera HeatCam,Camera Position x(MainCam),Camera Position Y(MainCam),Camera Position z(MainCam)
rotate camera HeatCam,Camera Angle x(MainCam),Camera Angle Y(MainCam),Camera Angle Z(MainCam)
sync mask 2^HeatCam
fastsync
sync mask 2^MainCam
Endfunction
Here is a pic of both effects, but not at the same time: