mirror of
https://github.com/DrBeef/ioq3quest.git
synced 2024-11-10 23:02:01 +00:00
OpenGL2: Set RGBM to use a multiplier of 1, and only use it with HDR lightmaps.
This commit is contained in:
parent
6beab9cf58
commit
79e9baedf8
3 changed files with 44 additions and 47 deletions
|
@ -21,7 +21,7 @@ void main()
|
||||||
#if defined(USE_LIGHTMAP)
|
#if defined(USE_LIGHTMAP)
|
||||||
vec4 color2 = texture2D(u_LightMap, var_LightTex);
|
vec4 color2 = texture2D(u_LightMap, var_LightTex);
|
||||||
#if defined(RGBM_LIGHTMAP)
|
#if defined(RGBM_LIGHTMAP)
|
||||||
color2.rgb *= 32.0 * color2.a;
|
color2.rgb *= color2.a;
|
||||||
color2.a = 1.0;
|
color2.a = 1.0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -346,7 +346,7 @@ void main()
|
||||||
vec4 lightSample = texture2D(u_LightMap, var_TexCoords.zw);
|
vec4 lightSample = texture2D(u_LightMap, var_TexCoords.zw);
|
||||||
vec3 lightColor = lightSample.rgb;
|
vec3 lightColor = lightSample.rgb;
|
||||||
#if defined(RGBM_LIGHTMAP)
|
#if defined(RGBM_LIGHTMAP)
|
||||||
lightColor *= 32.0 * lightSample.a;
|
lightColor *= lightSample.a;
|
||||||
#endif
|
#endif
|
||||||
#elif defined(USE_LIGHT_VECTOR) && !defined(USE_FAST_LIGHT)
|
#elif defined(USE_LIGHT_VECTOR) && !defined(USE_FAST_LIGHT)
|
||||||
vec3 lightColor = u_DirectedLight * CalcLightAttenuation(float(var_LightDir.w > 0.0), var_LightDir.w / sqrLightDist);
|
vec3 lightColor = u_DirectedLight * CalcLightAttenuation(float(var_LightDir.w > 0.0), var_LightDir.w / sqrLightDist);
|
||||||
|
|
|
@ -165,8 +165,6 @@ void ColorToRGBM(const vec3_t color, unsigned char rgbm[4])
|
||||||
vec3_t sample;
|
vec3_t sample;
|
||||||
float maxComponent;
|
float maxComponent;
|
||||||
|
|
||||||
VectorScale(color, 1.0f / 32.0f, sample);
|
|
||||||
|
|
||||||
maxComponent = MAX(sample[0], sample[1]);
|
maxComponent = MAX(sample[0], sample[1]);
|
||||||
maxComponent = MAX(maxComponent, sample[2]);
|
maxComponent = MAX(maxComponent, sample[2]);
|
||||||
maxComponent = CLAMP(maxComponent, 1.0f/255.0f, 1.0f);
|
maxComponent = CLAMP(maxComponent, 1.0f/255.0f, 1.0f);
|
||||||
|
@ -326,7 +324,6 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) {
|
||||||
{
|
{
|
||||||
char filename[MAX_QPATH];
|
char filename[MAX_QPATH];
|
||||||
byte *hdrLightmap = NULL;
|
byte *hdrLightmap = NULL;
|
||||||
float lightScale = 1.0f;
|
|
||||||
int size = 0;
|
int size = 0;
|
||||||
|
|
||||||
// look for hdr lightmaps
|
// look for hdr lightmaps
|
||||||
|
@ -383,16 +380,12 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) {
|
||||||
buf_p = buf + i * tr.lightmapSize * tr.lightmapSize * 3;
|
buf_p = buf + i * tr.lightmapSize * tr.lightmapSize * 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
lightScale = pow(2, r_mapOverBrightBits->integer - tr.overbrightBits - 8); //exp2(r_mapOverBrightBits->integer - tr.overbrightBits - 8);
|
|
||||||
|
|
||||||
for ( j = 0 ; j < tr.lightmapSize * tr.lightmapSize; j++ )
|
for ( j = 0 ; j < tr.lightmapSize * tr.lightmapSize; j++ )
|
||||||
{
|
{
|
||||||
if (r_hdr->integer)
|
if (hdrLightmap)
|
||||||
{
|
{
|
||||||
float color[3];
|
float color[3];
|
||||||
|
|
||||||
if (hdrLightmap)
|
|
||||||
{
|
|
||||||
#if 0 // HDRFILE_RGBE
|
#if 0 // HDRFILE_RGBE
|
||||||
float exponent = exp2(buf_p[j*4+3] - 128);
|
float exponent = exp2(buf_p[j*4+3] - 128);
|
||||||
|
|
||||||
|
@ -406,13 +399,21 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) {
|
||||||
color[1] = LittleFloat(color[1]);
|
color[1] = LittleFloat(color[1]);
|
||||||
color[2] = LittleFloat(color[2]);
|
color[2] = LittleFloat(color[2]);
|
||||||
#endif
|
#endif
|
||||||
}
|
R_ColorShiftLightingFloats(color, color, 1.0f/255.0f);
|
||||||
|
|
||||||
|
if (glRefConfig.textureFloat && glRefConfig.halfFloatPixel && r_floatLightmap->integer)
|
||||||
|
ColorToRGBA16F(color, (unsigned short *)(&image[j*8]));
|
||||||
else
|
else
|
||||||
|
ColorToRGBM(color, &image[j*4]);
|
||||||
|
}
|
||||||
|
else if (glRefConfig.textureFloat && glRefConfig.halfFloatPixel && r_floatLightmap->integer)
|
||||||
{
|
{
|
||||||
|
float color[3];
|
||||||
|
|
||||||
//hack: convert LDR lightmap to HDR one
|
//hack: convert LDR lightmap to HDR one
|
||||||
color[0] = (buf_p[j*3+0] + 1.0f);
|
color[0] = MAX(buf_p[j*3+0], 0.499f);
|
||||||
color[1] = (buf_p[j*3+1] + 1.0f);
|
color[1] = MAX(buf_p[j*3+1], 0.499f);
|
||||||
color[2] = (buf_p[j*3+2] + 1.0f);
|
color[2] = MAX(buf_p[j*3+2], 0.499f);
|
||||||
|
|
||||||
// if under an arbitrary value (say 12) grey it out
|
// if under an arbitrary value (say 12) grey it out
|
||||||
// this prevents weird splotches in dimly lit areas
|
// this prevents weird splotches in dimly lit areas
|
||||||
|
@ -423,14 +424,10 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) {
|
||||||
color[1] = avg;
|
color[1] = avg;
|
||||||
color[2] = avg;
|
color[2] = avg;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
VectorScale(color, lightScale, color);
|
R_ColorShiftLightingFloats(color, color, 1.0f/255.0f);
|
||||||
|
|
||||||
if (glRefConfig.textureFloat && glRefConfig.halfFloatPixel && r_floatLightmap->integer)
|
|
||||||
ColorToRGBA16F(color, (unsigned short *)(&image[j*8]));
|
ColorToRGBA16F(color, (unsigned short *)(&image[j*8]));
|
||||||
else
|
|
||||||
ColorToRGBM(color, &image[j*4]);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -737,9 +734,9 @@ static void ParseFace( dsurface_t *ds, drawVert_t *verts, float *hdrVertColors,
|
||||||
//hack: convert LDR vertex colors to HDR
|
//hack: convert LDR vertex colors to HDR
|
||||||
if (r_hdr->integer)
|
if (r_hdr->integer)
|
||||||
{
|
{
|
||||||
color[0] = verts[i].color[0] + 1.0f;
|
color[0] = MAX(verts[i].color[0], 0.499f);
|
||||||
color[1] = verts[i].color[1] + 1.0f;
|
color[1] = MAX(verts[i].color[1], 0.499f);
|
||||||
color[2] = verts[i].color[2] + 1.0f;
|
color[2] = MAX(verts[i].color[2], 0.499f);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -881,9 +878,9 @@ static void ParseMesh ( dsurface_t *ds, drawVert_t *verts, float *hdrVertColors,
|
||||||
//hack: convert LDR vertex colors to HDR
|
//hack: convert LDR vertex colors to HDR
|
||||||
if (r_hdr->integer)
|
if (r_hdr->integer)
|
||||||
{
|
{
|
||||||
color[0] = verts[i].color[0] + 1.0f;
|
color[0] = MAX(verts[i].color[0], 0.499f);
|
||||||
color[1] = verts[i].color[1] + 1.0f;
|
color[1] = MAX(verts[i].color[1], 0.499f);
|
||||||
color[2] = verts[i].color[2] + 1.0f;
|
color[2] = MAX(verts[i].color[2], 0.499f);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -982,9 +979,9 @@ static void ParseTriSurf( dsurface_t *ds, drawVert_t *verts, float *hdrVertColor
|
||||||
//hack: convert LDR vertex colors to HDR
|
//hack: convert LDR vertex colors to HDR
|
||||||
if (r_hdr->integer)
|
if (r_hdr->integer)
|
||||||
{
|
{
|
||||||
color[0] = verts[i].color[0] + 1.0f;
|
color[0] = MAX(verts[i].color[0], 0.499f);
|
||||||
color[1] = verts[i].color[1] + 1.0f;
|
color[1] = MAX(verts[i].color[1], 0.499f);
|
||||||
color[2] = verts[i].color[2] + 1.0f;
|
color[2] = MAX(verts[i].color[2], 0.499f);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue