How can I add overbright lighting to Quake engine?
Moderator: InsideQC Admins
29 posts
• Page 2 of 2 • 1, 2
thanks mh
by the way, i'm pimping mhquake on my moddb site, and i also uploaded the version of bengtquake with overbrights you gave me. hope you don't mind
by the way, i'm pimping mhquake on my moddb site, and i also uploaded the version of bengtquake with overbrights you gave me. hope you don't mind
- hondobondo
- Posts: 207
- Joined: Tue Sep 26, 2006 2:48 am
gonna get this working
thanks guys for all your help so far.
ok here's what i did
R_BuildLightMaps
changed this
to this
R_BlendLightMaps
changed this
to this
in R_DrawSequentialPoly. No shifts as far as i can tell
did this in gl_rmain, and gl_rsurf:
Find this:
Code:
and replace it with this:
Code:
and added this to the end of every function where i did the above ^ replacement
just as dark as ever
here is mh's bengtglob.exe
any ideas?
ok here's what i did
R_BuildLightMaps
changed this
- Code: Select all
case GL_RGBA:
stride -= (smax<<2);
bl = blocklights;
// CDL - epca@powerup.com.au
blcr = blocklightcolors[0];
blcg = blocklightcolors[1];
blcb = blocklightcolors[2];
// CDL
for (i=0 ; i<tmax ; i++, dest += stride)
{
for (j=0 ; j<smax ; j++)
{
// CDL - epca@powerup.com.au
q = *blcr++; q >>= 7;
if (q > 255) q = 255;
r = *blcg++; r >>= 7;
if (r > 255) r = 255;
s = *blcb++; s >>= 7;
if (s > 255) s = 255;
dest[0] = 255-q;
dest[1] = 255-r;
dest[2] = 255-s;
// CDL
t = *bl++;
t >>= 7;
if (t > 255)
t = 255;
// epca@powerup.com.au
// Fix bug in quake where this mode is just fullbright
//dest[0] = dest[1] = dest[2] = 255-t;
// End of fix
dest[3] = 255-t;
dest += 4;
}
}
break;
to this
- Code: Select all
case GL_RGBA:
stride -= (smax<<2);
bl = blocklights;
// CDL - epca@powerup.com.au
blcr = blocklightcolors[0];
blcg = blocklightcolors[1];
blcb = blocklightcolors[2];
// CDL
for (i=0 ; i<tmax ; i++, dest += stride)
{
for (j=0 ; j<smax ; j++)
{
// CDL - epca@powerup.com.au
q = *blcr++; q >>= 8;
if (q > 255) q = 255;
r = *blcg++; r >>= 8;
if (r > 255) r = 255;
s = *blcb++; s >>= 8;
if (s > 255) s = 255;
dest[0] = 255-q;
dest[1] = 255-r;
dest[2] = 255-s;
// CDL
t = *bl++;
t >>= 8;
if (t > 255)
t = 255;
// epca@powerup.com.au
// Fix bug in quake where this mode is just fullbright
//dest[0] = dest[1] = dest[2] = 255-t;
// End of fix
dest[3] = 255-t;
dest += 4;
}
}
break;
R_BlendLightMaps
changed this
- Code: Select all
if (gl_lightmap_format == GL_LUMINANCE)
glBlendFunc (GL_ZERO, GL_ONE_MINUS_SRC_COLOR);
else if (gl_lightmap_format == GL_INTENSITY || gl_lightmap_format == GL_RGBA)
{
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glColor4f (0,0,0,1);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
...
glDisable (GL_BLEND);
if (gl_lightmap_format == GL_LUMINANCE || gl_lightmap_format == GL_RGBA)
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
else if (gl_lightmap_format == GL_INTENSITY)
{
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glColor4f (1,1,1,1);
}
to this
- Code: Select all
if (gl_lightmap_format == GL_LUMINANCE)
glBlendFunc (GL_ZERO, GL_ONE_MINUS_SRC_COLOR);
else if (gl_lightmap_format == GL_INTENSITY || gl_lightmap_format == GL_RGBA)
{
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glColor4f (0,0,0,1);
glBlendFunc (GL_DST_COLOR, GL_SRC_COLOR);
}
...
glDisable (GL_BLEND);
if (gl_lightmap_format == GL_LUMINANCE || gl_lightmap_format == GL_RGBA)
glBlendFunc (GL_DST_COLOR, GL_SRC_COLOR);
else if (gl_lightmap_format == GL_INTENSITY)
{
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glColor4f (1,1,1,1);
}
in R_DrawSequentialPoly. No shifts as far as i can tell
did this in gl_rmain, and gl_rsurf:
Find this:
Code:
- Code: Select all
glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
and replace it with this:
Code:
- Code: Select all
glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
glTexEnvi (GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
glTexEnvi (GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE);
glTexEnvi (GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PRIMARY_COLOR);
glTexEnvf (GL_TEXTURE_ENV, GL_RGB_SCALE, 2.0f);
and added this to the end of every function where i did the above ^ replacement
- Code: Select all
glTexEnvf (GL_TEXTURE_ENV, GL_RGB_SCALE, 1.0f);
glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
just as dark as ever
here is mh's bengtglob.exe
any ideas?
- hondobondo
- Posts: 207
- Joined: Tue Sep 26, 2006 2:48 am
DONE
thanks guys. tried also replacing this line
with this
now the hud is too bright, but ask me if i care engine snobs! (not you really nice helpful guys of course--you guys are awesome)

- Code: Select all
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
with this
- Code: Select all
glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); //try glTexEnvf?
glTexEnvf (GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
glTexEnvf (GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE);
glTexEnvf (GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PRIMARY_COLOR);
glTexEnvf (GL_TEXTURE_ENV, GL_RGB_SCALE, 2.0f);
now the hud is too bright, but ask me if i care engine snobs! (not you really nice helpful guys of course--you guys are awesome)

- hondobondo
- Posts: 207
- Joined: Tue Sep 26, 2006 2:48 am
Re: DONE
hondobondo wrote:thanks guys. tried also replacing this line
- Code: Select all
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
with this
- Code: Select all
glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); //try glTexEnvf?
glTexEnvf (GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
glTexEnvf (GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE);
glTexEnvf (GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PRIMARY_COLOR);
glTexEnvf (GL_TEXTURE_ENV, GL_RGB_SCALE, 2.0f);
now the hud is too bright, but ask me if i care engine snobs! (not you really nice helpful guys of course--you guys are awesome)
maybe i'll fix that later
- hondobondo
- Posts: 207
- Joined: Tue Sep 26, 2006 2:48 am
Re: DONE
hondobondo wrote:hondobondo wrote:thanks guys. tried also replacing this line
- Code: Select all
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
with this
- Code: Select all
glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); //try glTexEnvf?
glTexEnvf (GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
glTexEnvf (GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE);
glTexEnvf (GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PRIMARY_COLOR);
glTexEnvf (GL_TEXTURE_ENV, GL_RGB_SCALE, 2.0f);
now the hud is too bright, but ask me if i care engine snobs! (not you really nice helpful guys of course--you guys are awesome)
maybe i'll fix that later
maybe you will
i should not be here
- leileilol
- Posts: 2783
- Joined: Fri Oct 15, 2004 3:23 am
You need this during your takedown:
- Code: Select all
glTexEnvf (GL_TEXTURE_ENV, GL_RGB_SCALE, 1.0f);
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
We knew the words, we knew the score, we knew what we were fighting for
-

mh - Posts: 2292
- Joined: Sat Jan 12, 2008 1:38 am
While we're on the subject, does anybody know how to bake a variale contrast level into the lightmap while it's being built? The PSP's screen doesn't display certain dark color so well so I want to up the brightness and down the contrast, like what gamma is actually supposed to do.
-

Downsider - Posts: 621
- Joined: Tue Sep 16, 2008 1:35 am
You could use a 256 element byte array as a lookup (just using the calculated result from blocklights as the index) and put anything you wanted into it. Making it dynamically changable at runtime would be just a matter of setting modified = true and expanding rectchange to cover the full texture rectangle.
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
We knew the words, we knew the score, we knew what we were fighting for
-

mh - Posts: 2292
- Joined: Sat Jan 12, 2008 1:38 am
Aye.. Unfortunately, with HLBSP comes me greedy for coloured lighting, and since I've got support for that, I'd need 256^3 elements and that just seems sloppy.. Also, are you aware which function actually builds the final RGB values into the texture? In which case I'd know how to modify a bunch more stuff.
-

Downsider - Posts: 621
- Joined: Tue Sep 16, 2008 1:35 am
mh wrote:You need this during your takedown:Stick it in maybe GL_Set2D and it should work fine.
- Code: Select all
glTexEnvf (GL_TEXTURE_ENV, GL_RGB_SCALE, 1.0f);
that works great! thanks again
- hondobondo
- Posts: 207
- Joined: Tue Sep 26, 2006 2:48 am
Downsider wrote:Aye.. Unfortunately, with HLBSP comes me greedy for coloured lighting, and since I've got support for that, I'd need 256^3 elements and that just seems sloppy.. Also, are you aware which function actually builds the final RGB values into the texture? In which case I'd know how to modify a bunch more stuff.
You could just use a single array and put each colour into it:
- Code: Select all
dst[0] = r_lighttable[r];
dst[1] = r_lighttable[g];
dst[2] = r_lighttable[b];
R_BuildLightmap is the function you need.
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
We knew the words, we knew the score, we knew what we were fighting for
-

mh - Posts: 2292
- Joined: Sat Jan 12, 2008 1:38 am
It's fair to give warning that it's not the best place to do it, but it won't cause you any problems (at least so far as the 2D stuff is concerned). You might also get sky, water, particles and sprites being drawn too bright though.hondobondo wrote:mh wrote:You need this during your takedown:Stick it in maybe GL_Set2D and it should work fine.
- Code: Select all
glTexEnvf (GL_TEXTURE_ENV, GL_RGB_SCALE, 1.0f);
that works great! thanks again
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
We knew the words, we knew the score, we knew what we were fighting for
-

mh - Posts: 2292
- Joined: Sat Jan 12, 2008 1:38 am
MH, i implemented overbright lightning to hexen2 from bentgOverbrights engine but i have question how to make it compatible with GL_RGBA to use colored lightning .lit files
bentg... use overbright only in gl_lightmap_format = LUMINANCE
bentg... use overbright only in gl_lightmap_format = LUMINANCE
- WhiteMagicRaven
- Posts: 14
- Joined: Tue Apr 13, 2010 8:55 am
29 posts
• Page 2 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 1 guest