L3DT generation (Q&A inside)
by Kyle Cook · in Torque Game Engine Advanced · 07/13/2006 (9:37 am) · 3 replies
I have discovered the following with the assistance of Matt Vitelli.
When performing the first step you should make sure the second parameter, in my example it is the "1024" matches the size of your heightfield. Also don't forget to add that 1 pixel on each side of your RAW file.
When you export in step three make sure that your texture map is using the mosaic tiles, this should increase the visual appearance of your map. Although that is optional, I highly suggest it.
Finally when you blend the terrain together, make sure the files are in the right order.
The only problem I am getting from this is an incorrect texture map in game, truely baffeling.
// Generate a blended terrain from a L3DT dataset.
//[i]Step ONE - use the exported heightfield[/i]
// Convert the raw heightfield.
atlasOldGenerateChunkFileFromRaw16("starter.fps/heightfield.RAW", 1024, 1.0, 1.0/512.0, "starter.fps/geometry.chu", 1.0, 5);
importOldAtlasCHU("starter.fps/geometry.chu", "starter.fps/geometry.atlas");
//[i]Step TWO - use the exported lightmap[/i]
// Import opacity/alpha map. ** ERROR SHOULD BE LIGHTMAP **
// note: the png file need to contain the 4 alpha maps on separate layers
atlasGenerateTextureTOCFromTiles(1, "starter.fps/lightmap.png", "starter.fps/lightmap.atlas");
//[i]Step THREE - use the exported texture map mosaic[/i]
// Load lightmap and JPEG compress. ** ERROR SHOULD BE TEXTURE
atlasGenerateTextureTOCFromTiles(8, "starter.fps/texturemap_x%dy%d.jpg", "starter.fps/texturemap_png.atlas");
atlasConvertTextureTOC("starter.fps/texturemap_png.atlas", "starter.fps/texture.atlas", 0);
//[i]Step FOUR - combine all the .atlas files[/i]
// Finally combine into a blender terrain.
atlasGenerateBlenderTerrain("starter.fps/downtownDenver.atlas", "starter.fps/geometry.atlas", "starter.fps/lightmap.atlas", "starter.fps/texture.atlas");When performing the first step you should make sure the second parameter, in my example it is the "1024" matches the size of your heightfield. Also don't forget to add that 1 pixel on each side of your RAW file.
When you export in step three make sure that your texture map is using the mosaic tiles, this should increase the visual appearance of your map. Although that is optional, I highly suggest it.
Finally when you blend the terrain together, make sure the files are in the right order.
atlasGenerateBlenderTerrain("outfile", "step1", "step2", "step3");The only problem I am getting from this is an incorrect texture map in game, truely baffeling.
#2
As for the texture map; somehow when it is blended in the colors don't match up with the terrain and sometimes the colors are 'made up' as far as I can tell. I have looked at the texture map and then looked at the blended map in game and it is essentially turning an apple into an orange. Any clue why it is distorting my texture? Should I use the other method for generating atlas files? As far as I can tell the whole lightmap thing will become obsolete when terrain lighting is in TSE with MS4.
I guess one problem that I am having is not knowing what all the parameters do exactly.
Can someone tell me what all the parameters in the function "atlasOldGenerateChunkFileFromRaw16" mean?
One last question here and then I will leave this thread in the oven overnight.
leafCount, say I mosaic my texture files and to cover the map it takes 8x8, would that mean I use 8 for leafCount?
Also I am editing my previous post to correct the error that Ben pointed out.
07/13/2006 (9:55 pm)
Ah hah, that would explain that error I was seeing with the flat terrain.As for the texture map; somehow when it is blended in the colors don't match up with the terrain and sometimes the colors are 'made up' as far as I can tell. I have looked at the texture map and then looked at the blended map in game and it is essentially turning an apple into an orange. Any clue why it is distorting my texture? Should I use the other method for generating atlas files? As far as I can tell the whole lightmap thing will become obsolete when terrain lighting is in TSE with MS4.
// Convert the raw heightfield.
atlasOldGenerateChunkFileFromRaw16("starter.fps/heightfield.RAW", 2048, 2.0, 1.0, "starter.fps/geometry.chu", 1.2, 4);
importOldAtlasCHU("starter.fps/geometry.chu", "starter.fps/geometry.atlas");
// Convert the texture map
atlasGenerateTextureTOCFromLargeJPEG("starter.fps/texturemap.jpg", 4, "starter.fps/texture.atlas");
// Blend thetwo together
atlasGenerateUniqueTerrain("outfile", "starter.fps/geometry.atlas", "starter.fps/texture.atlas");I guess one problem that I am having is not knowing what all the parameters do exactly.
Can someone tell me what all the parameters in the function "atlasOldGenerateChunkFileFromRaw16" mean?
One last question here and then I will leave this thread in the oven overnight.
leafCount, say I mosaic my texture files and to cover the map it takes 8x8, would that mean I use 8 for leafCount?
Quote:
atlasGenerateTextureTOCFromTiles(leafCount, tileMask, outFile)
Generate a texture TOC from a set of tiles. leafCount is the size of the grid of tiles on a side. tileMask is the path for the tiles (no extension) with %d for x and y, ie, 'demo/alpha/Alpha1_x%dy%d'. outFile is the file to output a new .atlas file to.
Also I am editing my previous post to correct the error that Ben pointed out.
#3
(I am working hard on introducing a new way to import RAWs that isn't so painful. I realize that this current situation is lame. :)
The parameters are basically the same as what's outlined in the section for Atlas in the CHM file that ships with TSE - it just has a different name. If there's a mismatch let me know and I'll clarify it immediately for you! :)
07/13/2006 (11:34 pm)
One gotcha - your raw must be pow2 + 1. So it needs to be 2049x2049, and your generator should match. Getting this wrong will introduce skew into the heightfield which will make your heightfield never, ever match up to your texture!(I am working hard on introducing a new way to import RAWs that isn't so painful. I realize that this current situation is lame. :)
The parameters are basically the same as what's outlined in the section for Atlas in the CHM file that ships with TSE - it just has a different name. If there's a mismatch let me know and I'll clarify it immediately for you! :)
Associate Ben Garney
Also - I think you're pretty much right on except for "you can adjust the tree depth by changing the "1024" number value to one higher in a multiple of 2" - that parameter is the size of the heightmap IIRC, and changing it improperly will result in bad stuff! (ie, reading past end of file)