PDA

View Full Version : Best way to texture 3d landscape?



lief
12-07-2005, 11:10 PM
IF I was going to (hypothetical question) make 3d island models, draw the models to a scene, render the water over the top and around the islands...

1. Does the water automatically fit around the islands?
2. Is there any way to make the water more transparent as it gets shallower? Like depth fog but constrained to the inside of an object...
3. How can I texture the islands? With one big texture plonked over the top of it? Can I access the water model at runtime and make waves? Will these waves go up and down the beaches of the islands?

If I WAS to go 3d, could I still draw my pritty 2d effects over the top?

thanks for any questions you may be able to answer. thanks for reading this even if you can't help. and thanks for ummm nothing otherwise?

czar
13-07-2005, 02:28 AM
I am no expert of 3d stuff. I know that it looks very complicated. I have tried combining 3d objects (text rotating) with 2d stuff drawn in the background and found that it is possible. I needed to set z-enabled off and on depending if I was drawing 3d or not. However, it sounds like you want to go fully 3d.

It would be great if someone would make a 3d wrapper to make 3d programming a bit easier. Sort of like what asphyre and omega did for directx 2d programming and glxtreem did for opengl.

However, you might get some ideas by looking at these demos

http://www.delphisanctuary.com/forums/viewtopic.php?t=553

Sly
13-07-2005, 03:51 AM
1. Does the water automatically fit around the islands?
The z- or depth-buffer will automatically handle this for you.


2. Is there any way to make the water more transparent as it gets shallower? Like depth fog but constrained to the inside of an object...
At run-time, yes, but it could get expensive, ie. slow. You would have to check every vertex and see how deep the water was there. This would usually be done as a table lookup if you used a height map for your terrain. Then set the alpha component of the vertex colour to suit according to the depth.

I would do this as a pre-processing step. The idea behind this is to pre-process these values since they are usually not going to change over the lifetime of the game, so why repeatedly calculate the same values over and over each frame? Create the water mesh beforehand and set the vertex alpha for every vertex, then store this in a data file somewhere. At run-time, read that data file in and use that to draw the water. Less processing at run-time means higher frame rate and more CPU time to do other cool stuff.


3. How can I texture the islands? With one big texture plonked over the top of it? Can I access the water model at runtime and make waves? Will these waves go up and down the beaches of the islands?
Here is a document by Charles Bloom on 'texture splatting'. Fairly theoretical with no practical examples.
http://www.cbloom.com/3d/techdocs/splatting.txt
Here is a practical example of using the above technique in DirectX9.
http://www.gamedev.net/reference/articles/article2238.asp

You implement the water model however you want. Here at Krome, we generally make a grid for the water and punch holes in it where it will not be seen. The quickest polygon is the one you do not draw. This is treated just like any other model, with the exception of a few special effects to make the surface look watery (offsetting vertices, texture effects, etc). The z-buffer (as mentioned above) makes sure that the square edges of the water grid are hidden beneath the ground. Using the vertex offset effect, yes it looks like waves going up and down the beach. But this effect can be costly if you have too many vertices to offset each frame. This is best done using a vertex shader or something similar.


If I WAS to go 3d, could I still draw my pritty 2d effects over the top?
Of course. Draw your 3D using a perspective projection matrix, then switch to an orthographic projection to draw the 2D effects in whatever two-dimensional space you specify. You would also usually disable z-buffer writing and reading during this 2D drawing. This is the HUD elements of most games are drawn.

LP
13-07-2005, 04:02 AM
2. Is there any way to make the water more transparent as it gets shallower? Like depth fog but constrained to the inside of an object...

Steve got the point there. Also, you can use one big texture with alpha-channel which gets more transparent in some areas. You can even modify this texture at run-time to reflect any changes.


3. How can I texture the islands? With one big texture plonked over the top of it? Can I access the water model at runtime and make waves? Will these waves go up and down the beaches of the islands?

First, multi-texturing would be logical step to improve the overall look of the island. Second, you can generate a model at run-time but, as always, Steve got good point there ;)


If I WAS to go 3d, could I still draw my pritty 2d effects over the top?
This can be just as easy as if you didn't have 3D stuff at all. And if you use Asphyre (err, this is Asphyre forum right? :D), it automatically provides state changes for you, so just draw 2D after 3D (or before, if you want it to appear as background for 3D scene) ;)

Sly
13-07-2005, 04:09 AM
Steve got the point there. Also, you can use one big texture with alpha-channel which gets more transparent in some areas. You can even modify this texture at run-time to reflect any changes.
Personally, I would avoid using a very large texture with alpha. That's an expensive texture if it is 32-bit, and depending on the size of the water, the texture resolution may need to be quite high as well. I would use a smaller texture to represent the water surface without alpha, and set the translucency using the vertex colours of the water grid.

LP
13-07-2005, 04:15 AM
Personally, I would avoid using a very large texture with alpha. That's an expensive texture if it is 32-bit, and depending on the size of the water, the texture resolution may need to be quite high as well.
What if you use multi-texturing and use the second texture in 8-bit alpha format?


I would use a smaller texture to represent the water surface without alpha, and set the translucency using the vertex colours of the water grid.
Talking about optimization, wouldn't this require more heavy vertex format that include vertex colors and the additional blending options? Looks like more bandwidth and more per-pixel processing, although I agree that multi-texturing might not be that cheap anyway...

Sly
13-07-2005, 04:37 AM
It would best be decided by trying both approaches and seeing which one works for the situation.

lief
13-07-2005, 04:53 AM
Thanks a heap guys! Keep in mind this is for low tech old laptop...
has about a card which supports some directX 7? 8? and nearly no OpenGL (software drivers only, i have to use some scitech directX emulated OpenGL thingo). I'm not even sure if it supports multitexturing, i sure hope so...

So...

1. Make a giant plane for water, give it a tiled water texture, make it shiny and transparent

(I have already done the above using a hand-made-3d-thing similar to 2d iso landscape demo in asphyre, but it wasn't all that cool... no z-buffer to stick islands through water with, and when i did make a software zbuffer, the only framerate i could get that was nearly decent was around 20fps at about 256 x 256 rendering area...)

2. Make some island models
3. Make an individual texture for each one that works well
4. Load the island models and precalculate the alpha - adjusting the vertice alpha depending on depth below water

rendering loop
5. Wiggle the water vertices for viewable area using a sinus function of some kind
6. Draw the islands in the viewable area (i'm using a top down view, the camera basically stays static, so its simply just a rectangle for the screen I draw)
7. Draw the water
8. Draw anything I want on top, player models etc

i have read the texture splatting articles, slightly too complex for me at this stage... and like i said i have no idea what my laptop can handle past putting colored rectangles on the screen (jk - it runs games like ummm age of sail 2, however halo didn't work)

thanks again peoples

Sly
13-07-2005, 04:55 AM
Draw all opaque models before the translucent water. This way, the opaque models can go in the water and you will see their lower half under the water as well as their top half above the water.

lief
13-07-2005, 05:05 AM
the water will work as a plane object yes? I dont need to make a big box?

i still have a query on the texturing of models within asphyre... how is it done?
set one texture for each model? are UVmaps supported? or do i need to make a seperate model for every texture section on an object? how does it wrap around? arghhghgh DAMN 3d! STAY 2d FOREVER SO I AM HIGH TECH!
a$%#%@@

Sly
13-07-2005, 05:10 AM
A plane object is fine.

lief
13-07-2005, 05:38 AM
i swear on my mouse hand (the right hand) that i will have this working tomorrow and upload a screen shot. prepare to be amazed at my technicality!! btw how do i compile a delphi program once i have written what i wanted it to do in notepad?

Sly
13-07-2005, 05:42 AM
btw how do i compile a delphi program once i have written what i wanted it to do in notepad?
C:\>WriteCodeForMe.exe specification.txt IllustriousGame.dpr

lief
13-07-2005, 06:22 AM
can i get the WriteCodeForMe.exe file from you? don't worry about serial numbers because i can get them and cracks if i need them.
and i need some money to buy DarkBasic so i need to sell my 3d game really fast to activision so can you send it really soon?
ill give you a discounted copy of the game if you do.
i want to upload the game tomorrow.

Sly
13-07-2005, 06:32 AM
I think DodgyPublisher.comTM would readily accept your game (for a minimal fee, plus exclusive rights to it and sequels, plus your first-born) whether it is finished or not.

We (Krome) are actually publishing a game this year through Activision. :)

lief
13-07-2005, 07:02 AM
Dodgy publisher told me they would like games that already have an established name, splash screen, and cd.

krome... brisbane... cool. i am up in hervey bay (i can nearly see you from here)

Sly
13-07-2005, 07:12 AM
Here's a dodgy CD for you.

http://www.istockphoto.com/file_thumbview_approve/162071/2/Broken_CD_DVD___Vector.jpg

LP
13-07-2005, 01:22 PM
OMG!! :shock: