How can I add overbright lighting to Quake engine?
-
- Posts: 207
- Joined: Tue Sep 26, 2006 2:48 am
- Contact:
How can I add overbright lighting to Quake engine?
Enhanced GlQuake is the only engine that can run SDQuake, besides Darkplaces, and I want to add overbrights to it? Any tuts?
Simple enough for the world model. Just shift the lightmap by 8 (jnstead of by 7) in R_BuildLightmap, then use glBlendFunc (GL_DST_COLOR, GL_SRC_COLOR); in R_BlendLightmaps or a 2 x RGB combine instead of GL_MODULATE in R_DrawSequentialPoly. If those last items sound like too much you can double your palette values for mipmapped textures instead.
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
BengtOverbrights.zip
Present for you Hondo.
Use gl_overbright 1 (default) to enable. Overbrights are only available if GL_ARB_texture_env_combine is also available. In general that means that they're available on everything aside from old first and second gen 3dfx cards (or other hardware of comparable age).
They could be easily added to the gl_texsort 1 path for brush models on this ancient hardware, as that doesn't depend on combine. Adding them to alias models needs a little more work though.
I've made the whole project Visual C++ 2008 friendly, and removed the need to use gas2masm (just added the generated .asm files to it; ml.exe comes with 2008). The WinQuake builds won't compile successfully though, and I didn't bother with fixing them.
Just search for the word "overbright" in the source and you'll find most of what you need.
Incidentally, there is a third engine that can run SDQuake.
Present for you Hondo.
Use gl_overbright 1 (default) to enable. Overbrights are only available if GL_ARB_texture_env_combine is also available. In general that means that they're available on everything aside from old first and second gen 3dfx cards (or other hardware of comparable age).
They could be easily added to the gl_texsort 1 path for brush models on this ancient hardware, as that doesn't depend on combine. Adding them to alias models needs a little more work though.
I've made the whole project Visual C++ 2008 friendly, and removed the need to use gas2masm (just added the generated .asm files to it; ml.exe comes with 2008). The WinQuake builds won't compile successfully though, and I didn't bother with fixing them.
Just search for the word "overbright" in the source and you'll find most of what you need.
Incidentally, there is a third engine that can run SDQuake.
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
-
- Posts: 207
- Joined: Tue Sep 26, 2006 2:48 am
- Contact:
you are sooper awesome
thanks MHmh wrote:BengtOverbrights.zip
Present for you Hondo.
Use gl_overbright 1 (default) to enable. Overbrights are only available if GL_ARB_texture_env_combine is also available. In general that means that they're available on everything aside from old first and second gen 3dfx cards (or other hardware of comparable age).
They could be easily added to the gl_texsort 1 path for brush models on this ancient hardware, as that doesn't depend on combine. Adding them to alias models needs a little more work though.
I've made the whole project Visual C++ 2008 friendly, and removed the need to use gas2masm (just added the generated .asm files to it; ml.exe comes with 2008). The WinQuake builds won't compile successfully though, and I didn't bother with fixing them.
Just search for the word "overbright" in the source and you'll find most of what you need.
Incidentally, there is a third engine that can run SDQuake.
-
- Posts: 207
- Joined: Tue Sep 26, 2006 2:48 am
- Contact:
ummm
i tried out the code but had some problems:mh wrote:BengtOverbrights.zip
Present for you Hondo.
Use gl_overbright 1 (default) to enable. Overbrights are only available if GL_ARB_texture_env_combine is also available. In general that means that they're available on everything aside from old first and second gen 3dfx cards (or other hardware of comparable age).
They could be easily added to the gl_texsort 1 path for brush models on this ancient hardware, as that doesn't depend on combine. Adding them to alias models needs a little more work though.
I've made the whole project Visual C++ 2008 friendly, and removed the need to use gas2masm (just added the generated .asm files to it; ml.exe comes with 2008). The WinQuake builds won't compile successfully though, and I didn't bother with fixing them.
Just search for the word "overbright" in the source and you'll find most of what you need.
Incidentally, there is a third engine that can run SDQuake.
first i tried merging your changes with mine, but since i use GL_RGBA every level came out with colored splotches everywhere (WTF?)
then i tried adding colored lights to yours but the same thing happened. anyway, i have no idea what you said above with the openGL gibberish(?!)
gl_overbright is just a cvar for enabling/disabling the overbrights nothing to do with opengl as such
shift means the part in R_DrawSequentialPoly where you see << 7 make that << 8 (<< means shift in C).
then use the appropriate blendmodes in R_BlendLightmaps or
R_DrawSequentialPoly.
have a look at the zip mh sent ya
this part in particular
[/code]
shift means the part in R_DrawSequentialPoly where you see << 7 make that << 8 (<< means shift in C).
then use the appropriate blendmodes in R_BlendLightmaps or
R_DrawSequentialPoly.
have a look at the zip mh sent ya
this part in particular
Code: Select all
// mh - set/unset combine modes
void GL_BeginLightBlend (void)
{
if (gl_usingoverbright)
{
// mh - combine mode
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_PREVIOUS_ARB);
glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 2.0f);
}
else
{
// mh - uninverted range
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
}
}
-
- Posts: 207
- Joined: Tue Sep 26, 2006 2:48 am
- Contact:
thanks reckless
i'll see what i can make sense of
Actually it can't; the only legal values are 1, 2 or 4: http://www.opengl.org/sdk/docs/man/xhtml/glTexEnv.xmlreckless wrote:not sure
btw. this part glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 2.0f); the 2.0f at the end can actually be replaced by a cvar for scaling the overbrights, just dont go overboard with silly values keep it clamped to some valid ranges.
a range from 0.0f to 2.0f should be fine.
Also http://msdn.microsoft.com/en-us/library ... 85%29.aspx which tends to more accurately represent what the hardware can actually do (at the expense of having it explode in your face if you try to do something it can't! )GL_INVALID_VALUE is generated if the params value for GL_RGB_SCALE or GL_ALPHA_SCALE are not one of 1.0, 2.0, or 4.0.
It would probably work on NVIDIA hardware though, but don't expect it to work on anything else.
(Aside: I have done some experiments with 4 x overbrighting in the past. It does give a slightly better light range, but only very slightly, and the stair-step effect becomes very strong (due to >> 9). It's fine if you can do 64-bit or 128-bit textures, but not really that big a deal overall.)
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
-
- Posts: 207
- Joined: Tue Sep 26, 2006 2:48 am
- Contact:
you funny
i'm laughing because all of this is gibberish to me. i think i can do the first part in R_BuildLightMap (change all the <<= 7s and >>= 7s to 8s). but i don't know what 2xRGB combine is.mh wrote:Simple enough for the world model. Just shift the lightmap by 8 (jnstead of by 7) in R_BuildLightmap, then use glBlendFunc (GL_DST_COLOR, GL_SRC_COLOR); in R_BlendLightmaps or a 2 x RGB combine instead of GL_MODULATE in R_DrawSequentialPoly. If those last items sound like too much you can double your palette values for mipmapped textures instead.
I DO MATH! but poor at OPENGL
Re: you funny
Find this:hondobondo wrote:i'm laughing because all of this is gibberish to me. i think i can do the first part in R_BuildLightMap (change all the <<= 7s and >>= 7s to 8s). but i don't know what 2xRGB combine is.mh wrote:Simple enough for the world model. Just shift the lightmap by 8 (jnstead of by 7) in R_BuildLightmap, then use glBlendFunc (GL_DST_COLOR, GL_SRC_COLOR); in R_BlendLightmaps or a 2 x RGB combine instead of GL_MODULATE in R_DrawSequentialPoly. If those last items sound like too much you can double your palette values for mipmapped textures instead.
I DO MATH! but poor at OPENGL
Code: Select all
glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
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);
Code: Select all
glTexEnvf (GL_TEXTURE_ENV, GL_RGB_SCALE, 1.0f);
glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
You'll also need these in your glquake.h:
Code: Select all
#define GL_COMBINE 0x8570
#define GL_COMBINE_RGB 0x8571
#define GL_COMBINE_ALPHA 0x8572
#define GL_SOURCE0_RGB 0x8580
#define GL_SOURCE1_RGB 0x8581
#define GL_SOURCE2_RGB 0x8582
#define GL_SOURCE0_ALPHA 0x8588
#define GL_SOURCE1_ALPHA 0x8589
#define GL_SOURCE2_ALPHA 0x858A
#define GL_OPERAND0_RGB 0x8590
#define GL_OPERAND1_RGB 0x8591
#define GL_OPERAND2_RGB 0x8592
#define GL_OPERAND0_ALPHA 0x8598
#define GL_OPERAND1_ALPHA 0x8599
#define GL_OPERAND2_ALPHA 0x859A
#define GL_RGB_SCALE 0x8573
#define GL_ADD_SIGNED 0x8574
#define GL_INTERPOLATE 0x8575
#define GL_SUBTRACT 0x84E7
#define GL_CONSTANT 0x8576
#define GL_PRIMARY_COLOR 0x8577
#define GL_PREVIOUS 0x8578
#define GL_DOT3_RGB 0x86AE
#define GL_DOT3_RGBA 0x86AF
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