View previous topic :: View next topic |
Author |
Message |
hondobondo
Joined: 26 Sep 2006 Posts: 101
|
Posted: Tue Jun 15, 2010 6:01 pm Post subject: 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? |
|
Back to top |
|
 |
reckless
Joined: 24 Jan 2008 Posts: 390 Location: inside tha debugger
|
Posted: Tue Jun 15, 2010 8:25 pm Post subject: |
|
|
i think mh had some code for that ?.
aye older release before mhquake went d3d controllable to as its used to replace the software gamma code. |
|
Back to top |
|
 |
mh

Joined: 12 Jan 2008 Posts: 909
|
Posted: Tue Jun 15, 2010 9:08 pm Post subject: |
|
|
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. _________________ DirectQ Engine - New release 1.8.666a, 9th August 2010
MHQuake Blog (General)
Direct3D 8 Quake Engines |
|
Back to top |
|
 |
mh

Joined: 12 Jan 2008 Posts: 909
|
Posted: Wed Jun 16, 2010 6:15 pm Post subject: |
|
|
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.
 _________________ DirectQ Engine - New release 1.8.666a, 9th August 2010
MHQuake Blog (General)
Direct3D 8 Quake Engines |
|
Back to top |
|
 |
hondobondo
Joined: 26 Sep 2006 Posts: 101
|
Posted: Wed Jun 16, 2010 7:58 pm Post subject: you are sooper awesome |
|
|
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.
 |
thanks MH  |
|
Back to top |
|
 |
hondobondo
Joined: 26 Sep 2006 Posts: 101
|
Posted: Fri Jul 09, 2010 3:26 pm Post subject: ummm |
|
|
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.
 |
i tried out the code but had some problems:
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(?!) |
|
Back to top |
|
 |
reckless
Joined: 24 Jan 2008 Posts: 390 Location: inside tha debugger
|
Posted: Sat Jul 10, 2010 1:20 am Post subject: |
|
|
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: |
// 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);
}
}
| [/code] |
|
Back to top |
|
 |
hondobondo
Joined: 26 Sep 2006 Posts: 101
|
Posted: Mon Jul 12, 2010 2:14 am Post subject: thanks reckless |
|
|
i'll see what i can make sense of |
|
Back to top |
|
 |
r00k
Joined: 13 Nov 2004 Posts: 483
|
Posted: Mon Jul 12, 2010 5:56 am Post subject: |
|
|
Oh, is this how QMB made the strobe effect for ammo models?  |
|
Back to top |
|
 |
reckless
Joined: 24 Jan 2008 Posts: 390 Location: inside tha debugger
|
Posted: Mon Jul 12, 2010 10:01 am Post subject: |
|
|
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. |
|
Back to top |
|
 |
mh

Joined: 12 Jan 2008 Posts: 909
|
Posted: Mon Jul 12, 2010 11:48 am Post subject: |
|
|
reckless 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. |
Actually it can't; the only legal values are 1, 2 or 4: http://www.opengl.org/sdk/docs/man/xhtml/glTexEnv.xml
Quote: | 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. |
Also http://msdn.microsoft.com/en-us/library/bb172616%28v=VS.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! )
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.) _________________ DirectQ Engine - New release 1.8.666a, 9th August 2010
MHQuake Blog (General)
Direct3D 8 Quake Engines |
|
Back to top |
|
 |
reckless
Joined: 24 Jan 2008 Posts: 390 Location: inside tha debugger
|
Posted: Mon Jul 12, 2010 3:18 pm Post subject: |
|
|
limited cvar usage then well could probably round those values somehow but aye would be a bit messy if the user wrote 1.5 should it then be 1 or 2
idea actually came from a quake2 engine that used a cvar that way allthough the menu item for it was clamped at 2 highest 1 normal. |
|
Back to top |
|
 |
hondobondo
Joined: 26 Sep 2006 Posts: 101
|
Posted: Sun Jul 25, 2010 11:39 pm Post subject: you funny |
|
|
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'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.
I DO MATH! but poor at OPENGL |
|
Back to top |
|
 |
mh

Joined: 12 Jan 2008 Posts: 909
|
Posted: Sun Jul 25, 2010 11:55 pm Post subject: Re: you funny |
|
|
hondobondo wrote: | 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'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.
I DO MATH! but poor at OPENGL |
Find this: Code: | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); | and replace it with this: Code: | 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); | When shutting down the state at the end of your draw function you'll also need this: Code: | glTexEnvf (GL_TEXTURE_ENV, GL_RGB_SCALE, 1.0f);
glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); | But beware! Your code may use glTexEnvf where I use glTexEnvi. No practical difference though.
You'll also need these in your glquake.h: Code: | #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 |
_________________ DirectQ Engine - New release 1.8.666a, 9th August 2010
MHQuake Blog (General)
Direct3D 8 Quake Engines |
|
Back to top |
|
 |
Baker

Joined: 14 Mar 2006 Posts: 1538
|
Posted: Mon Jul 26, 2010 11:17 am Post subject: |
|
|
To hell with the death of Quakesrc.org
MH is his own Quakesrc.org galaxy.  _________________ Tomorrow Never Dies. I feel this Tomorrow knocking on the door ... |
|
Back to top |
|
 |
|