fps.gif (3966 bytes)
Textures5

transparent.gif (893 bytes)FPSNews Up

Up
Texture1
Textures2
Textures3
Textures4
Textures5
Textures6
Starfeild Shader

Qworkshop3 Tutorials

Custom Textures 5, Metal
This is the last custom textures tutorial. The focus has already drifted from textures to shaders so my next tutorial will be all about shaders. Making reflective metal is mostly texture/image work though.

Layout of a shader

A shader can be divided in to two major parts. Surface properties and 'stages'. I use the word properties here though I have not seen it used anywhere else. In my definition, the surface properties include all 'surfaceparm' and 'q3map_' keywords, as well as a few others like 'cull'. In short, all keywords that are not stage specific. The compiler uses this part of the shader, so if the shader is edited, the map must be recompiled for the changes to take effect.

A 'stage' is something that happens once per frame, and with the stage specific keywords the designer can control how the surface is rendered. A shader can have plenty of stages, but every stage means an extra rendering phase before the frame can be displayed, and thus affect the frame rate. The stages are loaded with the texture and used in real-time, so all that is required to see the effect of changes is to do a 'vid_restart' from the console. Most of the stage keywords affect how and what is sent to the frame buffer, more on that later in the next tut.

Metal Shader

I'm sure you have seen the reflective metal textures in some q3a levels. I'm also sure you have wondered what on earth the little screenshots in textures/effects are for. Well, these screenshots are what is being reflected in the reflective surfaces. Unlike mirrors that (actually mirror the world), most shiny appearing surfaces in q3a are made with shaders similar to the one below. A special texture, usually tinfx.tga is stretched way out, and then alpha blended with a second texture.

___________________________________

textures/papas_stuff/dark_metal
{
qer_editorimage textures/papas_stuff/dark.tga
{
map textures/ papas_stuff/lscape.tga
tcGen environment
rgbGen identity
}
{
map textures/papas_stuff/dark.tga
blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
rgbGen identity
}
{
map $lightmap
blendFunc GL_DST_COLOR GL_ONE_MINUS_DST_ALPHA
rgbGen identity
}
}
___________________________________

This shader has three stages. The first maps lscape.tga to the environment. This makes it behave like a farbox in a sky shader. It is stretched out and centered on the player. This is where the images in the effects folder usually go. Like tinfx.tga in the zinc_shiny shader.

The second stage loads the texture dark.tga and blends it with the one already in the frame buffer. This blend function uses the alpha channel of dark.tga, so with the alpha channel we can control how reflective different parts of the texture should be. This blend func is written as an explicit blendfunc, but actually it is the same as we used for the grates, i.e. 'blend'.

The last stage loads the light map and does an explicit blend with the background. In this case I believe the blend func applies the lightmap to the same degree that the texture was applied in the previous stage. This means that the parts of the surface that are reflective will not be lightmapped. The func retrives the alpha channel from the image in the frame buffer and applies the lightmap with this as a template.

Now, this is the rgb channel of dark.tga used in the script above. It doesn't look much like metal, but the contrast has been slightly exaggerated. Most of this image will not be seen. It will be seen in the editor though, put there by the qer_editorimage keyword.
This is the alpha channel of dark.tga. It has two levels of reflective ness, two shades of gray. If we were to make it darker, more of the rgb channel would be seen.
This is lscape.tga. The 24-bit image used for reflections in the script. This would be suitable for outdoor use. You can use what ever suits. Id uses the images in the texture/effects folder. Tinfx, tinfx2 etc.

So, that's all for now. You can download these textures and the script here. Its not a pk3 file. I figured you know what to do with the files by now. Don't forget to add the script name to shaders txt if you want to use it in Q3radiant.

Papa Bongo

 

 

Hit Counter

 

Bill Brooks © 1999
email contact: Bill Brooks