Intro to Modding 2 - Creating Shaders and Weapon Skins

©2017 by .Twi – Please feel free to share!

This tutorial will go over the creation of shaders in UnrealEd, and using them as weapon skins. You can make numerous effects with shaders, including transparency, shininess, and illumination.

Shiny Shaders
Start by opening UnrealEd and opening the texture browser. Then go File > New, and set up your new shader like the picture below. It is very important that you change the Package name to something new! If you do not, you could end up overwriting a default game file and wrecking your ability to play multiplayer. When you've picked a package and name for the shader (and make sure that the MaterialClass is set to Class'Engine.Shader' -- it should be by default), hit the " New " button and you will see a properties window open for your new shader. To get started, you will be mostly interested in the settings for " Diffuse ", " Specular ", and " SpecularityMask ". The "Diffuse" is the base texture that your shader will modify. Leave the shader properties open, and go back to the texture browser. Open up the file R61stWeapons_T.utx. We are going to make a shiny pistol skin for the 92FS. Find the Pistols group and select the texture R61stPistol92FS. Keeping that texture selected, return to the shader properties window, and click on the "None" next to "Diffuse". You can now choose the button that says " Use ", and the pistol texture you selected will automatically be added to your shader. Now we need to add a " Specular " setting for shininess. Keep the shader properties open, and return to the texture browser. Still in R61stWeapons_T, choose the CubeMap group. We now need to add an environment map, which is like a 3d texture with 6 sides, in the shape of a cube. These can be used to make realistic reflections and shine. Click on the " TexEnv_Spec_01 " to select it, return to the shader properties, and click the "None" next to "Specular". Again click " Use ", and the environment map will be added to your shader. At this point, you can preview your shader in the shader properties window. Click on the cube shape under the window, and your shader will be applied to a cube that you can click and drag to rotate. This will let you see how the shininess is working. You can see what it should look like in the window above.

Let's try out our new shader in-game. Close the shader properties, and go back to your new package file that has the shader. Click on the shader to select it.

VERY IMPORTANT: if you do not follow this next step perfectly, you may overwrite a default game file, and will be unable to join a multiplayer game. We need to make a backup of our 1st person weapon models. Minimize UnrealEd, and find your game's StaticMeshes folder. Make a backup copy of R61stWeapons_SM.usx.

Once your backup is made, return to UnrealEd. Go to the staticmesh browser, and open up R61stWeapons_SM.usx. Open the Pistols group, and select the model R61stPistol92FSSlide. A box will open below the model section window. (If it does not appear, try clicking on the slide model again.)  Here is where we can change the skins of a model. Expand the little "+" beside "Materials", and then expand the "+" beside "[0]". You can now see the material that is the gun's skin. Click on the material name, and once again click the "Use" button. Now your new shader is applied to the slide model! If you use your mouse to move around in the preview window, you should be able to see the shininess. Hit the " Save " button or go File > Save to save the R61stWeapons_SM.usx file. You should overwrite the existing file -- this won't be an issue because you made a backup, right? Then return to the texture browser and save your new file that contains your shader. Save it with the same name as you chose for the package name way back at the beginning of the tutorial, in the textures folder. Close UnrealEd.

Open up a game of Raven Shield, and go to Custom Mission. Make sure you load up with a 92FS. Start the mission, and enjoy! If you like the effect, try adding it to the pistol's frame as well to make the whole thing shiny! (If you notice that the shiny effect doesn't seem to move like it should, you can change the setting m_bDynamicMaterial in your shader to True .  We will discuss this more in the next part of the tutorial.) NOTE: When you are done with the modding process, don't forget to delete the game files that you modified, and replace them with their backup!

Now that we've learned how to make a shiny shader, let's give the L85A1 some shininess. This one will be trickier because there are parts of the gun that are synthetic material and so shouldn't be shiny. In Section 2 of the tutorial, we will learn about SpecularityMasks !

Changing shininess with a SpecularityMask
Let's give the L85A1 some shininess. We'll need to apply the shader's specularity to the metal parts of the gun, but not so much on the synthetic materials. To do this, let's start by grabbing the L85A1's skin texture. Open up UnrealEd, open the file R61stWeapons_T.utx, and find the L85A1 skin in the assault rifles group. Right click and choose " Export to File ", and save it in a convenient location. Open up this new texture file that you exported in your image editor. I am using Adobe Photoshop CS2 in this tutorial, but this should be doable with most versions of Photoshop or GIMP (available for free).

