|
Ok,
just to set the scene, here's the original post
from RAWBEEFSKiN
Topic:
shit.......we're not in Manchester anymore sanji
!!
okay......i
just had a idea.....there was one thing i liked
about UT (that's unreal tournament...for those of
u that can't memorize hundreds of
abbreviations).....anyway the only thing i liked
about UT was that level in a little
spaceship.....i liked it because when u looked
out of the windows that texture with stars
zooming past made it really feel like you were
going some place.....and not stuck in
self-contained static arena....i think something
like that would be pretty nice for Q3 (if i need
to explain that you're in the wrong place).....I've
had a couple of attempts but my knowledge of
shaders n' stuff isn't that great........if any
ones bored, bored, understands what i mean or
bored and feels like having a go I'd be
interested to see what ya come up with.....
------------------
<simplicity precedes equanimity>
Well
as I was thinking to myself what a cool idea, I
started drooling uncontrollably. it's so easy to
add several 'planes' to a shader to give us an
effective vision of perspective.
Ok,
so you have no idea what im going on about. Think
of it like this, imagine a fast moving object
close to us, it wizzes past. Now think of the same
object traveling at the same speed but this time
further away from us, it's still traveling at the
same speed, and will move the same distance, but
it appears to move much slower.
Here's
a little pic of what we're all on about.

Catching
on yet ?
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.
Oh
and them images
|
starfield-00a.tga
|
starfield-01a.tga
|
starfield-02a.tga
|
|
|
|
|
|
This
is the image for the close up stars.
|
This
is the image for the in the middle
stars.
|
This
is the image for the farthest away
stars.
|
They're
a bit crap, but they serve their purpose well.
You'd be well advised to make you're own, lol
Download
here !
Rather than c'n'p you can download a zip
file that contains the images and the
shader.
Sign
Off
Gee I'm a nice guy today. If u have any questions
then mail me Crashmeplease.
|