mirror of
https://github.com/DrBeef/ioq3quest.git
synced 2024-11-13 07:57:23 +00:00
OpenGL2: Add option in code for alternate overbright method.
This commit is contained in:
parent
e5aabdaff6
commit
92d4b20129
5 changed files with 35 additions and 7 deletions
|
@ -101,7 +101,11 @@ static void R_ColorShiftLightingBytes( byte in[4], byte out[4] ) {
|
||||||
int shift, r, g, b;
|
int shift, r, g, b;
|
||||||
|
|
||||||
// shift the color data based on overbright range
|
// shift the color data based on overbright range
|
||||||
|
#if defined(USE_OVERBRIGHT)
|
||||||
shift = r_mapOverBrightBits->integer - tr.overbrightBits;
|
shift = r_mapOverBrightBits->integer - tr.overbrightBits;
|
||||||
|
#else
|
||||||
|
shift = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
// shift the data based on overbright range
|
// shift the data based on overbright range
|
||||||
r = in[0] << shift;
|
r = in[0] << shift;
|
||||||
|
@ -136,7 +140,9 @@ static void R_ColorShiftLightingFloats(float in[4], float out[4], float scale )
|
||||||
{
|
{
|
||||||
float r, g, b;
|
float r, g, b;
|
||||||
|
|
||||||
|
#if defined(USE_OVERBRIGHT)
|
||||||
scale *= pow(2.0f, r_mapOverBrightBits->integer - tr.overbrightBits);
|
scale *= pow(2.0f, r_mapOverBrightBits->integer - tr.overbrightBits);
|
||||||
|
#endif
|
||||||
|
|
||||||
r = in[0] * scale;
|
r = in[0] * scale;
|
||||||
g = in[1] * scale;
|
g = in[1] * scale;
|
||||||
|
@ -2755,7 +2761,11 @@ void R_LoadLightGrid( lump_t *l ) {
|
||||||
|
|
||||||
if (hdrLightGrid)
|
if (hdrLightGrid)
|
||||||
{
|
{
|
||||||
|
#if defined(USE_OVERBRIGHT)
|
||||||
float lightScale = pow(2, r_mapOverBrightBits->integer - tr.overbrightBits);
|
float lightScale = pow(2, r_mapOverBrightBits->integer - tr.overbrightBits);
|
||||||
|
#else
|
||||||
|
float lightScale = 1.0f;
|
||||||
|
#endif
|
||||||
|
|
||||||
//ri.Printf(PRINT_ALL, "found!\n");
|
//ri.Printf(PRINT_ALL, "found!\n");
|
||||||
|
|
||||||
|
|
|
@ -2855,7 +2855,11 @@ void R_SetColorMappings( void ) {
|
||||||
int inf;
|
int inf;
|
||||||
|
|
||||||
// setup the overbright lighting
|
// setup the overbright lighting
|
||||||
|
#if defined(USE_OVERBRIGHT)
|
||||||
tr.overbrightBits = r_overBrightBits->integer;
|
tr.overbrightBits = r_overBrightBits->integer;
|
||||||
|
#else
|
||||||
|
tr.overbrightBits = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
// allow 2 overbright bits
|
// allow 2 overbright bits
|
||||||
if ( tr.overbrightBits > 2 ) {
|
if ( tr.overbrightBits > 2 ) {
|
||||||
|
|
|
@ -58,6 +58,7 @@ typedef unsigned int glIndex_t;
|
||||||
#define CUBE_MAP_SIZE (1 << CUBE_MAP_MIPS)
|
#define CUBE_MAP_SIZE (1 << CUBE_MAP_MIPS)
|
||||||
|
|
||||||
#define USE_VERT_TANGENT_SPACE
|
#define USE_VERT_TANGENT_SPACE
|
||||||
|
#define USE_OVERBRIGHT
|
||||||
|
|
||||||
typedef struct dlight_s {
|
typedef struct dlight_s {
|
||||||
vec3_t origin;
|
vec3_t origin;
|
||||||
|
|
|
@ -349,7 +349,11 @@ void RE_BeginScene(const refdef_t *fd)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#if defined(USE_OVERBRIGHT)
|
||||||
float scale = pow(2, r_mapOverBrightBits->integer - tr.overbrightBits - 8);
|
float scale = pow(2, r_mapOverBrightBits->integer - tr.overbrightBits - 8);
|
||||||
|
#else
|
||||||
|
float scale = (1 << r_mapOverBrightBits->integer) / 255.0f;
|
||||||
|
#endif
|
||||||
if (r_forceSun->integer)
|
if (r_forceSun->integer)
|
||||||
{
|
{
|
||||||
VectorScale(tr.sunLight, scale * r_forceSunLightScale->value, tr.refdef.sunCol);
|
VectorScale(tr.sunLight, scale * r_forceSunLightScale->value, tr.refdef.sunCol);
|
||||||
|
|
|
@ -444,9 +444,22 @@ static void ProjectDlightTexture( void ) {
|
||||||
|
|
||||||
static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t vertColor, int blend )
|
static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t vertColor, int blend )
|
||||||
{
|
{
|
||||||
|
qboolean isBlend = ((blend & GLS_SRCBLEND_BITS) == GLS_SRCBLEND_DST_COLOR)
|
||||||
|
|| ((blend & GLS_SRCBLEND_BITS) == GLS_SRCBLEND_ONE_MINUS_DST_COLOR)
|
||||||
|
|| ((blend & GLS_DSTBLEND_BITS) == GLS_DSTBLEND_SRC_COLOR)
|
||||||
|
|| ((blend & GLS_DSTBLEND_BITS) == GLS_DSTBLEND_ONE_MINUS_SRC_COLOR);
|
||||||
|
|
||||||
|
qboolean isWorldDraw = !(backEnd.refdef.rdflags & RDF_NOWORLDMODEL);
|
||||||
|
|
||||||
|
#if defined(USE_OVERBRIGHT)
|
||||||
|
float exactLight = 1.0f;
|
||||||
|
#else
|
||||||
|
float exactLight = (isBlend || !isWorldDraw) ? 1.0f : (float)(1 << r_mapOverBrightBits->integer);
|
||||||
|
#endif
|
||||||
|
|
||||||
baseColor[0] =
|
baseColor[0] =
|
||||||
baseColor[1] =
|
baseColor[1] =
|
||||||
baseColor[2] =
|
baseColor[2] = exactLight;
|
||||||
baseColor[3] = 1.0f;
|
baseColor[3] = 1.0f;
|
||||||
|
|
||||||
vertColor[0] =
|
vertColor[0] =
|
||||||
|
@ -473,7 +486,7 @@ static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t
|
||||||
|
|
||||||
vertColor[0] =
|
vertColor[0] =
|
||||||
vertColor[1] =
|
vertColor[1] =
|
||||||
vertColor[2] =
|
vertColor[2] = exactLight;
|
||||||
vertColor[3] = 1.0f;
|
vertColor[3] = 1.0f;
|
||||||
break;
|
break;
|
||||||
case CGEN_CONST:
|
case CGEN_CONST:
|
||||||
|
@ -601,11 +614,7 @@ static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t
|
||||||
}
|
}
|
||||||
|
|
||||||
// multiply color by overbrightbits if this isn't a blend
|
// multiply color by overbrightbits if this isn't a blend
|
||||||
if (tr.overbrightBits
|
if (tr.overbrightBits && !isBlend)
|
||||||
&& !((blend & GLS_SRCBLEND_BITS) == GLS_SRCBLEND_DST_COLOR)
|
|
||||||
&& !((blend & GLS_SRCBLEND_BITS) == GLS_SRCBLEND_ONE_MINUS_DST_COLOR)
|
|
||||||
&& !((blend & GLS_DSTBLEND_BITS) == GLS_DSTBLEND_SRC_COLOR)
|
|
||||||
&& !((blend & GLS_DSTBLEND_BITS) == GLS_DSTBLEND_ONE_MINUS_SRC_COLOR))
|
|
||||||
{
|
{
|
||||||
float scale = 1 << tr.overbrightBits;
|
float scale = 1 << tr.overbrightBits;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue