Global scenery placement using two textures
by Thor Zollinger · in Torque Game Engine · 02/21/2003 (7:06 pm) · 0 replies
Global scenery placement using two textures:
Hi Guys,
I had a unique scenery placement tool in the graphics engine I just scrapped when I bought Torque, which I thought would be useful to everyone. It was programmed in Delphi, I am new to C++ and Torque, so I am not the one to program this right now, but I thought I would throw out the concept to see if anyone is interested in taking it on...
MAIN FEATURES:
The entire terrain map can be populated instantly using just two 256x256 textures and a set of scenery objects.
A set of 20 or 30 or more scenery objects are placed controllably across the landscape.
The scenery varies with altitude (or ground steepness).
I have set up a screenshot from my old engine to look at here:
http://www.myweb.cableone.net/thor276/Shot1.jpg
I duplicated the scrolling mini-map/compass/radar in the old screenshot for Torque, just in case you guys might want it:
http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=3846
DESCRIPTION:
The scenery items are placed using two textures. The first texture fits over the height map and holds the scenery density, a number from 0 to 255. Black areas have no scenery, darker gray areas have some scenery, white areas are totally saturated. I never used more than a medium gray because it placed way too many objects for my graphics card to handle. The second texture acts much like a ground detail texture and holds an object number ranging from 0 to 255. This one was replicated across the height map 8 times, giving you 8X the density of the base height map for placing scenery objects. This texture was a collection of randomly scattered dots (0 to 255) on a black background. Black (0) meant no object was placed in that location of the detail map. Both of these textures are very easy to create, and I have a tool which makes these up in a heartbeat, though it will have to be cut way back since it is actually a full-blown terrain editor.
An object library was used, holding 30 or so scenery objects. The objects were mostly billboards, but full 3D objects like trees can be mixed in with the grass, rocks and scrub plants. The object library was used to fill up an array of 256 plants, each with a slight random X/Y offset so the plants didn't get placed on a rigid grid. The array was filled up with objects depending upon what altitude (or steepness) they were to be placed at. For example, the first 10 library objects were used to fill up the first 1/3 of the 256 array slots and go onto the lowland areas, the second 10 fill the middle third, the last 10 fill up the balance of the array and got placed at high altitudes or steep rocky areas. The old engine had 5 distinct altitude bands (or steepness bands) so the plants transitioned smoothly from lowland plants to high mountain plants. I was using 5 different terrain textures, which is where the band number came from. I am not sure how Torque handles this yet. In addition, each 3D object (not the billboards) also had a color modifier to shade each instance of the same object a slightly different color, a height modifier of +-30%, and a rotation modifier. These can be skipped for simplicity.
A scenery object was placed based on the following scheme:
First, the object number from the detail texture was used and compared to the density texture value. If the object number was less than the density, the object was rendered. The object number (N, from 0 to 255) was then modified by the altitude band (AB, which ranged from 0 lowland to 4 mountain tops) to get the actual object array index. Each of the 5 bands covered one third of the object array so they would overlap for smooth scenery transitions.
N = round(N/3 + AB*42.5)
This allowed the 5 bands to overlap, but did not use the top 40 or so slots in the array unless the density was set really high. I had it set up so it would, but that equation would just confuse things.
Now comes the tricky part... The objects are at different altitudes at different locations on the map depending upon where the player is, so an array of altitudes was set up to hold these values to match the detail texture locations, 256x256. A portion of this array is zeroed out each time the player moves to a new integer grid location out just beyond the visible range and all zero values were filled in each frame as needed. Teleporting would require the entire array to be redone. It will take some visual aids (which I will have to make) to get this across clearly, so I am expecting questions on this part. Indexing into the detail array is also a bit tricky, but I have that in my old source code so no one has to figure that part out.
The object rendering code faded the scenery objects in at the edge of the object visible range, which was out at about 300 meters. Larger 3D objects faded in at 800 meters, but that would require a larger detail texture and arrays. Mine were 512x512, with the visible horizon actually out at 2-4 kms. It was adjustable, since aircraft really need more visual range. The default Torque grid spacing is 8 meters, so the spacing in the detail texture is down to 1 meter, i.e. a scenery object can be placed on every square meter of ground if you want to. Melv has a superb tool to do this for groups of single objects, but it would be nice to be able to do this for multiple scenery objects over the entire map in one shot.
I have hope that someone like Melv with take up the torch, since my C++ and Torque skills are still at the infant level.
Any takers? If you like this concept, make a comment and we will see how much noise we can make! Maybe we can talk someone into doing this, otherwise you will have to wait a year until I can get up to speed and around to doing it.
Thor
Hi Guys,
I had a unique scenery placement tool in the graphics engine I just scrapped when I bought Torque, which I thought would be useful to everyone. It was programmed in Delphi, I am new to C++ and Torque, so I am not the one to program this right now, but I thought I would throw out the concept to see if anyone is interested in taking it on...
MAIN FEATURES:
The entire terrain map can be populated instantly using just two 256x256 textures and a set of scenery objects.
A set of 20 or 30 or more scenery objects are placed controllably across the landscape.
The scenery varies with altitude (or ground steepness).
I have set up a screenshot from my old engine to look at here:
http://www.myweb.cableone.net/thor276/Shot1.jpg
I duplicated the scrolling mini-map/compass/radar in the old screenshot for Torque, just in case you guys might want it:
http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=3846
DESCRIPTION:
The scenery items are placed using two textures. The first texture fits over the height map and holds the scenery density, a number from 0 to 255. Black areas have no scenery, darker gray areas have some scenery, white areas are totally saturated. I never used more than a medium gray because it placed way too many objects for my graphics card to handle. The second texture acts much like a ground detail texture and holds an object number ranging from 0 to 255. This one was replicated across the height map 8 times, giving you 8X the density of the base height map for placing scenery objects. This texture was a collection of randomly scattered dots (0 to 255) on a black background. Black (0) meant no object was placed in that location of the detail map. Both of these textures are very easy to create, and I have a tool which makes these up in a heartbeat, though it will have to be cut way back since it is actually a full-blown terrain editor.
An object library was used, holding 30 or so scenery objects. The objects were mostly billboards, but full 3D objects like trees can be mixed in with the grass, rocks and scrub plants. The object library was used to fill up an array of 256 plants, each with a slight random X/Y offset so the plants didn't get placed on a rigid grid. The array was filled up with objects depending upon what altitude (or steepness) they were to be placed at. For example, the first 10 library objects were used to fill up the first 1/3 of the 256 array slots and go onto the lowland areas, the second 10 fill the middle third, the last 10 fill up the balance of the array and got placed at high altitudes or steep rocky areas. The old engine had 5 distinct altitude bands (or steepness bands) so the plants transitioned smoothly from lowland plants to high mountain plants. I was using 5 different terrain textures, which is where the band number came from. I am not sure how Torque handles this yet. In addition, each 3D object (not the billboards) also had a color modifier to shade each instance of the same object a slightly different color, a height modifier of +-30%, and a rotation modifier. These can be skipped for simplicity.
A scenery object was placed based on the following scheme:
First, the object number from the detail texture was used and compared to the density texture value. If the object number was less than the density, the object was rendered. The object number (N, from 0 to 255) was then modified by the altitude band (AB, which ranged from 0 lowland to 4 mountain tops) to get the actual object array index. Each of the 5 bands covered one third of the object array so they would overlap for smooth scenery transitions.
N = round(N/3 + AB*42.5)
This allowed the 5 bands to overlap, but did not use the top 40 or so slots in the array unless the density was set really high. I had it set up so it would, but that equation would just confuse things.
Now comes the tricky part... The objects are at different altitudes at different locations on the map depending upon where the player is, so an array of altitudes was set up to hold these values to match the detail texture locations, 256x256. A portion of this array is zeroed out each time the player moves to a new integer grid location out just beyond the visible range and all zero values were filled in each frame as needed. Teleporting would require the entire array to be redone. It will take some visual aids (which I will have to make) to get this across clearly, so I am expecting questions on this part. Indexing into the detail array is also a bit tricky, but I have that in my old source code so no one has to figure that part out.
The object rendering code faded the scenery objects in at the edge of the object visible range, which was out at about 300 meters. Larger 3D objects faded in at 800 meters, but that would require a larger detail texture and arrays. Mine were 512x512, with the visible horizon actually out at 2-4 kms. It was adjustable, since aircraft really need more visual range. The default Torque grid spacing is 8 meters, so the spacing in the detail texture is down to 1 meter, i.e. a scenery object can be placed on every square meter of ground if you want to. Melv has a superb tool to do this for groups of single objects, but it would be nice to be able to do this for multiple scenery objects over the entire map in one shot.
I have hope that someone like Melv with take up the torch, since my C++ and Torque skills are still at the infant level.
Any takers? If you like this concept, make a comment and we will see how much noise we can make! Maybe we can talk someone into doing this, otherwise you will have to wait a year until I can get up to speed and around to doing it.
Thor
About the author