Terrain Caves in Irrlicht

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Terrain Caves in Irrlicht

Post by BlindSide »

Hey guys, I started experimenting with ways to make caves using just Irrlicht terrain because everyone is always moaning about "Morrowind" or whatever it was that did this. And I think the results are not too bad...

(Removed Screeny cuz it was misleading, better to download example and try number 4 method!)

You can download the program here (Thx Spintz):
http://irrnet.spintz.com/CavesTest.zip

It includes 3 different methods I experimented with to get (Nearly) the same result. They are all a bit juvenile and hacky, but I think the last method is definately the best (Only requires one heightmap file and supports correct dynamic lighting).

The three methods are:
Inverted Heightmap - An identical but inverted (in paint :P ) heightmap file is loaded on top of the original, with backface culling disabled so that the underside is visible. This is the first one I tried but it gives poor performance because the other side of the "ceiling" terrain has to be drawn and also the normals are the wrong way round for dynamic lighting.

Rotated Mirrored Heightmap - An identical but horizontally mirrored (in paint :P) heightmap is drawn on top of the original. Backface culling is NOT disabled so this method provides the best perforamance out of all three (I got a 5-10fps gain.) BUT it looks like crap because the rotated terrain does not line up perfectly, and much to my dismay when I tried this method the normals are still screwy for the top part.

Inverted Y-Axis Terrain - Now to me, this was the first method I thought of, but the last one I tried. Mainly because I feared something will go wrong, or look buggy, or whatever can happen when the scale is inverted. Luckily, I chose to do this just for the sake of doing a third method, and it turned out to be the best! It only requires one heightmap, the textures line up perfectly, and dynamic lighting looks just like it should. :D The screenshot above is using this method.



Now, while making this I realized, the most obvious advantage to this is the ease of customization by an end user, and also the ease to create maps. For example, here is the terrain file I am using in this program:

Image

Thats right! I just opened up paint and scribbled something in 5 seconds, and no matter what you say the result does not look bad for the amount of work I put in modelling this map! :lol:

So...TRY THIS: Open up the file in the media folder "cave1.bmp" in paint, and do a little scribble in paint, and walla! You have your own customized cave map :P This could lead to literally hundreds of maps for an fps shooter for example, or a gigantic dungeon crawl thing.
(Please try to make the shapes as squigly as possible, no uniform shapes like squares or straight lines because there is a bug with the terrain smoothing at the mo...)

Im thinking of making a shooter called "irrCaves" based on this method sometime.

Cheers.
Last edited by BlindSide on Wed May 30, 2007 12:37 pm, edited 1 time in total.
Strong99
Admin
Posts: 687
Joined: Fri Mar 31, 2006 7:06 pm
Location: Netherlands
Contact:

Post by Strong99 »

but that means the cave top is always mirrored? but how to create then different heights to walk and different ceiling heights?
Dances
Posts: 454
Joined: Sat Jul 02, 2005 1:45 am
Location: Canada
Contact:

Post by Dances »

Use greys instead of just black and white. You could also scale the entire top terrain.
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

strong99 wrote:but that means the cave top is always mirrored? but how to create then different heights to walk and different ceiling heights?
Your not restricted to using the same terrain image in the first and second methods for both the ceiling and the floor, I only like it so you only need to draw something in paint quickly and start shooting ppl.
TheRLG
Posts: 372
Joined: Thu Oct 07, 2004 11:20 pm

Post by TheRLG »

That's pretty neat. With some nicely-setup lightning, grass, and water, it would look pretty killer
IainC
Posts: 27
Joined: Tue Feb 24, 2004 5:55 pm
Location: Aberystwyth, UK
Contact:

Post by IainC »

I really like that; might play some with it.
JRowe47
Posts: 55
Joined: Sat Jun 30, 2007 9:09 am

Post by JRowe47 »

Awesome program and concept :)

It would rock if you could do a cave map, and integrate it with a heightmap for normal terrain. You'd be able to designate depth, and by using depth, someone could add cavemap paging, similar to terrain paging, for unlimited depth. Doing a 3D paging system shouldn't be too great of a leap, I would think. I'd love to see procedurally generated cavemaps in a 3D roguelike. Definitely huge possibilities for fun!

The simplest way to do it, I think, would be to create your tunnels raw, like the black squiggly lines, then do a difference on the heightmap used for your terrain, so that you end up with a cavemap that is perfectly level with your terrain (on top.) Then you can modify the height of the map as a whole, by lightening or darkening the pixels.

Once that's finished, you can finally go in and modify the cavemap height in specific areas, to add slope. All this could be done automagically with a simple photoshop/GIMP script.

How hard would it be to add another terrain layer with caves specifically in mind, so you could integrate heightmaps and cavemaps in the same scene?
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Good idea jrowe, ill definately give that a shot...
SwitchCase
Posts: 170
Joined: Sun Jul 01, 2007 11:41 pm
Location: Manchester, UK

Post by SwitchCase »

That's pretty neat. With some nicely-setup lightning, grass, and water, it would look pretty killer
Yeh but i reckon it would be a tedious task positioning these correctly.

Anyway, nice job blindside, its pretty cool. :D
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

If anyone is interested here is a link to the source of the demo, it is very simple. (I found testtype 4 to be the best personally, also, collision was done using a normal terrain selecter with bottom terrain and limiting the camera to certain height so it doesnt go through the roof. You will need a better method than this if you decide to make roof heightmap different from floor heightmap, so you can use testtype 2, and use collision selectors for top and bottom, although testtype 2 can have some inaccuracy in the positioning, it will require a little tinkering to work correctly.)

Oh yeah, here it is: http://rafb.net/p/xNFkje73.html

Cheers :D
etcaptor
Posts: 871
Joined: Fri Apr 09, 2004 10:32 pm
Location: Valhalla
Contact:

Post by etcaptor »

Nice!
ImageImage
Site development -Rock and metal online
--- etcaptor.com ------freenetlife.com
JRowe47
Posts: 55
Joined: Sat Jun 30, 2007 9:09 am

Post by JRowe47 »

If I can figure out how, I'll post the code to do dynamic lighting for the #2 method, which is more flexible, I would think. By making spires and whatnot on the terrain, you can create stalactites, stalagmites, and columns (where they join.)

Very cool technique, can't wait to start trying it out tomorrow on arras' tiled terrain.
gd_anon
Posts: 98
Joined: Sun Nov 30, 2008 11:03 am
Location: Nowhere

Post by gd_anon »

Excuse me for resurrecting this, but the link to the source is dead (only link to demo works). Can someone reupload it?
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

gd_anon wrote:Excuse me for resurrecting this, but the link to the source is dead (only link to demo works). Can someone reupload it?
It's not easily accessible for me at the moment (Old harddrive) but it's not rocket science.

You just create an ordinary terrain scene node, and then create another one using the same heightmap but with an inverted Y-Scale (e.g. "terrain->setScale(core::vector3df(1.0f, -1.0f, 1.0f))"). That's pretty much the best and easiest way to do it (Method 3).

BTW: Wow 2+ years resurrection, nice going (Man did I love smiley faces back then!).
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
deanhanson
Posts: 3
Joined: Thu Sep 17, 2009 6:47 am

Post by deanhanson »

It is a good idea and a different project. It seems little bit difficult and doubtful. But when there is will, there is a way. So my best wishes for you. and update the thread as work progress
Post Reply