What we will need to do is add an alpha channel to this texture. View the channels, and there should already be an alpha channel there (although it is not used by default in the base game). The alpha channel is a black and white only image. Areas that are closer to white will be shinier, and black areas will not be shiny at all. Edit the image how you like, with the metal parts of the gun brighter. Below you can see how I edited my alpha channel. Save the file ( make sure you are saving as a 32-bit *.TGA file! ).  Then open up UnrealEd again. Go to File > Import, and import your new texture with a new package name and new texture name. I imported mine to the "MyCustomL85" package, with the name "L85MaskedTex". Now create a new shader, also in the same package that you imported your L85 texture to. When the properties window pops up, set both the Diffuse and the SpecularityMask to your new L85 texture. Once again, set your Specular setting to the " TexEnv_Spec_01 " from R61stWeapons_T.

There is a small issue with the shininess that we made in the first part of this tutorial. Perhaps you noticed it when you made the 92FS slide shiny. In game, the lighting doesn't seem to move around on the gun as we move! That is because our shader needs to be set as a dynamic material. Find the m_bDynamicMaterial setting, and change it to True. Like in my example above, you should be able to see plenty of shine on the metal parts, but little or no shine on the synthetics. If you like the results, save the custom package. Name it exactly what you named it when importing the L85 texture, and save as a *.UTX file in the Textures folder.

Now go to the staticmesh browser. Don't forget to back up R61stWeapons_SM.usx if you haven't already! Like we did last time, find R61stWeapons_SM, but this time find the L85A1 weapon model, and apply the shader to it in the Materials box. You will notice that there are two materials for the L85; only apply your new shader in the first material. The second is for the reflective scope lens. Preview it in the window, and if you like the result, save R61stWeapons_SM.usx. Only save it if you have made a backup of the original file! Then try it out in a Custom Game, and see what you think! Don't forget to restore any backed up default files so you don't mess up your game!

Other shader effects: transparency and illumination
There are two other important effects that you can do with shaders, and now that you've figured out using Specular to get shininess, they should both be pretty easy! The first is transparency, and it uses the setting Opacity in the shader properties. Set a texture with an alpha channel in the Opacity box, and the shader will use that texture's alpha channel to determine what parts should be transparent.

For this part of the tutorial, we will make a ghostly electric purple TAR-21. Use UnrealEd's texture browser to find and export the TAR-21 's skin from the R61stWeapons_T.utx file. Use your image editor to color the gun purple. In the alpha channel, color the edges of the gun white, and the rest a dark grey. Save this file as a 32-bit *.TGA. Now import this new purple texture into a new package in UnrealEd, and make a new shader. Set this texture to the Diffuse and Opacity settings. You will probably also want to set TwoSided to True. You can preview the new shader in the shader properties window. If you like the results, save your new package as a *.UTX in the Textures folder. Now open up the staticmesh browser, and find the TAR-21's static mesh. (Notice that there are two meshes for the TAR, one for the default gun and one for if you need a scope.  Feel free to replace the skin for both.)  Use your mouse to maneuver in the preview window and check out how it looks. If you like it, save the R61stWeapons_SM.usx file ( as long as you have saved a backup copy already! ) and then try it out in game! But what if our new bright purple skin is NOT BRIGHT ENOUGH? It's time to talk about another setting in the shader properties, called SelfIllumination. Put a texture into this box, and the shader will be illuminated brightly. You can also set a texture with an alpha channel into SelfIlluminationMask, and the shader will use its alpha channel to determine how bright to render itself. White parts of the alpha channel will be completely bright and unaffected by shadows. Black parts of the alpha channel will be completely affected by in-game lighting and shadows. Try it out now. We have already made a texture that has a good alpha channel, our custom purple TAR-21 skin, so add that into both the SelfIllumination box and the SelfIlluminationMask box. If it worked, our TAR-21's outlines should be bright in-game, and the rest will be partially lit. Save your custom package and go in-game, into a dark map, to try it out! Don't forget to restore your backups of the R61stWeapons_SM.usx file so that you don't mess up your game installation!

I hope you have learned something about specular, opacity, and selfillumination in this tutorial! My next tutorial will hopefully be about making mods for a multiplayer server, and will include some info about how to get your new gun skins in-game without overwriting the game's default files or messing up your multiplayer game!

If you have any questions, I am always happy to help. You can usually find me to chat with on the AllR6 Discord channel, at R6Chat.com.