December 03, 2020, 08:53:06 PM

Author Topic: [bb] FastExt postprocess to groups by GIB3D [ 1+ years ago ]  (Read 738 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
Title : FastExt postprocess to groups
Author : GIB3D
Posted : 1+ years ago

Description : Use a postprocess effect such as glow, on certain objects.

Code :
Code: BlitzBasic
  1. Include "FastExt.bb"
  2.  
  3. Const RG_Normal = 1
  4. Const RG_Glow = 2
  5.  
  6. Global Camera
  7. Global GlowStick
  8.  
  9. Global GlowOverlay
  10.  
  11.  
  12. InitMedia
  13. Main
  14.  
  15. Function Main()
  16.         While Not KeyDown(1)
  17.                
  18.                 pxRenderPhysic 30,0
  19.                
  20.                 TurnEntity GlowStick,0,1,0,1
  21.                
  22.                 UpdateWorld
  23.                
  24.                 ;1. Render Glow Objects with Black Objects
  25.                 ;2. Put into overlay texture
  26.                 ;3. Cls
  27.                 ;4. Render normal objects
  28.                 ;5. Place glow overlay
  29.                
  30.                 ColorFilter 0,0,0
  31.                 RenderGroup RG_Normal,Camera,1
  32.                 ColorFilter
  33.                 RenderGroup RG_Glow,Camera,0
  34.                 SpecialRender
  35.                
  36.                 CopyRectStretch 0,0,GraphicsWidth(),GraphicsHeight(),0,0,TextureWidth(GlowOverlay),TextureHeight(GlowOverlay),BackBuffer(),TextureBuffer(GlowOverlay)
  37.                
  38.                 RenderGroup RG_Normal,Camera,1
  39.                 CustomPostprocessOverlay(1,1,255,255,255,GlowOverlay)
  40.                 RenderPostprocess(FE_Overlay)
  41.                
  42.                 ;CopyRectStretch 0,0,TextureWidth(GlowOverlay),TextureHeight(GlowOverlay),0,0,256,256,TextureBuffer(GlowOverlay),BackBuffer()
  43.                
  44.                 Flip
  45.         Wend
  46. End Function
  47.  
  48. Function InitMedia()
  49.         Graphics3D 800,600,0,2
  50.         InitExt()
  51.         SetBuffer BackBuffer()
  52.        
  53.         Local Light = CreateLight()
  54.         GroupAttach RG_Normal,Light
  55.         GroupAttach RG_Glow,Light
  56.        
  57.         Camera = CreateCamera()
  58.         PositionEntity Camera,0,5,-10
  59.         RotateEntity Camera,30,0,0
  60.        
  61.         GlowStick = CreateCylinder()
  62.         PositionMesh GlowStick,0,1,0
  63.         PositionEntity GlowStick,2,-1,4
  64.         ScaleEntity GlowStick,.125,2,.125
  65.         RotateEntity GlowStick,30,0,0
  66.         EntityFX GlowStick,1
  67.         GroupAttach RG_Glow,GlowStick
  68.        
  69.         Local Sphere = CreateSphere(8)
  70.         PositionEntity Sphere,2,1,-2
  71.         EntityColor Sphere,255,80,0
  72.         EntityFX Sphere,4
  73.         GroupAttach RG_Glow,Sphere
  74.        
  75.         Local Ground = CreatePlane()
  76.         EntityTexture Ground,GTexture(100,50,20)
  77.         GroupAttach RG_Normal,Ground
  78.        
  79.         Local Obstruction = CreateCube()
  80.         ScaleMesh Obstruction,1,4,1
  81.         EntityColor Obstruction,150,50,10
  82.         EntityFX Obstruction,1
  83.         GroupAttach RG_Normal,Obstruction
  84.        
  85.         GlowOverlay = CreateTexture(1024,1024,1+16+32)
  86. End Function
  87.  
  88. Function GTexture(r,g,b) ; Green Checkered Texture
  89.         Local T = CreateTexture(64,64)
  90.        
  91.         SetBuffer TextureBuffer(T)
  92.                 Color r,g,b
  93.                 Rect 0,0,64,64
  94.                
  95.                 Color r*1.14,g*1.14,b*1.14
  96.                 Rect 32,0,32,32
  97.                 Rect 0,32,32,32
  98.         SetBuffer BackBuffer()
  99.         ScaleTexture T,4,4
  100.         PositionTexture T,.25,.25
  101.        
  102.         Return T
  103. End Function
  104.  
  105. Function SpecialRender()
  106.         CustomPostprocessGlow(1,0,4)
  107.         CustomPostprocessGlowEx(2,2)
  108.         RenderPostprocess(FE_Glow)
  109. End Function


Comments :


puki(Posted 1+ years ago)

 I'll just mention that "GIB3D" has offered this code for use with FastExtension: <a href="http://fastlibs.com/." target="_blank">http://fastlibs.com/.[/url]FastExtension being an awesome way to extend the capabilities of Blitz3D.


 

SimplePortal 2.3.6 © 2008-2014, SimplePortal