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 Discussion / Terrain Texturing

Author
Message
luke810
18
Years of Service
User Offline
Joined: 4th Sep 2006
Location: United States
Posted: 13th Dec 2007 03:28
I've been working with some different terrain editing stuff and I'm interest in creating a non-tile based texturing system but I'm not sure how to implement it. I was thinking that each texture would be the size of the entire terrains main texture and when you selected one spot to apply that texture to on the terrain, it would take a circle from that position on the large texture and copy it over to the terrains main texture. This probably isn't the best method so I'm just asking to see if anyone has any better ideas. I was also wondering how I might use alphablending to make the edges around the area where the new texture is being applied look more "real" and I have no idea where to start with this as I've never done anything like it before.
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 13th Dec 2007 18:47 Edited at: 13th Dec 2007 18:49
Well, there's always using a height map - then matching a color map. For example, you can either create the terrain using a black and white height map or you can create the height map from a matrix (terrain) that you've altered manually.

You can create the height map from the matrix by getting the heights of the points and dividing between them based on the size of the bitmap you want to use. Once you have the height map (in the form of a .bmp), you can scan through it (generally the colors would range from 0 to 255 - depends on how you want to handle it) and create a color map that represents terrain at the varying heights( from the lowest - 0, to the highest 255) Like from 0 to 20 = blue for water and 21 to 30 = = dark green for grass.

It can be more subtle with more subdivisions with a little bit of randomness to change the hues from time to time. You could apply this to the whole terrain or you could capture sections with a widening arc or box. You can take it further by having a few predefined terrain patterns (grass, swamp, trees whatever). Draw these with black backgrounds so that you can paste the images with transparency (onto your color map). This will also allow you to place them at pixel positions so that the area is not so square. You can even have themed maps so specific color / terrain combinations are used with specific selections.

You can use alphablending or you can use transitional colors in the color map. As the height changes from lower to higher, have many subdivisions to gradate the colors. You could also use a mini matrix that is high poly and randomize it and extend it over an area on the real terrain. You won't keep the matrix, you'll just use it's height caclulations to "patch" an area.

For example, you want some dry earth between the grass and the hills. You expand your mini matrix over the area, randomize it around the maximum heights for grass or earth, create a height map for it, then a color map and copy this color map to your main bitmap. If done properly, it could have the effect of patchy grass and earth. Though I see it in my mind, it may not work as well in practice!

Instead of tiling images on the matrix, you are in essence compiling a bitmap that you will map over the entire terrain. If you use those matrix to object functions from Kelenbridae (sp?), the texturing is a little more flexible than the standard DBC matrix but the functions are similar so there's no real learning curve. If you want to use the bitmap on the matrix, divide the bitmap into as many tiles as there are in the matrix and lay each one down as they match.

Enjoy your day.
luke810
18
Years of Service
User Offline
Joined: 4th Sep 2006
Location: United States
Posted: 15th Dec 2007 07:07
Quote: "there's always using a height map - then matching a color map"


That sounds much better! Thank you. It will also make the texturing process for random maps ten times easier. I'm going to try and use predefined terrain patterns as you suggested also to make it easier to edit the main texture without changing the heightmap if you wanted to.

Quote: "divide the bitmap into as many tiles as there are in the matrix and lay each one down as they match"


Couldn't you just texture the entire terrain object with the bitmap instead of breaking it down into chunks? Although my terrain consists of multiple objects so I'll have to break it down for each individual object.
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 15th Dec 2007 18:21 Edited at: 15th Dec 2007 18:23
Quote: "Couldn't you just texture the entire terrain object with the bitmap "


Yeah, if it's an object mesh you just texture it like any other object. If it's a DB matrix, then you have to tile it. And if you want the entire bitmap distributed over the matrix, then you have to break it up into as many squares as there are on the matrix.

If you haven't already, take a look at the example I included with the 1.2 command explanation. After using a height map to make the terrain, I use a very simple color map to texture it. Should give you a basic idea of one way to do it. And if you don't have the 1.2 upgrade, you can still test the example (as long as you have dbc enhanced) just comment out the 1.2 lighting commands - though it looks better with the specular on.

With your terrain program, watch the size of your bitmap. The larger it is, the more processing power it consumes - and if you use predefined bitmaps to paste onto the main terrain bitmap, you'll probably want to match the size to keep everything consistant.

Actually, COPY BITMAP does a pretty good job of resampling images so you can resize them with fair quality and pretty easily.

Enjoy your day.
luke810
18
Years of Service
User Offline
Joined: 4th Sep 2006
Location: United States
Posted: 16th Dec 2007 22:44 Edited at: 16th Dec 2007 22:45
Ok, I'm using an object for the terrain so I'll just be pasting the texture onto the terrain. I also looked at your 1.2 lighting commands example so I think I'll try to do something similar to that with mine but using bitmap images and copying from different bitmaps based on the heightmap information. That way I'll be able to get a more realistic looking terrain.
Bluestar4
19
Years of Service
User Offline
Joined: 19th Dec 2005
Location: USA
Posted: 17th Dec 2007 09:16
this should prove interesting - post a screenie when you work it out

Login to post a reply

Server time is: 2025-06-02 10:16:07
Your offset time is: 2025-06-02 10:16:07