Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions trinity/Curves/Tr2CurveColorMixer.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Copyright © 2023 CCP ehf.

#include "Tr2CurveColorMixer.h"

Tr2CurveColorMixer::Tr2CurveColorMixer( IRoot* lockobj ) :
Expand All @@ -9,7 +7,8 @@ Tr2CurveColorMixer::Tr2CurveColorMixer( IRoot* lockobj ) :
m_color2( 0, 0, 0, 1 ),
m_lerpValue( 0.f ),
m_saturation( 1.f ),
m_brightness( 1.f )
m_brightness( 1.f ),
m_alphaOverride( -1.f )
{
}

Expand All @@ -28,23 +27,27 @@ Color Tr2CurveColorMixer::GetValue( double time ) const
{
Color out = Lerp( m_color1, m_color2, m_lerpValue );

if( m_saturation == 1.f )
if( m_saturation != 1.f )
{
return out * m_brightness;
// color intensity
float i = ( out.r * 0.299f ) + ( out.g * 0.587f ) + ( out.b * 0.114f );

out = Lerp( Color( i, i, i, i ), out, max( 0.0f, m_saturation ) );
}

// color intensity
float i = ( out.r * 0.299f ) + ( out.g * 0.587f ) + ( out.b * 0.114f );
out *= m_brightness;

out = Lerp( Color( i, i, i, i ), out, max( 0.0f, m_saturation ) );
if( m_alphaOverride != -1.f )
{
out.a = min( 1.f, max( 0.f, m_alphaOverride ) );
}

return out * m_brightness;
return out;
}

Color* Tr2CurveColorMixer::Update( Color* in, Be::Time time )
{
*in = m_currentValue = GetValue( TimeAsDouble( time ) );

return in;
}

Expand Down Expand Up @@ -72,6 +75,7 @@ void Tr2CurveColorMixer::InvertLinearColor( Color* in, Color* out )
out->r = InvertLinearValue( in->r );
out->b = InvertLinearValue( in->b );
out->g = InvertLinearValue( in->g );
out->a = in->a;
}

float Tr2CurveColorMixer::InvertLinearValue( float x )
Expand Down
5 changes: 3 additions & 2 deletions trinity/Curves/Tr2CurveColorMixer.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2021 CCP ehf.
// Copyright © 2023 CCP ehf.

#pragma once

Expand Down Expand Up @@ -44,6 +44,7 @@ BLUE_CLASS( Tr2CurveColorMixer ) :
float m_lerpValue;
float m_saturation;
float m_brightness;
float m_alphaOverride;
};

TYPEDEF_BLUECLASS( Tr2CurveColorMixer );
TYPEDEF_BLUECLASS( Tr2CurveColorMixer );
6 changes: 6 additions & 0 deletions trinity/Curves/Tr2CurveColorMixer_Blue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ const Be::ClassInfo* Tr2CurveColorMixer::ExposeToBlue()
"[0:inf] 0=black 1=normal",
Be::READWRITE | Be::PERSIST )

MAP_ATTRIBUTE(
"alphaOverride",
m_alphaOverride,
"[-1: disabled] 0=transparent, 1=opaque. value is clamped [0:1]",
Be::READWRITE | Be::PERSIST )

MAP_ATTRIBUTE(
"currentValue",
m_currentValue,
Expand Down
Loading