mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-24 17:13:54 +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
|
|
@ -31,12 +31,12 @@
|
|||
namespace ConvertRGB
|
||||
{
|
||||
|
||||
ColorF toLUV( const ColorF &rgbColor )
|
||||
LinearColorF toLUV( const LinearColorF &rgbColor )
|
||||
{
|
||||
static const Point3F scXYZLUVDot( 1.0f, 15.0f, 3.0f );
|
||||
static const Point2F sc49( 4.0f, 9.0f );
|
||||
|
||||
ColorF xyzColor = ConvertRGB::toXYZ( rgbColor );
|
||||
LinearColorF xyzColor = ConvertRGB::toXYZ( rgbColor );
|
||||
|
||||
const Point2F &xyz_xy = *((Point2F *)&xyzColor);
|
||||
|
||||
|
|
@ -44,12 +44,12 @@ ColorF toLUV( const ColorF &rgbColor )
|
|||
uvColor.convolve( xyz_xy );
|
||||
uvColor /= mDot( *(Point3F *)&xyzColor, scXYZLUVDot );
|
||||
|
||||
return ColorF( uvColor.x, uvColor.y, xyzColor.green, rgbColor.alpha );
|
||||
return LinearColorF( uvColor.x, uvColor.y, xyzColor.green, rgbColor.alpha );
|
||||
}
|
||||
|
||||
ColorF toLUVScaled( const ColorF &rgbColor )
|
||||
LinearColorF toLUVScaled( const LinearColorF &rgbColor )
|
||||
{
|
||||
ColorF luvColor = toLUV( rgbColor );
|
||||
LinearColorF luvColor = toLUV( rgbColor );
|
||||
luvColor.red /= 0.62f;
|
||||
luvColor.green /= 0.62f;
|
||||
return luvColor;
|
||||
|
|
|
|||
|
|
@ -29,9 +29,9 @@
|
|||
|
||||
namespace ConvertRGB
|
||||
{
|
||||
ColorF toLUV( const ColorF &rgbColor );
|
||||
ColorF toLUVScaled( const ColorF &rgbColor );
|
||||
ColorF fromLUV( const ColorF &luvColor );
|
||||
LinearColorF toLUV( const LinearColorF &rgbColor );
|
||||
LinearColorF toLUVScaled( const LinearColorF &rgbColor );
|
||||
LinearColorF fromLUV( const LinearColorF &luvColor );
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -46,20 +46,20 @@ static const F32 scXYZ2RGB[] =
|
|||
0.0f, 0.0f, 0.0f, 1.0f,
|
||||
};
|
||||
|
||||
ColorF toXYZ( const ColorF &rgbColor )
|
||||
LinearColorF toXYZ( const LinearColorF &rgbColor )
|
||||
{
|
||||
const MatrixF &rgb2xyz = *((MatrixF *)scRGB2XYZ);
|
||||
|
||||
ColorF retColor = rgbColor;
|
||||
LinearColorF retColor = rgbColor;
|
||||
rgb2xyz.mul( *(Point4F *)&retColor );
|
||||
return retColor;
|
||||
}
|
||||
|
||||
ColorF fromXYZ( const ColorF &xyzColor )
|
||||
LinearColorF fromXYZ( const LinearColorF &xyzColor )
|
||||
{
|
||||
const MatrixF &xyz2rgb = *((MatrixF *)scXYZ2RGB);
|
||||
|
||||
ColorF retColor = xyzColor;
|
||||
LinearColorF retColor = xyzColor;
|
||||
xyz2rgb.mul( *(Point4F *)&retColor );
|
||||
return retColor;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@
|
|||
|
||||
namespace ConvertRGB
|
||||
{
|
||||
ColorF toXYZ( const ColorF &rgbColor );
|
||||
ColorF fromXYZ( const ColorF &xyzColor );
|
||||
LinearColorF toXYZ( const LinearColorF &rgbColor );
|
||||
LinearColorF fromXYZ( const LinearColorF &xyzColor );
|
||||
};
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue