Suggestions on texturing a large terrain (8092x8092)
by Emil Diego · in Torque Game Engine Advanced · 10/18/2006 (11:09 am) · 26 replies
I have a large terrain that I created and successfully imported into TSE with a basic texture. The size of the terrain is 8092 x 8092 pixels. I want to now focus on creating the texture for it. I want the texture to be detailed enought so that it looks good up close. Currently I have a single texture file that I am importing using the atlas console commands.
I was hoping to get some feedback from the community about my 2 attempts.
1) I was planning on creating a single large texture and importing it using the importOldAtlasCHU console command. I was thinking of making the terrain 4-6 times the size of the terrain and hope that this would give me the level of detail i needed.
2) The second idea I had, which i don't know if it's possible to do, was to take the single terrain heightmap and break it up into 512 x 512 pices and then texture each piece individually. Create a seperate atlas file for each and then somehow stich them back together using atlas.
If anyone has any thoughts or knows of a better way, please let me know.
I was hoping to get some feedback from the community about my 2 attempts.
1) I was planning on creating a single large texture and importing it using the importOldAtlasCHU console command. I was thinking of making the terrain 4-6 times the size of the terrain and hope that this would give me the level of detail i needed.
2) The second idea I had, which i don't know if it's possible to do, was to take the single terrain heightmap and break it up into 512 x 512 pices and then texture each piece individually. Create a seperate atlas file for each and then somehow stich them back together using atlas.
If anyone has any thoughts or knows of a better way, please let me know.
#2
I bet you will have to go trough a lot of pain to get a unique texture approach to look detailed up close. :/
10/18/2006 (1:01 pm)
Quote:
1) I was planning on creating a single large texture and importing it using the importOldAtlasCHU console command. I was thinking of making the terrain 4-6 times the size of the terrain and hope that this would give me the level of detail i needed.
I bet you will have to go trough a lot of pain to get a unique texture approach to look detailed up close. :/
#3
I don't know how large an area is covered by your 8096x8096 terrain, so I can't talk specifics (I purposefully made mine 1.0m/0.25m). What I can tell you is if you want a texture that's 4 times bigger than your terrain, the jpg (if you go that route) would be 32,000 pixels square. That is getting to be a BIG file. Photoshop2 can only open 30,000 pixel wide images. TSE may be able to read it in, but processing it may take a HUGE amount of memory (Ben Garney said he fixed that in MS4.0, but I haven't tested it yet). A JPG that big could run into the hundreds of megabytes, and the final atlas "could" approach a gigabyte.
So what I'm saying is this. Its theoretically possible to create a unique texture to cover a very large terrain, but you are pushing the limits of both hardware and software to the point that it becomes both unweildy and unpractical.
You're second idea is also has merit and is theoretically possible, but has issues of its own I won't discuss here. Whichever way you go, I wish you the best of luck, and be sure to report back to us if you have any success.
10/18/2006 (3:59 pm)
It all depends on the definition of "detailed". For my visualization projects, which are in eternal R&D, I create terrain/texture atlas files that cover 4096 meters x 4096 meters. For the terrain, I use 1m resolution, creating a 4096x4096 pixel .raw file (I do all my work from Photoshop). For the unique texture, I use 0.25m (10inch) resolution aerial imagery, creating a 16,384x16384 pixel image (which is actually broken into tiles for the atlasGenerateTextureTOCFromTiles() command). In my opinion, and for my needs, this resolution is fine. If you are looking to see every blade of grass, 0.25m-resolution wouldn't be sufficient.... you would need something closer to 0.1m (4inch).I don't know how large an area is covered by your 8096x8096 terrain, so I can't talk specifics (I purposefully made mine 1.0m/0.25m). What I can tell you is if you want a texture that's 4 times bigger than your terrain, the jpg (if you go that route) would be 32,000 pixels square. That is getting to be a BIG file. Photoshop2 can only open 30,000 pixel wide images. TSE may be able to read it in, but processing it may take a HUGE amount of memory (Ben Garney said he fixed that in MS4.0, but I haven't tested it yet). A JPG that big could run into the hundreds of megabytes, and the final atlas "could" approach a gigabyte.
So what I'm saying is this. Its theoretically possible to create a unique texture to cover a very large terrain, but you are pushing the limits of both hardware and software to the point that it becomes both unweildy and unpractical.
You're second idea is also has merit and is theoretically possible, but has issues of its own I won't discuss here. Whichever way you go, I wish you the best of luck, and be sure to report back to us if you have any success.
#4
10/19/2006 (12:27 am)
I think you should go with 1024 and 2048 for the heightmaps and then start moving them together...I'm making a series of Islands so a bunch of 1024 - 2048 heightmaps is perfect, I make the texture maps 16384x16384...I actually take the original heightmap and enlarge it to 16384 and paint right on it works pretty well....although I must say make sure you pay attention to texture scale:)I keep forgetting so when the ferns arent as big as houses ill post some screen shots:)
#5
It seems that the consesnus is smaller terrain and texture files is the best approach. Easier to manage, easier to import, etc.
Here is how I am currently doing the large terrain:
new AtlasInstance2(NewTerrain) {
position = "-4096.0 -4096.0 80";
rotation = "1 0 0 0";
scale = "1 1 1";
detailTex = "~/data/terrains/details/detail1";
atlasFile = "~/data/terrains/terrain_20_final_size_2_0.atlas";
lightMapSize = "1024";
};
I'm still a little new to using the TSE engine, so if I break up my terrain into multiple 1024x1024 atlas files how do I get them all together? Should I create multiple atlas instances and place them next to eachother?
Or is there a way to specify multiple atlas files in a single atlas instance?
10/19/2006 (5:18 am)
I want to thank you all for your feedback. I really appreciate it.It seems that the consesnus is smaller terrain and texture files is the best approach. Easier to manage, easier to import, etc.
Here is how I am currently doing the large terrain:
new AtlasInstance2(NewTerrain) {
position = "-4096.0 -4096.0 80";
rotation = "1 0 0 0";
scale = "1 1 1";
detailTex = "~/data/terrains/details/detail1";
atlasFile = "~/data/terrains/terrain_20_final_size_2_0.atlas";
lightMapSize = "1024";
};
I'm still a little new to using the TSE engine, so if I break up my terrain into multiple 1024x1024 atlas files how do I get them all together? Should I create multiple atlas instances and place them next to eachother?
Or is there a way to specify multiple atlas files in a single atlas instance?
#6
This loads in three distinct atlas files that are 4096 meters square. It sounds like maybe other people have other experiences, but I find that when I load four or more Atlas instances, I run into "Paging" issues where the textures either load in the wrong spots (at various levels of detail), or they don't load at all, leaving just white ground. I believe (though I guess I could be wrong), that we've been told by Ben that loading a lot of seperate atlas instances into a single mission is a "bad thing". If you'd like some background reading on that stuff (as it related to MS3.5), here is the thread.
10/19/2006 (8:23 am)
Here is the pertinant section of my current mission file:new AtlasInstance2(Terrain_B11E14) {
position = "4096 2048 200";
rotation = "1 0 0 0";
scale = "1 1 1";
detailTex = "~/data/terrains/details/detail1";
atlasFile = "~/data/terrains/Data_NDTIP_B11E14.atlas";
lightMapSize = "1024";
};
new AtlasInstance2(Terrain_D07G10) {
position = "0 0 200";
rotation = "1 0 0 0";
scale = "1 1 1";
detailTex = "~/data/terrains/details/detail1";
atlasFile = "~/data/terrains/Data_NDTIP_D07G10.atlas";
lightMapSize = "1024";
};
new AtlasInstance2(Terrain_G03J06) {
position = "-4096 -3072 200";
rotation = "1 0 0 0";
scale = "1 1 1";
detailTex = "~/data/terrains/details/detail1";
atlasFile = "~/data/terrains/Data_NDTIP_G03J06.atlas";
lightMapSize = "1024";
};This loads in three distinct atlas files that are 4096 meters square. It sounds like maybe other people have other experiences, but I find that when I load four or more Atlas instances, I run into "Paging" issues where the textures either load in the wrong spots (at various levels of detail), or they don't load at all, leaving just white ground. I believe (though I guess I could be wrong), that we've been told by Ben that loading a lot of seperate atlas instances into a single mission is a "bad thing". If you'd like some background reading on that stuff (as it related to MS3.5), here is the thread.
#7
It seems that there is also a way to read in a set of texture tiles. It's a function called atlasGenerateTextureTOCFromTiles. I'll also give this a try too, since it will allow me to keep one large terrain file and import a set of high resolution tiles for the texture. This should give me the best of moth worlds. I'll let you all know how it turns out.
10/19/2006 (9:12 am)
Thanks for the info ryan. I'll try the multiple atlas instances.It seems that there is also a way to read in a set of texture tiles. It's a function called atlasGenerateTextureTOCFromTiles. I'll also give this a try too, since it will allow me to keep one large terrain file and import a set of high resolution tiles for the texture. This should give me the best of moth worlds. I'll let you all know how it turns out.
#8
The important part here is to make sure you understand the tree depths and what they mean and do for you and what you should be using. I wish I could go through and explain everything in detail, but I just don't have the time these days (TsE is a side project to real work these days)
10/19/2006 (9:45 am)
Current commands I use to input one of my Atlas data:atlasGenerateTextureTOCFromTiles(32, "./4kmOutTilesA/Aerial_B11E14_x%d_y%d", "./aerial_B11E14.atlas", "PNG");
atlasOldGenerateChunkFileFromRaw16("./elev_B11E14_4097.raw", 4096, 1.0, 1.0 / 100.0,"./elev_B11E14_4097.chu", 0.3, 4 );
ImportOldAtlasCHU("./elev_B11E14_4097.chu","./elev_B11E14_4097.atlas");
atlasGenerateUniqueTerrain("./Data_NDTIP_B11E14.atlas","./elev_B11E14_4097.atlas","./aerial_B11E14.atlas");The important part here is to make sure you understand the tree depths and what they mean and do for you and what you should be using. I wish I could go through and explain everything in detail, but I just don't have the time these days (TsE is a side project to real work these days)
#9
Just to recap, My terrain is 8192 x 8192. Now i broke that up into 16 2048x2048 chunks. Each chunk has it's own texture that's 8192 x 8192. (I'm trying to get a really detailed texture)
1) I created the textures as PNG files but I kept getting an error message saying that "Error cannot load pngs taller than 1024 pixels !"
Is there a reason for that limit in the engine or does the file not support > 1024 x 1024 pixels?
atlasGenerateTextureTOCFromTiles(4, "terrain_water_demo/data/textures/texture_8192x8192_%d_%d.png", "terrain_water_demo/data/textures/worldTexture.atlas", "PNG");
2) I then recreated all the textures as JPGs and tried it again. Now i'm getting a different message. "AtlasTexChunk::write - failed writing bitmap!"
atlasGenerateTextureTOCFromTiles(4, "terrain_water_demo/data/textures/texture_8192x8192_%d_%d.jpg", "terrain_water_demo/data/textures/worldTexture.atlas", "JPEG");
--------------------------
Anyone have any ideas to resolve this issue or is my approach flawed.
Thanx in advance for the help :)
10/26/2006 (11:20 am)
Here's my first attempt at creating a texture from individual tiles. I am running into some issues and I was hoping to get some feedback.Just to recap, My terrain is 8192 x 8192. Now i broke that up into 16 2048x2048 chunks. Each chunk has it's own texture that's 8192 x 8192. (I'm trying to get a really detailed texture)
1) I created the textures as PNG files but I kept getting an error message saying that "Error cannot load pngs taller than 1024 pixels !"
Is there a reason for that limit in the engine or does the file not support > 1024 x 1024 pixels?
atlasGenerateTextureTOCFromTiles(4, "terrain_water_demo/data/textures/texture_8192x8192_%d_%d.png", "terrain_water_demo/data/textures/worldTexture.atlas", "PNG");
2) I then recreated all the textures as JPGs and tried it again. Now i'm getting a different message. "AtlasTexChunk::write - failed writing bitmap!"
atlasGenerateTextureTOCFromTiles(4, "terrain_water_demo/data/textures/texture_8192x8192_%d_%d.jpg", "terrain_water_demo/data/textures/worldTexture.atlas", "JPEG");
--------------------------
Anyone have any ideas to resolve this issue or is my approach flawed.
Thanx in advance for the help :)
#10
Your naming convention for the atlasGenerateTextureTocFromTiles texture names may be wrong...what are the exact names of your tiles?
10/26/2006 (11:24 am)
There is a constant in the source code (can't remember what it is off the top of my head) for tile size maximum, you could change it to be higher, but performance could take a pretty drastic hit, experiment!Your naming convention for the atlasGenerateTextureTocFromTiles texture names may be wrong...what are the exact names of your tiles?
#11
the x and y values go from 0 - 3. and i have a JPG and PNG version of each file.
10/26/2006 (11:27 am)
I checked the file names and they seem to be ok. The file names I am using are texture_8192x8192_0_0.jpg.the x and y values go from 0 - 3. and i have a JPG and PNG version of each file.
#12
I also seem to find that a 2049 height field need to be processed at a treeDepth of at least 4, but I don't remember the details on that. So far I just have not converted any heigth maps larger than 2049 over to Atlas 2.
10/26/2006 (12:16 pm)
I have not tried creating Blended terrain, only Unique terrains. But I've noticed that when I call atlasGenerateTextureTOCFromLargeJPEG() and the JPEG texture size is 8192, the treeDepth has to be at least 4 or I get the "Error cannot load pngs taller than 1024 pixels !". If the texture is 16384 then the treeDepth needs to be 5. I assume the limit is on the leaf size, larger treeDepth, smaller leafs.I also seem to find that a 2049 height field need to be processed at a treeDepth of at least 4, but I don't remember the details on that. So far I just have not converted any heigth maps larger than 2049 over to Atlas 2.
#13
I really don't want to hack and slash my way through the code maging alterations that I don't 100% understand, so let me ask this.
Should i break up my terrain texture, currently 8192x8192, to smaller tiles (1024x1024) ?
Is there another approace aside from creating a Unique terrain that I can use?
10/27/2006 (5:33 am)
I did find a hard coded contraint to the file sizes allowed in bitmapjpeg.cpp. There is a MAX_HEIGHT field that was set to 2048. I changed it to 8192 and reran the texture command, but now i'm getting a differet error.I really don't want to hack and slash my way through the code maging alterations that I don't 100% understand, so let me ask this.
Should i break up my terrain texture, currently 8192x8192, to smaller tiles (1024x1024) ?
Is there another approace aside from creating a Unique terrain that I can use?
#14
Let's think about this in terms of checkerboards. Your terrain (the 8192 one) is the entire checkboard (if you break the terrain into 16 smaller terrains, each of them becomes an entire checkerboard). The atlasGenerateTextureTOCFromTiles function lays down a grid of tiles on the face of the checkerboard, and you need to specify each of those tiles... every square of the checkerboard.
Trying to match this to what I can figure out from what sizes you say you are using...
You said you had broken the terrain down into 16 individual terrain tiles, and want each of those to have an 8192px texture. Assuming you use the biggest recommended texture tile (512px or so), what you want to do is break each of the 16 individual 8192px textures down into a 16x16 tile grid, turning 1 large texture into 256 smaller textures (each 512 x 512px). Then, use those smaller textures in the ..FromTiles function and your 2048px terrain to create a final atlat terrain. Repeat this for the other 15 final, unique atlas terrains. This would be the best way to at least get your feet wet with what is required to do this stuff.
Then you could try doing it all on one, massive terrain (your original 8192px one). This would require 32768 x 32768 pixels of texture, which could be broken into 512px tiles as well... you would need a grid of 64x64 of them, or a total of 4096 unique texture tiles.
It's a lot of work, and will push TSE and your computer to extremes, but it can be done. Again, I wish you luck.
10/27/2006 (8:37 am)
I assume you are still trying to use atlasGenerateTextureTOCFromTiles. As that function has been described to me (by Ben Garney, whom wrote it). Each of the tiles that you use to load in textures will be the actual tiles tiles sent to the video card for rendering. When you use the jpg import function, it breaks that jpg up into tiles, but in this function, you specify the tiles specifically. Traditionally, video cards like using textures that are no more than 256 or 512 pixels wide. I personally have been using 128px wide png files as my tiles, and I think a 8192px isn't what you really want.Let's think about this in terms of checkerboards. Your terrain (the 8192 one) is the entire checkboard (if you break the terrain into 16 smaller terrains, each of them becomes an entire checkerboard). The atlasGenerateTextureTOCFromTiles function lays down a grid of tiles on the face of the checkerboard, and you need to specify each of those tiles... every square of the checkerboard.
Trying to match this to what I can figure out from what sizes you say you are using...
You said you had broken the terrain down into 16 individual terrain tiles, and want each of those to have an 8192px texture. Assuming you use the biggest recommended texture tile (512px or so), what you want to do is break each of the 16 individual 8192px textures down into a 16x16 tile grid, turning 1 large texture into 256 smaller textures (each 512 x 512px). Then, use those smaller textures in the ..FromTiles function and your 2048px terrain to create a final atlat terrain. Repeat this for the other 15 final, unique atlas terrains. This would be the best way to at least get your feet wet with what is required to do this stuff.
Then you could try doing it all on one, massive terrain (your original 8192px one). This would require 32768 x 32768 pixels of texture, which could be broken into 512px tiles as well... you would need a grid of 64x64 of them, or a total of 4096 unique texture tiles.
It's a lot of work, and will push TSE and your computer to extremes, but it can be done. Again, I wish you luck.
#15
10/29/2006 (6:34 pm)
I have successfully generated unique terrains using a heightmap of 8192 x 8192 px and a 32k x 32k texture. The texture was tiled in a 64 x 64 mosaic of 512 x 512 jpegs. It worked fine. The time required to run it through atlas was fairly long but not unreasonable. And more importantly it ran smoothly in TSE.
#17
10/31/2006 (11:48 am)
I am writing a small program that will take my large textures and break them up into smaller 512x512 tiles using ImageMagick. So far I only have half of the textures done and the tiles are 1.2GB all together. Of course all of that is the repeated png header and palette informaiion. Once I finish all the tiles and generate the Texture TOC, i'll let you all know how big it gets.
#18
11/06/2006 (4:26 am)
Our project is a large-terrain project as well...we we'll be interested in how this turns out.
#19
Now I can import Atlas terrain textures that are 32K by 32K. So far, I have only created one terrain but that one runs fine.
I am currently trying to process a 64k texture.
11/06/2006 (1:59 pm)
I recently followed Ben's advice and built my own texture importer function for Atlas2 textures. Basicly I copied \engine\atlas\editor\atlasImportLargeImage.cpp and called it atlasImportLargeRaw.cpp. Then I stripped out all of the JPEG specific code to create a new console function 'atlasGenerateTextureTOCFromLargeRaw' which can import raw 8-bit RGB files.Now I can import Atlas terrain textures that are 32K by 32K. So far, I have only created one terrain but that one runs fine.
I am currently trying to process a 64k texture.
#20
Here's what I did so far.
I took a small piece of my terrain and created the texture for it as a test run before i do the entire thing.
1) I created the terrain raw. 2049 x 2049 16 bit heightmap
2) I converted it to a chunk
atlasOldGenerateChunkFileFromRaw16("chunk_1_1.raw", 2048, 1.0, 1.0/256.0, "chunk_1_1.chu", 1.0, 2);
3) Next I created the atlas filefrom the chunk
importOldAtlasCHU("chunk_1_1.chu", "chunk_1_1.atlas");
4) Next I took the 8192 x 8192 terrain that corresponds to that chunk of terrain and broke it up into 512x512 jpgs
5) I created the texture TOC
atlasGenerateTerrainTOCFromTiles(16, "text_512x512_%d_%d", "chunk_1_1_texture.atlas", "JPEG");
6) Then I generated the unique terrain
atlasGenerateUniqueTerrain("chunk_1_1_final.atlas", "chunk_1_1.atlas", "chunk_1_1_texture.atlas");
I then changed the mission file from the terrain_water_demo to point to the new terrain file and ran the program.
11/08/2006 (6:23 am)
I am not getting good results with generating the texture from a set of tiles. When i finally create the terrain and view it, I am getting seams around each tile texture. The source tiles are seamless and the original texture does not contain the seems. The texture is also not matching up with the terrain. I hace checked the terrain tiles and they all look ok and have the correct numbering (0-15, 0-15). Any ideas what I can be doing wrong. Here's what I did so far.
I took a small piece of my terrain and created the texture for it as a test run before i do the entire thing.
1) I created the terrain raw. 2049 x 2049 16 bit heightmap
2) I converted it to a chunk
atlasOldGenerateChunkFileFromRaw16("chunk_1_1.raw", 2048, 1.0, 1.0/256.0, "chunk_1_1.chu", 1.0, 2);
3) Next I created the atlas filefrom the chunk
importOldAtlasCHU("chunk_1_1.chu", "chunk_1_1.atlas");
4) Next I took the 8192 x 8192 terrain that corresponds to that chunk of terrain and broke it up into 512x512 jpgs
5) I created the texture TOC
atlasGenerateTerrainTOCFromTiles(16, "text_512x512_%d_%d", "chunk_1_1_texture.atlas", "JPEG");
6) Then I generated the unique terrain
atlasGenerateUniqueTerrain("chunk_1_1_final.atlas", "chunk_1_1.atlas", "chunk_1_1_texture.atlas");
I then changed the mission file from the terrain_water_demo to point to the new terrain file and ran the program.
Torque 3D Owner Bobby Leighton