Colors that don't fade.

Started by
7 comments, last by griffenjam 22 years, 3 months ago
I''m writing a simple game (no textures) in which you are in an arena. There is a kind of maze in the arena. The problems is that I am making all the walls the same color, but I can''t tell one wall from another, is there a way to fade the color based on distance? Jason Mickela ICQ : 873518 E-Mail: jmickela@sbcglobal.net -Making "alot" a real word one paragraph at a time.-
-Can''t sleep, clown''ll eat me, can''t sleep, clown''ll eat me.
"The paths of glory lead but to the grave." - Thomas GrayMy Stupid BlogMy Online Photo Gallery
Advertisement
You could use lighting. Otherwise, using textures isn''t really difficult. Have a look at NeHe''s tutorials.
I know how to use textures.
I''ve done 2D stuff in OpenGL, just not 3D.
The biggest problem is that my test machine (the one here at work) has a crappy onboard video card. This computer has no hardware support at all. So I kinda wanted to stay away from lighting and textures.

Jason Mickela
ICQ : 873518
E-Mail: jmickela@sbcglobal.net
-Making "alot" a real word one paragraph at a time.-


-Can''t sleep, clown''ll eat me, can''t sleep, clown''ll eat me.
"The paths of glory lead but to the grave." - Thomas GrayMy Stupid BlogMy Online Photo Gallery
The only way to do this is ti simulate... Test the distance of the player position away from the wall and give the walls different shades....
Use the opengl fog.
I coud send you my el junko software lighting code, but you would have to rewrite it for your code.
Kinda fast, I think, though.
~V'lionBugle4d
What is fast on an accellerated card isn''t always fast in software mode. My particle engine runs at a decent speed in hardware mode (80fps - with about 3500 particles on screen), but in software I get about 8fps.

Jason Mickela
ICQ : 873518
E-Mail: jmickela@sbcglobal.net
-Making "alot" a real word one paragraph at a time.-


-Can''t sleep, clown''ll eat me, can''t sleep, clown''ll eat me.
"The paths of glory lead but to the grave." - Thomas GrayMy Stupid BlogMy Online Photo Gallery
I'm guessing here, but is the arena composed of walls entirely at right angles? If it is, then just make the walls different colors, like so:

             dark               |               v             _____            |     | medium-->  |     | <--medium            |_____|               ^               |             bright 


Also, for more advanced lighting, all you need to do is precalculate the vertex colors. You can use flat shading!

Edited by - TerranFury on January 10, 2002 6:47:51 PM
use glColor3f();

Lets say you have the colours r,g,b.

Lets say each vertex (or wall centre depending on how you wrote it) is located by something like x,y,z.

Now you have your players location Px,Py,Pz.

Make a variable (a float) called DIST.

All you have to do is
DIST=1.0f/((Px-x)*(Px-x)+(Py-y)*(Py-y)+(Pz-z)*(Pz-z));
You would do this for each vertex. This gives the 1/distance^2 to the object, bascially a really good factor to get lighting to fade faster the further it gets from the player.

Now instead of calling
glColor3f(r,g,b);

glColor3f(r*DIST,g*DIST,b*DIST);

and it will divide it by the ratio and make it get darker (closer to 0) the further it gets from the player. If it gets dark to fast or slow, change the 1.0f/ to 0.5f/ (to make it get darker faster) or 40.0f/ (to make it get darker slower).

If anyone sees a mistake in the above stuff, point it out, I'm half a sleep at the moment.


Beer - the love catalyst
good ol' homepage

Edited by - Dredge-Master on January 12, 2002 11:20:57 AM
Beer - the love catalystgood ol' homepage
u can do lighting yourself in software this''ll be quicker on all software t+l cards (even my vanta) than letting opengl do it.
and pass in the values per vertice as glColor3ub(..)

btw quake3 + most games do it this way, check out the red book for the opengl lighting equation

This topic is closed to new replies.

Advertisement