[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4787: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4789: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4790: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4791: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
InsideQC Forums • View topic - Help fixing Q3's dynamic lights

Help fixing Q3's dynamic lights

Discuss programming topics for the various GPL'd game engine sources.

Moderator: InsideQC Admins

Help fixing Q3's dynamic lights

Postby Revanic45 » Thu Feb 16, 2012 3:47 am

Wrote this before on some other forum, but it turns out to not be very active at all which I overlooked >_>

I have recently set out to fix quake 3's dynamic lighting. I have found a way to get dynamic lights to be properly additive. Which is done by a small and easy hack. Though it does break some multiplicative shader stages against lightmaps very slightly, they simply won't get lit right by the dlights.
I've had theories on how to fix that, but haven't really tried.

The main problem is getting these dynamic lights to orientate properly on walls and slopes...

This altered code seems to be heading in the right direction, but it does not work proberly.

texCoords[0] = 0.5f + (dist[0]*scale) - (normal[0]*(dist[2]*scale - dist[0]*scale));
texCoords[1] = 0.5f + (dist[1]*scale) - (normal[1]*(dist[2]*scale - dist[1]*scale));

It gives some mixed results... the dynamic lights appear on some walls correctly whilist sliding up some other walls depending on how far away it is, slopes end up being pretty weird... If anyone would like to help me that would be great!

Image
Image
Revanic45
 
Posts: 7
Joined: Sun Nov 21, 2010 1:41 am

Re: Help fixing Q3's dynamic lights

Postby Vic » Wed Mar 07, 2012 10:49 pm

What you're trying to accomplish isn't quite possible without using a 3D texture for the lighting attenuation. You might look up qfusion/warsow source code to see how it's done there.
User avatar
Vic
 
Posts: 21
Joined: Sun Nov 07, 2010 12:42 am

Re: Help fixing Q3's dynamic lights

Postby mh » Thu Mar 08, 2012 12:13 am

You can use a 2D texture and a 1D texture in two texture units to get the same effect as a 3D texture, with the obvious tradeoff being that it needs two texture units. That's not a big deal unless you really need to run on Voodoo 1 generation hardware.

Here's a fully realtime lit Grisly Grotto using that method:

Image

Rubbish performance and note the rendering glitches - I wrote that code in about 2003/2004 and never finished it.
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Re: Help fixing Q3's dynamic lights

Postby Vic » Thu Mar 08, 2012 10:11 am

True, but I wouldn't bother with double-pass dynamic lights, really.
User avatar
Vic
 
Posts: 21
Joined: Sun Nov 07, 2010 12:42 am

Re: Help fixing Q3's dynamic lights

Postby Revanic45 » Thu Mar 08, 2012 3:50 pm

I am fairly sure it's possible, Elite force 2 and Jedi Academy had this fixed. I think it's a matter of orientating it onto each individual plane. I just don't really know how to do that here. though if it's really not possible I guess I will look into a 3d texture.
Revanic45
 
Posts: 7
Joined: Sun Nov 21, 2010 1:41 am

Re: Help fixing Q3's dynamic lights

Postby Vic » Fri Mar 09, 2012 10:24 am

No, it's not possible.
User avatar
Vic
 
Posts: 21
Joined: Sun Nov 07, 2010 12:42 am

Re: Help fixing Q3's dynamic lights

Postby Revanic45 » Fri Mar 09, 2012 7:35 pm

I don't see how its not possible, the dynamic light is just a projected texture that uses texture coords. In this case those coords are being created in a way that only aligns it properly in either the X, Y, or Z axis. I'm sure theres a way to align it on all 3. Warsow also allows you to turn off 3d texturing and the dynamic lights, whilst they look a little different, they are still aligned.
There is probably a different way I need to handle the texcoords than what I'm doing now, but I know its possible. Jedi academy and elite force 2 did NOT use 3d textures. In fact, jedi academy's dynamic light texture was external and easily editable, which I have done for fun before.
Revanic45
 
Posts: 7
Joined: Sun Nov 21, 2010 1:41 am

Re: Help fixing Q3's dynamic lights

Postby mh » Fri Mar 09, 2012 11:23 pm

Stop thinking about how to do this on the CPU. The GPU is much better at this kind of thing and does it so much faster and easier. Not everything is software. You use the vertex positions as your texcoords. Translate the texture matrix to the light origin and scale it according to the light radius. Set your texture wrap mode to clamp, use either a 3D texture or a combination of a 2D and 1D texture in 2 texture units; whichever you pick you encode the light falloff into the texture. Or use a shader and you don't even need to bother with textures. Modulate by light colour. Initial light pass in replace mode, subsequent passes over the same surfaces in add mode (or do a prepass clearing everything to black then all light passes in add mode) (for Quake 3 dlights you draw lightmap in pass 1 then add dlights in subsequent passes). Life gets a lot easier if you use a 64-bit or floating point render target instead of the framebuffer, but there is a performance hit. Of course it's possible - this is completely standard attenuation map stuff, it was old 10 years ago.
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am


Return to Engine Programming

Who is online

Users browsing this forum: No registered users and 2 guests