Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (534)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Max number of lights in GL  (Read 2145 times)
0 Members and 1 Guest are viewing this topic.
Offline erikd

JGO Ninja


Medals: 16
Projects: 4
Exp: 14 years


Maximumisness


« Posted 2003-03-02 14:46:59 »

Is it really impossible to have more than 8 ligths in open GL? It seems such a restriction...  :-/

Erik

Offline gregorypierce

Senior Member




I come upon thee like the blue screen of death....


« Reply #1 - Posted 2003-03-02 15:03:18 »

If you need so many lights in order to achieve an effect - you probably want to start looking into shaders. In reality most games don't use many lights and instead, even to this day, fake lighting through various texture tricks.

http://www.gregorypierce.com

She builds, she builds oh man
When she links, she links I go crazy
Cause she looks like good code but she's really a hack
I think I'll run upstairs and grab a snack!
Offline erikd

JGO Ninja


Medals: 16
Projects: 4
Exp: 14 years


Maximumisness


« Reply #2 - Posted 2003-03-02 15:45:14 »

Thanks for your reply  Smiley.
Excuse my ignorance, but what's a shader?

For example in Unreal, some weapons's bullets are all lighting up. And I made some classes for Unreal once for effects like rain where each raindrop lights up, and 'light fountains'. Looked really cool and really looked like light.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline princec

JGO Kernel


Medals: 342
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #3 - Posted 2003-03-02 16:19:04 »

Nearly all the current crop of 3D FPS games use a lighting hack which is to project a coloured spotlight texture onto all the surfaces in range, and attenuate it according to distance by tweaking the alpha. The surface normal is not usually taken into account for these lights but you could try a hack and see what it looks like. The end result isn't really lighting but it looks very pretty and it works on everything from a Voodoo1 and upwards.

If you draw all the lighting in your scene in a series of first passes using GL.ONE, GL.ONE, and then draw a single texturing pass using GL.DST_COLOR, GL.SRC_COLOR to blend them on top, you'll get pretty much the effect of as many coloured lightsources as you want, at the expense of a lot of fill-rate. Sadly there isn't really a great way to use multitexture for this.

The other alternative as Gregory suggests is to use a shader, which is a little machine-code style programming language available in OpenGL1.4 and on the very latest graphics cards - which means maybe about 1 in a 100 people will be able to see what you've done. For about the next 4-5 years or so. The number of lights you can incorporate in a shader is limited to 8 generally and may be less depending on the implementation but it'll draw the whole surface with 8 lights and a texture (plus any other fancy stuff like bump mapping etc) in a single pass.

Cas Smiley

Offline cfmdobbie

Senior Member


Medals: 1


Who, me?


« Reply #4 - Posted 2003-03-02 21:09:18 »

However, if you *really do* want to use OpenGL's lighting system but still need more than eight, there was a trick that one of the SGI demos pulled where they had a large number of "virtual" lights (data about lights in a big array I guess), and at run time they calculated which the eight closest were and set them up to be the OpenGL lights.  Bit of a cheat, but it works! Grin

Naturally this will only work if your lights have a limited range of effect, you don't have an obscene number of them,  and they're quite well spaced out.  Quite limited, but if you fall in that camp it may be easier than the usual texture hacks. Wink

Hellomynameis Charlie Dobbie.
Offline aldacron

Senior Member


Medals: 9
Exp: 16 years


Java games rock!


« Reply #5 - Posted 2003-03-03 03:28:17 »

Also, the 8 light limit does not apply to the entire scene, but rather to each glBegin, glEnd pair. Furthermore, 8 is only the minimum number that implementations are required to provide for. In reality, an implementation may allow a higher number of lights. I've never checked the caps on the NVidia, ATI or other drivers though, so I have no hard numbers on this.
Offline gregorypierce

Senior Member




I come upon thee like the blue screen of death....


« Reply #6 - Posted 2003-03-03 17:49:28 »

Here is an article I grabbed from Flipcode which talks about lightmapping. Once you read through what's really being done you will say "OH! Wait that's cheesy", and it is ... but it works surprisingly well. In fact it works well enough that unless you're trying to do Doom3 style lighting, it looks more than sufficient.

Remember, large numbers of lights is slow and usually wasteful... especially when you can achieve the effect by either precomputing lighting at the vertex level (something done in Morrowind) or using lightmapping.

http://www.gregorypierce.com

She builds, she builds oh man
When she links, she links I go crazy
Cause she looks like good code but she's really a hack
I think I'll run upstairs and grab a snack!
Offline gregorypierce

Senior Member




I come upon thee like the blue screen of death....


« Reply #7 - Posted 2003-03-04 01:21:04 »

http://www.flipcode.com/tutorials/tut_advlightmaps.shtml

Guess having a link would help  Grin

http://www.gregorypierce.com

She builds, she builds oh man
When she links, she links I go crazy
Cause she looks like good code but she's really a hack
I think I'll run upstairs and grab a snack!
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

pw (35 views)
2014-07-24 01:59:36

Riven (33 views)
2014-07-23 21:16:32

Riven (21 views)
2014-07-23 21:07:15

Riven (24 views)
2014-07-23 20:56:16

ctomni231 (55 views)
2014-07-18 06:55:21

Zero Volt (47 views)
2014-07-17 23:47:54

danieldean (38 views)
2014-07-17 23:41:23

MustardPeter (43 views)
2014-07-16 23:30:00

Cero (59 views)
2014-07-16 00:42:17

Riven (56 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!