• ### Announcements

#### Archived

This topic is now archived and is closed to further replies.

## Recommended Posts

griffenjam    193
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.

##### Share on other sites
You could use lighting. Otherwise, using textures isn''t really difficult. Have a look at NeHe''s tutorials.

##### Share on other sites
griffenjam    193
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.

##### Share on other sites
ANSI2000    122
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....

##### Share on other sites
Vlion    151
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.

##### Share on other sites
griffenjam    193
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.

##### Share on other sites
TerranFury    142
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

##### Share on other sites
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.

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