|04-16-2011, 12:35 PM||#1|
Join Date: Sep 2007
United States of America
Location: Denver, Colorado
Hand-packing OG and UG Atlases
This tutorial will teach you how to create your Overgrowth (OG) and Undergrowth (UG) atlases by hand, thus overwriting the ones created by BF2 Editor. This process should be done as a very last step before releasing your map because if you add or subtract items from your OG or UG, the atlas will need to be changed again.
What is an OG / UG Atlas?
BF2 uses texture pallets for every object in the game, including overgrowth and undergrowth. These pallets are what we see in game and what gives color and detail to the objects. To prevent the computer from having to find and load a texture pallet every time it loads a blade of grass, it collects the necessary texture pallets all in one place and essentially creates a new texture pallet called an "atlas". This atlas has all of the textures in one place, thus making it more efficient.
Unfortunately, the Editor usually does a horrible job of creating these atlases because it leaves lots of empty space, which in turn creates a larger atlas than needed. Also, some overgrowth textures are solid (like bark) and when they are placed directly next to another overgrowth texture on the atlas, it can cause a bleed. The result is that from a distance a dark line may appear next to (or over) a tree or bush. This is caused by the solid texture on the atlas. By hand-packing your atlas, you can move the solid textures to another part of the atlas and get rid of the texture bleed.
Since they are both so similar, I will just explain how to create an overgrowth atlas.
Photoshop, plus any .dds plug-ins, such as this one for NVIDIA card users:
NVIDIA Texture Tools for Adobe Photoshop | NVIDIA Developer Zone
Step 1: Create OG Atlas in Editor
Open your map in Editor and make sure your overgrowth is loaded as well as any hand-placed overgrowth statics. It's important that if you hand-placed a certain type of bush and that bush isn't part of one of your overgrowth types, that is be loaded because its texture needs to be included on the atlas.
Now go to the top menu and select Compile > Generate Overgrowth Atlas.
This shouldn't take long. Once it's done, close the editor.
Step 2: View OG Atlas
Now open your map's overgrowth folder and you'll see a file called OvergrowthAtlas0.dds
Open it and take a look. If it looks like this, then you probably don't need to hand-pack it:
but if you have lots of empty space or a solid object next to a non-solid, it will look like this:
Before you close it, let me show you how to determine what's solid and what's transparent. On the right side of Photoshop, you should see a window with tabs like this:
Click on the "Channels" tab like so and you'll see that RGB, Red, Green, and Blue are already selected:
To see what's transparent, click on "Alpha 1"
You'll then notice that your main screen turns to something like this:
Only what's white will show up in game, which means the black is transparent. Now if you look at the big white blocks and switch between "RBG" and "Alpha 1", you'll see which items on your atlas are completely solid. Once you start hand-packing your atlas, you'll want to make sure these items don't border the edge of the atlas or a non-solid object... but we'll talk more about that later.
Step 3: Decide on new Atlas Size
If you decide that there is lots of wasted space and you want to hand-pack your atlas, the first thing you need to do is decide what size your new atlas will be. With your Editor-packed atlas open, you can click on "Image" on the top toolbar and then pick "Image Size" to see what the current size is. Atlas dimensions always use this scheme: 8, 16, 32, 64, 128, 256, 512, 1024, and 2048.
The atlas we'll use as an example from above is 2048 x 2048. Looking at how much space is actually used, my guess is that I only need an atlas half that size to still fit everything on. So the resulting atlas could be 2048 x 1024.
Step 4: Setting up Photoshop
Since we decided that everything would fit on an atlas 2048 x 1024, let's open up a new file with those dimensions and the following settings:
Once you hit "OK" you should have a rectangular black picture.
Now you'll need to set up grids so that you can place the textures on the atlas. First, click on "Edit" on the top toolbar, then select "Preferences > Guides, Grid & Slices".
Then set up the grid just as you see below (I've highlighted the area to be concerned with):
You can change this to your liking (such as using a grid spacing of 6.25) but make sure you're always using a number that is 1/4, 1/8, 1/16 of 100, etc. FYI: too few grid lines makes it hard to build the atlas but too many grid lines clutters the screen, so find a good balance.
Now click on "View" on the top tool bar and make sure that "Ruler", "Extras" and "Snap" are checked. Under snap, check "Grid". This will ensure you see the ruler and the new grids you just set up, and that when you move items they'll snap to the grid.
Now one final thing is to switch the ruler so that it reads "percentage". To do this, RIGHT-click on the ruler. You'll see a choice of measurements. Just check "percent" like so:
Okay, you should be good to go. The black picture should have red dashed grids and the ruler should show percent, like so:
Step 5: Understanding the .tai file
The next thing you'll need to understand is HOW the atlas is organized by looking at the OvergrowthAtlas.tai file. It is located in the same folder as the OvergrowthAtlas0.dds file and can be opened using any text program (like notepad).
For the atlas we've been using as an example, here is what the .tai file looks like:
# mods/pr_edit/levels\jungle_fire\overgrowth\OvergrowthAtlas.tai # # # <filename> <atlas filename>, <atlas idx>, <woffset>, <hoffset>, <width>, <height> # # Texture <filename> can be found in texture atlas <atlas filename>, i.e., # <group><idx>.dds with texture coordinates boundary given by: # A = ( <woffset>, <hoffset> ) # B = ( <woffset> + <width>, <hoffset> + <height> ) # # where coordinates (0,0) and (1,1) of the original texture map correspond # to coordinates A and B, respectively, in the texture atlas. objects/vegitation/jungle-pr/textures/jungle_tree_01_lod.dds levels\jungle_fire\overgrowth\OvergrowthAtlas0.dds, 0, 0, 0, 0.25, 0.125 objects/vegitation/pr/textures/bark1.dds levels\jungle_fire\overgrowth\OvergrowthAtlas0.dds, 0, 0, 0.125, 0.125, 0.25 objects/vegitation/pr/textures/tree_deciduous_2_lod.dds levels\jungle_fire\overgrowth\OvergrowthAtlas0.dds, 0, 0.25, 0, 0.25, 0.125 objects/vegitation/jungle-pr/textures/jungle_bush_10m_lod.dds levels\jungle_fire\overgrowth\OvergrowthAtlas0.dds, 0, 0.5, 0, 0.25, 0.0625 objects/vegitation/jungle-pr/textures/jungle_bush_20m_lod.dds levels\jungle_fire\overgrowth\OvergrowthAtlas0.dds, 0, 0.5, 0.0625, 0.25, 0.0625 objects/vegitation/jungle-pr/textures/jungle_tree_02_lod.dds levels\jungle_fire\overgrowth\OvergrowthAtlas0.dds, 0, 0.75, 0, 0.125, 0.125 objects/vegitation/jungle-pr/textures/jungle_tree_03_lod.dds levels\jungle_fire\overgrowth\OvergrowthAtlas0.dds, 0, 0.875, 0, 0.125, 0.125 objects/vegitation/jungle-pr/textures/jungle_tree_04_lod.dds levels\jungle_fire\overgrowth\OvergrowthAtlas0.dds, 0, 0, 0.375, 0.125, 0.125 objects/vegitation/jungle-pr/textures/jungle_tree_05_lod.dds levels\jungle_fire\overgrowth\OvergrowthAtlas0.dds, 0, 0, 0.5, 0.125, 0.125 objects/vegitation/jungle-pr/textures/palmfoliage_01_lod.dds levels\jungle_fire\overgrowth\OvergrowthAtlas0.dds, 0, 0, 0.625, 0.125, 0.125 objects/vegitation/pr/textures/camonet_lod.dds levels\jungle_fire\overgrowth\OvergrowthAtlas0.dds, 0, 0, 0.75, 0.125, 0.125 objects/vegitation/asia/textures/leaf_nc_leafybush01_lod.dds levels\jungle_fire\overgrowth\OvergrowthAtlas0.dds, 0, 0, 0.875, 0.125, 0.0625 objects/vegitation/asia/textures/leaf_ncbam02de_lod.dds levels\jungle_fire\overgrowth\OvergrowthAtlas0.dds, 0, 0.125, 0.125, 0.0625, 0.125 objects/vegitation/asia/textures/leaf_ncweeping02de_lod.dds levels\jungle_fire\overgrowth\OvergrowthAtlas0.dds, 0, 0, 0.9375, 0.125, 0.0625 objects/vegitation/jungle-pr/textures/jungle_groundfern_02_lod.dds levels\jungle_fire\overgrowth\OvergrowthAtlas0.dds, 0, 0.125, 0.25, 0.0625, 0.125 objects/vegitation/jungle-pr/textures/jungleplant_01_lod.dds levels\jungle_fire\overgrowth\OvergrowthAtlas0.dds, 0, 0.1875, 0.125, 0.125, 0.0625 objects/vegitation/middle-east/textures/leaf_me_vines01de_lod.dds levels\jungle_fire\overgrowth\OvergrowthAtlas0.dds, 0, 0.3125, 0.125, 0.125, 0.0625 objects/vegitation/asia/textures/tile_ncbark01de_lod.dds levels\jungle_fire\overgrowth\OvergrowthAtlas0.dds, 0, 0.4375, 0.125, 0.125, 0.03125 objects/vegitation/jungle-pr/textures/tile_junglebark_03_de_lod.dds levels\jungle_fire\overgrowth\OvergrowthAtlas0.dds, 0, 0.125, 0.375, 0.0625, 0.0625 objects/vegitation/pr/textures/hedgerow_10m_lod.dds levels\jungle_fire\overgrowth\OvergrowthAtlas0.dds, 0, 0.4375, 0.15625, 0.125, 0.03125 objects/vegitation/jungle-pr/textures/tile_junglebark_02_de_lod.dds levels\jungle_fire\overgrowth\OvergrowthAtlas0.dds, 0, 0.125, 0.4375, 0.03125, 0.0625 objects/vegitation/jungle-pr/textures/tile_junglebark_04_de_lod.dds levels\jungle_fire\overgrowth\OvergrowthAtlas0.dds, 0, 0.15625, 0.4375, 0.03125, 0.0625 objects/vegitation/pr/textures/hedgerow_5m_lod.dds levels\jungle_fire\overgrowth\OvergrowthAtlas0.dds, 0, 0.125, 0.5, 0.0625, 0.03125
First off, scroll down to the first line below the ones that start with "#", and you'll see a line that starts with: objects/vegitation/jungle-pr/textures/jungle_tree_01_lod.dds
This (and the first part of each line that follows) is the location of a texture that is needed. For this example, there are a total of 23 textures. So let's open the first texture in Photoshop. It should look like this:
Now if you look at the atlas again, you'll notice this matches one of the textures. Now I would recommend opening all of the remaining textures because we'll need them in step 6. A word of caution: Be very careful selecting the right file to open. You will see many similar named files in the overgrowth texture folders, so double check before opening.
Okay, now let's look at the second part of each line in the .tai file. You'll notice that the second part of the first line looks like this:
levels\jungle_fire\overgrowth\OvergrowthAtlas0.dds, 0, 0, 0, 0.25, 0.125.The first part just states the location of the atlas, which is in your map's overgrowth folder. Nothing too cosmic there. If you're doing an UndergrowthAtlas, then all of the textures will be located at EA GAMES/Battlefield 2/bf2editor/content/terrain/undergrowth.
So now let's break down what the five numerals mean:
0 = OvergrowthAtlas0.dds (if you had more than one OG atlas, it would be numbered 1, 2, etc.)The part that gets a little confusing is that the location and size numerals are based on percentage (thus why we changed our ruler and grids to percent earlier in the tutorial). Let me try to explain.
Location on Atlas
As stated above, the second and third numerals tell the program where the texture is located on the atlas. This is done by using the top left corner of the atlas as the 0,0 point on an x,y coordinate system. Since this texture was the first one placed on the atlas by BF2 Editor, it is located in the top left corner and thus has a location of 0,0... but for the sake of understanding how it works, I've provided an example below that shows what its location would be as it's moved around the atlas.
Once again, the example above is just for teaching purposes. A texture would never appear more than once on an atlas. Also, don't let the actual dimensions of the atlas fool you. The location is always stated as a percentage.
Size on Atlas
Okay, now let's look at the last two numerals. They state the size of the texture as it exists on the atlas. Once again, we'll be working with percentage but this time we won't be using the top left corner of the atlas as our anchor. Instead, the size of the texture is based on the size of the atlas. There's two ways to go about figuring this out:
Note that although the texture size remained the same, its size in respect to the atlas changed. When using a 2048x2048 atlas, the texture size was .25, .0125 while using a 2048x1024 atlas it changed to .25, .25. So once again, it relative to the atlas and you'll have to pay special attention to this.
So you've successfully unraveled the mystery of the OvergrowthAtlas.tai file. Congrats! Now we'll move on to creating an atlas of our own.
Step 6: Creating a new Atlas
Now that we understand how the atlas and .tai file works, we'll create a new one; one that doesn't have so much wasted space and that doesn't place solid objects next to non-solid ones.
Let's go back to the file you created earlier in step 4. It should be a blank black rectangle with the red grid lines showing. The first thing you'll need to do is create an "alpha 1" channel. Do this by clicking on "Channels" on the right window, then on the small icon on the bottom that looks like a piece of paper (see photo):
The new channel will automatically be called "alpha 1".
Now you're ready to start placing the textures. You can do this however you wish, but it's generally a good idea to start with the largest textures first... BUT don't select any of the solid ones. They'll need to go last so they're separated from the non-solid ones.
There are probably different ways to add the textures, but the way I do it is open the first texture you want to add, such as the jungle_tree_01_lod.dds that we used earlier. I then make sure the RGB channels are showing and select it with my rectangular marquee tool (highlighted icon) by drawing a box around the whole image.
Then click on Edit > Copy. now switch to your new atlas and make sure the RGB channels are selected. Then click Paste. The image will paste itself right in the middle of the atlas, so now you need to move it. Change your cursor to the Move tool and move the texture to where you want it. In this case, we'll place it in the top left corner. As you move it, go slowly when near its final resting place so that you can see when it snaps. If you set up everything correctly earlier, it should snap into place and be right on the grid lines.
For each texture, you'll need to copy/paste the RGB and the Alpha 1 separately. We just did the RGB, so now switch back to the jungle_tree_01_lod.dds file and click on the alpha 1 channel. Use the rectangular marquee tool again to select the entire image.
Switch back to the atlas, select the alpha 1 channel, and paste it. You won't see the RBG version you pasted seconds ago, so you'll have to make sure you remembered where you placed it. Now use the Move Tool to place it in the same place as it RGB version:
Alright, nice job! Now you have a choice... You can either update the .tai text file as you go or wait until the end. I prefer to do it as I go, but there are pros/cons to either way. If you do it now and decide to move a texture later, then you have to remember to update the .tai again. If you wait until the end, you may not remember which texture is which and will likely have to spend time confirming what each texture looks like.
Since I like to update the .tai as I go, that's what we'll do for the tutorial. So open the OvergrowthAtlas.tai file and save it to a new location so you don't overwrite the original one just yet.
The first texture originally stated:
objects/vegitation/jungle-pr/textures/jungle_tree_01_lod.dds levels\jungle_fire\overgrowth\OvergrowthAtlas0.dds , 0, 0, 0, 0.25, 0.125
So we'll change it to read:
objects/vegitation/jungle-pr/textures/jungle_tree_01_lod.dds levels\jungle_fire\overgrowth\OvergrowthAtlas0.dds , 0, 0, 0, 0.25, 0.25
Now repeat this process filling the atlas from left to right, as such:
Another word of warning: You'll notice that each RGB texture will be given its own layer when you paste it in. This is nice in case you want to move it later. However, the alpha 1 texture doesn't, so it isn't movable. If you goof up or want to change a location of a texture, you'll have to cover the alpha 1 grid with another texture and re-paste the texture to the location that corresponds with the new RGB location. Another option is to do the RBG layer first and once you're happy with it, go back and do the alpha 1 layer. Just be sure that everything matches perfectly.
Okay, once you've placed all of your non-solid textures, it's time to place your solid textures like bark, camo nets, etc. Basically you don't want these texture to border a non-solid texture. As stated above, there are only a few textures that are solid and the way to tell is to look at its alpha 1 channel. Here's an example:
As you can see, the alpha 1 channel is completely white, which means it's solid. If you place this next to a bush or tree that's not solid, it will bleed over. So we'll have to place it on the atlas with one grid of spacing around it, like so:
This isn't the same atlas that I showed earlier, so don't let that confuse you. It's just an example of how to place the solid objects. In the example, you'll see that the camo net and two types of solid bark are solid white (or almost solid). Lastly, since the atlas is like a typical texture sheet when you're done, the edges tile. So if you place a solid object on the edge of the atlas, make sure the opposing edge is empty or has another solid object. You'll see in the example that the right-most edge is empty so that the solid objects don't bleed onto the left edge.
Okay, you should have enough information to build your own atlas. It will take some time to fully perfect it, so be patient.
Step 7: Saving
All OG and UG atlases are saved as .dds files. And regardless of which size you picked, they are all saved as DXT5 ARGB 8 bpp | interpolated alpha, with 10 MIP maps.
I would suggest saving this in a place other than your map folder so that you'll always have it. It's probably a good idea to save the .PSD somewhere as well, in case you need to go back and make changes.
Step 8: Using new Atlases
The first thing I'd recommend is that you make the atlas and the .tai file read only by right clicking on them and checking the "read only" box. Then paste them into your map's folder. The OG atlas will go into the overgrowth folder and the UG atlas goes into map's main folder.
With the files marked as read-only, now load up Editor and re-save your OG and UG. I don't think this is 100% necessary for OG, but I'm pretty sure it is for UG so you might as well do it for both.
You should now be done. Load up your map in-game and check everything out. If you made an error on the atlas or on the .tai file, this is when you'll notice. Most likely it will be a .tai error so it's easy to go back and check your numbers for the texture that's affected.
Hope this tutorial helps. It's not overly hard to create your own atlas, but it does take a while to get your head around the process. If you have questions or suggestions (or if I stated something incorrectly) just respond below.
Last edited by [R-DEV]AFsoccer; 04-17-2011 at 03:09 AM..
|01-12-2014, 12:21 PM||#2|
Join Date: Dec 2006
United States of America
Blog Entries: 5
Re: Hand-packing OG and UG Atlases
Think we lost the pictures on this one too
|01-12-2014, 01:43 PM||#3|
Join Date: Sep 2007
United States of America
Location: Denver, Colorado
Re: Hand-packing OG and UG Atlases
Crap... I'll see if I can find them.
Edit: I couldn't find them so I'm going to have to re-create them and that may be a while. Sorry.
Last edited by [R-DEV]AFsoccer; 01-22-2014 at 01:40 AM..
|atlases, handpacking, tutorial|