Rem *** Include File: Bloom.dba ***
Rem Created: 11/19/2007 2:15:04 AM

Rem Included in Project: D:\Workspace\Models\Model and Mats\kid\test.dbpro
   UpDate_Bloom:
   `-----------------------

   `Update bloom camera
      position camera bloom_cam,camera position x(),camera position y(),camera position z()
      rotate camera bloom_cam,camera angle x(),camera angle y(),camera angle z()

   `Update screen object
      dis#=(sh#/2)/tan(fov/2)
      position object bloom_obj+2,camera position x(),camera position y(),camera position z()
      rotate object bloom_obj+2,camera angle x(),camera angle y(),camera angle z()
      move object bloom_obj+2,dis#/400
      move object up bloom_obj+2,0.01
      move object left bloom_obj+2,0.01
      scale object bloom_obj+2,101,101,0

   return
   `-----------------------

   `-----------------------
   `Set up bloom objects and cameras
   Init_Bloom:
   `-----------------------

      fov= int(360.0/4.0)
      sw#=screen width()
      sh#=screen height()
      dis#=(sh#/2)/tan(fov/2)
      brightness#=0.11
      blurWidth#=0.0175
      bloom_cam=7000
      bloom_img=7000
      bloom_obj=7000

   `Camera
      set camera range 0.5,10000
      rem set camera fov fov

   `Screen grabbing Camera
      make camera bloom_cam
      set camera to image bloom_cam,bloom_img,256,256
      set camera range bloom_cam,3,100000
      set camera fov bloom_cam,fov

   `Tone
      make object plain bloom_obj,sw#/100,sh#/100
      load effect "shaders\Bloom.fx",bloom_obj,0
      texture object bloom_obj,0,bloom_img
      set object effect bloom_obj,bloom_obj
      position object bloom_obj,0,-10000,dis#/100
      make camera bloom_cam+1
      set camera to image bloom_cam+1,bloom_img+1,256,256
      set camera range bloom_cam+1,1,100
      set camera fov bloom_cam+1,fov
      position camera bloom_cam+1,0,-10000,0

   `Blur X
      make object plain bloom_obj+1,sw#/100,sh#/100
      load effect "shaders\Bloom.fx",bloom_obj+1,0
      texture object bloom_obj+1,bloom_img+1
      set object effect bloom_obj+1,bloom_obj+1
      position object bloom_obj+1,500,-10000,dis#/100
      make camera bloom_cam+2
      set camera to image bloom_cam+2,bloom_img+2,256,256
      set camera range bloom_cam+2,1,100
      set camera fov bloom_cam+2,fov
      position camera bloom_cam+2,500,-10000,0

   `Screen object + Blur Y
      make object plain bloom_obj+2,-sw#/(400),sh#/(400)
      load effect "shaders\Bloom.fx",bloom_obj+2,0
      texture object bloom_obj+2,0,bloom_img+2
      set object effect bloom_obj+2,bloom_obj+2
      ghost object on bloom_obj+2

   `Set effect data
      set effect technique bloom_obj,"Tone"
      set effect technique bloom_obj+1,"blurpassX"
      set effect technique bloom_obj+2,"blurpassY"
      set effect constant float bloom_obj+1,"Brightness",brightness#
      set effect constant float bloom_obj+1,"blurWidth",blurWidth#
      set effect constant float bloom_obj+2,"Brightness",brightness#
      set effect constant float bloom_obj+2,"blurWidth",blurWidth#

   return
