Ooops
November 30, 2020, 02:02:00 AM

Author Topic: [bb] Underwater-ish Screen Distortion by jfk EO-11110 [ 1+ years ago ]  (Read 679 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
Title : Underwater-ish Screen Distortion
Author : jfk EO-11110
Posted : 1+ years ago

Description : This is the Function that was used in the "Twilight of Gods" Demo for the Underwater Screen distortion Effect. I also tried to distort not only the y axis, but also the x axis, but the effect wasn't much more impressive, tho it was twice as slow, so I decided to use only the y-axis.

For the animated Texture that is used as additional Surface layers in underwater zones, I used this effect too, plus the said X-Distortion and a number of further steps.

This is a simple thing and maybe it can be done more elegantly and efficiently.


Code :
Code: BlitzBasic
  1. ;Underwater FX by jfk of CSP, please mention this in the credits.
  2. Graphics3D 640,480,32,1
  3. SetBuffer BackBuffer()
  4.  
  5.  
  6. camera=CreateCamera()
  7. TranslateEntity camera,0,0,-12
  8. ; probably use some fog...
  9. CameraFogMode camera,1
  10. CameraFogColor camera,50,100,150
  11. CameraFogRange camera,-100,200
  12. CameraClsColor camera,50,100,150
  13.  
  14.  
  15.  
  16. ; used by screen sinus-distortion fx:
  17. Global screenbk=CreateImage(GraphicsWidth(),GraphicsHeight())
  18. Global underw_a
  19.  
  20.  
  21. ; some dummy content...
  22. n=100
  23. Dim o(n)
  24. For i=0 To n
  25.  o(i)=CreateCube()
  26.  PositionEntity o(i),Rnd(-10,10),Rnd(-10,10),Rnd(-10,10)
  27.  RotateEntity o(i),Rand(360),Rand(360),Rand(360)
  28.  EntityColor o(i),Rand(255),Rand(255),Rand(255)
  29. Next
  30.  
  31.  
  32. While Not KeyDown(1)
  33.  RenderWorld()
  34.  CaptureScreen()
  35.  WobbleView()
  36.  VWait
  37.  Flip 0
  38. Wend
  39. End
  40.  
  41.  
  42. Function capturescreen()
  43.  CopyRect 0,0,GraphicsWidth(),GraphicsHeight(),0,0,BackBuffer(),ImageBuffer(screenbk)
  44. End Function
  45.  
  46. Function WobbleView()
  47.  gw#=GraphicsWidth()
  48.  gh#=GraphicsHeight()
  49.  underw_a=(underw_a+4)
  50.  steph#=gh/32
  51.  mu8#=gh/60
  52.  If underw_a>359 Then underw_a=0
  53.   For iif#=0 To gh-4  Step .001
  54.    wsin#=(Sin((underw_a+iif)Mod 360.0)*mu8#)
  55.    CopyRect 0,  iif,         gw,steph+4, 0,iif+wsin#, ImageBuffer(screenbk),BackBuffer()
  56.    iif=iif+steph
  57.   Next
  58. End Function


Comments :


puki(Posted 1+ years ago)

 I like that "jfk", in fact I notice a bit of water on the ledge at the bottom of my monitor screen - you best check your code for leaks.


Kozmi(Posted 1+ years ago)

 Hey jfk, Thanks for the code example here...;)


RifRaf(Posted 1+ years ago)

 nice effect, compact code.  thanks


aCiD2(Posted 1+ years ago)

 Hey, nice work :) Im doing something similar - a screen pinch and ripple thing


Dirk Krause(Posted 1+ years ago)

 very nice, thanks.


Filax(Posted 1+ years ago)

 Great Code


churchaxe(Posted 1+ years ago)

 looks sow-cool


Clyde(Posted 1+ years ago)

 Nice Stuff!


Ben(t)(Posted 1+ years ago)

 Awesome!


Ben(t)(Posted 1+ years ago)

 a good addition, take out the VWait and that runs a bazillion times faster


 

SimplePortal 2.3.6 © 2008-2014, SimplePortal