ripples
Blitz3D Forums/Blitz3D Programming/ripples
| ||
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... |
| ||
Use an animated texture? |
| ||
that's cheating. |
| ||
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. |
| ||
no, i mean for the sake of a screensaver and waking me up, not as an effect for implementation in a game. |
| ||
You can still use an animated texture (like the ones in Unreal) and pack it into the exe. |
| ||
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. |
| ||
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 |
| ||
but how does it work with adding impulses (a splash) |
| ||
try thisGraphics 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 |
| ||
kinda, but you gave me an idea with that that I'm gonna go experiment on... |
| ||
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 |
| ||
check out my shader engine: http://blitzbasic.com/Community/posts.php?topic=74965 |