November 30, 2020, 01:36:12 AM

Author Topic: [bb] Screen interference effect by big10p [ 1+ years ago ]  (Read 621 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] Screen interference effect by big10p [ 1+ years ago ]
« on: June 29, 2017, 12:28:41 AM »
Title : Screen interference effect
Author : big10p
Posted : 1+ years ago

Description : This is a simple screen filter effect that mimicks screen static/interference. It's variable so can be used like the effect in Metroid Prime where the strength of the effect depends on the proximity to radioactive objects, for example.

It requires a version of Blitz 3D and graphics card that supports x2 multiply blend. If this is a problem, you can change it to use regular multiply blend but the effect isn't as good.

This is just one of many effects possible using this technique. Playing with texture scale, blend modes etc. can reveal many more!

Not sure if I like the scrolling lines or not, but I kept them in anyway! :)


Code :
Code: BlitzBasic
  1. ;
  2. ; Variable screen filter static/interference effect demo.
  3. ;
  4. ; By Big10p (A.K.A. Chris Chadwick) 2004
  5. ;
  6.  
  7.         Graphics3D 800,600,32
  8.  
  9.         WireFrame 0
  10.         AntiAlias 0
  11.         SeedRnd MilliSecs()
  12.         fps_timer = CreateTimer(60)
  13.  
  14.         ; Create fuzz texture.
  15.         fuzz_tex = CreateTexture(128,128)
  16.         SetBuffer TextureBuffer(fuzz_tex)
  17.         For n = 1 To 5000
  18.                 c = Rand(0,255)
  19.                 Color c,c,c
  20.                 Plot Rand(0,127),Rand(0,127)
  21.         Next
  22.  
  23.         ; Create line texture.
  24.         line_tex = CreateTexture(128,128)
  25.         SetBuffer TextureBuffer(line_tex)
  26.         Color 255,255,255
  27.         Line 0,50,127,50
  28.         Color 128,128,128
  29.         Line 0,51,127,51
  30.         Line 0,49,127,49
  31.         SetBuffer BackBuffer()
  32.  
  33.         ; Lights, camera!
  34.         ;
  35.         piv = CreatePivot()
  36.         cam = CreateCamera(piv)
  37.         PositionEntity cam,0,5,-5
  38.         PointEntity cam,piv
  39.         light = CreateLight(1,cam)
  40.         RotateEntity light,45,45,0
  41.  
  42.         ; Create static filter.
  43.         ;
  44.         filter = create_quad(5)
  45.         ScaleMesh filter,2,2,1
  46.         EntityFX filter,1
  47.         EntityParent filter,cam
  48.         TextureBlend fuzz_tex,5
  49.         TextureBlend line_tex,3
  50.         EntityTexture filter,fuzz_tex,0,0
  51.         EntityTexture filter,line_tex,0,1
  52.         PositionEntity filter,EntityX(cam,1),EntityY(cam,1),EntityZ(cam,1),1
  53.         RotateEntity filter,EntityPitch(cam),EntityYaw(cam),EntityRoll(cam),1
  54.         MoveEntity filter,0,0,1.01
  55.         EntityOrder filter,-1
  56.         filter_alpha# = 0.5
  57.         line_scroll# = 0.0
  58.  
  59.         ; Create scene objects.
  60.         ;      
  61.         ground = CreateCube()
  62.         ScaleMesh ground,10,.1,10
  63.         EntityColor ground,100,100,200
  64.         PositionEntity ground,0,-2,0
  65.         EntityAlpha ground,.4
  66.         mirror = CreateMirror()
  67.         PositionEntity mirror,0,-2,0
  68.         ball = CreateSphere(16)
  69.         cube = CreateCube()
  70.         EntityColor cube,255,0,0
  71.         PositionEntity cube,4,0,0
  72.         cone = CreateCone(16)
  73.         EntityColor cone,0,255,0
  74.         PositionEntity cone,-4,0,0
  75.         cylinder = CreateCylinder(16)
  76.         EntityColor cylinder,0,0,255
  77.         PositionEntity cylinder,0,0,4
  78.         thing = CreateSphere(3)
  79.         EntityColor thing,255,255,0
  80.         PositionEntity thing,0,0,-4
  81.  
  82.         info$ = "Press up/down ARROW KEYS to alter effect strength"
  83.  
  84.                        
  85.         ; --- Main loop ---
  86.        
  87.         While Not KeyHit(1)
  88.                 TurnEntity piv,0,.5,0
  89.                
  90.                 ; Set filter alpha (visibility).
  91.                 ;
  92.                 If KeyDown(200) Then filter_alpha = filter_alpha + .01
  93.                 If KeyDown(208) Then filter_alpha = filter_alpha - .01
  94.                 If filter_alpha > 1.0
  95.                         filter_alpha = 1.0
  96.                 ElseIf filter_alpha < 0
  97.                         filter_alpha = 0
  98.                 EndIf
  99.                 EntityAlpha filter,filter_alpha
  100.  
  101.                 ; Update filter textures.
  102.                 ;
  103.                 PositionTexture fuzz_tex,Rnd(0,1),Rnd(0,1)
  104.                 PositionTexture line_tex,0,line_scroll
  105.                 line_scroll = (line_scroll + .01) Mod 1.0
  106.  
  107.                 RenderWorld
  108.                
  109.                 Color 255,0,0
  110.                 Text 401,10,info$,1
  111.                 Text 399,10,info$,1
  112.                 Text 401,9,info$,1
  113.                 Text 401,11,info$,1
  114.                 Color 255,255,0
  115.                 Text 400,10,info$,1
  116.                
  117.                 WaitTimer(fps_timer)
  118.                 Flip(1)
  119.         Wend
  120.  
  121.         End
  122.  
  123. Function create_quad(tex_scale#)
  124.        
  125.         m = CreateMesh()
  126.         s = CreateSurface(m)
  127.        
  128.         AddVertex s,-1,1,0,  0,0
  129.         AddVertex s,1,1,0,   tex_scale,0
  130.         AddVertex s,-1,-1,0, 0,tex_scale
  131.         AddVertex s,1,-1,0,  tex_scale,tex_scale
  132.        
  133.         AddTriangle s,0,1,3
  134.         AddTriangle s,0,3,2
  135.        
  136.         Return m
  137.  
  138. End Function


Comments :


WendellM(Posted 1+ years ago)

 That looks great! I can think of several possible uses for it - thanks.


puki(Posted 1+ years ago)

 Wow, that is the best one that I've seen so far in Blitz - very good stuff "big10p"!


CodeD(Posted 1+ years ago)

 awesome


BlitzSupport(Posted 1+ years ago)

 Love it.


Dirk Krause(Posted 1+ years ago)

 Great...


Perturbatio(Posted 1+ years ago)

 you know the weirdest thing?  if I adjust it up or down, I can almost hear the noise as well :)


Clyde(Posted 1+ years ago)

 Wicked mate :)Welldone.


big10p(Posted 1+ years ago)

 Glad you like. :)As I said, playing around can get different effects, for example:The effect can be changed to lines of static by changing both textures to blend mode 5, and adding EntityBlend filter,3.OrChanging the line filter = create_quad(5) to filter = create_quad(.1) gives a kind of magical glow effect, when used subtlely.


Gavin Beard(Posted 1+ years ago)

 pretty damn sweet, my gfx doesnt support x2 multiply blend, but even standard blending looks fine


big10p(Posted 1+ years ago)

 Yeah, there's not that much difference really. Just the white static dots don't get as bright as they do with x2 blending. :)


Jerome Squalor(Posted 1+ years ago)

 it's like i feel the static!!Great job


 

SimplePortal 2.3.6 © 2008-2014, SimplePortal