Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / Simple approach to simulate water effect

Author
Message
skovron
21
Years of Service
User Offline
Joined: 14th Sep 2003
Location:
Posted: 26th Sep 2003 02:40 Edited at: 4th Oct 2003 00:00
Just a simple Water Wave Effect
It generates waves on bitmap while you moving mouse and pressing left button.
The code is"ver unoptimised" so it rather run slowly but still it someone may find it useful. Experiment with some variables and remember to load rather small bitmaps, I used 320x240 becouse larger couse it run very very slow.

Hamish McHaggis
21
Years of Service
User Offline
Joined: 13th Dec 2002
Location: Modgnik Detinu
Posted: 27th Sep 2003 01:00
Nout happens for me...

Brains are for idiots.

Athelon XP 1400 Plus - Nvidia Geforce MX400 - 256mb RAM
Sedate Solution
21
Years of Service
User Offline
Joined: 15th Apr 2003
Location:
Posted: 27th Sep 2003 01:13
You have posted a DEMO that requires an external file, can you incorporate the external file into the demo or give a link for it to be downloaded.
skovron
21
Years of Service
User Offline
Joined: 14th Sep 2003
Location:
Posted: 27th Sep 2003 22:09
Yea, sorry for that (you could use any picture)
but ofcourse, here is the link for example picture

http://www.arena.free-host.com/examples/example1.jpg
D Man
22
Years of Service
User Offline
Joined: 3rd Oct 2002
Location: Germany
Posted: 28th Sep 2003 14:25
This is very nice.
I think I'll try to optimize it a little bit.

God is real, unless declared integer.
skovron
21
Years of Service
User Offline
Joined: 14th Sep 2003
Location:
Posted: 30th Sep 2003 01:43
Just let me know when you finished. Id like to compare this 2 versions
D Man
22
Years of Service
User Offline
Joined: 3rd Oct 2002
Location: Germany
Posted: 30th Sep 2003 13:27
Well, at least I could double the frame rate.
I wished that I could do more, but it's really hard for me to see throw the code.
I think I'll try to understand this code fully .


God is real, unless declared integer.
D Man
22
Years of Service
User Offline
Joined: 3rd Oct 2002
Location: Germany
Posted: 30th Sep 2003 14:41
Ok...
I could increase the sync rate once more.
Now it runs with ~28 fps on my pc.



God is real, unless declared integer.
skovron
21
Years of Service
User Offline
Joined: 14th Sep 2003
Location:
Posted: 30th Sep 2003 18:11
Wow! Great work!
I had ~26 with last improvement and now I've got ~36

by the way, didnt know that inc, dec are faster than standard +, - operators
skovron
21
Years of Service
User Offline
Joined: 14th Sep 2003
Location:
Posted: 1st Oct 2003 13:04
I saw that when the waves disapear the image stays a little "pixelized" (It looks nice too, like picture from some voxel engine). To solve this function UpdateHeights() should rather looks like this:


I mean there souldnt be checked condition: and (tx<>x or ty<>y)
D Man
22
Years of Service
User Offline
Joined: 3rd Oct 2002
Location: Germany
Posted: 1st Oct 2003 17:05
Oh...you're right, but it is a little faster, when you don't syncronize what you don't have to.
It's better to use this function even if there is an unwanted effect at the start .



God is real, unless declared integer.
D Man
22
Years of Service
User Offline
Joined: 3rd Oct 2002
Location: Germany
Posted: 1st Oct 2003 17:12
ok...forget about the last post.
There are more unwanted effects than wanted .

God is real, unless declared integer.
Hamish McHaggis
21
Years of Service
User Offline
Joined: 13th Dec 2002
Location: Modgnik Detinu
Posted: 1st Oct 2003 18:51
OMG! That is an amazingly amazing effect. Looks so realistic. Great job !

Brains are for idiots.

Athelon XP 1400 Plus - Nvidia Geforce MX400 - 256mb RAM
skovron
21
Years of Service
User Offline
Joined: 14th Sep 2003
Location:
Posted: 1st Oct 2003 19:16
Quote: "It's better to use this function even if there is an unwanted effect at the start "


I didnt mean the effect at the start but that when all waves stops, when image became "dissolved" (dontknow is it wright word), but now it dissapeared and it looks very good and ofcourse compared to the first version it run almost like a rocket

Really good job D Man.
D Man
22
Years of Service
User Offline
Joined: 3rd Oct 2002
Location: Germany
Posted: 1st Oct 2003 19:47
Thank' you , but you had the idea and I knew how to optimize it .
Great job from you, too.

