Login x
User Name:
Password:
Social Links Facebook Twitter YouTube Steam RSS News Feeds

Members Online

»
0 Active | 82 Guests
Online:

LATEST FORUM THREADS

»
CoD: Battle Royale
CoD+UO Map + Mod Releases
Damaged .pk3's
CoD Mapping
heli to attack ai
CoD4 SP Mapping

Tutorials

»
CoDUO Mapping
ratings:
Awful Rating
Poor Rating
Average Rating
Good Rating
Excellent Rating
Custom Glass Textures - Making Them
Versions: You must be logged in to view history.
A tutorial on the making of custom glass textures for Call of Duty and Call of Duty : United Offensive....(Yes...GLASS textures)
Everybody wants glass textures! No-one is having any luck.

I am going to open the flood gate, and show you how to make custom tinted glass textures that you can see through and shoot through

The first thing I am going to do is dispell the myth that textures need to be in .dds format. There are situations where a texture needs an alpha channel (like a chain link fence that you want to shoot through) - and that is when a .dds texture comes in handy.

Custom textures can be in .dds, .tga (24 bit Targa), or .jpeg.

The big confusion over the shaders is the .stype extension. The .stype extension stands for "sorted type" and is great for quickly adding custom textures. You simply add the "glass@" to the beginning of your texture name and your texture will now respond like glass. The list of existing .stype textures can be found in Shoot's tutorial here


A texture could have a .shader file associated with it instead of a sorted type. Note that I said "instead of" - a single texture CANNOT have both a sorted type shader (.stype) and a Q3A type of shader (.shader)


About Shaders


Call of Duty and Call of Duty : United Offensive come with files called brad.shader, common.shader, etcetera. You might not notice them, because they are hidden inside that huge pak4.pk3 file. Of course, we all know that a .pk3 file is just a zip file with another file name extension. If you rename it to pak4.zip (or associate the .pk3 extension with the WinZip program), you’ll be able to open it up with WinZip. Look in the directory called ‘scripts’.

These files are actually scripts that define how a material should be constructed by layering a number of textures and applying various effects. It tells the graphics pipeline what to do if it encounters a triangle of that material. The scripts are written in a very simple language specific to defining shaders. The scripts are parsed by the engine on start-up and stored as an internal data structure. The graphics engine selects the data structure corresponding to the material of the triangles it’s about to render and that data structure drives the processing that is done to those triangles. For some materials a single texture pass is sufficient, some materials may require eight passes and lots of effects.

Not all surfaces need to be have a shader defined for it. By default, surfaces of models are rendered using a single texture and surfaces of the map are rendered using a single colour texture plus a lightmap texture.

Let’s have a look at a portion of one of those shader files.


textures/battleship2a/shipdoor2a_trans
{
qer_editorimage textures/editorimages/clearwindow1a.tga
surfaceparm metal
surfaceparm trans
{
map textures/sfx/environmap_1day.jpg
tcGen environment
rgbGen exactVertex
alphaGen const .25
blendFunc blend
}
{
map textures/battleship/shipdoor2a_trans
blendFunc blend
rgbGen exactVertex
nextbundle
map $lightmap
}
{
perlight
map textures/battleship/shipdoor2a_trans.tga
rgbGen exactVertex
blendFunc GL_SRC_ALPHA GL_ONE
nextbundle
map $dlight
}
}



This is only one block in the file, some of the files contain lots of these blocks, some only contain one. In other words, a single shader file can define one or more shaders.

The first line gives the shader name. Each shader has to have a unique name. In this case the name is “textures/battleship2a/shipdoor2a_trans”, but a name like “foobar” is fine too. You will notice that the name in this case looks like a file path, and that’s no coincidence. A lot of the shaders have names that correspond to the file path of a texture image file. Model files provide a material name for surfaces. If these are matched by a shader name, then that shader will be used. Otherwise the CoD engine will look for a JPG or a TGA file matching that name and use that. If these aren’t found either, your level designer or model builder goofed. You’ll see warnings in the console and the surface will look weird.

