Terrain Caves in Irrlicht
Terrain Caves in Irrlicht
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 ) 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 ) 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. 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:
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!
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 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.
(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 ) 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 ) 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. 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:
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!
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 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.
but that means the cave top is always mirrored? but how to create then different heights to walk and different ceiling heights?
Compete or join in irrlichts monthly screenshot competition!
Blog/site: http://rex.4vandorp.eu
Company: http://www.islandworks.eu/, InCourse
Twitter: @strong99
Blog/site: http://rex.4vandorp.eu
Company: http://www.islandworks.eu/, InCourse
Twitter: @strong99
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.strong99 wrote:but that means the cave top is always mirrored? but how to create then different heights to walk and different ceiling heights?
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?
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?
-
- Posts: 170
- Joined: Sun Jul 01, 2007 11:41 pm
- Location: Manchester, UK
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
Oh yeah, here it is: http://rafb.net/p/xNFkje73.html
Cheers
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.
Very cool technique, can't wait to start trying it out tomorrow on arras' tiled terrain.
It's not easily accessible for me at the moment (Old harddrive) but it's not rocket science.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?
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
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
-
- Posts: 3
- Joined: Thu Sep 17, 2009 6:47 am