mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-09 07:20:40 +00:00
Implementation of sRGB image support. Overhauls the linearization setup to utilize the sRGB image types, as well as refactors the use of ColorF and ColorI to be properly internally consistent. ColorIs are used only for front-facing/editing/UI settings, and ColorFs, now renamed to LinearColorF to reduce confusion of purpose, are used for color info in the engine itself. This avoids confusing and expensive conversions back and forth between types and avoids botches with linearity. Majority work done by @rextimmy
This commit is contained in:
parent
8780f83262
commit
25686ed4be
294 changed files with 3894 additions and 2813 deletions
|
|
@ -603,7 +603,7 @@ bool ParticleEmitterData::preload(bool server, String &errorStr)
|
|||
// load emitter texture if specified
|
||||
if (textureName && textureName[0])
|
||||
{
|
||||
textureHandle = GFXTexHandle(textureName, &GFXDefaultStaticDiffuseProfile, avar("%s() - textureHandle (line %d)", __FUNCTION__, __LINE__));
|
||||
textureHandle = GFXTexHandle(textureName, &GFXStaticTextureSRGBProfile, avar("%s() - textureHandle (line %d)", __FUNCTION__, __LINE__));
|
||||
if (!textureHandle)
|
||||
{
|
||||
errorStr = String::ToString("Missing particle emitter texture: %s", textureName);
|
||||
|
|
@ -833,10 +833,10 @@ bool ParticleEmitter::onNewDataBlock( GameBaseData *dptr, bool reload )
|
|||
//-----------------------------------------------------------------------------
|
||||
// getCollectiveColor
|
||||
//-----------------------------------------------------------------------------
|
||||
ColorF ParticleEmitter::getCollectiveColor()
|
||||
LinearColorF ParticleEmitter::getCollectiveColor()
|
||||
{
|
||||
U32 count = 0;
|
||||
ColorF color = ColorF(0.0f, 0.0f, 0.0f);
|
||||
LinearColorF color = LinearColorF(0.0f, 0.0f, 0.0f);
|
||||
|
||||
count = n_parts;
|
||||
for( Particle* part = part_list_head.next; part != NULL; part = part->next )
|
||||
|
|
@ -937,7 +937,7 @@ void ParticleEmitter::setSizes( F32 *sizeList )
|
|||
//-----------------------------------------------------------------------------
|
||||
// setColors
|
||||
//-----------------------------------------------------------------------------
|
||||
void ParticleEmitter::setColors( ColorF *colorList )
|
||||
void ParticleEmitter::setColors( LinearColorF *colorList )
|
||||
{
|
||||
for( S32 i=0; i<ParticleData::PDC_NUM_KEYS; i++ )
|
||||
{
|
||||
|
|
@ -1467,7 +1467,7 @@ S32 QSORT_CALLBACK cmpSortParticles(const void* p1, const void* p2)
|
|||
return -1;
|
||||
}
|
||||
|
||||
void ParticleEmitter::copyToVB( const Point3F &camPos, const ColorF &ambientColor )
|
||||
void ParticleEmitter::copyToVB( const Point3F &camPos, const LinearColorF &ambientColor )
|
||||
{
|
||||
static Vector<SortParticle> orderedVector(__FILE__, __LINE__);
|
||||
|
||||
|
|
@ -1653,7 +1653,7 @@ void ParticleEmitter::copyToVB( const Point3F &camPos, const ColorF &ambientColo
|
|||
void ParticleEmitter::setupBillboard( Particle *part,
|
||||
Point3F *basePts,
|
||||
const MatrixF &camView,
|
||||
const ColorF &ambientColor,
|
||||
const LinearColorF &ambientColor,
|
||||
ParticleVertexType *lVerts )
|
||||
{
|
||||
F32 width = part->size * 0.5f;
|
||||
|
|
@ -1663,7 +1663,7 @@ void ParticleEmitter::setupBillboard( Particle *part,
|
|||
mSinCos(spinAngle, sy, cy);
|
||||
|
||||
const F32 ambientLerp = mClampF( mDataBlock->ambientFactor, 0.0f, 1.0f );
|
||||
ColorF partCol = mLerp( part->color, ( part->color * ambientColor ), ambientLerp );
|
||||
LinearColorF partCol = mLerp( part->color, ( part->color * ambientColor ), ambientLerp );
|
||||
|
||||
// fill four verts, use macro and unroll loop
|
||||
#define fillVert(){ \
|
||||
|
|
@ -1673,7 +1673,7 @@ void ParticleEmitter::setupBillboard( Particle *part,
|
|||
camView.mulV( lVerts->point ); \
|
||||
lVerts->point *= width; \
|
||||
lVerts->point += part->pos; \
|
||||
lVerts->color = partCol; } \
|
||||
lVerts->color = partCol.toColorI(); } \
|
||||
|
||||
// Here we deal with UVs for animated particle (billboard)
|
||||
if (part->dataBlock->animateTexture && !part->dataBlock->animTexFrames.empty())
|
||||
|
|
@ -1737,7 +1737,7 @@ void ParticleEmitter::setupBillboard( Particle *part,
|
|||
//-----------------------------------------------------------------------------
|
||||
void ParticleEmitter::setupOriented( Particle *part,
|
||||
const Point3F &camPos,
|
||||
const ColorF &ambientColor,
|
||||
const LinearColorF &ambientColor,
|
||||
ParticleVertexType *lVerts )
|
||||
{
|
||||
Point3F dir;
|
||||
|
|
@ -1766,8 +1766,8 @@ void ParticleEmitter::setupOriented( Particle *part,
|
|||
Point3F end = part->pos + dir;
|
||||
|
||||
const F32 ambientLerp = mClampF( mDataBlock->ambientFactor, 0.0f, 1.0f );
|
||||
ColorF partCol = mLerp( part->color, ( part->color * ambientColor ), ambientLerp );
|
||||
|
||||
LinearColorF partCol = mLerp( part->color, ( part->color * ambientColor ), ambientLerp );
|
||||
const ColorI color = partCol.toColorI();
|
||||
// Here we deal with UVs for animated particle (oriented)
|
||||
if (part->dataBlock->animateTexture)
|
||||
{
|
||||
|
|
@ -1779,55 +1779,55 @@ void ParticleEmitter::setupOriented( Particle *part,
|
|||
uv[1] = uv[0] + (part->dataBlock->animTexTiling.x + 1);
|
||||
uv[2] = uv[1] + 1;
|
||||
uv[3] = uv[0] + 1;
|
||||
|
||||
lVerts->point = start + crossDir;
|
||||
lVerts->color = color;
|
||||
// Here and below, we copy UVs from particle datablock's current frame's UVs (oriented)
|
||||
lVerts->texCoord = part->dataBlock->animTexUVs[uv[0]];
|
||||
++lVerts;
|
||||
|
||||
lVerts->point = start + crossDir;
|
||||
lVerts->color = partCol;
|
||||
// Here and below, we copy UVs from particle datablock's current frame's UVs (oriented)
|
||||
lVerts->texCoord = part->dataBlock->animTexUVs[uv[0]];
|
||||
++lVerts;
|
||||
lVerts->point = start - crossDir;
|
||||
lVerts->color = color;
|
||||
lVerts->texCoord = part->dataBlock->animTexUVs[uv[1]];
|
||||
++lVerts;
|
||||
|
||||
lVerts->point = start - crossDir;
|
||||
lVerts->color = partCol;
|
||||
lVerts->texCoord = part->dataBlock->animTexUVs[uv[1]];
|
||||
++lVerts;
|
||||
lVerts->point = end - crossDir;
|
||||
lVerts->color = color;
|
||||
lVerts->texCoord = part->dataBlock->animTexUVs[uv[2]];
|
||||
++lVerts;
|
||||
|
||||
lVerts->point = end - crossDir;
|
||||
lVerts->color = partCol;
|
||||
lVerts->texCoord = part->dataBlock->animTexUVs[uv[2]];
|
||||
++lVerts;
|
||||
lVerts->point = end + crossDir;
|
||||
lVerts->color = color;
|
||||
lVerts->texCoord = part->dataBlock->animTexUVs[uv[3]];
|
||||
++lVerts;
|
||||
|
||||
lVerts->point = end + crossDir;
|
||||
lVerts->color = partCol;
|
||||
lVerts->texCoord = part->dataBlock->animTexUVs[uv[3]];
|
||||
++lVerts;
|
||||
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
lVerts->point = start + crossDir;
|
||||
lVerts->color = partCol;
|
||||
lVerts->color = color;
|
||||
// Here and below, we copy UVs from particle datablock's texCoords (oriented)
|
||||
lVerts->texCoord = part->dataBlock->texCoords[1];
|
||||
++lVerts;
|
||||
|
||||
lVerts->point = start - crossDir;
|
||||
lVerts->color = partCol;
|
||||
lVerts->color = color;
|
||||
lVerts->texCoord = part->dataBlock->texCoords[2];
|
||||
++lVerts;
|
||||
|
||||
lVerts->point = end - crossDir;
|
||||
lVerts->color = partCol;
|
||||
lVerts->color = color;
|
||||
lVerts->texCoord = part->dataBlock->texCoords[3];
|
||||
++lVerts;
|
||||
|
||||
lVerts->point = end + crossDir;
|
||||
lVerts->color = partCol;
|
||||
lVerts->color = color;
|
||||
lVerts->texCoord = part->dataBlock->texCoords[0];
|
||||
++lVerts;
|
||||
}
|
||||
|
||||
void ParticleEmitter::setupAligned( const Particle *part,
|
||||
const ColorF &ambientColor,
|
||||
const LinearColorF &ambientColor,
|
||||
ParticleVertexType *lVerts )
|
||||
{
|
||||
// The aligned direction will always be normalized.
|
||||
|
|
@ -1877,8 +1877,8 @@ void ParticleEmitter::setupAligned( const Particle *part,
|
|||
Point3F end = part->pos + right;
|
||||
|
||||
const F32 ambientLerp = mClampF( mDataBlock->ambientFactor, 0.0f, 1.0f );
|
||||
ColorF partCol = mLerp( part->color, ( part->color * ambientColor ), ambientLerp );
|
||||
|
||||
LinearColorF partCol = mLerp( part->color, ( part->color * ambientColor ), ambientLerp );
|
||||
const ColorI color = partCol.toColorI();
|
||||
// Here we deal with UVs for animated particle
|
||||
if (part->dataBlock->animateTexture)
|
||||
{
|
||||
|
|
@ -1891,46 +1891,46 @@ void ParticleEmitter::setupAligned( const Particle *part,
|
|||
uv[2] = uv[1] + 1;
|
||||
uv[3] = uv[0] + 1;
|
||||
|
||||
lVerts->point = start + cross;
|
||||
lVerts->color = partCol;
|
||||
lVerts->texCoord = part->dataBlock->animTexUVs[uv[0]];
|
||||
++lVerts;
|
||||
lVerts->point = start + cross;
|
||||
lVerts->color = color;
|
||||
lVerts->texCoord = part->dataBlock->animTexUVs[uv[0]];
|
||||
++lVerts;
|
||||
|
||||
lVerts->point = start - cross;
|
||||
lVerts->color = partCol;
|
||||
lVerts->texCoord = part->dataBlock->animTexUVs[uv[1]];
|
||||
++lVerts;
|
||||
lVerts->point = start - cross;
|
||||
lVerts->color = color;
|
||||
lVerts->texCoord = part->dataBlock->animTexUVs[uv[1]];
|
||||
++lVerts;
|
||||
|
||||
lVerts->point = end - cross;
|
||||
lVerts->color = partCol;
|
||||
lVerts->texCoord = part->dataBlock->animTexUVs[uv[2]];
|
||||
++lVerts;
|
||||
lVerts->point = end - cross;
|
||||
lVerts->color = color;
|
||||
lVerts->texCoord = part->dataBlock->animTexUVs[uv[2]];
|
||||
++lVerts;
|
||||
|
||||
lVerts->point = end + cross;
|
||||
lVerts->color = partCol;
|
||||
lVerts->texCoord = part->dataBlock->animTexUVs[uv[3]];
|
||||
++lVerts;
|
||||
lVerts->point = end + cross;
|
||||
lVerts->color = color;
|
||||
lVerts->texCoord = part->dataBlock->animTexUVs[uv[3]];
|
||||
++lVerts;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Here and below, we copy UVs from particle datablock's texCoords
|
||||
lVerts->point = start + cross;
|
||||
lVerts->color = partCol;
|
||||
lVerts->color = color;
|
||||
lVerts->texCoord = part->dataBlock->texCoords[0];
|
||||
++lVerts;
|
||||
|
||||
lVerts->point = start - cross;
|
||||
lVerts->color = partCol;
|
||||
lVerts->color = color;
|
||||
lVerts->texCoord = part->dataBlock->texCoords[1];
|
||||
++lVerts;
|
||||
|
||||
lVerts->point = end - cross;
|
||||
lVerts->color = partCol;
|
||||
lVerts->color = color;
|
||||
lVerts->texCoord = part->dataBlock->texCoords[2];
|
||||
++lVerts;
|
||||
|
||||
lVerts->point = end + cross;
|
||||
lVerts->color = partCol;
|
||||
lVerts->color = color;
|
||||
lVerts->texCoord = part->dataBlock->texCoords[3];
|
||||
++lVerts;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue