mirror of
https://github.com/DrBeef/ioq3quest.git
synced 2025-03-21 01:10:59 +00:00
OpenGL2: Store vertex colors and hdr lightmaps/lightgrid as RGBA16.
This commit is contained in:
parent
239f539702
commit
aa79738c50
15 changed files with 240 additions and 184 deletions
|
@ -881,14 +881,14 @@ const void *RB_StretchPic ( const void *data ) {
|
|||
tess.indexes[ numIndexes + 5 ] = numVerts + 1;
|
||||
|
||||
{
|
||||
vec4_t color;
|
||||
uint16_t color[4];
|
||||
|
||||
VectorScale4(backEnd.color2D, 1.0f / 255.0f, color);
|
||||
VectorScale4(backEnd.color2D, 257, color);
|
||||
|
||||
VectorCopy4(color, tess.vertexColors[ numVerts ]);
|
||||
VectorCopy4(color, tess.vertexColors[ numVerts + 1]);
|
||||
VectorCopy4(color, tess.vertexColors[ numVerts + 2]);
|
||||
VectorCopy4(color, tess.vertexColors[ numVerts + 3 ]);
|
||||
VectorCopy4(color, tess.color[ numVerts ]);
|
||||
VectorCopy4(color, tess.color[ numVerts + 1]);
|
||||
VectorCopy4(color, tess.color[ numVerts + 2]);
|
||||
VectorCopy4(color, tess.color[ numVerts + 3 ]);
|
||||
}
|
||||
|
||||
tess.xyz[ numVerts ][0] = cmd->x;
|
||||
|
|
|
@ -136,11 +136,10 @@ R_ColorShiftLightingFloats
|
|||
|
||||
===============
|
||||
*/
|
||||
static void R_ColorShiftLightingFloats(float in[4], float out[4], float scale )
|
||||
static void R_ColorShiftLightingFloats(float in[4], float out[4])
|
||||
{
|
||||
float r, g, b;
|
||||
|
||||
scale *= 1 << (r_mapOverBrightBits->integer - tr.overbrightBits);
|
||||
float scale = (1 << (r_mapOverBrightBits->integer - tr.overbrightBits)) / 255.0f;
|
||||
|
||||
r = in[0] * scale;
|
||||
g = in[1] * scale;
|
||||
|
@ -185,12 +184,11 @@ void ColorToRGBM(const vec3_t color, unsigned char rgbm[4])
|
|||
rgbm[2] = (unsigned char) (sample[2] * 255);
|
||||
}
|
||||
|
||||
void ColorToRGBA16F(const vec3_t color, unsigned short rgba16f[4])
|
||||
void ColorToRGB16(const vec3_t color, uint16_t rgb16[3])
|
||||
{
|
||||
rgba16f[0] = FloatToHalf(color[0]);
|
||||
rgba16f[1] = FloatToHalf(color[1]);
|
||||
rgba16f[2] = FloatToHalf(color[2]);
|
||||
rgba16f[3] = FloatToHalf(1.0f);
|
||||
rgb16[0] = color[0] * 65535.0f + 0.5f;
|
||||
rgb16[1] = color[1] * 65535.0f + 0.5f;
|
||||
rgb16[2] = color[2] * 65535.0f + 0.5f;
|
||||
}
|
||||
|
||||
|
||||
|
@ -277,10 +275,16 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) {
|
|||
if (tr.worldDeluxeMapping)
|
||||
tr.deluxemaps = ri.Hunk_Alloc( tr.numLightmaps * sizeof(image_t *), h_low );
|
||||
|
||||
if (glRefConfig.floatLightmap)
|
||||
textureInternalFormat = GL_RGBA16F_ARB;
|
||||
else
|
||||
textureInternalFormat = GL_RGBA8;
|
||||
textureInternalFormat = GL_RGBA8;
|
||||
if (r_hdr->integer)
|
||||
{
|
||||
// Check for the first hdr lightmap, if it exists, use GL_RGBA16 for textures.
|
||||
char filename[MAX_QPATH];
|
||||
|
||||
Com_sprintf(filename, sizeof(filename), "maps/%s/lm_0000.hdr", s_worldData.baseName);
|
||||
if (ri.FS_FileExists(filename))
|
||||
textureInternalFormat = GL_RGBA16;
|
||||
}
|
||||
|
||||
if (r_mergeLightmaps->integer)
|
||||
{
|
||||
|
@ -318,7 +322,7 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) {
|
|||
int size = 0;
|
||||
|
||||
// look for hdr lightmaps
|
||||
if (r_hdr->integer)
|
||||
if (textureInternalFormat == GL_RGBA16)
|
||||
{
|
||||
Com_sprintf( filename, sizeof( filename ), "maps/%s/lm_%04d.hdr", s_worldData.baseName, i * (tr.worldDeluxeMapping ? 2 : 1) );
|
||||
//ri.Printf(PRINT_ALL, "looking for %s\n", filename);
|
||||
|
@ -382,14 +386,12 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) {
|
|||
#endif
|
||||
color[3] = 1.0f;
|
||||
|
||||
R_ColorShiftLightingFloats(color, color, 1.0f/255.0f);
|
||||
R_ColorShiftLightingFloats(color, color);
|
||||
|
||||
if (glRefConfig.floatLightmap)
|
||||
ColorToRGBA16F(color, (unsigned short *)(&image[j*8]));
|
||||
else
|
||||
ColorToRGBM(color, &image[j*4]);
|
||||
ColorToRGB16(color, (uint16_t *)(&image[j * 8]));
|
||||
((uint16_t *)(&image[j * 8]))[3] = 65535;
|
||||
}
|
||||
else if (glRefConfig.floatLightmap)
|
||||
else if (textureInternalFormat == GL_RGBA16)
|
||||
{
|
||||
vec4_t color;
|
||||
|
||||
|
@ -409,9 +411,10 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) {
|
|||
}
|
||||
color[3] = 1.0f;
|
||||
|
||||
R_ColorShiftLightingFloats(color, color, 1.0f/255.0f);
|
||||
R_ColorShiftLightingFloats(color, color);
|
||||
|
||||
ColorToRGBA16F(color, (unsigned short *)(&image[j*8]));
|
||||
ColorToRGB16(color, (uint16_t *)(&image[j * 8]));
|
||||
((uint16_t *)(&image[j * 8]))[3] = 65535;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -679,7 +682,8 @@ void LoadDrawVertToSrfVert(srfVert_t *s, drawVert_t *d, int realLightmapNum, flo
|
|||
}
|
||||
v[3] = d->color[3] / 255.0f;
|
||||
|
||||
R_ColorShiftLightingFloats(v, s->vertexColors, 1.0f / 255.0f);
|
||||
R_ColorShiftLightingFloats(v, v);
|
||||
R_VaoPackColor(s->color, v);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1738,7 +1742,7 @@ static void CopyVert(const srfVert_t * in, srfVert_t * out)
|
|||
VectorCopy2(in->st, out->st);
|
||||
VectorCopy2(in->lightmap, out->lightmap);
|
||||
|
||||
VectorCopy4(in->vertexColors, out->vertexColors);
|
||||
VectorCopy4(in->color, out->color);
|
||||
}
|
||||
|
||||
|
||||
|
@ -2636,25 +2640,47 @@ void R_LoadLightGrid( lump_t *l ) {
|
|||
|
||||
if (hdrLightGrid)
|
||||
{
|
||||
float lightScale = 1 << (r_mapOverBrightBits->integer - tr.overbrightBits);
|
||||
|
||||
//ri.Printf(PRINT_ALL, "found!\n");
|
||||
|
||||
if (size != sizeof(float) * 6 * numGridPoints)
|
||||
{
|
||||
ri.Error(ERR_DROP, "Bad size for %s (%i, expected %i)!", filename, size, (int)(sizeof(float)) * 6 * numGridPoints);
|
||||
}
|
||||
|
||||
w->hdrLightGrid = ri.Hunk_Alloc(size, h_low);
|
||||
w->lightGrid16 = ri.Hunk_Alloc(sizeof(w->lightGrid16) * 6 * numGridPoints, h_low);
|
||||
|
||||
for (i = 0; i < numGridPoints ; i++)
|
||||
{
|
||||
w->hdrLightGrid[i * 6 ] = hdrLightGrid[i * 6 ] * lightScale;
|
||||
w->hdrLightGrid[i * 6 + 1] = hdrLightGrid[i * 6 + 1] * lightScale;
|
||||
w->hdrLightGrid[i * 6 + 2] = hdrLightGrid[i * 6 + 2] * lightScale;
|
||||
w->hdrLightGrid[i * 6 + 3] = hdrLightGrid[i * 6 + 3] * lightScale;
|
||||
w->hdrLightGrid[i * 6 + 4] = hdrLightGrid[i * 6 + 4] * lightScale;
|
||||
w->hdrLightGrid[i * 6 + 5] = hdrLightGrid[i * 6 + 5] * lightScale;
|
||||
vec4_t c;
|
||||
|
||||
c[0] = hdrLightGrid[i * 6];
|
||||
c[1] = hdrLightGrid[i * 6 + 1];
|
||||
c[2] = hdrLightGrid[i * 6 + 2];
|
||||
c[3] = 1.0f;
|
||||
|
||||
R_ColorShiftLightingFloats(c, c);
|
||||
ColorToRGB16(c, &w->lightGrid16[i * 6]);
|
||||
|
||||
c[0] = hdrLightGrid[i * 6 + 3];
|
||||
c[1] = hdrLightGrid[i * 6 + 4];
|
||||
c[2] = hdrLightGrid[i * 6 + 5];
|
||||
c[3] = 1.0f;
|
||||
|
||||
R_ColorShiftLightingFloats(c, c);
|
||||
ColorToRGB16(c, &w->lightGrid16[i * 6 + 3]);
|
||||
}
|
||||
}
|
||||
else if (0)
|
||||
{
|
||||
// promote 8-bit lightgrid to 16-bit
|
||||
w->lightGrid16 = ri.Hunk_Alloc(sizeof(w->lightGrid16) * 6 * numGridPoints, h_low);
|
||||
|
||||
for (i = 0; i < numGridPoints; i++)
|
||||
{
|
||||
w->lightGrid16[i * 6] = w->lightGridData[i * 8] * 257;
|
||||
w->lightGrid16[i * 6 + 1] = w->lightGridData[i * 8 + 1] * 257;
|
||||
w->lightGrid16[i * 6 + 2] = w->lightGridData[i * 8 + 2] * 257;
|
||||
w->lightGrid16[i * 6 + 3] = w->lightGridData[i * 8 + 3] * 257;
|
||||
w->lightGrid16[i * 6 + 4] = w->lightGridData[i * 8 + 4] * 257;
|
||||
w->lightGrid16[i * 6 + 5] = w->lightGridData[i * 8 + 5] * 257;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -54,10 +54,10 @@ static void LerpDrawVert( srfVert_t *a, srfVert_t *b, srfVert_t *out ) {
|
|||
out->lightmap[0] = 0.5f * (a->lightmap[0] + b->lightmap[0]);
|
||||
out->lightmap[1] = 0.5f * (a->lightmap[1] + b->lightmap[1]);
|
||||
|
||||
out->vertexColors[0] = 0.5f * (a->vertexColors[0] + b->vertexColors[0]);
|
||||
out->vertexColors[1] = 0.5f * (a->vertexColors[1] + b->vertexColors[1]);
|
||||
out->vertexColors[2] = 0.5f * (a->vertexColors[2] + b->vertexColors[2]);
|
||||
out->vertexColors[3] = 0.5f * (a->vertexColors[3] + b->vertexColors[3]);
|
||||
out->color[0] = ((int)a->color[0] + (int)b->color[0]) >> 1;
|
||||
out->color[1] = ((int)a->color[1] + (int)b->color[1]) >> 1;
|
||||
out->color[2] = ((int)a->color[2] + (int)b->color[2]) >> 1;
|
||||
out->color[3] = ((int)a->color[3] + (int)b->color[3]) >> 1;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -295,9 +295,6 @@ 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);
|
||||
|
||||
// GL_ARB_vertex_array_object
|
||||
extension = "GL_ARB_vertex_array_object";
|
||||
glRefConfig.vertexArrayObject = qfalse;
|
||||
|
@ -318,8 +315,6 @@ void GLimp_InitExtraExtensions()
|
|||
extension = "GL_ARB_half_float_vertex";
|
||||
glRefConfig.packedTexcoordDataType = GL_FLOAT;
|
||||
glRefConfig.packedTexcoordDataSize = sizeof(float) * 2;
|
||||
glRefConfig.packedColorDataType = GL_FLOAT;
|
||||
glRefConfig.packedColorDataSize = sizeof(float) * 4;
|
||||
if( GLimp_HaveExtension( extension ) )
|
||||
{
|
||||
qboolean useExt = !!r_arb_half_float_vertex->integer;
|
||||
|
@ -328,8 +323,6 @@ void GLimp_InitExtraExtensions()
|
|||
{
|
||||
glRefConfig.packedTexcoordDataType = GL_HALF_FLOAT;
|
||||
glRefConfig.packedTexcoordDataSize = sizeof(uint16_t) * 2;
|
||||
glRefConfig.packedColorDataType = GL_HALF_FLOAT;
|
||||
glRefConfig.packedColorDataSize = sizeof(uint16_t) * 4;
|
||||
}
|
||||
|
||||
ri.Printf(PRINT_ALL, result[useExt], extension);
|
||||
|
|
|
@ -201,7 +201,7 @@ int NextPowerOfTwo(int in)
|
|||
|
||||
union f32_u {
|
||||
float f;
|
||||
uint32_t i;
|
||||
uint32_t ui;
|
||||
struct {
|
||||
unsigned int fraction:23;
|
||||
unsigned int exponent:8;
|
||||
|
@ -210,7 +210,7 @@ union f32_u {
|
|||
};
|
||||
|
||||
union f16_u {
|
||||
uint16_t i;
|
||||
uint16_t ui;
|
||||
struct {
|
||||
unsigned int fraction:10;
|
||||
unsigned int exponent:5;
|
||||
|
@ -229,5 +229,19 @@ uint16_t FloatToHalf(float in)
|
|||
f16.pack.fraction = f32.pack.fraction >> 13;
|
||||
f16.pack.sign = f32.pack.sign;
|
||||
|
||||
return f16.i;
|
||||
return f16.ui;
|
||||
}
|
||||
|
||||
float HalfToFloat(uint16_t in)
|
||||
{
|
||||
union f32_u f32;
|
||||
union f16_u f16;
|
||||
|
||||
f16.ui = in;
|
||||
|
||||
f32.pack.exponent = (int)(f16.pack.exponent) + 112;
|
||||
f32.pack.fraction = f16.pack.fraction << 13;
|
||||
f32.pack.sign = f16.pack.sign;
|
||||
|
||||
return f32.f;
|
||||
}
|
||||
|
|
|
@ -98,5 +98,6 @@ void BoundingSphereOfSpheres(vec3_t origin1, float radius1, vec3_t origin2, floa
|
|||
|
||||
int NextPowerOfTwo(int in);
|
||||
unsigned short FloatToHalf(float in);
|
||||
float HalfToFloat(unsigned short in);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -395,9 +395,9 @@ void RB_RenderFlare( flare_t *f ) {
|
|||
return;
|
||||
}
|
||||
|
||||
iColor[0] = color[0] * fogFactors[0];
|
||||
iColor[1] = color[1] * fogFactors[1];
|
||||
iColor[2] = color[2] * fogFactors[2];
|
||||
iColor[0] = color[0] * fogFactors[0] * 257;
|
||||
iColor[1] = color[1] * fogFactors[1] * 257;
|
||||
iColor[2] = color[2] * fogFactors[2] * 257;
|
||||
|
||||
RB_BeginSurface( tr.flareShader, f->fogNum, 0 );
|
||||
|
||||
|
@ -406,40 +406,40 @@ void RB_RenderFlare( flare_t *f ) {
|
|||
tess.xyz[tess.numVertexes][1] = f->windowY - size;
|
||||
tess.texCoords[tess.numVertexes][0][0] = 0;
|
||||
tess.texCoords[tess.numVertexes][0][1] = 0;
|
||||
tess.vertexColors[tess.numVertexes][0] = iColor[0] / 255.0f;
|
||||
tess.vertexColors[tess.numVertexes][1] = iColor[1] / 255.0f;
|
||||
tess.vertexColors[tess.numVertexes][2] = iColor[2] / 255.0f;
|
||||
tess.vertexColors[tess.numVertexes][3] = 1.0f;
|
||||
tess.color[tess.numVertexes][0] = iColor[0];
|
||||
tess.color[tess.numVertexes][1] = iColor[1];
|
||||
tess.color[tess.numVertexes][2] = iColor[2];
|
||||
tess.color[tess.numVertexes][3] = 65535;
|
||||
tess.numVertexes++;
|
||||
|
||||
tess.xyz[tess.numVertexes][0] = f->windowX - size;
|
||||
tess.xyz[tess.numVertexes][1] = f->windowY + size;
|
||||
tess.texCoords[tess.numVertexes][0][0] = 0;
|
||||
tess.texCoords[tess.numVertexes][0][1] = 1;
|
||||
tess.vertexColors[tess.numVertexes][0] = iColor[0] / 255.0f;
|
||||
tess.vertexColors[tess.numVertexes][1] = iColor[1] / 255.0f;
|
||||
tess.vertexColors[tess.numVertexes][2] = iColor[2] / 255.0f;
|
||||
tess.vertexColors[tess.numVertexes][3] = 1.0f;
|
||||
tess.color[tess.numVertexes][0] = iColor[0];
|
||||
tess.color[tess.numVertexes][1] = iColor[1];
|
||||
tess.color[tess.numVertexes][2] = iColor[2];
|
||||
tess.color[tess.numVertexes][3] = 65535;
|
||||
tess.numVertexes++;
|
||||
|
||||
tess.xyz[tess.numVertexes][0] = f->windowX + size;
|
||||
tess.xyz[tess.numVertexes][1] = f->windowY + size;
|
||||
tess.texCoords[tess.numVertexes][0][0] = 1;
|
||||
tess.texCoords[tess.numVertexes][0][1] = 1;
|
||||
tess.vertexColors[tess.numVertexes][0] = iColor[0] / 255.0f;
|
||||
tess.vertexColors[tess.numVertexes][1] = iColor[1] / 255.0f;
|
||||
tess.vertexColors[tess.numVertexes][2] = iColor[2] / 255.0f;
|
||||
tess.vertexColors[tess.numVertexes][3] = 1.0f;
|
||||
tess.color[tess.numVertexes][0] = iColor[0];
|
||||
tess.color[tess.numVertexes][1] = iColor[1];
|
||||
tess.color[tess.numVertexes][2] = iColor[2];
|
||||
tess.color[tess.numVertexes][3] = 65535;
|
||||
tess.numVertexes++;
|
||||
|
||||
tess.xyz[tess.numVertexes][0] = f->windowX + size;
|
||||
tess.xyz[tess.numVertexes][1] = f->windowY - size;
|
||||
tess.texCoords[tess.numVertexes][0][0] = 1;
|
||||
tess.texCoords[tess.numVertexes][0][1] = 0;
|
||||
tess.vertexColors[tess.numVertexes][0] = iColor[0] / 255.0f;
|
||||
tess.vertexColors[tess.numVertexes][1] = iColor[1] / 255.0f;
|
||||
tess.vertexColors[tess.numVertexes][2] = iColor[2] / 255.0f;
|
||||
tess.vertexColors[tess.numVertexes][3] = 1.0f;
|
||||
tess.color[tess.numVertexes][0] = iColor[0];
|
||||
tess.color[tess.numVertexes][1] = iColor[1];
|
||||
tess.color[tess.numVertexes][2] = iColor[2];
|
||||
tess.color[tess.numVertexes][3] = 65535;
|
||||
tess.numVertexes++;
|
||||
|
||||
tess.indexes[tess.numIndexes++] = 0;
|
||||
|
|
|
@ -1028,9 +1028,6 @@ void GLSL_InitGPUShaders(void)
|
|||
if (glRefConfig.swizzleNormalmap)
|
||||
Q_strcat(extradefines, 1024, "#define SWIZZLE_NORMALMAP\n");
|
||||
|
||||
if (r_hdr->integer && !glRefConfig.floatLightmap)
|
||||
Q_strcat(extradefines, 1024, "#define RGBM_LIGHTMAP\n");
|
||||
|
||||
if (lightType)
|
||||
{
|
||||
Q_strcat(extradefines, 1024, "#define USE_LIGHT\n");
|
||||
|
|
|
@ -150,12 +150,12 @@ void R_ImageList_f( void ) {
|
|||
int i;
|
||||
int estTotalSize = 0;
|
||||
|
||||
ri.Printf(PRINT_ALL, "\n -w-- -h-- type -size- --name-------\n");
|
||||
ri.Printf(PRINT_ALL, "\n -w-- -h-- -type-- -size- --name-------\n");
|
||||
|
||||
for ( i = 0 ; i < tr.numImages ; i++ )
|
||||
{
|
||||
image_t *image = tr.images[i];
|
||||
char *format = "???? ";
|
||||
char *format = "???? ";
|
||||
char *sizeSuffix;
|
||||
int estSize;
|
||||
int displaySize;
|
||||
|
@ -165,95 +165,121 @@ void R_ImageList_f( void ) {
|
|||
switch(image->internalFormat)
|
||||
{
|
||||
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
|
||||
format = "sDXT1";
|
||||
format = "sDXT1 ";
|
||||
// 64 bits per 16 pixels, so 4 bits per pixel
|
||||
estSize /= 2;
|
||||
break;
|
||||
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
|
||||
format = "sDXT5";
|
||||
format = "sDXT5 ";
|
||||
// 128 bits per 16 pixels, so 1 byte per pixel
|
||||
break;
|
||||
case GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB:
|
||||
format = "sBPTC";
|
||||
format = "sBPTC ";
|
||||
// 128 bits per 16 pixels, so 1 byte per pixel
|
||||
break;
|
||||
case GL_COMPRESSED_RG_RGTC2:
|
||||
format = "RGTC2";
|
||||
format = "RGTC2 ";
|
||||
// 128 bits per 16 pixels, so 1 byte per pixel
|
||||
break;
|
||||
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
|
||||
format = "DXT1 ";
|
||||
format = "DXT1 ";
|
||||
// 64 bits per 16 pixels, so 4 bits per pixel
|
||||
estSize /= 2;
|
||||
break;
|
||||
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
|
||||
format = "DXT1a";
|
||||
format = "DXT1a ";
|
||||
// 64 bits per 16 pixels, so 4 bits per pixel
|
||||
estSize /= 2;
|
||||
break;
|
||||
case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
|
||||
format = "DXT5 ";
|
||||
format = "DXT5 ";
|
||||
// 128 bits per 16 pixels, so 1 byte per pixel
|
||||
break;
|
||||
case GL_COMPRESSED_RGBA_BPTC_UNORM_ARB:
|
||||
format = "BPTC ";
|
||||
format = "BPTC ";
|
||||
// 128 bits per 16 pixels, so 1 byte per pixel
|
||||
break;
|
||||
case GL_RGB4_S3TC:
|
||||
format = "S3TC ";
|
||||
format = "S3TC ";
|
||||
// same as DXT1?
|
||||
estSize /= 2;
|
||||
break;
|
||||
case GL_RGBA16F:
|
||||
format = "RGBA16F";
|
||||
// 8 bytes per pixel
|
||||
estSize *= 8;
|
||||
break;
|
||||
case GL_RGBA16:
|
||||
format = "RGBA16 ";
|
||||
// 8 bytes per pixel
|
||||
estSize *= 8;
|
||||
break;
|
||||
case GL_RGBA4:
|
||||
case GL_RGBA8:
|
||||
case GL_RGBA:
|
||||
format = "RGBA ";
|
||||
format = "RGBA ";
|
||||
// 4 bytes per pixel
|
||||
estSize *= 4;
|
||||
break;
|
||||
case GL_LUMINANCE8:
|
||||
case GL_LUMINANCE16:
|
||||
case GL_LUMINANCE:
|
||||
format = "L ";
|
||||
format = "L ";
|
||||
// 1 byte per pixel?
|
||||
break;
|
||||
case GL_RGB5:
|
||||
case GL_RGB8:
|
||||
case GL_RGB:
|
||||
format = "RGB ";
|
||||
format = "RGB ";
|
||||
// 3 bytes per pixel?
|
||||
estSize *= 3;
|
||||
break;
|
||||
case GL_LUMINANCE8_ALPHA8:
|
||||
case GL_LUMINANCE16_ALPHA16:
|
||||
case GL_LUMINANCE_ALPHA:
|
||||
format = "LA ";
|
||||
format = "LA ";
|
||||
// 2 bytes per pixel?
|
||||
estSize *= 2;
|
||||
break;
|
||||
case GL_SRGB_EXT:
|
||||
case GL_SRGB8_EXT:
|
||||
format = "sRGB ";
|
||||
format = "sRGB ";
|
||||
// 3 bytes per pixel?
|
||||
estSize *= 3;
|
||||
break;
|
||||
case GL_SRGB_ALPHA_EXT:
|
||||
case GL_SRGB8_ALPHA8_EXT:
|
||||
format = "sRGBA";
|
||||
format = "sRGBA ";
|
||||
// 4 bytes per pixel?
|
||||
estSize *= 4;
|
||||
break;
|
||||
case GL_SLUMINANCE_EXT:
|
||||
case GL_SLUMINANCE8_EXT:
|
||||
format = "sL ";
|
||||
format = "sL ";
|
||||
// 1 byte per pixel?
|
||||
break;
|
||||
case GL_SLUMINANCE_ALPHA_EXT:
|
||||
case GL_SLUMINANCE8_ALPHA8_EXT:
|
||||
format = "sLA ";
|
||||
format = "sLA ";
|
||||
// 2 byte per pixel?
|
||||
estSize *= 2;
|
||||
break;
|
||||
case GL_DEPTH_COMPONENT16:
|
||||
format = "Depth16";
|
||||
// 2 bytes per pixel
|
||||
estSize *= 2;
|
||||
break;
|
||||
case GL_DEPTH_COMPONENT24:
|
||||
format = "Depth24";
|
||||
// 3 bytes per pixel
|
||||
estSize *= 3;
|
||||
break;
|
||||
case GL_DEPTH_COMPONENT:
|
||||
case GL_DEPTH_COMPONENT32:
|
||||
format = "Depth32";
|
||||
// 4 bytes per pixel
|
||||
estSize *= 4;
|
||||
break;
|
||||
}
|
||||
|
||||
// mipmap adds about 50%
|
||||
|
@ -1931,7 +1957,20 @@ static void RawImage_UploadTexture(GLuint texture, byte *data, int x, int y, int
|
|||
dataFormat = PixelDataFormatFromInternalFormat(internalFormat);
|
||||
|
||||
// FIXME: This is an old hack to use half floats with lightmaps, use picFormat to determine this instead.
|
||||
dataType = (internalFormat == GL_RGBA16F_ARB) ? GL_HALF_FLOAT_ARB : GL_UNSIGNED_BYTE;
|
||||
switch (internalFormat)
|
||||
{
|
||||
case GL_RGBA16F_ARB:
|
||||
dataType = GL_HALF_FLOAT_ARB;
|
||||
break;
|
||||
|
||||
case GL_RGBA16:
|
||||
dataType = GL_UNSIGNED_SHORT;
|
||||
break;
|
||||
|
||||
default:
|
||||
dataType = GL_UNSIGNED_BYTE;
|
||||
break;
|
||||
}
|
||||
|
||||
miplevel = 0;
|
||||
do
|
||||
|
|
|
@ -201,10 +201,10 @@ static void R_SetupEntityLightingGrid( trRefEntity_t *ent, world_t *world ) {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (world->hdrLightGrid)
|
||||
if (world->lightGrid16)
|
||||
{
|
||||
float *hdrData = world->hdrLightGrid + (int)(data - world->lightGridData) / 8 * 6;
|
||||
if (!(hdrData[0]+hdrData[1]+hdrData[2]+hdrData[3]+hdrData[4]+hdrData[5]) ) {
|
||||
uint16_t *data16 = world->lightGrid16 + (int)(data - world->lightGridData) / 8 * 6;
|
||||
if (!(data16[0]+data16[1]+data16[2]+data16[3]+data16[4]+data16[5])) {
|
||||
continue; // ignore samples in walls
|
||||
}
|
||||
}
|
||||
|
@ -227,18 +227,18 @@ static void R_SetupEntityLightingGrid( trRefEntity_t *ent, world_t *world ) {
|
|||
ent->directedLight[1] += factor * d4;
|
||||
ent->directedLight[2] += factor * d5;
|
||||
#else
|
||||
if (world->hdrLightGrid)
|
||||
if (world->lightGrid16)
|
||||
{
|
||||
// FIXME: this is hideous
|
||||
float *hdrData = world->hdrLightGrid + (int)(data - world->lightGridData) / 8 * 6;
|
||||
uint16_t *data16 = world->lightGrid16 + (int)(data - world->lightGridData) / 8 * 6;
|
||||
|
||||
ent->ambientLight[0] += factor * hdrData[0];
|
||||
ent->ambientLight[1] += factor * hdrData[1];
|
||||
ent->ambientLight[2] += factor * hdrData[2];
|
||||
ent->ambientLight[0] += factor * data16[0] / 257.0f;
|
||||
ent->ambientLight[1] += factor * data16[1] / 257.0f;
|
||||
ent->ambientLight[2] += factor * data16[2] / 257.0f;
|
||||
|
||||
ent->directedLight[0] += factor * hdrData[3];
|
||||
ent->directedLight[1] += factor * hdrData[4];
|
||||
ent->directedLight[2] += factor * hdrData[5];
|
||||
ent->directedLight[0] += factor * data16[3] / 257.0f;
|
||||
ent->directedLight[1] += factor * data16[4] / 257.0f;
|
||||
ent->directedLight[2] += factor * data16[5] / 257.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -894,7 +894,7 @@ typedef struct
|
|||
int16_t normal[4];
|
||||
int16_t tangent[4];
|
||||
int16_t lightdir[4];
|
||||
vec4_t vertexColors;
|
||||
uint16_t color[4];
|
||||
|
||||
#if DEBUG_OPTIMIZEVERTICES
|
||||
unsigned int id;
|
||||
|
@ -1153,7 +1153,7 @@ typedef struct {
|
|||
vec3_t lightGridInverseSize;
|
||||
int lightGridBounds[3];
|
||||
byte *lightGridData;
|
||||
float *hdrLightGrid;
|
||||
uint16_t *lightGrid16;
|
||||
|
||||
|
||||
int numClusters;
|
||||
|
@ -1399,11 +1399,8 @@ typedef struct {
|
|||
qboolean seamlessCubeMap;
|
||||
|
||||
GLenum packedTexcoordDataType;
|
||||
GLenum packedColorDataType;
|
||||
int packedTexcoordDataSize;
|
||||
int packedColorDataSize;
|
||||
|
||||
qboolean floatLightmap;
|
||||
qboolean vertexArrayObject;
|
||||
qboolean directStateAccess;
|
||||
} glRefConfig_t;
|
||||
|
@ -1994,7 +1991,7 @@ typedef struct shaderCommands_s
|
|||
int16_t normal[SHADER_MAX_VERTEXES][4] QALIGN(16);
|
||||
int16_t tangent[SHADER_MAX_VERTEXES][4] QALIGN(16);
|
||||
vec2_t texCoords[SHADER_MAX_VERTEXES][2] QALIGN(16);
|
||||
vec4_t vertexColors[SHADER_MAX_VERTEXES] QALIGN(16);
|
||||
uint16_t color[SHADER_MAX_VERTEXES][4] QALIGN(16);
|
||||
int16_t lightdir[SHADER_MAX_VERTEXES][4] QALIGN(16);
|
||||
//int vertexDlightBits[SHADER_MAX_VERTEXES] QALIGN(16);
|
||||
|
||||
|
@ -2161,7 +2158,7 @@ VERTEX BUFFER OBJECTS
|
|||
void R_VaoPackTangent(int16_t *out, vec4_t v);
|
||||
void R_VaoPackNormal(int16_t *out, vec3_t v);
|
||||
int R_VaoPackTexCoord(byte *out, vec2_t st);
|
||||
int R_VaoPackColors(byte *out, vec4_t color);
|
||||
void R_VaoPackColor(uint16_t *out, vec4_t c);
|
||||
void R_VaoUnpackTangent(vec4_t v, int16_t *pack);
|
||||
void R_VaoUnpackNormal(vec3_t v, int16_t *pack);
|
||||
|
||||
|
|
|
@ -1027,7 +1027,7 @@ void RB_IQMSurfaceAnim( surfaceType_t *surface ) {
|
|||
int16_t *outNormal;
|
||||
int16_t *outTangent;
|
||||
vec2_t (*outTexCoord)[2];
|
||||
vec4_t *outColor;
|
||||
uint16_t *outColor;
|
||||
|
||||
int frame = data->num_frames ? backEnd.currentEntity->e.frame % data->num_frames : 0;
|
||||
int oldframe = data->num_frames ? backEnd.currentEntity->e.oldframe % data->num_frames : 0;
|
||||
|
@ -1043,7 +1043,7 @@ void RB_IQMSurfaceAnim( surfaceType_t *surface ) {
|
|||
outNormal = tess.normal[tess.numVertexes];
|
||||
outTangent = tess.tangent[tess.numVertexes];
|
||||
outTexCoord = &tess.texCoords[tess.numVertexes];
|
||||
outColor = &tess.vertexColors[tess.numVertexes];
|
||||
outColor = tess.color[tess.numVertexes];
|
||||
|
||||
// compute interpolated joint matrices
|
||||
if ( data->num_poses > 0 ) {
|
||||
|
@ -1052,7 +1052,7 @@ void RB_IQMSurfaceAnim( surfaceType_t *surface ) {
|
|||
|
||||
// transform vertexes and fill other data
|
||||
for( i = 0; i < surf->num_vertexes;
|
||||
i++, outXYZ++, outNormal+=4, outTexCoord++, outColor++ ) {
|
||||
i++, outXYZ++, outNormal+=4, outTexCoord++, outColor+=4 ) {
|
||||
int j, k;
|
||||
float vtxMat[12];
|
||||
float nrmMat[9];
|
||||
|
@ -1137,10 +1137,10 @@ void RB_IQMSurfaceAnim( surfaceType_t *surface ) {
|
|||
outTangent+=4;
|
||||
}
|
||||
|
||||
(*outColor)[0] = data->colors[4*vtx+0] / 255.0f;
|
||||
(*outColor)[1] = data->colors[4*vtx+1] / 255.0f;
|
||||
(*outColor)[2] = data->colors[4*vtx+2] / 255.0f;
|
||||
(*outColor)[3] = data->colors[4*vtx+3] / 255.0f;
|
||||
outColor[0] = data->colors[4*vtx+0] * 257;
|
||||
outColor[1] = data->colors[4*vtx+1] * 257;
|
||||
outColor[2] = data->colors[4*vtx+2] * 257;
|
||||
outColor[3] = data->colors[4*vtx+3] * 257;
|
||||
}
|
||||
|
||||
tri = data->triangles + 3 * surf->first_triangle;
|
||||
|
|
|
@ -384,6 +384,7 @@ static void AutospriteDeform( void ) {
|
|||
}
|
||||
|
||||
for ( i = 0 ; i < oldVerts ; i+=4 ) {
|
||||
vec4_t color;
|
||||
// find the midpoint
|
||||
xyz = tess.xyz[i];
|
||||
|
||||
|
@ -414,7 +415,8 @@ static void AutospriteDeform( void ) {
|
|||
VectorScale(up, axisLength, up);
|
||||
}
|
||||
|
||||
RB_AddQuadStamp( mid, left, up, tess.vertexColors[i] );
|
||||
VectorScale4(tess.color[i], 1.0f / 65535.0f, color);
|
||||
RB_AddQuadStamp( mid, left, up, color );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -89,6 +89,7 @@ RB_AddQuadStampExt
|
|||
void RB_AddQuadStampExt( vec3_t origin, vec3_t left, vec3_t up, float color[4], float s1, float t1, float s2, float t2 ) {
|
||||
vec3_t normal;
|
||||
int16_t iNormal[4];
|
||||
uint16_t iColor[4];
|
||||
int ndx;
|
||||
|
||||
RB_CheckVao(tess.vao);
|
||||
|
@ -148,10 +149,13 @@ void RB_AddQuadStampExt( vec3_t origin, vec3_t left, vec3_t up, float color[4],
|
|||
|
||||
// constant color all the way around
|
||||
// should this be identity and let the shader specify from entity?
|
||||
VectorCopy4(color, tess.vertexColors[ndx]);
|
||||
VectorCopy4(color, tess.vertexColors[ndx+1]);
|
||||
VectorCopy4(color, tess.vertexColors[ndx+2]);
|
||||
VectorCopy4(color, tess.vertexColors[ndx+3]);
|
||||
|
||||
R_VaoPackColor(iColor, color);
|
||||
|
||||
VectorCopy4(iColor, tess.color[ndx]);
|
||||
VectorCopy4(iColor, tess.color[ndx + 1]);
|
||||
VectorCopy4(iColor, tess.color[ndx + 2]);
|
||||
VectorCopy4(iColor, tess.color[ndx + 3]);
|
||||
|
||||
tess.numVertexes += 4;
|
||||
tess.numIndexes += 6;
|
||||
|
@ -296,10 +300,10 @@ static void RB_SurfacePolychain( srfPoly_t *p ) {
|
|||
VectorCopy( p->verts[i].xyz, tess.xyz[numv] );
|
||||
tess.texCoords[numv][0][0] = p->verts[i].st[0];
|
||||
tess.texCoords[numv][0][1] = p->verts[i].st[1];
|
||||
tess.vertexColors[numv][0] = p->verts[ i ].modulate[0] / 255.0f;
|
||||
tess.vertexColors[numv][1] = p->verts[ i ].modulate[1] / 255.0f;
|
||||
tess.vertexColors[numv][2] = p->verts[ i ].modulate[2] / 255.0f;
|
||||
tess.vertexColors[numv][3] = p->verts[ i ].modulate[3] / 255.0f;
|
||||
tess.color[numv][0] = (int)p->verts[i].modulate[0] * 257;
|
||||
tess.color[numv][1] = (int)p->verts[i].modulate[1] * 257;
|
||||
tess.color[numv][2] = (int)p->verts[i].modulate[2] * 257;
|
||||
tess.color[numv][3] = (int)p->verts[i].modulate[3] * 257;
|
||||
|
||||
numv++;
|
||||
}
|
||||
|
@ -325,7 +329,7 @@ static void RB_SurfaceVertsAndIndexes( int numVerts, srfVert_t *verts, int numIn
|
|||
int16_t *normal;
|
||||
int16_t *tangent;
|
||||
glIndex_t *outIndex;
|
||||
float *color;
|
||||
uint16_t *color;
|
||||
|
||||
RB_CheckVao(tess.vao);
|
||||
|
||||
|
@ -381,9 +385,9 @@ static void RB_SurfaceVertsAndIndexes( int numVerts, srfVert_t *verts, int numIn
|
|||
if ( tess.shader->vertexAttribs & ATTR_COLOR )
|
||||
{
|
||||
dv = verts;
|
||||
color = tess.vertexColors[ tess.numVertexes ];
|
||||
color = tess.color[ tess.numVertexes ];
|
||||
for ( i = 0 ; i < numVerts ; i++, dv++, color+=4 )
|
||||
VectorCopy4(dv->vertexColors, color);
|
||||
VectorCopy4(dv->color, color);
|
||||
}
|
||||
|
||||
if ( tess.shader->vertexAttribs & ATTR_LIGHTDIRECTION )
|
||||
|
@ -639,34 +643,34 @@ static void DoRailCore( const vec3_t start, const vec3_t end, const vec3_t up, f
|
|||
VectorMA( start, spanWidth, up, tess.xyz[tess.numVertexes] );
|
||||
tess.texCoords[tess.numVertexes][0][0] = 0;
|
||||
tess.texCoords[tess.numVertexes][0][1] = 0;
|
||||
tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0] * 0.25 / 255.0f;
|
||||
tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1] * 0.25 / 255.0f;
|
||||
tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2] * 0.25 / 255.0f;
|
||||
tess.color[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0] * 0.25f * 257.0f;
|
||||
tess.color[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1] * 0.25f * 257.0f;
|
||||
tess.color[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2] * 0.25f * 257.0f;
|
||||
tess.numVertexes++;
|
||||
|
||||
VectorMA( start, spanWidth2, up, tess.xyz[tess.numVertexes] );
|
||||
tess.texCoords[tess.numVertexes][0][0] = 0;
|
||||
tess.texCoords[tess.numVertexes][0][1] = 1;
|
||||
tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0] / 255.0f;
|
||||
tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1] / 255.0f;
|
||||
tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2] / 255.0f;
|
||||
tess.color[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0] * 257;
|
||||
tess.color[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1] * 257;
|
||||
tess.color[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2] * 257;
|
||||
tess.numVertexes++;
|
||||
|
||||
VectorMA( end, spanWidth, up, tess.xyz[tess.numVertexes] );
|
||||
|
||||
tess.texCoords[tess.numVertexes][0][0] = t;
|
||||
tess.texCoords[tess.numVertexes][0][1] = 0;
|
||||
tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0] / 255.0f;
|
||||
tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1] / 255.0f;
|
||||
tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2] / 255.0f;
|
||||
tess.color[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0] * 257;
|
||||
tess.color[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1] * 257;
|
||||
tess.color[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2] * 257;
|
||||
tess.numVertexes++;
|
||||
|
||||
VectorMA( end, spanWidth2, up, tess.xyz[tess.numVertexes] );
|
||||
tess.texCoords[tess.numVertexes][0][0] = t;
|
||||
tess.texCoords[tess.numVertexes][0][1] = 1;
|
||||
tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0] / 255.0f;
|
||||
tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1] / 255.0f;
|
||||
tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2] / 255.0f;
|
||||
tess.color[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0] * 257;
|
||||
tess.color[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1] * 257;
|
||||
tess.color[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2] * 257;
|
||||
tess.numVertexes++;
|
||||
|
||||
tess.indexes[tess.numIndexes++] = vbase;
|
||||
|
@ -723,9 +727,9 @@ static void DoRailDiscs( int numSegs, const vec3_t start, const vec3_t dir, cons
|
|||
VectorCopy( pos[j], tess.xyz[tess.numVertexes] );
|
||||
tess.texCoords[tess.numVertexes][0][0] = ( j < 2 );
|
||||
tess.texCoords[tess.numVertexes][0][1] = ( j && j != 3 );
|
||||
tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0] / 255.0f;
|
||||
tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1] / 255.0f;
|
||||
tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2] / 255.0f;
|
||||
tess.color[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0] * 257;
|
||||
tess.color[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1] * 257;
|
||||
tess.color[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2] * 257;
|
||||
tess.numVertexes++;
|
||||
|
||||
VectorAdd( pos[j], dir, pos[j] );
|
||||
|
@ -1010,7 +1014,7 @@ static void RB_SurfaceGrid( srfBspSurface_t *srf ) {
|
|||
float *texCoords, *lightCoords;
|
||||
int16_t *normal;
|
||||
int16_t *tangent;
|
||||
float *color;
|
||||
uint16_t *color;
|
||||
int16_t *lightdir;
|
||||
srfVert_t *dv;
|
||||
int rows, irows, vrows;
|
||||
|
@ -1100,7 +1104,7 @@ static void RB_SurfaceGrid( srfBspSurface_t *srf ) {
|
|||
tangent = tess.tangent[numVertexes];
|
||||
texCoords = tess.texCoords[numVertexes][0];
|
||||
lightCoords = tess.texCoords[numVertexes][1];
|
||||
color = tess.vertexColors[numVertexes];
|
||||
color = tess.color[numVertexes];
|
||||
lightdir = tess.lightdir[numVertexes];
|
||||
//vDlightBits = &tess.vertexDlightBits[numVertexes];
|
||||
|
||||
|
@ -1141,7 +1145,7 @@ static void RB_SurfaceGrid( srfBspSurface_t *srf ) {
|
|||
|
||||
if ( tess.shader->vertexAttribs & ATTR_COLOR )
|
||||
{
|
||||
VectorCopy4(dv->vertexColors, color);
|
||||
VectorCopy4(dv->color, color);
|
||||
color += 4;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,30 +61,12 @@ int R_VaoPackTexCoord(byte *out, vec2_t st)
|
|||
}
|
||||
}
|
||||
|
||||
int R_VaoPackColors(byte *out, vec4_t color)
|
||||
void R_VaoPackColor(uint16_t *out, vec4_t c)
|
||||
{
|
||||
if (glRefConfig.packedTexcoordDataType == GL_HALF_FLOAT)
|
||||
{
|
||||
uint16_t *num = (uint16_t *)out;
|
||||
|
||||
*num++ = FloatToHalf(color[0]);
|
||||
*num++ = FloatToHalf(color[1]);
|
||||
*num++ = FloatToHalf(color[2]);
|
||||
*num++ = FloatToHalf(color[3]);
|
||||
|
||||
return sizeof(*num) * 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
float *num = (float *)out;
|
||||
|
||||
*num++ = color[0];
|
||||
*num++ = color[1];
|
||||
*num++ = color[2];
|
||||
*num++ = color[3];
|
||||
|
||||
return sizeof(*num) * 4;
|
||||
}
|
||||
out[0] = c[0] * 65535.0f + 0.5f;
|
||||
out[1] = c[1] * 65535.0f + 0.5f;
|
||||
out[2] = c[2] * 65535.0f + 0.5f;
|
||||
out[3] = c[3] * 65535.0f + 0.5f;
|
||||
}
|
||||
|
||||
void R_VaoUnpackTangent(vec4_t v, int16_t *pack)
|
||||
|
@ -267,7 +249,7 @@ vao_t *R_CreateVao2(const char *name, int numVertexes, srfVert_t *verts, int num
|
|||
vao->attribs[ATTR_INDEX_TANGENT ].type = GL_SHORT;
|
||||
vao->attribs[ATTR_INDEX_TEXCOORD ].type = glRefConfig.packedTexcoordDataType;
|
||||
vao->attribs[ATTR_INDEX_LIGHTCOORD ].type = glRefConfig.packedTexcoordDataType;
|
||||
vao->attribs[ATTR_INDEX_COLOR ].type = glRefConfig.packedColorDataType;
|
||||
vao->attribs[ATTR_INDEX_COLOR ].type = GL_UNSIGNED_SHORT;
|
||||
vao->attribs[ATTR_INDEX_LIGHTDIRECTION].type = GL_SHORT;
|
||||
|
||||
vao->attribs[ATTR_INDEX_POSITION ].normalized = GL_FALSE;
|
||||
|
@ -275,7 +257,7 @@ vao_t *R_CreateVao2(const char *name, int numVertexes, srfVert_t *verts, int num
|
|||
vao->attribs[ATTR_INDEX_TANGENT ].normalized = GL_TRUE;
|
||||
vao->attribs[ATTR_INDEX_TEXCOORD ].normalized = GL_FALSE;
|
||||
vao->attribs[ATTR_INDEX_LIGHTCOORD ].normalized = GL_FALSE;
|
||||
vao->attribs[ATTR_INDEX_COLOR ].normalized = GL_FALSE;
|
||||
vao->attribs[ATTR_INDEX_COLOR ].normalized = GL_TRUE;
|
||||
vao->attribs[ATTR_INDEX_LIGHTDIRECTION].normalized = GL_TRUE;
|
||||
|
||||
vao->attribs[ATTR_INDEX_POSITION ].offset = 0; dataSize = sizeof(verts[0].xyz);
|
||||
|
@ -283,7 +265,7 @@ vao_t *R_CreateVao2(const char *name, int numVertexes, srfVert_t *verts, int num
|
|||
vao->attribs[ATTR_INDEX_TANGENT ].offset = dataSize; dataSize += sizeof(verts[0].tangent);
|
||||
vao->attribs[ATTR_INDEX_TEXCOORD ].offset = dataSize; dataSize += glRefConfig.packedTexcoordDataSize;
|
||||
vao->attribs[ATTR_INDEX_LIGHTCOORD ].offset = dataSize; dataSize += glRefConfig.packedTexcoordDataSize;
|
||||
vao->attribs[ATTR_INDEX_COLOR ].offset = dataSize; dataSize += glRefConfig.packedColorDataSize;
|
||||
vao->attribs[ATTR_INDEX_COLOR ].offset = dataSize; dataSize += sizeof(verts[0].color);
|
||||
vao->attribs[ATTR_INDEX_LIGHTDIRECTION].offset = dataSize; dataSize += sizeof(verts[0].lightdir);
|
||||
|
||||
vao->attribs[ATTR_INDEX_POSITION ].stride = dataSize;
|
||||
|
@ -328,7 +310,8 @@ vao_t *R_CreateVao2(const char *name, int numVertexes, srfVert_t *verts, int num
|
|||
dataOfs += R_VaoPackTexCoord(data + dataOfs, verts[i].lightmap);
|
||||
|
||||
// colors
|
||||
dataOfs += R_VaoPackColors(data + dataOfs, verts[i].vertexColors);
|
||||
memcpy(data + dataOfs, &verts[i].color, sizeof(verts[i].color));
|
||||
dataOfs += sizeof(verts[i].color);
|
||||
|
||||
// light directions
|
||||
memcpy(data + dataOfs, &verts[i].lightdir, sizeof(verts[i].lightdir));
|
||||
|
@ -464,7 +447,7 @@ void R_InitVaos(void)
|
|||
vertexesSize = sizeof(tess.xyz[0]);
|
||||
vertexesSize += sizeof(tess.normal[0]);
|
||||
vertexesSize += sizeof(tess.tangent[0]);
|
||||
vertexesSize += sizeof(tess.vertexColors[0]);
|
||||
vertexesSize += sizeof(tess.color[0]);
|
||||
vertexesSize += sizeof(tess.texCoords[0][0]) * 2;
|
||||
vertexesSize += sizeof(tess.lightdir[0]);
|
||||
vertexesSize *= SHADER_MAX_VERTEXES;
|
||||
|
@ -496,7 +479,7 @@ void R_InitVaos(void)
|
|||
tess.vao->attribs[ATTR_INDEX_TANGENT ].type = GL_SHORT;
|
||||
tess.vao->attribs[ATTR_INDEX_TEXCOORD ].type = GL_FLOAT;
|
||||
tess.vao->attribs[ATTR_INDEX_LIGHTCOORD ].type = GL_FLOAT;
|
||||
tess.vao->attribs[ATTR_INDEX_COLOR ].type = GL_FLOAT;
|
||||
tess.vao->attribs[ATTR_INDEX_COLOR ].type = GL_UNSIGNED_SHORT;
|
||||
tess.vao->attribs[ATTR_INDEX_LIGHTDIRECTION].type = GL_SHORT;
|
||||
|
||||
tess.vao->attribs[ATTR_INDEX_POSITION ].normalized = GL_FALSE;
|
||||
|
@ -504,7 +487,7 @@ void R_InitVaos(void)
|
|||
tess.vao->attribs[ATTR_INDEX_TANGENT ].normalized = GL_TRUE;
|
||||
tess.vao->attribs[ATTR_INDEX_TEXCOORD ].normalized = GL_FALSE;
|
||||
tess.vao->attribs[ATTR_INDEX_LIGHTCOORD ].normalized = GL_FALSE;
|
||||
tess.vao->attribs[ATTR_INDEX_COLOR ].normalized = GL_FALSE;
|
||||
tess.vao->attribs[ATTR_INDEX_COLOR ].normalized = GL_TRUE;
|
||||
tess.vao->attribs[ATTR_INDEX_LIGHTDIRECTION].normalized = GL_TRUE;
|
||||
|
||||
tess.vao->attribs[ATTR_INDEX_POSITION ].offset = offset; offset += sizeof(tess.xyz[0]) * SHADER_MAX_VERTEXES;
|
||||
|
@ -515,13 +498,13 @@ void R_InitVaos(void)
|
|||
tess.vao->attribs[ATTR_INDEX_LIGHTCOORD ].offset = offset + sizeof(tess.texCoords[0][0]);
|
||||
offset += sizeof(tess.texCoords[0][0]) * 2 * SHADER_MAX_VERTEXES;
|
||||
|
||||
tess.vao->attribs[ATTR_INDEX_COLOR ].offset = offset; offset += sizeof(tess.vertexColors[0]) * SHADER_MAX_VERTEXES;
|
||||
tess.vao->attribs[ATTR_INDEX_COLOR ].offset = offset; offset += sizeof(tess.color[0]) * SHADER_MAX_VERTEXES;
|
||||
tess.vao->attribs[ATTR_INDEX_LIGHTDIRECTION].offset = offset;
|
||||
|
||||
tess.vao->attribs[ATTR_INDEX_POSITION ].stride = sizeof(tess.xyz[0]);
|
||||
tess.vao->attribs[ATTR_INDEX_NORMAL ].stride = sizeof(tess.normal[0]);
|
||||
tess.vao->attribs[ATTR_INDEX_TANGENT ].stride = sizeof(tess.tangent[0]);
|
||||
tess.vao->attribs[ATTR_INDEX_COLOR ].stride = sizeof(tess.vertexColors[0]);
|
||||
tess.vao->attribs[ATTR_INDEX_COLOR ].stride = sizeof(tess.color[0]);
|
||||
tess.vao->attribs[ATTR_INDEX_TEXCOORD ].stride = sizeof(tess.texCoords[0][0]) * 2;
|
||||
tess.vao->attribs[ATTR_INDEX_LIGHTCOORD ].stride = sizeof(tess.texCoords[0][0]) * 2;
|
||||
tess.vao->attribs[ATTR_INDEX_LIGHTDIRECTION].stride = sizeof(tess.lightdir[0]);
|
||||
|
@ -530,7 +513,7 @@ void R_InitVaos(void)
|
|||
tess.attribPointers[ATTR_INDEX_TEXCOORD] = tess.texCoords;
|
||||
tess.attribPointers[ATTR_INDEX_NORMAL] = tess.normal;
|
||||
tess.attribPointers[ATTR_INDEX_TANGENT] = tess.tangent;
|
||||
tess.attribPointers[ATTR_INDEX_COLOR] = tess.vertexColors;
|
||||
tess.attribPointers[ATTR_INDEX_COLOR] = tess.color;
|
||||
tess.attribPointers[ATTR_INDEX_LIGHTDIRECTION] = tess.lightdir;
|
||||
|
||||
Vao_SetVertexPointers(tess.vao);
|
||||
|
|
Loading…
Reference in a new issue