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:
Areloch 2017-06-23 11:36:20 -05:00
parent 8780f83262
commit 25686ed4be
294 changed files with 3894 additions and 2813 deletions

View file

@ -29,7 +29,7 @@ struct FogData
F32 density;
F32 densityOffset;
F32 atmosphereHeight;
ColorF color;
LinearColorF color;
FogData()
{

View file

@ -59,13 +59,14 @@ MODULE_END;
GFX_ImplementTextureProfile( ReflectRenderTargetProfile,
GFXTextureProfile::DiffuseMap,
GFXTextureProfile::PreserveSize | GFXTextureProfile::RenderTarget | GFXTextureProfile::Pooled,
GFXTextureProfile::PreserveSize | GFXTextureProfile::RenderTarget | GFXTextureProfile::SRGB | GFXTextureProfile::Pooled,
GFXTextureProfile::NONE );
GFX_ImplementTextureProfile( RefractTextureProfile,
GFXTextureProfile::DiffuseMap,
GFXTextureProfile::PreserveSize |
GFXTextureProfile::RenderTarget |
GFXTextureProfile::SRGB |
GFXTextureProfile::Pooled,
GFXTextureProfile::NONE );
@ -83,7 +84,7 @@ U32 ReflectionManager::smFrameReflectionMS = 10;
F32 ReflectionManager::smRefractTexScale = 0.5f;
ReflectionManager::ReflectionManager()
: mReflectFormat( GFXFormatR8G8B8A8 ),
: mReflectFormat( GFXFormatR8G8B8A8_SRGB ),
mUpdateRefract( true ),
mLastUpdateMs( 0 )
{

View file

@ -614,7 +614,7 @@ void PlaneReflector::updateReflection( const ReflectParams &params )
// In the future we may want to fix this instead by having the scatterSky
// render a skirt or something in its lower half.
//
ColorF clearColor = gClientSceneGraph->getAmbientLightColor();
LinearColorF clearColor = gClientSceneGraph->getAmbientLightColor();
GFX->clear( GFXClearZBuffer | GFXClearStencil | GFXClearTarget, clearColor, 1.0f, 0 );
if(GFX->getCurrentRenderStyle() == GFXDevice::RS_StereoSideBySide)

View file

@ -117,7 +117,7 @@ SceneManager::SceneManager( bool isClient )
mVisibleGhostDistance( 0 ),
mNearClip( 0.1f ),
mLightManager( NULL ),
mAmbientLightColor( ColorF( 0.1f, 0.1f, 0.1f, 1.0f ) ),
mAmbientLightColor( LinearColorF( 0.1f, 0.1f, 0.1f, 1.0f ) ),
mDefaultRenderPass( NULL )
{
VECTOR_SET_ASSOCIATION( mBatchQueryList );
@ -211,7 +211,7 @@ void SceneManager::renderScene( SceneRenderState* renderState, U32 objectMask, S
AssertFatal( baseObject != NULL, "SceneManager::renderScene - findZone() did not return an object" );
}
ColorF zoneAmbient;
LinearColorF zoneAmbient;
if( baseObject && baseObject->getZoneAmbientLightColor( baseZone, zoneAmbient ) )
mAmbientLightColor.setTargetValue( zoneAmbient );
else

View file

@ -158,7 +158,7 @@ class SceneManager
/// @name Lighting
/// @{
typedef InterpolatedChangeProperty< ColorF > AmbientLightInterpolator;
typedef InterpolatedChangeProperty< LinearColorF > AmbientLightInterpolator;
/// Light manager that is active for the scene.
LightManager* mLightManager;
@ -271,7 +271,7 @@ class SceneManager
bool setLightManager( const char *lmName );
/// Return the current global ambient light color.
const ColorF& getAmbientLightColor() const { return mAmbientLightColor.getCurrentValue(); }
const LinearColorF& getAmbientLightColor() const { return mAmbientLightColor.getCurrentValue(); }
/// Set the time it takes for a new ambient light color to take full effect.
void setAmbientLightTransitionTime( SimTime time ) { mAmbientLightColor.setTransitionTime( time ); }

View file

@ -94,7 +94,7 @@ class SceneRenderState
Point3F mVectorEye;
/// Global ambient light color.
ColorF mAmbientLightColor;
LinearColorF mAmbientLightColor;
/// Forces bin based post effects to be disabled
/// during rendering with this scene state.
@ -183,10 +183,10 @@ class SceneRenderState
/// light.
///
/// @return The ambient light color for rendering.
ColorF getAmbientLightColor() const { return mAmbientLightColor; }
LinearColorF getAmbientLightColor() const { return mAmbientLightColor; }
/// Set the global ambient light color to render with.
void setAmbientLightColor( const ColorF& color ) { mAmbientLightColor = color; }
void setAmbientLightColor( const LinearColorF& color ) { mAmbientLightColor = color; }
/// If true then Advanced Lighting bin draws are disabled during rendering with
/// this scene state.

View file

@ -143,7 +143,7 @@ void SceneSimpleZone::setUseAmbientLightColor( bool value )
//-----------------------------------------------------------------------------
void SceneSimpleZone::setAmbientLightColor( const ColorF& color )
void SceneSimpleZone::setAmbientLightColor( const LinearColorF& color )
{
mAmbientLightColor = color;
if( isServerObject() )
@ -152,7 +152,7 @@ void SceneSimpleZone::setAmbientLightColor( const ColorF& color )
//-----------------------------------------------------------------------------
bool SceneSimpleZone::getZoneAmbientLightColor( U32 zone, ColorF& outColor ) const
bool SceneSimpleZone::getZoneAmbientLightColor( U32 zone, LinearColorF& outColor ) const
{
AssertFatal( zone == getZoneRangeStart(), "SceneSimpleZone::getZoneAmbientLightColor - Invalid zone ID!" );
@ -356,6 +356,6 @@ bool SceneSimpleZone::_setUseAmbientLightColor( void* object, const char* index,
bool SceneSimpleZone::_setAmbientLightColor( void* object, const char* index, const char* data )
{
SceneSimpleZone* zone = reinterpret_cast< SceneSimpleZone* >( object );
zone->setAmbientLightColor( EngineUnmarshallData< ColorF >()( data ) );
zone->setAmbientLightColor( EngineUnmarshallData< LinearColorF >()( data ) );
return false;
}

View file

@ -61,7 +61,7 @@ class SceneSimpleZone : public SceneZoneSpace
bool mUseAmbientLightColor;
/// Ambient light color in this zone.
ColorF mAmbientLightColor;
LinearColorF mAmbientLightColor;
/// @}
@ -102,12 +102,12 @@ class SceneSimpleZone : public SceneZoneSpace
void setUseAmbientLightColor( bool value );
/// Return the ambient light color for this zone.
ColorF getAmbientLightColor() const { return mAmbientLightColor; }
LinearColorF getAmbientLightColor() const { return mAmbientLightColor; }
/// Set the ambient light color for the zone.
/// @note This only takes effect if useAmbientLightColor() return true.
/// @see setUseAmbientLightColor
void setAmbientLightColor( const ColorF& color );
void setAmbientLightColor( const LinearColorF& color );
/// @}
@ -131,7 +131,7 @@ class SceneSimpleZone : public SceneZoneSpace
virtual U32 getPointZone( const Point3F &p );
virtual bool getOverlappingZones( const Box3F& aabb, U32* outZones, U32& outNumZones );
virtual void traverseZones( SceneTraversalState* state );
virtual bool getZoneAmbientLightColor( U32 zone, ColorF& outColor ) const;
virtual bool getZoneAmbientLightColor( U32 zone, LinearColorF& outColor ) const;
virtual void traverseZones( SceneTraversalState* state, U32 startZoneId );
/// @}

View file

@ -211,7 +211,7 @@ class SceneZoneSpace : public SceneSpace
/// Get the ambient light color of the given zone in this space or return false if the
/// given zone does not have an ambient light color assigned to it.
virtual bool getZoneAmbientLightColor( U32 zone, ColorF& outColor ) const { return false; }
virtual bool getZoneAmbientLightColor( U32 zone, LinearColorF& outColor ) const { return false; }
/// @name Containment Tests
/// @{