[bb] Underwater-ish Screen Distortion by jfk EO-11110 [ 1+ years ago ]

Started by BlitzBot, June 29, 2017, 00:28:42

Previous topic - Next topic

BlitzBot

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) Select
;Underwater FX by jfk of CSP, please mention this in the credits.
Graphics3D 640,480,32,1
SetBuffer BackBuffer()


camera=CreateCamera()
TranslateEntity camera,0,0,-12
; probably use some fog...
CameraFogMode camera,1
CameraFogColor camera,50,100,150
CameraFogRange camera,-100,200
CameraClsColor camera,50,100,150



; used by screen sinus-distortion fx:
Global screenbk=CreateImage(GraphicsWidth(),GraphicsHeight())
Global underw_a


; some dummy content...
n=100
Dim o(n)
For i=0 To n
 o(i)=CreateCube()
 PositionEntity o(i),Rnd(-10,10),Rnd(-10,10),Rnd(-10,10)
 RotateEntity o(i),Rand(360),Rand(360),Rand(360)
 EntityColor o(i),Rand(255),Rand(255),Rand(255)
Next


While Not KeyDown(1)
 RenderWorld()
 CaptureScreen()
 WobbleView()
 VWait
 Flip 0
Wend
End


Function capturescreen()
 CopyRect 0,0,GraphicsWidth(),GraphicsHeight(),0,0,BackBuffer(),ImageBuffer(screenbk)
End Function

Function WobbleView()
 gw#=GraphicsWidth()
 gh#=GraphicsHeight()
 underw_a=(underw_a+4)
 steph#=gh/32
 mu8#=gh/60
 If underw_a>359 Then underw_a=0
  For iif#=0 To gh-4  Step .001
   wsin#=(Sin((underw_a+iif)Mod 360.0)*mu8#)
   CopyRect 0,  iif,         gw,steph+4, 0,iif+wsin#, ImageBuffer(screenbk),BackBuffer()
   iif=iif+steph
  Next
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