Civ4 NIf Exporter opacity tutorial
From Nexus Wiki
DISCLAIMER: I don't see myself as an expert on this subject and with this tutorial I'm not aspiring to show you the possibly best way to do this - just the way I do it myself, and which I've found works.
Download example files (55kb 7-zip archive)
What you'll need for this tutorial:
- "The Elder Scrolls IV: Oblivion" + "TES Construction Set", obviously
-Paint Shop Pro 7.04 or later
-DDS Converter by Yannick 'Bluehair' Leon
-The Civ4 NIF Exporter plugin for 3D Studio Max
The first step is to find which texture you want to use. Google Imagesearch is a really good resource. You'll want an image that is as crisp and clear as possible (the larger the better). If you can, scan something - that's both a good way to be absolutely sure you own the copyright as well as getting it the way you want it. Anyway, that's not the focus of this tutorial so I'll move on assuming you have a nice texture to work with.
It might be good to mention that your texture has to be sized to a power of 2 for it to show up at all. Powers of 2 are: 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096 etc (you probably don't want to go higher than 2048 or you might hog too much video memory when playing, but test it out and see). In fact I don't think you would even be able to convert it to .dds if it's not sized to a power of 2. If you have a picture you want to use and it's, say, 224x116 large, you shouldn't resize the whole picture to 128x64 just because of that... instead, go to "Image ] Canvas Size" and set it to the nearest power of 2 that won't force you to resize the image downward. It doesn't really matter where the image is on the canvas, since you'll control that through the mapping in 3D Studio Max.
Now that you have your texture, fill in the parts of it that you would like transparant with the color #FF00FF (bright pink). It really has to be that exact color. You can either set the #FF00FF color as the background and then use the magic wand to select the areas and then press DEL when you're satisfied. Or you could use Flood Fill from the start. Which of those are easiest depends on the texture.
This corresponds with how the tutorial file "Razorwings_CIV4_NIF_Exporter_Opacity_Tutorial_TextureExample01.psd" is set up.
Now comes the tricky part (at least for me it is). You'll want to separate this image to two layers, save the pink layer to the alpha channel, and move the alpha channel layer to the bottom of the stack.
What I did was that I:
- selected all the pink (using the magic wand)
- then [Selections ] Invert
- [Selections ] Promote to Layer
- [Selections ] Save to Alpha Channel" (just click ok, doesn't matter what you name it I think)
- Now, in the "Layers" menu, select the other layer at the bottom of the drop-down list (which isn't a layer yet)
- [Layers ] Promote to Layer
- [Layers ] Arrange ] Bring to Top
- And now your layer stack should look like in 'Razorwings_CIV4_NIF_Exporter_Opacity_Tutorial_proper_layer_stack.jpg'. The important thing is that the 'Promoted Selection' layer is at the bottom
- Right, now save your image as a "Photoshop (*.psd)" file. This is how the tutorial file 'Razorwings_CIV4_NIF_Exporter_Opacity_Tutorial_TextureExample02.psd' is set up.
Fire up "DDS Converter" and locate the .psd file you saved, and export it with the default options. Generating mipmaps is a really good idea, it makes your texure more efficient when viewed from afar. Corresponding with this step is "Razorwings_CIV4_NIF_Exporter_Opacity_Tutorial_TextureExample02.dds".
Open up 3D Studio Max and the material editor and start a new material. Use the default Blinn shader, it's easier to work with than the CivilizationIV shader when it comes to opacity. The easiest is probably to open the tutorial file "Razorwings_CIV4_NIF_Exporter_Opacity_Tutorial_maxscene.max".
In case you're using a different version of Max I'll try to explain it, and have included the picture "Razorwings_CIV4_NIF_Exporter_Opacity_Tutorial_maxrender.jpg" so you can quickly see how the max scene looks.
Set up your DDS texture in both the Diffuse and Opacity slots.
The Diffuse slot should have the default settings;
Mono Channel Output = RGB Intensity RGB Channel Output = RGB Alpha Source = Image Alpha
The Opacity slot on the other hand should have:
Mono Channel Output = Alpha RGB Channel Output = RGB Alpha Source = Image Alpha
If you've done everything right up until now and set it up correctly in Max, the material will display with opacity in the render viewport.
Right then. Export your model as a NIF using the CivilizationIV exporter (and make sure to bake the textures into the NIF, otherwise it won't work). Place it somewhere in the "OblivionMeshes" folder. If you don't have a "Meshes" folder, create one. It's a good idea to create a subdir in "Meshes" and gather all your NIFs in one place.
Feel free to check out the included .esp + NIF in the CS to see how this example turned out in-game. Just doubleclick the interior cell "aaaaaaRazorwingsTutorialCell" to see the transparant thingimajig.
And... you're done. All that's left to do is to go into the TES Construction Set, add a new entry in an appropriate list, supply an ID and search for your NIF.
I hope this tutorial has been informative to those who want to experiment with opacity and the Civ4 exporter. It's a tutorial I would have liked to have read myself, so, chances are someone else out there might benefit. Feel free to distribute it however you wish as long as it's apparant that I wrote it.
Happy modelling :D
/Razorwing 2006-04-13 firstname.lastname@example.org www.silgrad.com