God is real, unless declared integer.
skovron
21
Years of Service
User Offline
Joined: 14th Sep 2003
Location:
Posted: 2nd Oct 2003 10:31
Thanks!
I've got this code i Code Base so I'll update it with this version and I'll give you credit (wright word I hope).
What do you think about?
D Man
22
Years of Service
User Offline
Joined: 3rd Oct 2002
Location: Germany
Posted: 2nd Oct 2003 14:07
I definately agree that you should update the entry in the Code Base but you don't have to give me credits, as this was your idea, but if you wan't I've nothing against it .

God is real, unless declared integer.
skovron
21
Years of Service
User Offline
Joined: 14th Sep 2003
Location:
Posted: 3rd Oct 2003 13:43
Well I've updated the simulation with 2 more effects.
Now under keys 1, 2, 3 you've got three effects
1) old one (move mouse and press lmb)
2) something I called rain
3) similar to the 2nd but drops are bigger and slower

here's the code


and the bitmap:
http://www.arena.free-host.com/examples/example1.jpg

again: enjoy
D Man
22
Years of Service
User Offline
Joined: 3rd Oct 2002
Location: Germany
Posted: 4th Oct 2003 00:21
Good idea and thanks for the credits .

God is real, unless declared integer.
John H
Retired Moderator
22
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 5th Oct 2003 00:25
Great!

Current Project: Eternal Destiny
We need a texture artist!
If your interested email me - Johnrocs@aol.com
John H
Retired Moderator
22
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 5th Oct 2003 00:29
Hey I made a screenshot for all you guys Great effect, this should encourage you to try it out

Effect: 'Rain Drops'



RPGamer

Current Project: Eternal Destiny
We need a texture artist!
If your interested email me - Johnrocs@aol.com
skovron
21
Years of Service
User Offline
Joined: 14th Sep 2003
Location:
Posted: 5th Oct 2003 00:58
Hey thanx for your promotion
I thought this topic will die soon but.... now
John H
Retired Moderator
22
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 5th Oct 2003 03:11
No prob Skovron Just promoting a great snippet

Current Project: Eternal Destiny
We need a texture artist!
If your interested email me - Johnrocs@aol.com
Mike Inel
21
Years of Service
User Offline
Joined: 14th Feb 2003
Location: Sa upuan ko po...
Posted: 7th Oct 2003 13:12
"Simple Water Wave Effect"... It looks VERY complicated to me.....

Uh.....duh.....whut?
skovron
21
Years of Service
User Offline
Joined: 14th Sep 2003
Location:
Posted: 8th Oct 2003 00:35
I'm not good at english.
But still it's simple not becouse the code is easy to understand without comment but simple becouse it isnt accurate. I mean the algorithm rely on "simple" approximation instead of ray-tracing.

I dont know your programming skil but belive me that many programmers which know how to generate waves using grids would say that it is very easy

On the other side I agree that it is always hard to understand code written by somebody else especially when its not comment well (as my code is)
Imperial Darksith
21
Years of Service
User Offline
Joined: 29th Aug 2003
Location: The StarForge
Posted: 17th Oct 2003 12:55
I noticed that when playing KOTOR that they use something rather interesting... I believe that it's a bitmap that's ghosted and scrolled diagonally creating a wave effect. Looks really realistic too. I suspect that your code runs something a bit like this. Am I correct?

I find your lack of faith...disturbing.
D Man
22
Years of Service
User Offline
Joined: 3rd Oct 2002
Location: Germany
Posted: 17th Oct 2003 13:07
No, you're wrong .

God is real, unless declared integer.
skovron
21
Years of Service
User Offline
Joined: 14th Sep 2003
Location:
Posted: 18th Oct 2003 15:18
Youre wrong. No ghosted and scrolled bitmaps.
It just for every pixel checks height difference (along x and y axis) then this differences added to pixel coordinates gives new pixel position and that pixel is being copied from original bitmap

take a look at pseudo code:

Lenny Briscoe
22
Years of Service
User Offline
Joined: 15th Sep 2002
Location:
Posted: 19th Oct 2003 23:31
That's a nice effect. Have to experiment with it.

Lenny
Dreamora
22
Years of Service
User Offline
Joined: 20th Sep 2002
Location: Switzerland
Posted: 26th Oct 2003 12:26
remembers the effect that you can play with while WaveRace GC is loading the track

Dell Inspiron 8200,P4-M 1,7ghz, GF4 440go (45.23 - DX9b), 1GB RAM
DaemoN_v2
21
Years of Service
User Offline
Joined: 13th Oct 2003
Location: Wichita
Posted: 3rd Nov 2003 17:26
niiiiiiiiiiiice

[tT]

Login to post a reply

Server time is: 2024-11-23 23:40:09
Your offset time is: 2024-11-23 23:40:09