mirror of
https://github.com/UberGames/GtkRadiant.git
synced 2024-12-19 08:51:34 +00:00
145 lines
10 KiB
HTML
145 lines
10 KiB
HTML
|
<html>
|
||
|
<head>
|
||
|
<title>Quake III Arena Shader Manual: Notes on Alpha Channels</title>
|
||
|
<link rel = "stylesheet" type = "text/css" href = "../styles/q3rad.css">
|
||
|
</head>
|
||
|
<body>
|
||
|
<h1 class = "MsoTitle">Q3Radiant Shader Manual</h1>
|
||
|
<hr>
|
||
|
<h1>7 Notes on Alpha Channels</h1>
|
||
|
To use some blend modes of alphaFunc, you must add an alpha channel to your texture files. Photoshop can do this.
|
||
|
Paintshop Pro has the ability to make an alpha channel but cannot work directly in to it. In Photoshop you want to set the type to Mask. Black has a value of 255. White has a value of 0. The darkness of a pixel's alpha value determines the
|
||
|
transparency of the corresponding RGB value in the game world. Darker = more transparent.
|
||
|
|
||
|
<p>Care must be taken when reworking textures with alpha channels. Textures without alpha channels are saved as 24 bit images while textures with alpha channels are saved as 32 bit. If you save them out as 24 bit, the alpha channel is erased. Note: Adobe Photoshop will prompt you to save as 32, 24 or 16 bit. Choose wisely. If you save a texture as 32 bit and you don't actually have anything in the alpha channel, Quake III Arena may still be forced to use a lower quality texture format (when in 16 bit rendering) than if you had saved it as 24 bit.
|
||
|
|
||
|
<p>To create a texture that has "open" areas, make those areas black in the alpha channel and make white the areas that are to be opaque. Using gray shades can create varying degrees of opacity/transparency.
|
||
|
|
||
|
<p align = "center"><strong>Example: An opaque texture with see-through holes knocked in it.</strong>
|
||
|
|
||
|
<p><pre class = "type">
|
||
|
textures/base_floor/pjgrate1
|
||
|
{
|
||
|
surfaceparm metalsteps
|
||
|
cull none
|
||
|
|
||
|
// A GRATE OR GRILL THAT CAN BE SEEN FROM BOTH SIDES
|
||
|
{
|
||
|
map textures/base_floor/pjgrate1.tga
|
||
|
blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
|
||
|
alphaFunc GT0
|
||
|
depthWrite
|
||
|
rgbGen identity
|
||
|
}
|
||
|
{
|
||
|
map $lightmap
|
||
|
rgbGen identity
|
||
|
blendFunc GL_DST_COLOR GL_ZERO
|
||
|
depthFunc equal
|
||
|
}
|
||
|
}
|
||
|
</pre>
|
||
|
|
||
|
<p>The alpha channel can also be used to merge a texture (including one that contains black) into another image so that the merged art appears to be and opaque decal on a solid surface (unaffected by the surface it appears to sit on), without actually using an alpha function. The following is a very simple example:
|
||
|
|
||
|
<p align = "center"><img src = "../q3ashader_manual_files/image002.jpg" width = "600" height = "200">
|
||
|
|
||
|
<br>Figure 1
|
||
|
|
||
|
<p>Start with a TGA file image. In this case, a pentagram on a plain white field (figure 1A). The color of the field surrrounding the image to be merged is not relevant to this process (although having a hard-edged break between the image to be isolated and the field makes the mask making process easier). Make an alpha channel. The area of the image to be merged with another image is masked off in white. The area to be masked out (notused) is pure black (figure 1B). The image to be merged into is greenfloor.tga (figure 1C).
|
||
|
|
||
|
<p>Make a <b>qer_editorimage</b> of greenfloor.tga. This is placed inthe frame buffer as the map image for the texture. By
|
||
|
using GL_SRC_ALPHA as the source part of the blend equation, the shader adds in only the non-black parts of the pentagram.
|
||
|
Using GL_MINUS_ONE_SRC_ALPHA, the shader inverts the pentagram's alpha channel and adds in only the non-black parts of the green floor.
|
||
|
|
||
|
<p>In a like manner, the alpha channel can be used to blend the textures more evenly. A simple experiment involves using a
|
||
|
linear gradiant in the alpha channel (white to black) and merging two textures so they appear to cross fade into each other.
|
||
|
|
||
|
<p>A more complicated experiment would be to take the pentagram in the first example and give it an aliased edge so that the pentagram appeared to fade or blend into the floor.
|
||
|
|
||
|
<h1><a name = "trouble">8 Troubleshooting Shaders</a></h1>
|
||
|
If a shader is not working, look first for syntax errors.
|
||
|
<ul><li>Are the brackets correctly set?
|
||
|
<li>Do you have too many parameter values on a line?
|
||
|
<li>Are you using a word in a parameter that wants a numerical value?
|
||
|
<li>Are you using a numerical value in a parameter that wants a word?
|
||
|
<li>Are the path names to your textures correct?
|
||
|
<li>Are your texture names correct? There is a chance that the texture name is too long or too complex. Try renaming a
|
||
|
texture with a shorter, simpler name.</ul>
|
||
|
|
||
|
<h1><a name = "newtex">9 Creating New Textures</a></h1>
|
||
|
If you are familiar with the required tools, creating new assets for use in Quake III Arena is not particularly difficult. As a general rule, you should create new directories for each map with names different from the names used by id. If you are making a map that will be called "H4x0r_D00M", every directory containing new assets for that map should be titled H4x0r_D00M. This is to try and avoid asset directories overwriting each other as the editor and the gameload in assets.
|
||
|
|
||
|
<h2><a name = "tools">9.1 Tools Needed</a></h2>
|
||
|
Any combination of graphic programs and plug-ins that canout put a 24 bit MS windows compatible Targa (.tga) or JPEG (.jpg) graphic file.If you plan to make textures that will have an alpha channel component (a 4<sup>th</sup> 8-bit greyscale channel that is used by the shaders to further manipulate the art), you must have a program that can create 32-bit art with that fourth channel.
|
||
|
|
||
|
<p>Adobe Photoshop has the ability to easily create alpha channels. PaintShop Pro from JASC (v5.0+) can also make an
|
||
|
alpha channel by creating a mask and naming it "alpha".
|
||
|
|
||
|
<p>Generally speaking, regardless of the program used, we found it best to do most of the art manipulation of the alpha channel in a separate layer or file and then paste it into the alpha channel before saving.
|
||
|
|
||
|
<h2><a name = "files">9.2 Setting up Files</a></h2>
|
||
|
The editor and the game program look for assets to be located along the paths set up in your project file. Start by creating
|
||
|
a directory for you new textures by creating file folders to make a directory path as follows:
|
||
|
|
||
|
<p><div class = "type">quake3\baseq3\textures\[mymapname]</div>
|
||
|
|
||
|
<p>The installation of Q3Radiant will create a text document called "shaderlist.txt" in the following path:
|
||
|
|
||
|
<p><div class = "type">quake3\baseq3\scripts\shaderlist.txt</div>
|
||
|
|
||
|
<p>Q3Radiant will use the contents of this script to grab your new textures for inclusion in the game. The contents of shaderlist.txt document will contain a listing of all the shader documents that were used by id Software to create Quake III Arena.
|
||
|
|
||
|
<p>Since you will obviously want to create your own shaders, you need to put them in separate folders and create a new shader script for them.
|
||
|
|
||
|
<p>If you plan to work on several maps at once and want to distinguish between textures used in each map, simply add additional map names here. For map and mod makers, we STRONGLY recommend that any new shader scripts created use the name of the map or mod in the shader file name. We know we can't avoid every incident of files overwriting each other, but we certainly can advise you how to try.
|
||
|
|
||
|
<p>Now, in the scripts directory that you just created, create another text file and call it:
|
||
|
|
||
|
<p><div class = "type">[mymapname].shader</div>
|
||
|
|
||
|
<p>This file will contain the shader scripts you write to modify a particular texture.
|
||
|
|
||
|
<h2><a name = "rng">9.3 Rules and Guidelines</a></h2>
|
||
|
<div class = "subheading">9.3.1 Rules</div>
|
||
|
Follow these rules when creating textures for the Quake III Arena engine:
|
||
|
|
||
|
<ul><li>Save your textures into your new [map name] directories.
|
||
|
<li>Don't use the same names that id used for textures. It will cause problems.
|
||
|
<li>For best quality, save textures without an alpha channel as 24 bit TARGA files. Using JPEG files can save memory space, but at the risk of losing detail and depth in the texture. JPEG files cannot be used for textures requiring an alpha channel.
|
||
|
<li>Textures containing an alpha channel must be saved as32 bit TARGA files.
|
||
|
<li>If a new texture requires no further manipulation, it does not need a shader script.
|
||
|
<li>Size textures in powers of 2. Example: 8x8, 16x16,32x32, 64x64 pixels and so on.
|
||
|
<li>Textures don't need to be square. A 32x256 pixel texture is perfectly acceptable.</ul>
|
||
|
|
||
|
<p><div class = "subheading">9.3.2 Guidelines</div>
|
||
|
The following are some things the id designers learned about textures.
|
||
|
|
||
|
<ul><li>Create textures in "suites" built around one or two large textures with a number of much smaller supporting detail or accent textures.
|
||
|
<li>Very large textures are possible, but some video cards compress textures larger than 256x256 pixels.
|
||
|
<li>Textures are grouped alphabetically by name in the texture display window, so you may want to give suites of textures
|
||
|
similar names.
|
||
|
<li>Use the shader function qe3_editorimage to conserve memory when making multiple versions of a single texture (as in the case of a glowing texture with several light values).
|
||
|
<li>Unless you are creating special effects or textures designed to draw the player's eye to a specific spot, muted, middle value colors work best with the game engine.
|
||
|
<li>Extremely busy (a lot of fussy detail) textures can break up or form visually unpleasant patterns when seen at distances.</ul>
|
||
|
|
||
|
<h2><a name = "pk3">9.4 Making the .pk3 File></a></h2>
|
||
|
When you go to distribute your creation to the gaming world, you need to put your newly created map, textures, bot area files, and shader documents into an archive format called a "pk3" file. You do not need to include the shaderlist.txt file, since that is only used by the editor. You will need to keep the paths to the various assets the same. So your paths should be something like this:
|
||
|
|
||
|
<p>Textures: <span class = "type">baseq3/textures/[mymapnamefolder]</span>
|
||
|
<br>Bsp & aas: <span class = "type">baseq3/maps/mymapname.bsp, mymapname.aas</span>
|
||
|
<br>Shader scripts: <span class = "type">baseq3/scripts/mymapname.shader</span>
|
||
|
|
||
|
<p>You need to use an archiving program call Winzip to make the pk3 file. Get Winzip from <a href=
|
||
|
"http://www.winzip.com/winzip/winzip.htm">http://www.winzip.com/winzip/winzip.htm</a>
|
||
|
|
||
|
<br>Make a zip archive called mymapname.zip
|
||
|
|
||
|
<br>Zip all the required assets into a zip archive file (Quake III Arena <i>DOES</i> support compressed pk3 files).
|
||
|
|
||
|
<br>Rename the zip archive to mymapname.pk3
|
||
|
|
||
|
<br>Put it where the Quake III Arena community can find it.
|
||
|
<p align = "center"><a href = "../ch05/pg5_1.htm">Back</a> | <a href = "../index.htm">Home</a> | Next
|
||
|
</body>
|
||
|
</html>
|