| Shader
Example Files And Shaders
The following
is a list of shader examples aimed at those of you
who wish to create new effects using Quake II Evolved.
Contents
1) Making a shiny metal surface
2) Making a reflective window
3) Creating a normal mapped shader
Something not
here you would like to see? Request
an example!
Ok then, on with
the examples!
NOTE:
Before you start messing with these, check what version
of Quake II Evolved you have. These shaders have been
made using Quake II Evolved Version 0.46, and so using
them on older versions may provide visual errors or
shader warnings.
1)
Making AShiny Metal Surface
A common shader
used in games are metallic walls that give off a slight
reflection. This shader can also be manipulated so
that marble, glass and other none-transparent shiny
things can give off a slight reflection. Of course,
creating a real time reflection is overkill for our
generation of computers, and so all reflections are
a simple cube map. The results look good enough, however.
The shader:
First we will
make the shader. I will base this on the following
shader:
textures/texturedir/texturename
{
{
map textures/texturedir/texturename.tga
}
{
cubeMap env/cubemapname
tcGen reflection
blendfunc gl_one gl_one
}
{
map textures/texturedir/texturename.tga
blendFunc blend
}
{
map $lightmap
rgbGen identity
blendfunc gl_dst_color gl_zero
}
}
The first stage
is the metal base texture, this is obviously needed.
The second stage, is the cubemap reflection, this
will draw "over" the first stage, meaning
that it appears in front of the texture in-game. We
are using blendfunc gl_one gl_one here. The third
stage, is the metal texture again, only this time
we are loading the texture's alpha channel and displaying
that above the reflection. This gives the illusion
of depth, and also creates a much more interesting
effect than just a simple reflection on top. The final
stage is us blending the lightmap back over the top,
so that the texture is lit correctly.
Ok then, want
to check this effect out for yourself? Grab the following
file. It has all the textures needed, included the
.map and .bsp. To load the map, pull down the console
and type /map q2e_shader_1
Download
This File
Tips
And Tricks:
Its
always best to mess around with things. For example,
this shader loads the last layer as an alpha channel,
so try messing with different transparencies and such
to create more or less of a shine.
When
creating a cube map, its always best to know "where"
its going to go. For example, if your texture is going
to be outside next to rock with an open sky, its pointless
having a reflection that looks like something from
inside. A great way of creating the perfect cube map
is to create a series of "box maps" with
simple geometry inside them, but texture the decor
so that it looks like a certain place. Use "average
base1 textures" and there you go, you have a
nice map to take an envshot inside of. This means
that reflections are not of a specific area, but of
your average decor, and it will create a much more
nice effect in the long run. It also means that you
can save texture and memory space, by only loading
a certain cubemap for certain things.
Also
with cube maps, remember that detail is great, but
only if its "needed". For a window reflection,
sure, go for it, but on a wall? Is it REALLY needed?
Make the cubemap blury, make it less detailed, drop
the resolution down etc. It will create a slight reflection,
but it looks great.
2)
Making A Reflective Window
Another common
shader used a lot is reflective windows. This is very
much like making a reflective wall, only now we use
just two stages, and make the first transparent. Again,
we will use a cube map.
The shader:
First we will
make the shader. I will base this on the following
shader:
textures/texturedir/texturename
{
tesssize 8
{
map textures/texturedir/texturename.tga
blendFunc blend
}
{
cubeMap env/cubemapname
tcGen reflection
blendfunc gl_one gl_one
}
{
map $lightmap
rgbGen identity
blendfunc gl_dst_color gl_zero
}
}
The first stage
is the window texture, this is obviously needed. The
window texture is using blendFunc
blend, so that it draws transparent. The
second stage, is the cubemap reflection, this will
draw "over" the first stage, meaning that
it appears in front of the texture in-game. We are
using blendfunc gl_one gl_one here. The final stage
is us blending the lightmap back over the top, so
that the texture is lit correctly. You might also
notice "tesssize" in there. This will change
just how much the texture warps when you move past
it. A higher value means more tesselation, and so
a bigger hit on frame rate.
Ok then, want
to check this effect out for yourself? Grab the following
file. It has all the textures needed, included the
.map and .bsp. To load the map, pull down the console
and type /map q2e_shader_2
Download
This File
Tips
And Tricks:
Try
messing with different styles of cube maps. Again,
a blury image can sometimes look better than a sharp
one.
Always,
always remember where exactly this window will reflect.
Its great and all seeing that window in base1 reflect
your pod, but remember that its also in base3. Its
very hard to find a nice reflection that suits all
areas, at least when you are making shaders for stock
Quake 2 maps.
3)
Creating
A Normal Mapped Object
Quake II Evolved
has the ability to use normal mapped media, these
can be used for everything from interaction with lighting
(Such as Doom 3, for example) and even level effects
such as heat distortion or water. For this example,
we will concentrate on making a normal mapped object.
The shader:
First, lets make
our shader. The following is the shader we will use:
models/test_normal/test_skin
{
{
bumpmap models/test_normal/test_normal.tga
rgbGen identity
nextBundle combine
cubeMap $normalCube
tcGen lightVector
texEnvCombine
{
rgb = DOT3_RGB ( Cp , Ct )
}
}
{
map $white
blendFunc GL_ONE GL_ONE
rgbGen lightingAmbient
}
{
map models/test_normal/test_skin.tga
blendFunc GL_DST_COLOR GL_ZERO
rgbGen lightingDiffuse
}
}
Ok then. Download the test
model pk2 below, and go into base1, base2 or base3.
These are the 3 maps that I have included .lightgrid
files for. .lightgrid files contain advanced level
lighting information, and so these are the only maps
that have REAL lighting information. Information on
making lightgrid files can be found on the forums.
Ok, so you have the files, you loaded Q2E up in base1/2/3,
now what? Well, we are going to use the /testmodel
command to preview the model. Pull down the console,
and type: /testmodel models/test_normal/tris.md3
This will create the preview model in front
of your player. Want to test it out? Sure, just walk
around it, fire at it etc etc, notice how the angles
of lighting change? Try binding the command above
to a key, and pressing it at different places in the
map around lights. You will notice an even bigger
change. Please note that Normal mapping on models
is *STILL* work in progress, so its not perfect. But
you can really see the results. Try it yourself.
Download
This File
Tips
And Tricks:
You
can create lots of different effects with normal maps,
from refracted water reflections, to high detail cube
map reflections on models. There are so many different
ways to use them! Keep reading for more ways to find
out!
Want more fun? Try
this bind /bind l "testgun models/test_normal/tris.md3;wait;cl_testGunX
60;wait;cl_testGunY -25;wait;cl_testGunZ -24"
and walk around the level that way, with
the testmodel on your screen. You can notice it a
lot better this way!
|