Since we’ve been on this topic for a bit about Skyboxes, Sky-portals…Found a decent tutorial that gives a basic overview on creating a Sky Shader. The Sky Shaders are the ones that you’ll see the clouds passing overhead or a bolt of lighting flashing. Here’s the information off the site along with the link to follow and download the files. I tested them and they work fine, even in wolf.
Offsite link -
http://planetquake.com/qworkshop3/tutorials/starfield/index.html
Example download link -
http://planetquake.com/qworkshop3/tutorials/starfield/starfield-shader.zip
The Beginning
First of all, i’ve put a new directory in the textures folder named starfield and created three simple, well quite poor, but hey they took me like 10 minutes to make :o) starlike looking jpg files.
Next creating a new shader script called starfield.shader and adding this to the shaderlist.txt file.
The start of the shader code looks like this :
textures/starfield/starfield-3p
{
qer_editorimage textures/starfield/starfield-00a.tga
surfaceparm nodlights
surfaceparm noimpact
The name of the texture is starfield-3p and it lives in the textures > starfield directory.
The image we will all see in Radient is starfield-00a.tga.
A surface parameter of nodlights implies this shader will not be affected by dynamic lighting.
A surface parameter of noimpact implies that no projectiles will strike the surface, etc.
Somewhere in the Middle
Now comes the scrolling bit :
{
map textures/starfield/starfield-00a.tga
// tcmod scroll <sSpeed><tSpeed>
tcmod scroll 1 0
}
Here we are using the starfield-00a.tga texture.
The tcmod scroll function allows us to scroll out texture around. In this instance right by 1 texture a second.
Almost the End
Thats the basic’s done. Simple eh ?
We can now add as many planes as God will allow, by copying the middle shader stage and adding an add function, just like this :
{
map textures/starfield/starfield-01a.tga
// tcmod scroll <sSpeed><tSpeed>
tcmod scroll 0.75 0
blendfunc add
}
First you will notice that we’re using a different texture, this time starfield-01a.tga, cos it would get boring with the same texture.
And also the tcmod scroll speed has been reduced to 0.75.
Not forgetting the blendfunc add, this is responsible for combining all of our starfield images. Because the blendfunc add ‘adds’ the images together, stars passing over each other will appear brighter than they actually are. This gives quite a neat effect in my opinion.
The Final Script
Looks like this for a starfield with 3 planes. I don’t think it’s necessary for more planes, but you can add more it u like.
//
// Moving Starfields by crashmeplease.
// crashmeplease@yahoo.co.uk
//
// This shader came from the Starfield Shader Tutorial from:
// Q-workshop3
// http://qw3.gamedesign.net
//
// A three pass starfield example
//
textures/starfield/starfield-3p
{
qer_editorimage textures/starfield/starfield-00a.tga
surfaceparm nodlights
surfaceparm noimpact
// first pass
{
map textures/starfield/starfield-00a.tga
// tcmod scroll <sSpeed><tSpeed>
tcmod scroll 1 0
}
// second pass
{
map textures/starfield/starfield-01a.tga
// tcmod scroll <sSpeed><tSpeed>
tcmod scroll 0.75 0
blendfunc add
}
// third pass
{
map textures/starfield/starfield-02a.tga
// tcmod scroll <sSpeed><tSpeed>
tcmod scroll 0.5 0
blendfunc add
}
}
Thats all there is to it. You can see that the first pass is the fastest, and the third pass the slowest. Why not play with the scrolling speeds yourself.
One other thing if your feeling brave is to add a little motion blur effect by stretching the texture out a little