mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-13 11:43:49 +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
8943c673fb
commit
0801a3cca8
294 changed files with 3894 additions and 2813 deletions
|
|
@ -139,7 +139,7 @@ void DebugDrawer::setupStateBlocks()
|
|||
mRenderAlpha = GFX->createStateBlock(d);
|
||||
}
|
||||
|
||||
void DebugDrawer::drawBoxOutline(const Point3F &a, const Point3F &b, const ColorF &color)
|
||||
void DebugDrawer::drawBoxOutline(const Point3F &a, const Point3F &b, const LinearColorF &color)
|
||||
{
|
||||
Point3F point0(a.x, a.y, a.z);
|
||||
Point3F point1(a.x, b.y, a.z);
|
||||
|
|
@ -170,7 +170,7 @@ void DebugDrawer::drawBoxOutline(const Point3F &a, const Point3F &b, const Color
|
|||
drawLine(point3, point7, color);
|
||||
}
|
||||
|
||||
void DebugDrawer::drawTransformedBoxOutline(const Point3F &a, const Point3F &b, const ColorF &color, const MatrixF& transform)
|
||||
void DebugDrawer::drawTransformedBoxOutline(const Point3F &a, const Point3F &b, const LinearColorF &color, const MatrixF& transform)
|
||||
{
|
||||
Point3F point0(a.x, a.y, a.z);
|
||||
Point3F point1(a.x, b.y, a.z);
|
||||
|
|
@ -234,16 +234,23 @@ void DebugDrawer::render(bool clear)
|
|||
|
||||
// Set up the state block...
|
||||
GFXStateBlockRef currSB;
|
||||
if(p->type==DebugPrim::Capsule){
|
||||
if(p->type==DebugPrim::Capsule)
|
||||
{
|
||||
currSB = mRenderAlpha;
|
||||
}else if(p->useZ){
|
||||
}
|
||||
else if(p->useZ)
|
||||
{
|
||||
currSB = mRenderZOnSB;
|
||||
}else{
|
||||
}
|
||||
else
|
||||
{
|
||||
currSB = mRenderZOffSB;
|
||||
}
|
||||
|
||||
GFX->setStateBlock( currSB );
|
||||
|
||||
Point3F d;
|
||||
const ColorI color = p->color.toColorI();
|
||||
|
||||
switch(p->type)
|
||||
{
|
||||
|
|
@ -265,20 +272,23 @@ void DebugDrawer::render(bool clear)
|
|||
Point3F &start = p->a, &end = p->b;
|
||||
Point3F direction = end - start;
|
||||
F32 length = direction.len();
|
||||
if( length>ARROW_LENGTH ){
|
||||
if( length>ARROW_LENGTH )
|
||||
{
|
||||
//cylinder with arrow on end
|
||||
direction *= (1.0f/length);
|
||||
Point3F baseArrow = end - (direction*ARROW_LENGTH);
|
||||
GFX->getDrawUtil()->drawCone(currSB->getDesc(), baseArrow, end, ARROW_RADIUS, p->color);
|
||||
GFX->getDrawUtil()->drawCylinder(currSB->getDesc(), start, baseArrow, CYLINDER_RADIUS, p->color);
|
||||
}else if( length>0 ){
|
||||
GFX->getDrawUtil()->drawCone(currSB->getDesc(), baseArrow, end, ARROW_RADIUS, color);
|
||||
GFX->getDrawUtil()->drawCylinder(currSB->getDesc(), start, baseArrow, CYLINDER_RADIUS, color);
|
||||
}
|
||||
else if( length>0 )
|
||||
{
|
||||
//short, so just draw arrow
|
||||
GFX->getDrawUtil()->drawCone(currSB->getDesc(), start, end, ARROW_RADIUS, p->color);
|
||||
GFX->getDrawUtil()->drawCone(currSB->getDesc(), start, end, ARROW_RADIUS, color);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case DebugPrim::Capsule:
|
||||
GFX->getDrawUtil()->drawCapsule(currSB->getDesc(), p->a, p->b.x, p->b.y, p->color);
|
||||
GFX->getDrawUtil()->drawCapsule(currSB->getDesc(), p->a, p->b.x, p->b.y, color);
|
||||
break;
|
||||
case DebugPrim::OutlinedText:
|
||||
{
|
||||
|
|
@ -288,26 +298,26 @@ void DebugDrawer::render(bool clear)
|
|||
{
|
||||
GFX->setClipRect(GFX->getViewport());
|
||||
Point2I where = Point2I(result.x, result.y);
|
||||
|
||||
GFX->getDrawUtil()->setBitmapModulation(p->color2);
|
||||
//only switch statement that uses p->color2
|
||||
GFX->getDrawUtil()->setBitmapModulation(p->color2.toColorI());
|
||||
GFX->getDrawUtil()->drawText(mFont, Point2I(where.x-1, where.y), p->mText);
|
||||
GFX->getDrawUtil()->drawText(mFont, Point2I(where.x+1, where.y), p->mText);
|
||||
GFX->getDrawUtil()->drawText(mFont, Point2I(where.x, where.y-1), p->mText);
|
||||
GFX->getDrawUtil()->drawText(mFont, Point2I(where.x, where.y+1), p->mText);
|
||||
|
||||
GFX->getDrawUtil()->setBitmapModulation(p->color);
|
||||
GFX->getDrawUtil()->setBitmapModulation(color);
|
||||
GFX->getDrawUtil()->drawText(mFont, where, p->mText);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case DebugPrim::Box:
|
||||
d = p->a - p->b;
|
||||
GFX->getDrawUtil()->drawCube(currSB->getDesc(), d * 0.5, (p->a + p->b) * 0.5, p->color);
|
||||
GFX->getDrawUtil()->drawCube(currSB->getDesc(), d * 0.5, (p->a + p->b) * 0.5, color);
|
||||
break;
|
||||
case DebugPrim::Line:
|
||||
PrimBuild::begin( GFXLineStrip, 2);
|
||||
|
||||
PrimBuild::color(p->color);
|
||||
PrimBuild::color(color);
|
||||
|
||||
PrimBuild::vertex3fv(p->a);
|
||||
PrimBuild::vertex3fv(p->b);
|
||||
|
|
@ -321,7 +331,7 @@ void DebugDrawer::render(bool clear)
|
|||
if (MathUtils::mProjectWorldToScreen(p->a, &result, GFX->getViewport(), GFX->getWorldMatrix(), GFX->getProjectionMatrix()))
|
||||
{
|
||||
GFX->setClipRect(GFX->getViewport());
|
||||
GFX->getDrawUtil()->setBitmapModulation(p->color);
|
||||
GFX->getDrawUtil()->setBitmapModulation(color);
|
||||
GFX->getDrawUtil()->drawText(mFont, Point2I(result.x, result.y), p->mText);
|
||||
}
|
||||
}
|
||||
|
|
@ -346,7 +356,7 @@ void DebugDrawer::render(bool clear)
|
|||
#endif
|
||||
}
|
||||
|
||||
void DebugDrawer::drawBox(const Point3F &a, const Point3F &b, const ColorF &color)
|
||||
void DebugDrawer::drawBox(const Point3F &a, const Point3F &b, const LinearColorF &color)
|
||||
{
|
||||
if(isFrozen || !isDrawing)
|
||||
return;
|
||||
|
|
@ -364,7 +374,7 @@ void DebugDrawer::drawBox(const Point3F &a, const Point3F &b, const ColorF &colo
|
|||
mHead = n;
|
||||
}
|
||||
|
||||
void DebugDrawer::drawLine(const Point3F &a, const Point3F &b, const ColorF &color)
|
||||
void DebugDrawer::drawLine(const Point3F &a, const Point3F &b, const LinearColorF &color)
|
||||
{
|
||||
if(isFrozen || !isDrawing)
|
||||
return;
|
||||
|
|
@ -382,7 +392,7 @@ void DebugDrawer::drawLine(const Point3F &a, const Point3F &b, const ColorF &col
|
|||
mHead = n;
|
||||
}
|
||||
|
||||
void DebugDrawer::drawCapsule(const Point3F &a, const F32 &radius, const F32 &height, const ColorF &color)
|
||||
void DebugDrawer::drawCapsule(const Point3F &a, const F32 &radius, const F32 &height, const LinearColorF &color)
|
||||
{
|
||||
if(isFrozen || !isDrawing)
|
||||
return;
|
||||
|
|
@ -402,7 +412,7 @@ void DebugDrawer::drawCapsule(const Point3F &a, const F32 &radius, const F32 &he
|
|||
|
||||
}
|
||||
|
||||
void DebugDrawer::drawDirectionLine(const Point3F &a, const Point3F &b, const ColorF &color)
|
||||
void DebugDrawer::drawDirectionLine(const Point3F &a, const Point3F &b, const LinearColorF &color)
|
||||
{
|
||||
if(isFrozen || !isDrawing)
|
||||
return;
|
||||
|
|
@ -420,7 +430,7 @@ void DebugDrawer::drawDirectionLine(const Point3F &a, const Point3F &b, const Co
|
|||
mHead = n;
|
||||
}
|
||||
|
||||
void DebugDrawer::drawOutlinedText(const Point3F& pos, const String& text, const ColorF &color, const ColorF &colorOutline)
|
||||
void DebugDrawer::drawOutlinedText(const Point3F& pos, const String& text, const LinearColorF &color, const LinearColorF &colorOutline)
|
||||
{
|
||||
if(isFrozen || !isDrawing)
|
||||
return;
|
||||
|
|
@ -439,7 +449,7 @@ void DebugDrawer::drawOutlinedText(const Point3F& pos, const String& text, const
|
|||
mHead = n;
|
||||
}
|
||||
|
||||
void DebugDrawer::drawTri(const Point3F &a, const Point3F &b, const Point3F &c, const ColorF &color)
|
||||
void DebugDrawer::drawTri(const Point3F &a, const Point3F &b, const Point3F &c, const LinearColorF &color)
|
||||
{
|
||||
if(isFrozen || !isDrawing)
|
||||
return;
|
||||
|
|
@ -458,7 +468,7 @@ void DebugDrawer::drawTri(const Point3F &a, const Point3F &b, const Point3F &c,
|
|||
mHead = n;
|
||||
}
|
||||
|
||||
void DebugDrawer::drawPolyhedron( const AnyPolyhedron& polyhedron, const ColorF& color )
|
||||
void DebugDrawer::drawPolyhedron( const AnyPolyhedron& polyhedron, const LinearColorF& color )
|
||||
{
|
||||
const PolyhedronData::Edge* edges = polyhedron.getEdges();
|
||||
const Point3F* points = polyhedron.getPoints();
|
||||
|
|
@ -534,11 +544,11 @@ void DebugDrawer::drawPolyhedronDebugInfo( const AnyPolyhedron& polyhedron, cons
|
|||
p.convolve( scale );
|
||||
transform.mulP( p );
|
||||
|
||||
drawText( p, String::ToString( "%i: (%.2f, %.2f, %.2f)", i, p.x, p.y, p.z ), ColorF::WHITE );
|
||||
drawText( p, String::ToString( "%i: (%.2f, %.2f, %.2f)", i, p.x, p.y, p.z ), LinearColorF::WHITE );
|
||||
}
|
||||
}
|
||||
|
||||
void DebugDrawer::drawText(const Point3F& pos, const String& text, const ColorF &color)
|
||||
void DebugDrawer::drawText(const Point3F& pos, const String& text, const LinearColorF &color)
|
||||
{
|
||||
if(isFrozen || !isDrawing)
|
||||
return;
|
||||
|
|
@ -571,13 +581,13 @@ void DebugDrawer::setLastZTest(bool enabled)
|
|||
mHead->useZ = enabled;
|
||||
}
|
||||
|
||||
DefineEngineMethod( DebugDrawer, drawLine, void, ( Point3F a, Point3F b, ColorF color ), ( ColorF::WHITE ),
|
||||
DefineEngineMethod( DebugDrawer, drawLine, void, ( Point3F a, Point3F b, LinearColorF color ), ( LinearColorF::WHITE ),
|
||||
"Draws a line primitive between two 3d points." )
|
||||
{
|
||||
object->drawLine( a, b, color );
|
||||
}
|
||||
|
||||
DefineEngineMethod( DebugDrawer, drawBox, void, ( Point3F a, Point3F b, ColorF color ), ( ColorF::WHITE ),
|
||||
DefineEngineMethod( DebugDrawer, drawBox, void, ( Point3F a, Point3F b, LinearColorF color ), ( LinearColorF::WHITE ),
|
||||
"Draws an axis aligned box primitive within the two 3d points." )
|
||||
{
|
||||
object->drawBox( a, b, color );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue