RScripts/Shaders Guide
In lieu of native support for shaders in Quake 2, shaders were added to the game through files called rscripts. They can be used in Paintball for your maps to add detail.
General Format
The general format of an rscript is as goes:
[script name]
{
[mesh directives]
{
[stage directives]
}
{
[stage directives]
}
{
[stage directives]
}
[...]
}
Note how there can be more than one block containing stage directives. If there are two blocks, that means there are two passes, and etcetera.
An example of an rscript is below.
pics/conback
{
safe
{
map pics/backtile_inv.tga
scale static 3 static 4
blendfunc blend
}
{
map pics/guntemp_flash.tga
blendfunc gl_one_minus_dst_color gl_zero
}
}
Format
The script name is the path to the texture for the rscript to be applied to.
You can put more than one script in one file for multiple textures.
Mesh Directives
The following directives can be used, with different ones separated by a new line.
| Directive | Usage |
|---|---|
subdivide <size> |
The engine will subdivide the surface into blocks with sides of a specific length. Using this right creates better water warp/turbulating effects. <size> is the length, as an integer and preferrably a power of two. |
vertexwarp <speed> <distance> <smoothness> |
The vertexes of the surface will warp in a wave-like fashion on the plane. <speed> is the speed of the warp as a floating-point number. <distance> is the maximum distance of the warp as a floating-point number. <smoothness> is the smoothness of the warp, as a floating point number between 0.001 and 1.0, where 1.0 is a rough wrap. |
safe |
The script will persist in memory even if the map changes. Not a good idea for your maps. |
Stage Directives
The following directives can be used, with different ones separated by a new line.
| Directive | Usage |
|---|---|
map <path> |
This texture will be rendered instead of the texture affected by the rscript. <path> is the path to the texture. |
scroll <xtype> <xspeed> <ytype> <yspeed> |
Scrolls the texture. <xtype> and <ytype> can be static,
sin, or cos. <xspeed> and <yspeed>
are floating-point numbers describing the speed of the scroll. |
scale <xtype> <xspeed> <ytype> <yspeed> |
Scales the texture. <xtype> and <ytype> can be static,
sine, or cos. <xspeed> and <yspeed>
are floating-point numbers describing the speed of the scale. |
blendfunc <src> <dest> |
A blend function can be applied to a surface. This can be used
to make the surface translucent. <src>
can be
GL_ZERO, GL_ONE,
GL_DST_COLOR, GL_ONE_MINUS_DST_COLOR
GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA,
GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA,
or GL_SRC_ALPHA_SATURATE.
<dest> can be
GL_ZERO, GL_ONE,
GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR
GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA,
GL_DST_ALPHA, or GL_ONE_MINUS_DST_ALPHA. |
alphashift <speed> <min> <max> |
This is to be used with blendfunc to control the opacity
of a surface. <speed> is the speed of the shift as floating-point
number. <min> and <max> are floating-point numbers. |
anim <delay> <texture1> <texture2> <texture3> [...] <textureN> end |
This causes the surface to animate. <delay> is the pause between images,
specified in milliseconds as a floating-point number. <texture1>, <texture2>,
and <texture3> all the way up to <textureN> are the frames,
specified as paths to the textures. An end must be placed
at the end of this directive. To make your scripts readable,
you can put the paths to the textures on new lines,
but don't forget end, which you should put on a new
line too. |
envmap |
The surface allows sphere-mapping on the surface. The surface will then have a reflective "shiny" effect, similar to what you find on glass or the surface of water, though don't mistake this as something you can use as a mirror. |
alphamask |
This allows the transparent and translucent portions of an image file that supports such to appear transparent in the game. |
Using in Your Map
Create the script and put it in your pball/scripts/
folder. The script will end in the .txt file extension and it can be named anything, as the names of the textures affected are in the rscript file itself.
Add the requiredfiles key to your worldspawn
entity in your map. For the value, put a path to the script (i.e.
scripts/scriptname.txt) using spaces
to separate different scripts. Your script will download
from the server if and only if you put it in requiredfiles (as of build 20). However, if the player already has the rscript and the rscript is not specified in requiredfiles, it will be applied regardless.
Don't forget: you need to use the texture that you put in the rscript file in your map somewhere.
Example Scripts
Flame
This is notably used in the map anubis. One of the textures has a script set to it to create an animating 2-dimensional flame. Using two overlapping perpendicular surfaces with the animated flame, a 3-dimensional flame can be simulated. _flametest is a test of this script.
textures/pball/flame1
{
{
map textures/sfx/flame/flame1_01.jpg
blendfunc GL_ONE GL_ONE
anim .03
textures/sfx/flame/flame1_01.jpg
textures/sfx/flame/flame1_02.jpg
textures/sfx/flame/flame1_03.jpg
textures/sfx/flame/flame1_04.jpg
textures/sfx/flame/flame1_05.jpg
textures/sfx/flame/flame1_06.jpg
textures/sfx/flame/flame1_07.jpg
textures/sfx/flame/flame1_08.jpg
textures/sfx/flame/flame1_09.jpg
textures/sfx/flame/flame1_10.jpg
textures/sfx/flame/flame1_11.jpg
textures/sfx/flame/flame1_12.jpg
textures/sfx/flame/flame1_13.jpg
textures/sfx/flame/flame1_14.jpg
textures/sfx/flame/flame1_15.jpg
textures/sfx/flame/flame1_16.jpg
end
}
}
textures/pball/flame1b
{
{
map textures/sfx/flame/flame1_02.jpg
blendfunc GL_ONE GL_ONE
anim .031
textures/sfx/flame/flame1_01.jpg
textures/sfx/flame/flame1_02.jpg
textures/sfx/flame/flame1_03.jpg
textures/sfx/flame/flame1_04.jpg
textures/sfx/flame/flame1_05.jpg
textures/sfx/flame/flame1_06.jpg
textures/sfx/flame/flame1_07.jpg
textures/sfx/flame/flame1_08.jpg
textures/sfx/flame/flame1_09.jpg
textures/sfx/flame/flame1_10.jpg
textures/sfx/flame/flame1_11.jpg
textures/sfx/flame/flame1_12.jpg
textures/sfx/flame/flame1_13.jpg
textures/sfx/flame/flame1_14.jpg
textures/sfx/flame/flame1_15.jpg
textures/sfx/flame/flame1_16.jpg
end
}
}
