ripples

Blitz3D Forums/Blitz3D Programming/ripples

chwaga(Posted 2008) [#1]
how can i do basic 2d ripples? I don't want the code, but I just want the theory (wikipedia algebraic formulas confuse me). I want to be able to apply impulses to an X value on a basic 2d water 'plane' and see the ripples...


Mortiis(Posted 2008) [#2]
Use an animated texture?


chwaga(Posted 2008) [#3]
that's cheating.


GfK(Posted 2008) [#4]
Cheating is what special effects is all about.

You know that Shrek isn't real, right? ;) Because they couldn't find a real ogre, they had to cheat.


chwaga(Posted 2008) [#5]
no, i mean for the sake of a screensaver and waking me up, not as an effect for implementation in a game.


Mortiis(Posted 2008) [#6]
You can still use an animated texture (like the ones in Unreal) and pack it into the exe.


chwaga(Posted 2008) [#7]
ummm....no, I mean like a realtime calculation of ripples based on applied impulses on the x axis....I'm trying to wake up my brain by doing something like this.


Charrua(Posted 2008) [#8]
hi

think in concentric circles, each going up and down at the rate of a sin(angle). If you observe an object on water, the water doesn't have a direction other than up and down (when a ripple pass through). So your impulse is just an angle (a value) that is traveling to the next circle, the previous have a one value less, and so on.

confuse?, hope not?

Juan


chwaga(Posted 2008) [#9]
but how does it work with adding impulses (a splash)


Charrua(Posted 2008) [#10]
try this

Graphics 640,480

SetBuffer BackBuffer()

xPoints = GraphicsWidth()
yMiddle = GraphicsHeight()/2
InitAmplitude# = 30
Amplitude# = 0
DecreaseRate# = 0.04
Init = 0
PixelColor = -1	;a short way to declare Alpha=R=G=B = 255

While Not KeyHit(1)

	Cls
	Amplitude = InitAmplitude
	For i=0 To xPoints-1
		WritePixel i, Sin(i*3-Init)*Amplitude+yMiddle, PixelColor
		Amplitude = Amplitude - DecreaseRate
	Next
	Init = Init + 1
	Flip
	
Wend

End


Is it what you are talking about?

Juan


chwaga(Posted 2008) [#11]
kinda, but you gave me an idea with that that I'm gonna go experiment on...


Charrua(Posted 2008) [#12]
the hardest part: Sin(i*3-Init)*Amplitude+yMiddle

The amplitude of the wave decreases as go away (to the right) so I decrease it an ammount: DecreaseRate, if 0, all the waves will be the same.

i*3 gives you some waves in 640 x points, try simply i, or i*2, etc you will see more waves in the same width

Init controls where the maximum point is, that maximum point travels to the left one pixel by one pixel (Init = Init + 1), so the speed depends on it.

the code has bugs, of course: Amplitude should not became negative
Amplitude = Amplitude - DecreaseRate, should decrease to 0...

Juan


bytecode77(Posted 2008) [#13]
check out my shader engine: http://blitzbasic.com/Community/posts.php?topic=74965