Let’s further pick apart this shader script. After the name comes a block within curly brackets, this is the definition of the shader. After the block, you can define another shader, e.g.

Name1
{
shader 1
}

Name2
{
shader 2
}

The block starts with some general keywords, then come one or more sub-blocks delimited by curly brackets. Each of those corresponds to a shader stage. These are applied in order. Each stage typically refers to a different texture file. You can compare stages with the concept of layers in PhotoShop.

In a simple implementation each of the stages corresponds to a render pass over the geometry. A clever implementation will try to combine multiple stages into one multi-texture pass.

The script structure is therefore:

Name1
{
top-level settings
{
stage 1
}
{
stage 2
}
{
stage 3
}
}

Lines at either the top level or the stage level start with a keyword and have some parameters following on.

I am not going to go in depth about Q3A shaders, as explaining it all would take far too long. I will however give you this link which will take you to the most recent version of the Q3A Shader Manual. Keep in mind that while CoD and CoD:UO are based on the Q3A engine, there are some differences in the shaders syntax that will become apparant as you delve deeper into this.



Creating Your First Shader


There are several ways that you can create text only files. You need them for your gsc's, .efx files, and .shader files, as well as many others. Notepad and wordpad are common, and you can use them. I use edit plus for all of my editing.


Now, you may ask why am I making a .shader first? Because it is the hardest.


You need to start by naming your shader:


textures/stryder/glass/blueglass
{


Now, we are going to define what texture the shader is going to reference in the editor (basically what will our texture look like in Radiant or Gradiant):


qer_editorimage textures/stryder/glass/blueglass.tga

 Notice how this time we added the file extension

We can also alter the way that our texture will look in radiant...we are going to make our texture somewhat transparant:


qer_trans .5


We are also going to define a couple of surface paramaters (these are like defining the .stype shader):

surfaceparm glass
surfaceparm trans
{


Now we are going to define how the engine will render the texture....I am not going to explain too much in here, as you can read the Q3A shader manual to see what each line does and how it can affect your world. I will stop and show you one thing halfway through though:

map textures/stryder/glass/blueglass.tga
tcGen environment
rgbGen exactVertex
alphaGen const .5

OK...stopping there for a second. The alphaGen const value is what will set the INGAME transparancy of your image. Keep in mind that the value is normalized, so a value of 1.0 is the highest it can go - and a value of 1 will make your image look basically the same as you drew it in PhotoShop.

If you want your texture more transparant, lower the value.

Let's finish off our shader:


blendFunc blend
}
}


So, all completed - our shader should look like this:

textures/stryder/glass/blueglass
{
qer_editorimage textures/stryder/glass/blueglass.tga
qer_trans .5
surfaceparm glass
surfaceparm trans
{
map textures/stryder/glass/blueglass.tga
tcGen environment
rgbGen exactVertex
alphaGen const .5
blendFunc blend
}
}

Create a folder /main/scripts/ and save yourname.shader to there (mine is called stryder.shader)


Create the Image


The hardest part is over. Open photoshop and create a new image. For my example I am using a 512x512 image, but your textures you create can be any size that is a power of 2.

We are making blueglass, so simply select a blue color and turn the transparancy down to about 16 %. Color in the image, and if you dont like the looks of it you can give it more passes until it is how you waht it to look.

Click file --> save as -->
Now you need to make the directory that we referenced in the .shader file.
All textures go into the main folder textures, so we need to create this path (yours may differ from mine, as I used my name):

/main/textures/stryder/glass/blueglass.tga

When you save it as a .tga form PhotoShop - it gives you the option for export quality....24-bit is what you select

That is it....easy, huh?

StrYdeR
 

Latest Syndicated News

»
Codutility.com up and runn...
Nice, and there still using the logo and template for the screenshots, which...
Codutility.com up and runn...
dundy writes...Quote:Call of Duty modding and mapping is barly alive only a ...
Codutility.com up and runn...
Mystic writes...Quote:It seems to me the like the site is completely dead? ...
Codutility.com up and runn...
It seems to me the like the site is completely dead?

Partners & Friends

»