Lights in Quake
Moderator: InsideQC Admins
6 posts
• Page 1 of 1
Lights in Quake
Hi guys, I'm creating a scratch quakec structure using the wonderful scracth tutorial but I completely don't understand how lights work in Quake. I'm using DarkPlaces engine. If I put the definition of the lights in a entities/lights.qc like the tutorial said:
And I added in the main.qc
and this
(in the right areas, of course!) and when I compile, the map I created in NetRadiant is displayed the same way.
With or without light quakec code.
I tried another test. I put inside my game folder a quake orginal bsp map and it's visualised the same with or without lights!
So my question is: who lights interact with? With the bsp geometry, with the entity (I didn't try with a monster or a ammo box) or both?
I discovered DP has in the orginal menu (that I force to showup using forceqmenu command) different light settings: flares, normal high and full.
If I switch to full, the map created with netradiant becomes dark and only rtlights work with the r_editlights command
Can please someone explain to me how lights work?
Thanks guys!
- Code: Select all
/*
+------+
|Lights|
+------+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+
| Scratch Http://www.admdev.com/scratch |
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+
| Spawns and handles Quake's lights and torches |
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+
*/
float START_OFF = 1; // Light on/off spawnflag
void() Light_setup; // Definition from Lights.qc
void() light = // Basic Light
{
Light_setup(); // Setup Light
};
void() light_fluoro = // Light with hum ambient
{
Light_setup(); // Setup Light
};
void() light_fluorospark = // Light with buzz ambient
{
Light_setup(); // Setup Light
};
void() light_globe = // Light with visible globe
{
Precache_Set("progs/s_light.spr"); // Set model
makestatic(self); // Static entity. Never changes.
};
void() light_torch_small_walltorch = // Light with visible wall torch
{
Precache_Set("progs/flame.mdl"); // Set model
makestatic(self); // Static entity. Never changes.
};
void() light_flame_small_yellow = // Light with small flame & fire sound
{
Precache_Set("progs/flame2.mdl"); // Set model
makestatic(self); // Static entity. Never changes.
};
void() light_flame_large_yellow = // Light with larger flame & fire sound
{
Precache_Set("progs/flame2.mdl"); // Set model
self.frame = 1; // Switch to second frame (large)
makestatic(self); // Static entity. Never changes.
};
void() light_flame_small_white = // Light with small flame & fire sound
{
Precache_Set("progs/flame2.mdl"); // Set model
makestatic(self); // Static entity. Never changes.
};
void() Light_setup = // Set light on or off, as per spawnflags
{
if (self.style < 32) {return;} // Dont switch other styles.
if (self.spawnflags & START_OFF)
lightstyle(self.style, "a"); // If light starts off, set it off.
else
lightstyle(self.style, "m"); // If light starts ON, turn in ON. Simple :)
};
void() LightStyles_setup =
{
// Setup light animation tables. 'a' is total darkness, 'z' is maxbright.
lightstyle(0,"m"); // Style 0: Normal
lightstyle(1,"mmnmmommommnonmmonqnmmo"); // Style 1: Flicker
// Style 2: Slow Strong
// Pulse
lightstyle(2,"abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba");
lightstyle(3,"mmmmmaaaaammmmmaaaaaabcdefgabcdefg"); // Style 3: Candle
lightstyle(4,"mamamamamama"); // Style 4: Fast Strobe
lightstyle(5,"jklmnopqrstuvwxyzyxwvutsrqponmlkj"); // Style 5: Gentle Pulse
lightstyle(6,"nmonqnmomnmomomno"); // Style 6: Flicker 2
lightstyle(7,"mmmaaaabcdefgmmmmaaaammmaamm"); // Style 7: Candle 2
// Style 8: Candle 3
lightstyle(8,"mmmaaammmaaammmabcdefaaaammmmabcdefmmmaaaa");
lightstyle(9,"aaaaaaaazzzzzzzz"); // Style 9: Slow Strobe
lightstyle(10,"mmamammmmammamamaaamammma"); // Style 10: Fluro
// Style 11: Slow Pulse
// (no black)
lightstyle(11,"abcdefghijklmnopqrrqponmlkjihgfedcba");
};
And I added in the main.qc
- Code: Select all
void() LightStyles_setup; // Entities/Lights.QC
and this
- Code: Select all
void() worldspawn = {precaches(); LightStyles_setup();};
(in the right areas, of course!) and when I compile, the map I created in NetRadiant is displayed the same way.
With or without light quakec code.
I tried another test. I put inside my game folder a quake orginal bsp map and it's visualised the same with or without lights!
So my question is: who lights interact with? With the bsp geometry, with the entity (I didn't try with a monster or a ammo box) or both?
I discovered DP has in the orginal menu (that I force to showup using forceqmenu command) different light settings: flares, normal high and full.
If I switch to full, the map created with netradiant becomes dark and only rtlights work with the r_editlights command
Can please someone explain to me how lights work?
Thanks guys!
Meadow Fun!! - my first commercial game, made with FTEQW game engine
- toneddu2000
- Posts: 1352
- Joined: Tue Feb 24, 2009 4:39 pm
- Location: Italy
Re: Lights in Quake
The lights are transmogrified into lightmaps by the map compiling tools.
The void () light etc. in the QC is for use in the map editor.
I don't think you can access the lights from QuakeC, but ISTR that you can modify the light styles. Drake has some code that modifies the map's light level at runtime by messing with lightstyles. RMQ uses it to darken the map during shambler lightning etc.
I'd like a good explanation of the entire light stuff by someone knowledgeable, as well.
The void () light etc. in the QC is for use in the map editor.
I don't think you can access the lights from QuakeC, but ISTR that you can modify the light styles. Drake has some code that modifies the map's light level at runtime by messing with lightstyles. RMQ uses it to darken the map during shambler lightning etc.
I'd like a good explanation of the entire light stuff by someone knowledgeable, as well.
-

goldenboy - Posts: 924
- Joined: Fri Sep 05, 2008 11:04 pm
- Location: Kiel
Re: Lights in Quake
a thing that I don't understand is that in r_shadow.c (I don't know if there's in stock quake too) there's hardcoded same names of lights (light,light_fluoro,light_fluorospark,etc.). So I presume all these types of lights are already present in quake engine.
Anyway I tried the code to make the light "flickering" but the light I put in NetRadiant remain steady. Instead lights present in original quake maps are correct (normal where normal, flickering where flickering) so it's probably some key I fail to put in NetRadiant. Curious thing is that if I add the key "lightstylee" in NetRadiant the map file is unreadable next time I open it!
Anyway I tried the code to make the light "flickering" but the light I put in NetRadiant remain steady. Instead lights present in original quake maps are correct (normal where normal, flickering where flickering) so it's probably some key I fail to put in NetRadiant. Curious thing is that if I add the key "lightstylee" in NetRadiant the map file is unreadable next time I open it!
Meadow Fun!! - my first commercial game, made with FTEQW game engine
- toneddu2000
- Posts: 1352
- Joined: Tue Feb 24, 2009 4:39 pm
- Location: Italy
Re: Lights in Quake
look at your qc the functions for lights have something like abababababbba or something like that. that determines how the lights act. make a test map and try each type of light out so you know how it looks ingame and in qc. that way you can get an idea of how to create custom lighting effects. like the specific flicker you may want.
-

ceriux - Posts: 2223
- Joined: Sat Sep 06, 2008 3:30 pm
- Location: Indiana, USA
Re: Lights in Quake
The key you need to use is "style" with a number. I think the numbers are in the QC.
-

goldenboy - Posts: 924
- Joined: Fri Sep 05, 2008 11:04 pm
- Location: Kiel
Re: Lights in Quake
Yes, thanks guys. I was aware of the "abababababa" convention for differentiate illumination. The problem is that I tried even with style key and for value 1 or or 3 but nothing.
Let me ask you this: if a light is "written" inside a bsp file from a map file, what is the best method to "debug" it?
1) Use a misc_model in the map and see if it has been lit
2) Put a monster in the map and see if it has been lit
Thanks again
Let me ask you this: if a light is "written" inside a bsp file from a map file, what is the best method to "debug" it?
1) Use a misc_model in the map and see if it has been lit
2) Put a monster in the map and see if it has been lit
Thanks again
Meadow Fun!! - my first commercial game, made with FTEQW game engine
- toneddu2000
- Posts: 1352
- Joined: Tue Feb 24, 2009 4:39 pm
- Location: Italy
6 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest