normalize rendered light color for display consistency (compiler normalizes it anyway)
lower 3d light sphere brightness to reduce occlusion #63
This commit is contained in:
parent
d41adc5e93
commit
88a03b07be
|
|
@ -587,6 +587,16 @@ inline std::size_t vector3_min_abs_component_index( const BasicVector3<Element>&
|
|||
return ( fabs( self[2] ) < fabs( self[mini] ) )? 2 : mini;
|
||||
}
|
||||
|
||||
template<typename Element>
|
||||
inline Element vector3_max_component( const BasicVector3<Element>& v ){
|
||||
return ( v[0] > v[1] ) ? ( ( v[0] > v[2] ) ? v[0] : v[2] ) : ( ( v[1] > v[2] ) ? v[1] : v[2] );
|
||||
}
|
||||
|
||||
template<typename Element>
|
||||
inline Element vector3_min_component( const BasicVector3<Element>& v ){
|
||||
return ( v[0] < v[1] ) ? ( ( v[0] < v[2] ) ? v[0] : v[2] ) : ( ( v[1] < v[2] ) ? v[1] : v[2] );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -37,6 +37,18 @@ inline void read_colour( Vector3& colour, const char* value ){
|
|||
default_colour( colour );
|
||||
}
|
||||
}
|
||||
inline void read_colour_normalized( Vector3& colour, const char* value ){
|
||||
if ( !string_parse_vector3( value, colour ) ) {
|
||||
default_colour( colour );
|
||||
}
|
||||
else{
|
||||
const auto max = vector3_max_component( colour );
|
||||
if ( max == 0 )
|
||||
default_colour( colour );
|
||||
else
|
||||
colour /= max;
|
||||
}
|
||||
}
|
||||
inline void write_colour( const Vector3& colour, Entity* entity ){
|
||||
char value[64];
|
||||
|
||||
|
|
@ -52,19 +64,21 @@ class Colour
|
|||
|
||||
void capture_state(){
|
||||
m_state = colour_capture_state_fill( m_colour );
|
||||
m_state_additive = colour_capture_state_add( m_colour );
|
||||
m_state_additive = colour_capture_state_add( m_colour_add );
|
||||
}
|
||||
void release_state(){
|
||||
colour_release_state_fill( m_colour );
|
||||
colour_release_state_add( m_colour );
|
||||
colour_release_state_add( m_colour_add );
|
||||
}
|
||||
|
||||
Vector3 m_colour_add;
|
||||
public:
|
||||
Vector3 m_colour;
|
||||
|
||||
Colour( const Callback& colourChanged )
|
||||
: m_colourChanged( colourChanged ){
|
||||
default_colour( m_colour );
|
||||
m_colour_add = m_colour / 4;
|
||||
capture_state();
|
||||
}
|
||||
~Colour(){
|
||||
|
|
@ -73,7 +87,8 @@ public:
|
|||
|
||||
void colourChanged( const char* value ){
|
||||
release_state();
|
||||
read_colour( m_colour, value );
|
||||
read_colour_normalized( m_colour, value );
|
||||
m_colour_add = m_colour / 4;
|
||||
capture_state();
|
||||
|
||||
m_colourChanged();
|
||||
|
|
|
|||
|
|
@ -509,13 +509,11 @@ void Entity_ungroupSelectedPrimitives(){
|
|||
|
||||
/* scale color so that at least one component is at 1.0F */
|
||||
void NormalizeColor( Vector3& color ){
|
||||
const std::size_t maxi = vector3_max_abs_component_index( color );
|
||||
if ( color[maxi] == 0.f )
|
||||
const auto max = vector3_max_component( color );
|
||||
if ( max == 0 )
|
||||
color = Vector3( 1, 1, 1 );
|
||||
else{
|
||||
const float max = color[maxi];
|
||||
else
|
||||
color /= max;
|
||||
}
|
||||
}
|
||||
|
||||
void Entity_normalizeColor(){
|
||||
|
|
|
|||
|
|
@ -162,11 +162,6 @@ inline bool VectorCompare( const Vector3& v1, const Vector3& v2 ){
|
|||
return vector3_equal_epsilon( v1, v2, EQUAL_EPSILON );
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T VectorMax( const BasicVector3<T>& v ){
|
||||
return ( v[0] > v[1] ) ? ( ( v[0] > v[2] ) ? v[0] : v[2] ) : ( ( v[1] > v[2] ) ? v[1] : v[2] );
|
||||
}
|
||||
|
||||
inline bool VectorIsOnAxis( const Vector3& v ){
|
||||
int zeroComponentCount = 0;
|
||||
for ( int i = 0; i < 3; ++i )
|
||||
|
|
@ -349,7 +344,7 @@ inline EPlaneType PlaneTypeForNormal( const Vector3& normal ) {
|
|||
|
||||
|
||||
inline void ColorNormalize( Vector3& color ) {
|
||||
const float max = VectorMax( color );
|
||||
const float max = vector3_max_component( color );
|
||||
|
||||
if ( max == 0 ) {
|
||||
color.set( 1 );
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ Vector3b ColorToBytes( const Vector3& color, float scale ){
|
|||
|
||||
if ( lightmapExposure == 0 ) {
|
||||
/* clamp with color normalization */
|
||||
max = VectorMax( sample );
|
||||
max = vector3_max_component( sample );
|
||||
if ( max > maxLight ) {
|
||||
sample *= ( maxLight / max );
|
||||
}
|
||||
|
|
@ -98,7 +98,7 @@ Vector3b ColorToBytes( const Vector3& color, float scale ){
|
|||
inv = 1.f / lightmapExposure;
|
||||
//Exposure
|
||||
|
||||
max = VectorMax( sample );
|
||||
max = vector3_max_component( sample );
|
||||
|
||||
dif = ( 1 - exp( -max * inv ) ) * 255;
|
||||
|
||||
|
|
@ -123,7 +123,7 @@ Vector3b ColorToBytes( const Vector3& color, float scale ){
|
|||
sample[i] = std::max( 0.f, lightmapContrast * ( sample[i] - 128 ) + 128 );
|
||||
}
|
||||
/* clamp with color normalization */
|
||||
max = VectorMax( sample );
|
||||
max = vector3_max_component( sample );
|
||||
if ( max > 255.0f ) {
|
||||
sample *= ( 255.0f / max );
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user