Merge branch 'master' into sdl2
This commit is contained in:
commit
1250b352be
21 changed files with 2714 additions and 413 deletions
|
@ -21,7 +21,7 @@ void main()
|
|||
#if defined(USE_LIGHTMAP)
|
||||
vec4 color2 = texture2D(u_LightMap, var_LightTex);
|
||||
#if defined(RGBM_LIGHTMAP)
|
||||
color2.rgb *= 32.0 * color2.a;
|
||||
color2.rgb *= color2.a;
|
||||
color2.a = 1.0;
|
||||
#endif
|
||||
|
||||
|
|
|
@ -346,7 +346,7 @@ void main()
|
|||
vec4 lightSample = texture2D(u_LightMap, var_TexCoords.zw);
|
||||
vec3 lightColor = lightSample.rgb;
|
||||
#if defined(RGBM_LIGHTMAP)
|
||||
lightColor *= 32.0 * lightSample.a;
|
||||
lightColor *= lightSample.a;
|
||||
#endif
|
||||
#elif defined(USE_LIGHT_VECTOR) && !defined(USE_FAST_LIGHT)
|
||||
vec3 lightColor = u_DirectedLight * CalcLightAttenuation(float(var_LightDir.w > 0.0), var_LightDir.w / sqrLightDist);
|
||||
|
|
|
@ -165,7 +165,7 @@ void ColorToRGBM(const vec3_t color, unsigned char rgbm[4])
|
|||
vec3_t sample;
|
||||
float maxComponent;
|
||||
|
||||
VectorScale(color, 1.0f / 32.0f, sample);
|
||||
VectorCopy(color, sample);
|
||||
|
||||
maxComponent = MAX(sample[0], sample[1]);
|
||||
maxComponent = MAX(maxComponent, sample[2]);
|
||||
|
@ -286,13 +286,10 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) {
|
|||
tr.deluxemaps = ri.Hunk_Alloc( tr.numLightmaps * sizeof(image_t *), h_low );
|
||||
}
|
||||
|
||||
if (r_hdr->integer)
|
||||
{
|
||||
if (glRefConfig.textureFloat && glRefConfig.halfFloatPixel && r_floatLightmap->integer)
|
||||
textureInternalFormat = GL_RGBA16F_ARB;
|
||||
else
|
||||
textureInternalFormat = GL_RGBA8;
|
||||
}
|
||||
if (glRefConfig.floatLightmap)
|
||||
textureInternalFormat = GL_RGBA16F_ARB;
|
||||
else
|
||||
textureInternalFormat = GL_RGBA8;
|
||||
|
||||
if (r_mergeLightmaps->integer)
|
||||
{
|
||||
|
@ -326,7 +323,6 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) {
|
|||
{
|
||||
char filename[MAX_QPATH];
|
||||
byte *hdrLightmap = NULL;
|
||||
float lightScale = 1.0f;
|
||||
int size = 0;
|
||||
|
||||
// look for hdr lightmaps
|
||||
|
@ -383,55 +379,58 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) {
|
|||
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++ )
|
||||
{
|
||||
if (r_hdr->integer)
|
||||
if (hdrLightmap)
|
||||
{
|
||||
float color[3];
|
||||
vec4_t color;
|
||||
|
||||
if (hdrLightmap)
|
||||
{
|
||||
#if 0 // HDRFILE_RGBE
|
||||
float exponent = exp2(buf_p[j*4+3] - 128);
|
||||
float exponent = exp2(buf_p[j*4+3] - 128);
|
||||
|
||||
color[0] = buf_p[j*4+0] * exponent;
|
||||
color[1] = buf_p[j*4+1] * exponent;
|
||||
color[2] = buf_p[j*4+2] * exponent;
|
||||
color[0] = buf_p[j*4+0] * exponent;
|
||||
color[1] = buf_p[j*4+1] * exponent;
|
||||
color[2] = buf_p[j*4+2] * exponent;
|
||||
#else // HDRFILE_FLOAT
|
||||
memcpy(color, &buf_p[j*12], 12);
|
||||
memcpy(color, &buf_p[j*12], 12);
|
||||
|
||||
color[0] = LittleFloat(color[0]);
|
||||
color[1] = LittleFloat(color[1]);
|
||||
color[2] = LittleFloat(color[2]);
|
||||
color[0] = LittleFloat(color[0]);
|
||||
color[1] = LittleFloat(color[1]);
|
||||
color[2] = LittleFloat(color[2]);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
//hack: convert LDR lightmap to HDR one
|
||||
color[0] = (buf_p[j*3+0] + 1.0f);
|
||||
color[1] = (buf_p[j*3+1] + 1.0f);
|
||||
color[2] = (buf_p[j*3+2] + 1.0f);
|
||||
color[3] = 1.0f;
|
||||
|
||||
// if under an arbitrary value (say 12) grey it out
|
||||
// this prevents weird splotches in dimly lit areas
|
||||
if (color[0] + color[1] + color[2] < 12.0f)
|
||||
{
|
||||
float avg = (color[0] + color[1] + color[2]) * 0.3333f;
|
||||
color[0] = avg;
|
||||
color[1] = avg;
|
||||
color[2] = avg;
|
||||
}
|
||||
}
|
||||
R_ColorShiftLightingFloats(color, color, 1.0f/255.0f);
|
||||
|
||||
VectorScale(color, lightScale, color);
|
||||
|
||||
if (glRefConfig.textureFloat && glRefConfig.halfFloatPixel && r_floatLightmap->integer)
|
||||
if (glRefConfig.floatLightmap)
|
||||
ColorToRGBA16F(color, (unsigned short *)(&image[j*8]));
|
||||
else
|
||||
ColorToRGBM(color, &image[j*4]);
|
||||
}
|
||||
else if (glRefConfig.floatLightmap)
|
||||
{
|
||||
vec4_t color;
|
||||
|
||||
//hack: convert LDR lightmap to HDR one
|
||||
color[0] = MAX(buf_p[j*3+0], 0.499f);
|
||||
color[1] = MAX(buf_p[j*3+1], 0.499f);
|
||||
color[2] = MAX(buf_p[j*3+2], 0.499f);
|
||||
|
||||
// if under an arbitrary value (say 12) grey it out
|
||||
// this prevents weird splotches in dimly lit areas
|
||||
if (color[0] + color[1] + color[2] < 12.0f)
|
||||
{
|
||||
float avg = (color[0] + color[1] + color[2]) * 0.3333f;
|
||||
color[0] = avg;
|
||||
color[1] = avg;
|
||||
color[2] = avg;
|
||||
}
|
||||
color[3] = 1.0f;
|
||||
|
||||
R_ColorShiftLightingFloats(color, color, 1.0f/255.0f);
|
||||
|
||||
ColorToRGBA16F(color, (unsigned short *)(&image[j*8]));
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( r_lightmap->integer == 2 )
|
||||
|
@ -737,9 +736,9 @@ static void ParseFace( dsurface_t *ds, drawVert_t *verts, float *hdrVertColors,
|
|||
//hack: convert LDR vertex colors to HDR
|
||||
if (r_hdr->integer)
|
||||
{
|
||||
color[0] = verts[i].color[0] + 1.0f;
|
||||
color[1] = verts[i].color[1] + 1.0f;
|
||||
color[2] = verts[i].color[2] + 1.0f;
|
||||
color[0] = MAX(verts[i].color[0], 0.499f);
|
||||
color[1] = MAX(verts[i].color[1], 0.499f);
|
||||
color[2] = MAX(verts[i].color[2], 0.499f);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -881,9 +880,9 @@ static void ParseMesh ( dsurface_t *ds, drawVert_t *verts, float *hdrVertColors,
|
|||
//hack: convert LDR vertex colors to HDR
|
||||
if (r_hdr->integer)
|
||||
{
|
||||
color[0] = verts[i].color[0] + 1.0f;
|
||||
color[1] = verts[i].color[1] + 1.0f;
|
||||
color[2] = verts[i].color[2] + 1.0f;
|
||||
color[0] = MAX(verts[i].color[0], 0.499f);
|
||||
color[1] = MAX(verts[i].color[1], 0.499f);
|
||||
color[2] = MAX(verts[i].color[2], 0.499f);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -982,9 +981,9 @@ static void ParseTriSurf( dsurface_t *ds, drawVert_t *verts, float *hdrVertColor
|
|||
//hack: convert LDR vertex colors to HDR
|
||||
if (r_hdr->integer)
|
||||
{
|
||||
color[0] = verts[i].color[0] + 1.0f;
|
||||
color[1] = verts[i].color[1] + 1.0f;
|
||||
color[2] = verts[i].color[2] + 1.0f;
|
||||
color[0] = MAX(verts[i].color[0], 0.499f);
|
||||
color[1] = MAX(verts[i].color[1], 0.499f);
|
||||
color[2] = MAX(verts[i].color[2], 0.499f);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -725,4 +725,7 @@ void GLimp_InitExtraExtensions()
|
|||
{
|
||||
ri.Printf(PRINT_ALL, result[2], extension);
|
||||
}
|
||||
|
||||
// use float lightmaps?
|
||||
glRefConfig.floatLightmap = (glRefConfig.textureFloat && glRefConfig.halfFloatPixel && r_floatLightmap->integer && r_hdr->integer);
|
||||
}
|
||||
|
|
|
@ -903,7 +903,7 @@ void GLSL_InitGPUShaders(void)
|
|||
if (i & GENERICDEF_USE_LIGHTMAP)
|
||||
Q_strcat(extradefines, 1024, "#define USE_LIGHTMAP\n");
|
||||
|
||||
if (r_hdr->integer && !(glRefConfig.textureFloat && glRefConfig.halfFloatPixel && r_floatLightmap->integer))
|
||||
if (r_hdr->integer && !glRefConfig.floatLightmap)
|
||||
Q_strcat(extradefines, 1024, "#define RGBM_LIGHTMAP\n");
|
||||
|
||||
if (!GLSL_InitGPUShader(&tr.genericShader[i], "generic", attribs, qtrue, extradefines, qtrue, fallbackShader_generic_vp, fallbackShader_generic_fp))
|
||||
|
@ -1022,7 +1022,7 @@ void GLSL_InitGPUShaders(void)
|
|||
if (1)
|
||||
Q_strcat(extradefines, 1024, "#define SWIZZLE_NORMALMAP\n");
|
||||
|
||||
if (r_hdr->integer && !(glRefConfig.textureFloat && glRefConfig.halfFloatPixel && r_floatLightmap->integer))
|
||||
if (r_hdr->integer && !glRefConfig.floatLightmap)
|
||||
Q_strcat(extradefines, 1024, "#define RGBM_LIGHTMAP\n");
|
||||
|
||||
if (lightType)
|
||||
|
|
|
@ -1425,6 +1425,8 @@ typedef struct {
|
|||
qboolean seamlessCubeMap;
|
||||
|
||||
GLenum packedNormalDataType;
|
||||
|
||||
qboolean floatLightmap;
|
||||
} glRefConfig_t;
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue