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.

Dark GDK / Dark GDK Water?

Author
Message
Acidic Parisidic
15
Years of Service
User Offline
Joined: 8th Dec 2008
Location:
Posted: 9th Dec 2008 02:39
Hey, im pretty new to C++ and DarkGDK, but my question is:
How would i add water to my game, with terrain?
The Real Abaddon
16
Years of Service
User Offline
Joined: 26th Jun 2008
Location:
Posted: 9th Dec 2008 14:09
using shaders.
Acidic Parisidic
15
Years of Service
User Offline
Joined: 8th Dec 2008
Location:
Posted: 9th Dec 2008 14:43
Ok, could you be a little bit more specific, What exactly would i need to do to shade in a little patch of water, I also use Blender if it helps any
jezza
16
Years of Service
User Offline
Joined: 8th Mar 2008
Location: Bham, UK
Posted: 9th Dec 2008 17:42
A shader is a program written in either a high level language such as HLSL, or assembly language.
GDK uses HLSL. It tells the graphics card what colour to render each pixel or vertex.
You can download them from this site somewhere...
Acidic Parisidic
15
Years of Service
User Offline
Joined: 8th Dec 2008
Location:
Posted: 9th Dec 2008 17:53
ok would something like RenderMonkey, or NVidia FX Composer work, i have those programs as well?
Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 9th Dec 2008 22:11
FX Composer should work, and I know it produces nice results.
sydbod
16
Years of Service
User Offline
Joined: 14th Jun 2008
Location: Just look at the picture
Posted: 10th Dec 2008 02:03
Quote: "Hey, im pretty new to C++ and DarkGDK,....... How would i add water to my game, with terrain? "


The easy way is to just create a mesh object at the height of the water level. "dbMakeMatrix ()" and "dbPositionMatrix ()"

Texture it with a nice water looking texture. "dbLoadImage ()" and "dbPrepareMatrixTexture ()" and "dbSetMatrixTile ()"

Make the water looking mesh "dbGhostMatrixOn ()" and "dbUpdateMatrix ()"

Once you have the basics sorted, then maybe try the fancy way with Shaders.
Acidic Parisidic
15
Years of Service
User Offline
Joined: 8th Dec 2008
Location:
Posted: 10th Dec 2008 02:48
Great Advice, ill try that, also, i am having a little trouble with the FX Composer but im trying to work out the kinks, any more advice would help too.
Acidic Parisidic
15
Years of Service
User Offline
Joined: 8th Dec 2008
Location:
Posted: 10th Dec 2008 03:08
ok, the Matrix isnt working, here is my code, plz help me guyz, im on a learning curve.

Attachments

Login to view attachments
jezza
16
Years of Service
User Offline
Joined: 8th Mar 2008
Location: Bham, UK
Posted: 10th Dec 2008 20:01
Can you jsut post your code in your post? i don't really want to download. Both FX Composer and Render monkey should work.
sydbod
16
Years of Service
User Offline
Joined: 14th Jun 2008
Location: Just look at the picture
Posted: 10th Dec 2008 23:55 Edited at: 11th Dec 2008 00:00
Here is your code:


Here is some code that I use to handle generic forms of matrix for all sorts of things like water / terrain/ clouds .... etc
This fragment is configured to make an ocean mesh that is 1000000 x 1000000 units in area.

From it, you should be able to correct your understandings of the
dbMakeMatrix()
dbPrepareMatrixTexture()
dbSetMatrixTile()
dbGhostMatrixOn()
functions.




If you are still not sure about the problem, then please post again and we will go through each of your steps one instruction at a time, as it can be frustrating when one first starts programing this sort of thing.
jezza
16
Years of Service
User Offline
Joined: 8th Mar 2008
Location: Bham, UK
Posted: 11th Dec 2008 17:43
jus a question, ive never tried any of this myself so youknow, but since water is flat why can you not jsut use a plane object?
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 12th Dec 2008 03:50
yeah... but using a matrix you could get waves by manipulating it. also, I have seen a situation where having a large plane caused z-fighting... and making tiles got rid of it - but then I think the key to avoiding zfighting is not herein... its by changing the scale of how much your camera is looking at compared to everything in the world.. try to cover to big an area - get zfighting... change the scope a bit? Much better (Though then you get other issues too.. its a balancing act this game stuff)

In short - make a plane - texture with water as mentioned above - and go forward - you can revisit later

--Jason

jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 12th Dec 2008 03:50
yeah... but using a matrix you could get waves by manipulating it. also, I have seen a situation where having a large plane caused z-fighting... and making tiles got rid of it - but then I think the key to avoiding zfighting is not herein... its by changing the scale of how much your camera is looking at compared to everything in the world.. try to cover to big an area - get zfighting... change the scope a bit? Much better (Though then you get other issues too.. its a balancing act this game stuff)

In short - make a plane - texture with water as mentioned above - and go forward - you can revisit later


--Jason

sydbod
16
Years of Service
User Offline
Joined: 14th Jun 2008
Location: Just look at the picture
Posted: 12th Dec 2008 04:24
Quote: "but since water is flat why can you not jsut use a plane object? "


That is something to always strive for if you want a simple, low overhead, water layer.

the only problem is when you have a very large surface of water.... eg: 1,000Km x 1,000Km area. One can not create a texture that is large enough in resolution to get a realistic looking water surface. Even using a texture of 4096x4096 (only possible on very late generation video cards) each pixel represents an area of 250m x 250m . One could not draw realistic wave patterns.
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 12th Dec 2008 04:27
Whoa... you can change the scaling of the UV though and "Tile" the water... so the big plane is still a "go" ..

Make a plane, get it oriented, texture it, the change the uv to cause it to tile the bmp or whatever... I like PNG, dds should be ideal though LOL (The image format debate) LOL

--Jason

sydbod
16
Years of Service
User Offline
Joined: 14th Jun 2008
Location: Just look at the picture
Posted: 12th Dec 2008 04:40 Edited at: 12th Dec 2008 04:46
Quote: "Whoa... you can change the scaling of the UV though and "Tile" the water... so the big plane is still a "go" .."


EHHHHH!!!!!! I must have missed something

Are you talking about "dbTextureObject ()", allowing us to actually tile a texture within the one square polygon surface???

EDIT: please can you give a code fragment of what you are talking about.
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 12th Dec 2008 04:47
Well you texture it first I recall.. then cann one of the UV commands ... to modify the "scaling" of the UV I'm pretty sure... been awhile since I've been DarkGDK'ing it. Though I might give the C# a spin because I'm curious what the speed is like using APEX's new stuff. If its as easy to use as advertised and is fast - I might try it seriously... if not I might revert to DarkGDK C++ dev... or maybe just raw dx9 and dx10 for a bit.

--Jason

Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 12th Dec 2008 05:28
If it's anything like dbSetSpriteTextureCoord then you just set the UV to something greater than 1.0 to cause the texture to repeat. But then you run the risk of a tiling effect if the edges don't match.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
sydbod
16
Years of Service
User Offline
Joined: 14th Jun 2008
Location: Just look at the picture
Posted: 12th Dec 2008 06:24
AHHHHH... I think this is what you are talking about
"void dbScaleObjectTexture ( int iObject, float fU, float fV )"

So "float fU = 100" and "float fV = 100" should tile the texture 100 times across and 100 times down.

Will give it a try later tonight and see how it all falls out.
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 12th Dec 2008 06:38
There you go! There is also a scroll one too.. I used that to move tank treads in http://code.google.com/p/ironinfantrydbpro/

--Jason

sydbod
16
Years of Service
User Offline
Joined: 14th Jun 2008
Location: Just look at the picture
Posted: 12th Dec 2008 06:50
Quote: "I used that to move tank treads in http://code.google.com/p/ironinfantrydbpro/"


I should thank you for that code.
I came upon DarkGDK on the net ...... was not very impressed and thought it may be a bit too simplistic. At first I didnt even look properly at it.
I came upon some of your posts and took a look at your "ironinfantrydbpro" code.
I was so impressed with how much functionality could be placed is so little code, that it was the start for me to actually look at DarkGDK.
Looking at DarkGDK was one of the best things I have ever done .... it lets one do so much, in such a short time.
Likewise speed is primarily a function of the ingenuity of the programmer and NOT limited by the language.
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 12th Dec 2008 11:58
WOW - that's just awesome - thanx for the props - glad you came onboard!
--Jason

sydbod
16
Years of Service
User Offline
Joined: 14th Jun 2008
Location: Just look at the picture
Posted: 12th Dec 2008 14:02 Edited at: 12th Dec 2008 14:22
UPDATE: about using a "Plain Object" for a water level.

I used this code


It proved to NOT be a suitable way of doing things.

As soon as one looks at slightly off perpendicular from the water surface, then the surface texture darkens, and quickly turns black.
It looks like there is very little leeway to how large a single triangle can be before it starts to behave problematically when viewed at a slight angle.
The "matrix" does not show this sort of problem, but it has no way of scaling the texture like the object has.
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 12th Dec 2008 14:46
I think I MIGHT have seen that before - can you post a screenie?

sydbod
16
Years of Service
User Offline
Joined: 14th Jun 2008
Location: Just look at the picture
Posted: 13th Dec 2008 02:17
Quote: "can you post a screenie?
"


I have made in my game the following changes.

The ocean is now a small "Plain Object"



The ocean bed that has the same blu texture on it as the ocean, but is HUGE and 100 units lower.


This first screen shot is from 3000 units above the ocean and looking perpendicular to the surfaces.
The ocean square and the ocean bed are the exact same color.


Now I just tip the aircraft a little more so that we are looking at around 5Deg off from the perpendicular (around 85 deg), but not displacing the aircraft or anything else.


The little ocean square is now at the top end of the field of view and is still its original color.
the HUGE ocean floor square is now a little darker in color.


The more I tip the aircraft away from the perpendicular to the HUGE ocean floor square, the darker it becomes until it is black.
The small ocean square keeps its color until one is looking at it end on and then it disappears as it should.
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 13th Dec 2008 02:58 Edited at: 13th Dec 2008 02:59
Take a look at what I did in these projects:

http://code.google.com/p/ironinfantrydbpro/

and

http://code.google.com/p/darkgdkoop/

Note source included in both plus media - additionally the DarkGDK code with a little text searching is actually not all that hard to read... so both might be worthwhile downloads.

Here are some galleries I made up without being a water expert.. some do have shaders but on either planes of water or an object I made in milkshape (or was it 3DWS - that had the texture tiling already done)

http://www.jasonpetersage.com/?PAGE=ironinfantry&SECTION=gallery

and

http://www.jasonpetersage.com/?PAGE=ironinfantry&SECTION=gallery02/

I think that the IronInfantry DBPRO might have the water media you'd be interested in... I THINK

--Jason

sydbod
16
Years of Service
User Offline
Joined: 14th Jun 2008
Location: Just look at the picture
Posted: 13th Dec 2008 06:23 Edited at: 13th Dec 2008 06:27
Some nice pictures there Jason.

I noticed the FPS look to be very slow. Is that a DB Pro issue or were the pictures just taken on a slow machine.

I did a quick test and threw up some 200 odd aircraft, each with polygon count of well over 5000.
With everything in the picture at the one time I look to be getting well over 60FPS, and when I use lower resolution aircraft, the FPS goes over 300FPS.
I have not even started to optimize the code as I require some of the new functions from the new DGDK when it gets released to do my frustum culling for the 3 cameras that build up the view, or even any LOD optimization.
http://i16.photobucket.com/albums/b49/sydbod/untitled-2.jpg
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 13th Dec 2008 06:28
Thanx - yours look nice too (I love planes)

Anyway - yeah - those pics were all taken on a single system with I think a 64meg or maybe a 256 meg AGP nVidia... Now I'm running a dual core hp paviliion with PCI express2 I think.. running a nVidia 9600 which is much faster.

Also.. depending on the pics... the advanced terrain looking stuff is from IronInfantry DBPro code.. and the tread menu and scenes that look similiar are DarkGDK C++

so I have to ask.. where'd ya get that plane model? I love it!

--Jason

sydbod
16
Years of Service
User Offline
Joined: 14th Jun 2008
Location: Just look at the picture
Posted: 13th Dec 2008 06:42
Quote: "so I have to ask.. where'd ya get that plane model? I love it! "


It is a free model form one of the sites. It is rather poorly made when one looks at it closely.
I had to do a bit of jiggling around (moving meshes inside of the *.X file) with it to get the transparency to work. It is actually using transparent material, rather than a transparent texture over the cockpit and prop.

If you want it I can send you a copy of it.
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 13th Dec 2008 07:22
Yeah - I really would like that
--Jason (Email and stuff below)
Thanx

sydbod
16
Years of Service
User Offline
Joined: 14th Jun 2008
Location: Just look at the picture
Posted: 16th Dec 2008 14:05
Hope it arrived safely
Acidic Parisidic
15
Years of Service
User Offline
Joined: 8th Dec 2008
Location:
Posted: 19th Dec 2008 10:18 Edited at: 19th Dec 2008 10:58


Try this out, and tell me what you think, i could also use some tips on how to get a realistic wave pattern out of the matrix.

Login to post a reply

Server time is: 2024-09-30 13:25:34
Your offset time is: 2024-09-30 13:25:34