Alpha map should be used - Atlas commands don't like it
by Andy Hawkins · in Torque Game Engine Advanced · 03/29/2008 (8:48 pm) · 10 replies
When I want to create a blended terrain I need to load the Alpha map as the Opacity map right?
When I use this command it shouldn't be loading a JPG it needs to load a PNG. What's the correct syntax to load an alpha map in png form to create an opacity map for a blended terrain please?
When I use this command it shouldn't be loading a JPG it needs to load a PNG. What's the correct syntax to load an alpha map in png form to create an opacity map for a blended terrain please?
echo("********* ALPHA MAP:" @ %path @ "/" @ %fileName @ "_Alpha_1.png");
atlasGenerateTextureTOCFromLargeJPEG("terrain_water_demo/data/terrains/" @ %path @ "/" @ %fileName @ "_TX.jpg", 3,
"terrain_water_demo/data/terrains/" @ %path @ "/OpacityTex.atlas");
#2
03/30/2008 (4:47 pm)
And thanks again - I'll let you know how it goes.
#3
You can see the results in this thread.
www.garagegames.com/mg/forums/result.thread.php?qt=73599
Blended Terrain importer
04/01/2008 (8:16 am)
As stated in my other thread, Bill's advice here worked. I usedatlasGenerateTextureTOCFromTilesand provided this script, then ran a blank map in TGEA and spawn the command BT("b1","BraveFinal1",4); to generate the alpha, lightmap and textures required in atlas format.
You can see the results in this thread.
www.garagegames.com/mg/forums/result.thread.php?qt=73599
Blended Terrain importer
function BT(%path,%fileName,%tiles)
{
// BT("ab","blend_test5",false);
// BT("ab","blend_test5",1);
// BT("bl","test2",false);
// BT("b1","BraveFinal1",4);
// Bring up a dos window to display current status. This lets you see immediately how the import/generation process is going.
enableWinConsole(true);
// Enable logging so we get a console.log. This is useful if something goes wrong - we can check the log for errors.
setLogMode(6);
// Generate geometry from a raw 16 bit heightfield.
atlasOldGenerateChunkFileFromRaw16("terrain_water_demo/data/terrains/" @ %path @ "/" @ %fileName @ ".raw", 2048, 2.0, 624.66/65536.0,
"terrain_water_demo/data/terrains/" @ %path @ "/geometry.chu", 1.0, 3);
echo("********* CHU created ***************");
// Import from old CHU format to .atlas.
importOldAtlasCHU("terrain_water_demo/data/terrains/" @ %path @ "/geometry.chu",
"terrain_water_demo/data/terrains/" @ %path @ "/geometry.atlas");
echo("********* imported CHU export to atlas ***************");
// Import a tiled opacity map we generated with L3DT. Note we save it in PNG format to prevent artifacts in the blend results.
if (%tiles > 1)
{
echo("********* ALPHA MAP:" @ %path @ "/" @ %fileName @ "_Alpha_x%dy%d.png");
// Import data from some tiles we rendered out with L3DT.
atlasGenerateTextureTOCFromTiles(%tiles, "terrain_water_demo/data/terrains/" @ %path @ "/" @ %fileName @ "_Alpha_x%dy%d.png",
"terrain_water_demo/data/terrains/" @ %path @ "/OpacityTex.atlas", 1);
}
else
{
echo("********* ALPHA MAP:" @ %path @ "/" @ %fileName @ "_Alpha_1.png");
atlasGenerateTextureTOCFromTiles(1, "terrain_water_demo/data/terrains/" @ %path @ "/" @ %fileName @ "_Alpha_1.png",
"terrain_water_demo/data/terrains/" @ %path @ "/OpacityTex.atlas", 1);
}
echo("********* Opacity map created ***************");
if (%tiles>1)
{
// Import a tiled lightmap we generated, as well. We store these in JPEG as a little error is not going to be noticeable.
atlasGenerateTextureTOCFromTiles(%tiles, "terrain_water_demo/data/terrains/" @ %path @ "/" @ %fileName @ "_LM_x%dy%d.jpg",
"terrain_water_demo/data/terrains/" @ %path @ "/Lightmap.atlas", 0);
}
else
{
// Import a tiled lightmap we generated, as well. We store these in JPEG as a little error is not going to be noticeable.
atlasGenerateTextureTOCFromTiles(1, "terrain_water_demo/data/terrains/" @ %path @ "/" @ %fileName @ "_LM.jpg",
"terrain_water_demo/data/terrains/" @ %path @ "/Lightmap.atlas", 0);
}
echo("********* Lightmap created ***************");
// Finally, combine into a unique-textured terrain. Notice how this command is grouped
// onto multiple lines, to make it easier to read and understand. The first four parameters
// (the .atlas files) are the output file we are generating, and the three input files we
// need (geometry data, opacity data, and lightmap data).
atlasGenerateBlenderTerrain(
"terrain_water_demo/data/terrains/" @ %path @ "/Blended.atlas",
"terrain_water_demo/data/terrains/" @ %path @ "/Geometry.atlas",
"terrain_water_demo/data/terrains/" @ %path @ "/OpacityTex.atlas",
"terrain_water_demo/data/terrains/" @ %path @ "/Lightmap.atlas",
// This is the size of the virtual texturemap the blender will be producing. This directly affects how much the source images are tiled, so it is
// hardcoded into the terrain. This must be a power of 2 - if you get it wrong the engine will nicely let you know and suggest some alternatives
32768,
// These are the source textures that the blender will be using. List them in the REVERSE order that L3DT shows in the alpha map export
// wizard. If you specify too few, then your terrain may cause the engine to crash.
"terrain_water_demo/data/terrains/" @ %path @ "/rock1b",
"terrain_water_demo/data/terrains/" @ %path @ "/yellowsand1",
"terrain_water_demo/data/terrains/" @ %path @ "/grass1"
);
echo("done");
}
#4
* I grabbed the height range from the rescale height menu option from the L3DT (while viewing the heightmap) and divided that by 65536.
* The actual size of the map is meant to be 2048 in the command to load the height map
example\terrain_water_demo\data\terrains\b1 dir (see listing below)
* I exported the alpha and lightmaps using the L3DT export map option again (be careful to name your suffix in the first screen of the dialog to add the word Alpha or LM as required - or just reword your script) into that folder then ran my script
04/01/2008 (8:25 am)
* The heightmap was exported from L3DT using Export->Resize to 2049x2049 (or power of 2 +1)* I grabbed the height range from the rescale height menu option from the L3DT (while viewing the heightmap) and divided that by 65536.
* The actual size of the map is meant to be 2048 in the command to load the height map
// Generate geometry from a raw 16 bit heightfield.
atlasOldGenerateChunkFileFromRaw16("terrain_water_demo/data/terrains/" @ %path @ "/" @ %fileName @ ".raw", 2048, 2.0, 624.66/65536.0,
"terrain_water_demo/data/terrains/" @ %path @ "/geometry.chu", 1.0, 3);* When I generated the alpha map using L3DT I jotted down the texture maps used and dumped them into the example\terrain_water_demo\data\terrains\b1 dir (see listing below)
* I exported the alpha and lightmaps using the L3DT export map option again (be careful to name your suffix in the first screen of the dialog to add the word Alpha or LM as required - or just reword your script) into that folder then ran my script
BraveFinal1.raw BraveFinal1_Alpha_x0y0.png BraveFinal1_Alpha_x0y1.png BraveFinal1_Alpha_x0y2.png BraveFinal1_Alpha_x0y3.png BraveFinal1_Alpha_x1y0.png BraveFinal1_Alpha_x1y1.png BraveFinal1_Alpha_x1y2.png BraveFinal1_Alpha_x1y3.png BraveFinal1_Alpha_x2y0.png BraveFinal1_Alpha_x2y1.png BraveFinal1_Alpha_x2y2.png BraveFinal1_Alpha_x2y3.png BraveFinal1_Alpha_x3y0.png BraveFinal1_Alpha_x3y1.png BraveFinal1_Alpha_x3y2.png BraveFinal1_Alpha_x3y3.png BraveFinal1_LM_x0y0.jpg BraveFinal1_LM_x0y1.jpg BraveFinal1_LM_x0y2.jpg BraveFinal1_LM_x0y3.jpg BraveFinal1_LM_x1y0.jpg BraveFinal1_LM_x1y1.jpg BraveFinal1_LM_x1y2.jpg BraveFinal1_LM_x1y3.jpg BraveFinal1_LM_x2y0.jpg BraveFinal1_LM_x2y1.jpg BraveFinal1_LM_x2y2.jpg BraveFinal1_LM_x2y3.jpg BraveFinal1_LM_x3y0.jpg BraveFinal1_LM_x3y1.jpg BraveFinal1_LM_x3y2.jpg BraveFinal1_LM_x3y3.jpg dirt1.jpg grass1.jpg rock1b.jpg rock2b.jpg yellowsand1.jpg
#5
04/01/2008 (8:26 am)
Here's a script to generate a unique terrain (no shadows but looks cool)function UT(%path,%fileName,%tiled)
{
// UT("atlas_unique","atlas",false);
// Bring up a dos window to display current status. This lets you see immediately how the // import/generation process is going.
enableWinConsole(true);
// Enable logging so we get a console.log. This is useful if something goes wrong - we //can check the log for errors.
setLogMode(6);
// The following lines are the various commands we want to execute this time through:
// Generate geometry from a raw 16 bit heightfield.
//atlasOldGenerateChunkFileFromRaw16("terrain_water_demo/data/terrains/" @ %path @ "/" @ %fileName @ ".raw", 1024, 1.0,
// 1.0/1024.0, "terrain_water_demo/data/terrains/" @ %path @ "/geometry.chu", 1.5, 3);
atlasOldGenerateChunkFileFromRaw16("terrain_water_demo/data/terrains/" @ %path @ "/" @ %fileName @ ".raw", 1024, 1.0,
1024.0/65536.0, "terrain_water_demo/data/terrains/" @ %path @ "/geometry.chu", 1.5, 5);
// Import from old CHU format to .atlas.
importOldAtlasCHU("terrain_water_demo/data/terrains/" @ %path @ "/geometry.chu",
"terrain_water_demo/data/terrains/" @ %path @ "/geometry.atlas");
if (%tiled==true)
{
// Import data from some tiles we rendered out with L3DT.
atlasGenerateTextureTOCFromTiles(8, "terrain_water_demo/data/terrains/" @ %path @ "/" @ %fileName @ "_TX_x%dy%d.jpg",
"terrain_water_demo/data/terrains/" @ %path @ "/texture.atlas", 0);
}
else
{
atlasGenerateTextureTOCFromLargeJPEG("terrain_water_demo/data/terrains/" @ %path @ "/" @ %fileName @ "_TX.jpg",
3, "terrain_water_demo/data/terrains/" @ %path @ "/texture.atlas");
}
// Finally, combine into a unique-textured terrain.
//atlasGenerateUniqueTerrain("terrain_water_demo/clean.atlas", "terrain_water_demo/geometry.atlas", "terrain_water_demo/arcticTexture.atlas");
atlasGenerateUniqueTerrain("terrain_water_demo/data/terrains/" @ %path @ "/atlas.atlas",
"terrain_water_demo/data/terrains/" @ %path @ "/geometry.atlas",
"terrain_water_demo/data/terrains/" @ %path @ "/texture.atlas");
echo("done");
}
#6
04/01/2008 (8:28 am)
As a footnote - I hope this and the other threads I've created save someone else the week I spent trying to get this working.
#7
04/01/2008 (9:06 am)
Excellent work Andy
#8
04/04/2008 (1:20 pm)
Very, very cool!
#9
could someone please tell me why i get such an terrain?
Image1
Image2
I did the following:
created a 1024 terrain in L3DT (standard though because i am still evaluating)
created alphamaps (got 4 PNG)
then run following commands (all commands executed ok):
atlasOldGenerateChunkFileFromRaw16("scriptsAndAssets/data/terrains/terrain/l3dtHM1.raw",1024,1.0,0.002777,
"scriptsAndAssets/data/terrains/terrain/deleteme.geometry.chu",2.0,4);
importOldAtlasCHU("scriptsAndAssets/data/terrains/terrain/deleteme.geometry.chu",
"scriptsAndAssets/data/terrains/terrain/geometry.atlas");
atlasGenerateTextureTOCFromTiles(1, "scriptsAndAssets/data/terrains/terrain/newProj_LM.jpg",
"scriptsAndAssets/data/terrains/terrain/textureLM.atlas", 0);
atlasGenerateTextureTOCFromTiles(4, "scriptsAndAssets/data/terrains/terrain/newProj_Alpha_%d.png",
"scriptsAndAssets/data/terrains/terrain/textureOP.atlas", 1); // 4 alphamaps (newProj_Alpha_0.png - newProj_Alpha_3.png)
atlasGenerateBlenderTerrain("scriptsAndAssets/data/terrains/terrain/terrain.atlas",
"scriptsAndAssets/data/terrains/terrain/geometry.atlas",
"scriptsAndAssets/data/terrains/terrain/textureOP.atlas",
"scriptsAndAssets/data/terrains/terrain/textureLM.atlas", 65536, "scriptsAndAssets/data/terrains/terrain/rock1.jpg", //in reverse order then in the alphamap structure
"scriptsAndAssets/data/terrains/terrain/grass1.jpg",
"scriptsAndAssets/data/terrains/terrain/rock1b.jpg",
"scriptsAndAssets/data/terrains/terrain/grass1-dry.jpg");
Thanks for your answer.
P.S.: I also got the same result with Freeworld3D exports? And for some reason the execution of atlasGenerateTextureTOCFromLargeJPEG for Unique terrains always crashes my torque (with exported jpeg).
04/08/2008 (4:19 pm)
Hi,could someone please tell me why i get such an terrain?
Image1
Image2
I did the following:
created a 1024 terrain in L3DT (standard though because i am still evaluating)
created alphamaps (got 4 PNG)
then run following commands (all commands executed ok):
atlasOldGenerateChunkFileFromRaw16("scriptsAndAssets/data/terrains/terrain/l3dtHM1.raw",1024,1.0,0.002777,
"scriptsAndAssets/data/terrains/terrain/deleteme.geometry.chu",2.0,4);
importOldAtlasCHU("scriptsAndAssets/data/terrains/terrain/deleteme.geometry.chu",
"scriptsAndAssets/data/terrains/terrain/geometry.atlas");
atlasGenerateTextureTOCFromTiles(1, "scriptsAndAssets/data/terrains/terrain/newProj_LM.jpg",
"scriptsAndAssets/data/terrains/terrain/textureLM.atlas", 0);
atlasGenerateTextureTOCFromTiles(4, "scriptsAndAssets/data/terrains/terrain/newProj_Alpha_%d.png",
"scriptsAndAssets/data/terrains/terrain/textureOP.atlas", 1); // 4 alphamaps (newProj_Alpha_0.png - newProj_Alpha_3.png)
atlasGenerateBlenderTerrain("scriptsAndAssets/data/terrains/terrain/terrain.atlas",
"scriptsAndAssets/data/terrains/terrain/geometry.atlas",
"scriptsAndAssets/data/terrains/terrain/textureOP.atlas",
"scriptsAndAssets/data/terrains/terrain/textureLM.atlas", 65536, "scriptsAndAssets/data/terrains/terrain/rock1.jpg", //in reverse order then in the alphamap structure
"scriptsAndAssets/data/terrains/terrain/grass1.jpg",
"scriptsAndAssets/data/terrains/terrain/rock1b.jpg",
"scriptsAndAssets/data/terrains/terrain/grass1-dry.jpg");
Thanks for your answer.
P.S.: I also got the same result with Freeworld3D exports? And for some reason the execution of atlasGenerateTextureTOCFromLargeJPEG for Unique terrains always crashes my torque (with exported jpeg).
#10
Your lightmap is setup to be created from 1 image?
atlasGenerateTextureTOCFromTiles is meant to be used in with an array of textures.
Example . 4 textures in a 2 X 2 array.
I guess you could get it to load 1 texture but it would have to be named like newProj_LMx0y0.jpg
If you were using an array of textures newProj_LM.jpg should be newProj_LMx%dy%d.jpg or similar.
Also the second atlasGenerateTextureTOCFromTiles is wrong as well.
It should read like newProj_Alpha_x%dy%d.png not newProj_Alpha_%d.png.
04/08/2008 (6:11 pm)
@Ales PotocnikYour lightmap is setup to be created from 1 image?
atlasGenerateTextureTOCFromTiles is meant to be used in with an array of textures.
Example . 4 textures in a 2 X 2 array.
I guess you could get it to load 1 texture but it would have to be named like newProj_LMx0y0.jpg
If you were using an array of textures newProj_LM.jpg should be newProj_LMx%dy%d.jpg or similar.
Also the second atlasGenerateTextureTOCFromTiles is wrong as well.
It should read like newProj_Alpha_x%dy%d.png not newProj_Alpha_%d.png.
Torque Owner Bill Vee
DayOfWar Studios
atlasGenerateTextureTOCFromTiles determines the input file format and uses that.