[quake2] overbright models
-
- Posts: 10
- Joined: Sat Nov 12, 2011 2:05 am
[quake2] overbright models
I already implemented overbright in wals so now the game is a lot brighter without washed up textures, but it seems that the routine to include overbrights in models (like npcs and items or your weapons is different). Can somenone give some advice at this, I am working in the 3.21 source provided by ID.
Re: [quake2] overbright models
overbrights:
Which of the following 2 has the greater dynamic range?
clamp(texture*clamp(lighting*0.5) * 2)
clamp(texture*clamp(lighting))
yup, the top one. that's the maths you need to set up to do your overbrights, instead of the second one.
or in other words, halve the light values passed per-vertex in your engine, and configure the GL_RGB_SCALE_ARB to double the resulting texture samples (or quater/quadruple, your choice).
with lightmaps its the lightmap samples which are halved (before being clamped to 255=1.0), which allows you to double the maximum range in there. with models its the glVertex values which is halved (before being clamped to 255=1.0)
that's the only difference.
if you calc the light levels in the vertex program using non-clamped colour values etc then you can bypass the inner clamp making any overbrighting limit value much much larger. sadly for world lighting, the inner clamp is limited by the precision provided by a 24bit colour image. you can achieve higher ranges by using a floating-point texture format. In the case of q3bsp, the lightmaps are already scaled down to 0.25, while quake/quake2 scales down in the lightmap generation code.
Which of the following 2 has the greater dynamic range?
clamp(texture*clamp(lighting*0.5) * 2)
clamp(texture*clamp(lighting))
yup, the top one. that's the maths you need to set up to do your overbrights, instead of the second one.
or in other words, halve the light values passed per-vertex in your engine, and configure the GL_RGB_SCALE_ARB to double the resulting texture samples (or quater/quadruple, your choice).
with lightmaps its the lightmap samples which are halved (before being clamped to 255=1.0), which allows you to double the maximum range in there. with models its the glVertex values which is halved (before being clamped to 255=1.0)
that's the only difference.
if you calc the light levels in the vertex program using non-clamped colour values etc then you can bypass the inner clamp making any overbrighting limit value much much larger. sadly for world lighting, the inner clamp is limited by the precision provided by a 24bit colour image. you can achieve higher ranges by using a floating-point texture format. In the case of q3bsp, the lightmaps are already scaled down to 0.25, while quake/quake2 scales down in the lightmap generation code.
Re: [quake2] overbright models
very old code for pics or models overbright
Code: Select all
void GL_Overbrights(qboolean enable)
{
if (enable) { // turn on
GL_TexEnv(GL_COMBINE_ARB);
qglTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE);
qglTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE);
qglTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_PREVIOUS_ARB);
qglTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, (int) r_overBrightBits->value);
qglTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_MODULATE);
qglTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_TEXTURE);
qglTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_ARB, GL_PREVIOUS_ARB);
qglTexEnvi(GL_TEXTURE_ENV, GL_ALPHA_SCALE, 1);
} else { // turn off
GL_TexEnv(GL_MODULATE);
qglTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 1);
qglTexEnvi(GL_TEXTURE_ENV, GL_ALPHA_SCALE, 1);
}
}
-
- Posts: 10
- Joined: Sat Nov 12, 2011 2:05 am
Re: [quake2] overbright models
I forgot to mention that I took the code from this page "http://www.quakewiki.net/quakesrc/28.html" where Vic coded overbrights for the engine, but sadly there isnt working for models. I already took a look at KMQuake2 source and they changed a lot of stuff to get overbrights on models but I wasnt very sure how they implemented this, since the vanilla source and theirs are too much different.
Re: [quake2] overbright models
Vic's method really only works for the BSP.
for models and pictures overbright use above code. If I remember correctly it code uses in kmquake2
for models and pictures overbright use above code. If I remember correctly it code uses in kmquake2
-
- Posts: 10
- Joined: Sat Nov 12, 2011 2:05 am
Re: [quake2] overbright models
Yep, Vic's code only works for BSPs, thanks for the quick responses to both of you I will go to sleep and see if tomorrow I can get something work.
Re: [quake2] overbright models
Code: Select all
qglTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, (int) r_overBrightBits->value);
Accepted by the <params> parameter of TexEnvf, TexEnvi, TexEnvfv,
and TexEnviv when the <pname> parameter value is RGB_SCALE_ARB or
ALPHA_SCALE
1.0
2.0
4.0
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
Re: [quake2] overbright models
I should mention that unlike Quake, Quake2's models aren't intended to be overbrightened (not even in software) so brightening only the BSP still is logical.
Don't forget to nuke that stupid "intensity" feature. It sucks.
Don't forget to nuke that stupid "intensity" feature. It sucks.
i should not be here
Re: [quake2] overbright models
I think there is more correct to speak not about the overbright, but the multiplication of the color intensity of 2 times
like
gl_FragColor = color * u_ColorModulate;
like
gl_FragColor = color * u_ColorModulate;
Re: [quake2] overbright models
I believe that Q2 actually does overbright MD2s as it sends their textures through it's lightscale/intensity thing, and glColor/glColorPointer will clamp in the 0..1 range. There is a lot of second-system-effect crap in the Q2 renderer (gl_modulate is something else that must also die) that does confuse the issue 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
We knew the words, we knew the score, we knew what we were fighting for
-
- Posts: 10
- Joined: Sat Nov 12, 2011 2:05 am
Re: [quake2] overbright models
The function that controls the textures in bmodels is "void R_DrawInlineBModel (void)"? (found in gl_rsurf.c). Also this forum is about coding Quake engine? or Quake 2 too?. KmQuake2 already implemented overbright in models but since their project and their webpage is dead I cant find how they did it .
Re: [quake2] overbright models
Mostly Quake but we do help on Q2 to if we can
Productivity is a state of mind.
-
- Posts: 10
- Joined: Sat Nov 12, 2011 2:05 am
Re: [quake2] overbright models
@reckless
Oh I see, I was reading the tutorial section of the forums and almost all the code is related to Quake1
I think I am near the solution of the problem, I found the following function in Kmquake2 source:
Its almost the same of what Barnes posted, btw Barnes where do I put the calls?
Oh I see, I was reading the tutorial section of the forums and almost all the code is related to Quake1
I think I am near the solution of the problem, I found the following function in Kmquake2 source:
Code: Select all
/*
=================
R_SetVertexOverbrights
=================
*/
void R_SetVertexOverbrights (qboolean toggle)
{
if (!r_overbrightbits->value || !glConfig.mtexcombine)
return;
if (toggle) // turn on
{
#if 1
qglTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
qglTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE);
qglTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, r_overbrightbits->value);
qglTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_MODULATE);
GL_TexEnv(GL_COMBINE_ARB);
#else
qglTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
qglTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE);
qglTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, r_overbrightbits->value);
qglTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_MODULATE);
GL_TexEnv(GL_COMBINE_EXT);
#endif
}
else // turn off
{
GL_TexEnv(GL_MODULATE);
qglTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 1);
}
}
Re: [quake2] overbright models
I remember about it. Although it code I used for pictures, decals or skyboxes. Almost everything else I'm drawing with glslmh wrote:Beware. You can't really do this.Code: Select all
qglTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, (int) r_overBrightBits->value);
Re: [quake2] overbright models
A lot of the code is so similar in both engines that it doesn't really matter.marcelo_20xx wrote: Oh I see, I was reading the tutorial section of the forums and almost all the code is related to Quake1
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