Forum

How can I add overbright lighting to Quake engine?

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

Moderator: InsideQC Admins

Postby hondobondo » Mon Jul 26, 2010 3:55 pm

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
hondobondo
 
Posts: 207
Joined: Tue Sep 26, 2006 2:48 am

gonna get this working

Postby hondobondo » Sat Aug 14, 2010 6:29 pm

thanks guys for all your help so far.

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
Image

here is mh's bengtglob.exe
Image

any ideas?
hondobondo
 
Posts: 207
Joined: Tue Sep 26, 2006 2:48 am

Postby hondobondo » Sun Aug 22, 2010 2:34 am

well the alias models are nice and bright
hondobondo
 
Posts: 207
Joined: Tue Sep 26, 2006 2:48 am

DONE

Postby hondobondo » Wed Aug 25, 2010 12:18 am

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)

Image
hondobondo
 
Posts: 207
Joined: Tue Sep 26, 2006 2:48 am

Re: DONE

Postby hondobondo » Wed Aug 25, 2010 12:21 am

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)

Image


maybe i'll fix that later
hondobondo
 
Posts: 207
Joined: Tue Sep 26, 2006 2:48 am

Re: DONE

Postby leileilol » Wed Aug 25, 2010 12:41 am

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)

Image


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

Postby mh » Wed Aug 25, 2010 4:08 pm

You need this during your takedown:
Code: Select all
      glTexEnvf (GL_TEXTURE_ENV, GL_RGB_SCALE, 1.0f);
Stick it in maybe GL_Set2D and it should work fine.
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
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Postby Downsider » Wed Aug 25, 2010 5:24 pm

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.
User avatar
Downsider
 
Posts: 621
Joined: Tue Sep 16, 2008 1:35 am

Postby mh » Wed Aug 25, 2010 7:22 pm

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
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Postby Downsider » Thu Aug 26, 2010 12:04 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.
User avatar
Downsider
 
Posts: 621
Joined: Tue Sep 16, 2008 1:35 am

Postby hondobondo » Thu Aug 26, 2010 12:46 am

mh wrote:You need this during your takedown:
Code: Select all
      glTexEnvf (GL_TEXTURE_ENV, GL_RGB_SCALE, 1.0f);
Stick it in maybe GL_Set2D and it should work fine.


that works great! thanks again
hondobondo
 
Posts: 207
Joined: Tue Sep 26, 2006 2:48 am

Postby mh » Thu Aug 26, 2010 4:45 pm

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
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Postby mh » Thu Aug 26, 2010 4:47 pm

hondobondo wrote:
mh wrote:You need this during your takedown:
Code: Select all
      glTexEnvf (GL_TEXTURE_ENV, GL_RGB_SCALE, 1.0f);
Stick it in maybe GL_Set2D and it should work fine.


that works great! thanks again
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.
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
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Postby WhiteMagicRaven » Mon Jun 06, 2011 3:27 pm

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
WhiteMagicRaven
 
Posts: 14
Joined: Tue Apr 13, 2010 8:55 am

Previous

Return to Engine Programming

Who is online

Users browsing this forum: No registered users and 1 guest