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.

DarkBASIC Professional Discussion / Oceeaaaaaannnn with waves

Author
Message
Mecha
18
Years of Service
User Offline
Joined: 20th Mar 2006
Location: The awesome places
Posted: 10th Jan 2007 15:20
I\'m making an ocean in my game, but at first, I used a matrix along with a wave effect. It lagged like hell when I made it huge so that method sort of sucks.

I need some sort of ocean effect that can be really huge (around 10.000x10.000) and still have wave splashing.
The waves doesn\'t have to be active all the time, it\'s OK if it\'s only active when the camera is around.
Also, it should be possible detect the height of the wave since I\'m having objects floating on the water.

Please
GatorHex
19
Years of Service
User Offline
Joined: 5th Apr 2005
Location: Gunchester, UK
Posted: 10th Jan 2007 15:24
Just have a smaller matrix and shrink your models

Large numbers kill frame rate

http://www.KumKie.com http://bulldog.servegame.com
Mecha
18
Years of Service
User Offline
Joined: 20th Mar 2006
Location: The awesome places
Posted: 10th Jan 2007 15:25
I was thinking something else than matrixes, since it saves alot of FPS.
GatorHex
19
Years of Service
User Offline
Joined: 5th Apr 2005
Location: Gunchester, UK
Posted: 10th Jan 2007 15:51
Many moons ago I was coding a flight sim and to have a decent ammount of scenery to fly over I increade the matrix and then everything crawled.

On day it hit me, if i shrink the planes instead of increasing the matrix I would get a large world without the speed penalty

it works good try it, hehehe

http://www.KumKie.com http://bulldog.servegame.com
Mecha
18
Years of Service
User Offline
Joined: 20th Mar 2006
Location: The awesome places
Posted: 10th Jan 2007 17:28
It's not the SIZE of the matrix that drops my FPS, but more the number of tiles.

Having a 50x50 matrix with 18x18 tiles would still give the same FPS as a 50000x50000 matrix with 18x18.
Nicholas Thompson
19
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 10th Jan 2007 18:34
Mecha
18
Years of Service
User Offline
Joined: 20th Mar 2006
Location: The awesome places
Posted: 10th Jan 2007 18:49
Because new subject, basically.
Red Ocktober
20
Years of Service
User Offline
Joined: 6th Dec 2003
Location:
Posted: 10th Jan 2007 19:15 Edited at: 10th Jan 2007 19:23
memblocks and ocean waves... no real problem here...



i think your real problem is that you aren't looking at the problem you are experiencing completely...

step back for a second and ask yourself... why do i need to have an entire large matrix move... does that make much sense...

say, for instance, you want to make a naval game, with ships, and a large expansive ocean... how far will the viewer be able to see...

think about it...

all you really need is to have the moving waves in the immediate area around the view... the rest will look far enough away so that moving all those waves would just be a waste of cpu resource... they wouldn't be able to be seen that well anyways...

just make it so that the wave portion is always where the view is... the rest can be a flat ocean...

same techinigue works here in another engine...



look at any game or simulation... look off into the horizion... those waves wayyyy out there probably aren't moving...

ya gotta learn how to use DB's smoke and mirrors function

good luck...

--Mike
Mecha
18
Years of Service
User Offline
Joined: 20th Mar 2006
Location: The awesome places
Posted: 10th Jan 2007 19:59
Thanks Red Ocktober, that actually helped me quite alot =D
Red Ocktober
20
Years of Service
User Offline
Joined: 6th Dec 2003
Location:
Posted: 10th Jan 2007 20:31
no problemo...

if you need it, the code for memblocks and matrices is in the code archives, here http://darkbasicpro.thegamecreators.com/?m=codebase_view&i=ff622260deaf05fa7890237516f9147f

--Mike
The admiral
21
Years of Service
User Offline
Joined: 29th Aug 2002
Location:
Posted: 10th Jan 2007 23:23
Red october that video is awesome how do you get such good waves??

The admiral
G Man
19
Years of Service
User Offline
Joined: 17th Nov 2004
Location:
Posted: 11th Jan 2007 11:06
Quote: "how do you get such good waves??"


A shader... There's a number of very good publicly available water shaders posted elsewhere on this forum.

Intel Pentium 4, 3.4GHz, 1280MB RAM, NVidia Quadro FX3000/256MB, 240GB HD, XP Pro
Red Ocktober
20
Years of Service
User Offline
Joined: 6th Dec 2003
Location:
Posted: 11th Jan 2007 13:11 Edited at: 11th Jan 2007 13:15
hey there Admiral... thx... i'm not 100% done with the code,but... well, read on...

Quote: "A shader... There's a number of very good publicly available water shaders posted elsewhere on this forum.
"


wrong!!!<<<wrong buzzer sound goes here>>>

it's not the shader G... Evolved did the great shader code, and it is fine for most purposes... but i needed real moving waves...

now if you look carefully at most of these shadered water demos, you'll see that while the shaders give the illusion of waves and movement, the water is actually a flat plain...

not too realistic if you need a stormy sea with waves up against a boat, or a submarine... is it...


now look at the video again... carefully this time... does the moving shadered surface appear to be flat to you... or is it actually moving...

that was the whole purpose of placing the untextured cube alongside the water... so you could see the wave action...

what i did (am doing) is applying a lil application of a sin wave to the vertices, and adding the resulting movement to a shadered surface... and dadaaaa!!! instant real (well, sorta real) ocean waves...

that's why the memblock discussion.

--Mike
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 11th Jan 2007 14:22
Seems to be a common misconception that all you ever need for a great water effect is a shader. Using memblocks or directly changing the vertice data is really the only effective way, stick a shader on it after you get nice waves to improve visuals, but there's no getting away from the work you need to put in to do it right.

''Stick that in your text and scroll it!.''
Red Ocktober
20
Years of Service
User Offline
Joined: 6th Dec 2003
Location:
Posted: 11th Jan 2007 16:06 Edited at: 11th Jan 2007 16:08
you're quite right Van...

i'm really not a shader coder, just dabbling in it at the moment (due to my interest in dx10, seeing that shaders will take on more functionality)... but, i do think that a shader can be coded to actually move the vertices around...

i'm not 100% sure about this though...

regardless, whether you code it for the cpu to do the work, or the gpu to do the work, you're correct in saying that you will still have to code some additional lines to get real moving waves, as opposed to just letting the shader graphics provide the illusion alone...

--Mike
Scraggle
Moderator
20
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 11th Jan 2007 16:17 Edited at: 11th Jan 2007 16:18
Quote: "i do think that a shader can be coded to actually move the vertices around"


You are indeed correct. Green Gandalf has been dabbling with vertex manipulation from within a shader.
You can see his work on my Nvidia Compo thread.

Red Ocktober
20
Years of Service
User Offline
Joined: 6th Dec 2003
Location:
Posted: 11th Jan 2007 19:24 Edited at: 12th Jan 2007 12:44
thx for the link Scrag...

this would be the most efficient way to do something like this, i would guess...

--Mike
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 11th Jan 2007 23:28
Quote: "Green Gandalf has been dabbling with vertex manipulation from within a shader."


Indeed I have.

I attach a demo of a simple wave shader that I wrote when I first started dabbling in shaders. I'm sure I could improve on the code - and the dba code is a mess. But it should show you what shaders can do. You can move the camera in the usual way.

Attachments

Login to view attachments
Steve J
18
Years of Service
User Offline
Joined: 22nd Apr 2006
Location: Vancouver, Washington
Posted: 12th Jan 2007 01:02
that cant be right...my fps said it was 1700!!!!! Madness I tell you! It ran great, cool effect.

Aaron Miller
18
Years of Service
User Offline
Joined: 25th Feb 2006
Playing: osu!
Posted: 12th Jan 2007 08:14
1700?!

I only get about 100-200... Ah...

GameDeveloper, make your own games with a drag-and-drop interface. Basically t3dgm+fpsc editor combined.
http://forum.thegamecreators.com/?m=forum_view&t=86045&b=8&p=2
Steve J
18
Years of Service
User Offline
Joined: 22nd Apr 2006
Location: Vancouver, Washington
Posted: 13th Jan 2007 01:17
I have 8800's now, might attribute to that

Aaron Miller
18
Years of Service
User Offline
Joined: 25th Feb 2006
Playing: osu!
Posted: 14th Jan 2007 02:33
Lucky...

-db

GameDeveloper, make your own games with a drag-and-drop interface. Basically t3dgm+fpsc editor combined.
http://forum.thegamecreators.com/?m=forum_view&t=86045&b=8&p=2
bandM
17
Years of Service
User Offline
Joined: 27th Sep 2006
Location: Home
Posted: 14th Jan 2007 02:50
Wow!Cool effect.I saw more than 550 fps with my 6600GT,great.
Roxas
18
Years of Service
User Offline
Joined: 11th Nov 2005
Location: http://forum.thegamecreators.com
Posted: 14th Jan 2007 12:06 Edited at: 14th Jan 2007 12:07
dang my card handle's only SM 1.4 and i haven't seen any SM 1.4 water shaders in dbpro that's sad

I have no soul.. I nobody.. I have no heart.. I have felt in the darkness.. Im the darkness.. Whatever..
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 14th Jan 2007 12:51
Cool I get 310fps

Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 14th Jan 2007 13:37 Edited at: 14th Jan 2007 14:03
I get 220 fps before I move the camera.

Quote: "dang my card handle's only SM 1.4 and i haven't seen any SM 1.4 water shaders in dbpro that's sad"


That shader runs with VS1.1 and PS1.4. Change the following lines in the shader:



to:



It should run on a PS1.4 capable graphics card. If that doesn't work try changing "vs_1_1" back to "vs_2_0" - it seems some newer cards don't support vs_1_1 which is odd. Let me know how you get on.

That shader was written before I fully appreciated the significance of the different vertex/pixel shader versions and also the code could be tidied up a lot. In fact I might do that later this week and post it on the "Learning To Write Shaders" thread on the NVIDIA Comp board.

Edit: Just done a quick clean-up of the shader code and fixed one minor bug (the specular highlights didn't work before). Will see if it can be optimised/improved further later in the week. Here's the fixed and cleaned code:

Roxas
18
Years of Service
User Offline
Joined: 11th Nov 2005
Location: http://forum.thegamecreators.com
Posted: 14th Jan 2007 15:38
OMG i tried that thing longtime ago and it didn't work but i think i did something wrong THANKS! It works.. Hope this system works in other shader's too ..

Oh btw. 140-150 fps with older code

I have no soul.. I nobody.. I have no heart.. I have felt in the darkness.. Im the darkness.. Whatever..
Codger
21
Years of Service
User Offline
Joined: 23rd Nov 2002
Location:
Posted: 14th Jan 2007 19:35 Edited at: 14th Jan 2007 19:36
Great Job Green Gandalf

I modified some of you code to increase the size of the ocean and "roughen up the sea" by pressing the left mouse button. If you get sea sick press the right mouse button. I was amazed that these changes had no noticeable effect on FPS



I really have to get into shaders after seeing these effects

All the best

Codger

System
PIV 2.8 MZ 512 Mem
FX 5600 256 mem
Codger
21
Years of Service
User Offline
Joined: 23rd Nov 2002
Location:
Posted: 14th Jan 2007 19:40
Is their any way to measure the height of the waves under the camera? It would be neat to have the camera / boat move up and down with the waves

System
PIV 2.8 MZ 512 Mem
FX 5600 256 mem
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 14th Jan 2007 21:57
Quote: "Is their any way to measure the height of the waves under the camera? It would be neat to have the camera / boat move up and down with the waves"


That is a good question. My understanding is that that is a major limitation of shaders and/or presently available GPUs - i.e. you can't read data from the graphics card (except via what you see on the screen of course). I vaguely recall seeing talk of new features allowing you to do that - whether that was DX10 stuff, DBP stuff or GFX card stuff I can't recall. But it's definitely in the offing.

Of course, I could be completely wrong.
Aaron Miller
18
Years of Service
User Offline
Joined: 25th Feb 2006
Playing: osu!
Posted: 14th Jan 2007 22:22
Reading data from VCards would be rather nice.

-db

GameDeveloper, make your own games with a drag-and-drop interface. Basically t3dgm+fpsc editor combined.
http://forum.thegamecreators.com/?m=forum_view&t=86045&b=8&p=2
dononeton
19
Years of Service
User Offline
Joined: 12th Jun 2004
Location: Tusaloosa, AL : USA
Posted: 14th Jan 2007 22:33
This is great I get 385 fps
General Reed
18
Years of Service
User Offline
Joined: 24th Feb 2006
Location:
Posted: 7th Mar 2007 00:18
Cool effect GG, 534fps on an overclocked geforce 6600 - Very efficient coding id say.

Beware, Killing chavs is not a crime, but is the only way to cure the earth
Vist www.scratchyrice-dev.co.uk
Dragon12
17
Years of Service
User Offline
Joined: 31st Dec 2006
Location:
Posted: 7th Mar 2007 03:30
I thought I had a pretty good computer, but 2500 fps?

That's more than Steve J who has a 8800, I only have a 7900GT. What gives?

Very cool by the way.
Steve J
18
Years of Service
User Offline
Joined: 22nd Apr 2006
Location: Vancouver, Washington
Posted: 7th Mar 2007 04:34
My pc has been on for about 20 days straight I believe. Ram gets used up. Plus I render stuff, which uses up CPU cycles. Then I think I might have been modelling. The joy of dual monitors, and an 8800, and a c2d, and 2gb ram=P

pleading and needing and bleeding and breeding and feeding exceeding..where is everybody? trying and lying defying denying crying and dying..where is everybody?
Parkey
17
Years of Service
User Offline
Joined: 1st Mar 2007
Location:
Posted: 7th Mar 2007 17:23
I have to say that I've seen Red Ocktober's waves before and they are quite impressive.

I've recently coded my own ocean using a 20x20 mesh and it looks good enough for what I want. The trick is to manipulate the vertices so that they are evenly spaced on the SCREEN rather than on the ground, then overlay multiple sine functions to move those vertices vertically according to their position to create the effect of overlapping waves.

Login to post a reply

Server time is: 2024-04-27 17:54:18
Your offset time is: 2024-04-27 17:54:18