Problems converting Lightmaps for Atlas2
by Andy Hawkins · in Torque Game Engine Advanced · 03/29/2008 (8:46 pm) · 2 replies
To overcome some problems exporting Blended terrain from L3DT I decided to write my own function
Only it errors out when I try to load lightmap. What am I supposed to do, to get the light map to load? (function is below errors)
Only it errors out when I try to load lightmap. What am I supposed to do, to get the light map to load? (function is below errors)
********* Opacity map created *************** atlasGenerateTextureTOCFromLargeJPEG - Successfully opened JPEG 'terrain_water_demo/data/terrains/bl/test2_LM.jpg' for reading. atlasGenerateTextureTOCFromLargeJPEG - Image is 1024px (hopefully square!). [b]atlasGenerateTextureTOCFromLargeJPEG - Tree depth of 0 mandates -2147483648 tiles on a side. atlasGenerateTextureTOCFromLargeJPEG - Therefore, tiles are 0px wide. AtlasFile::createNew - failed to open '0' for wipe! Are you currently using it in an AtlasInstance2? atlasGenerateTextureTOCFromLargeJPEG - Could not create new Atlas file '0'[/b] AtlasFile::waitForPendingWrites - Waiting for pending output to finish. AtlasFile::waitForPendingWrites - Done! ********* Lightmap created *************** atlasGenerateBlenderTerrain - Getting ready to produce blender terrain... o Opening 'terrain_water_demo/data/terrains/bl/Geometry.atlas' for geometry... AtlasFile::load - loading Atlas resource 2cff250 with terrain_water_demo/data/terrains/bl/Geometry.atlas o Opening 'terrain_water_demo/data/terrains/bl/OpacityTex.atlas' for opacity data... AtlasFile::load - loading Atlas resource 2d12580 with terrain_water_demo/data/terrains/bl/OpacityTex.atlas o Opening 'terrain_water_demo/data/terrains/bl/Lightmap.atlas' for lightmap data... AtlasFile::load - cannot open atlas file 'terrain_water_demo/data/terrains/bl/Lightmap.atlas'. atlasGenerateBlenderTerrain - unable to open 'terrain_water_demo/data/terrains/bl/Lightmap.atlas' for input! done
#2
These is the correct script
04/01/2008 (8:34 am)
To close this issue - this was caused by using the wrong loading command and incorrect heightmap settings.These is the correct script
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");
}
Associate Andy Hawkins
DrewFX
function BT(%path,%fileName,%tiled) { // BT("ab","blend_test5",false); // BT("bl","test2",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); // 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.0, 5); 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 (%tiled==true) { echo("********* ALPHA MAP:" @ %path @ "/" @ %fileName @ "_Alpha_1_x%dy%d.png"); // Import data from some tiles we rendered out with L3DT. atlasGenerateTextureTOCFromTiles(8, "terrain_water_demo/data/terrains/" @ %path @ "/" @ %fileName @ "_Alpha_1_x%dy%d.png", "terrain_water_demo/data/terrains/" @ %path @ "/OpacityTex.atlas", 1); } else { 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"); } echo("********* Opacity map created ***************"); if (%tiled==true) { // Import a tiled lightmap we generated, as well. We store these in JPEG as a little error is not going to be noticeable. atlasGenerateTextureTOCFromTiles(16, "terrain_water_demo/data/terrains/" @ %path @ "/" @ %fileName @ "_LM_x%dy%d", "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. atlasGenerateTextureTOCFromLargeJPEG("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 @ "/yellowsand1", "terrain_water_demo/data/terrains/" @ %path @ "/dirt1", "terrain_water_demo/data/terrains/" @ %path @ "/rock1", "terrain_water_demo/data/terrains/" @ %path @ "/grass1" ); echo("done"); }