vmap: support for _light in light_environment

This commit is contained in:
Marco Cawthorne 2021-08-26 00:24:16 +02:00
parent d23ad3e797
commit 5537a7c2b3

View file

@ -264,6 +264,7 @@ void CreateEntityLights( void ){
float a, b; float a, b;
sun = safe_malloc( sizeof( *sun ) ); sun = safe_malloc( sizeof( *sun ) );
memset( sun, 0, sizeof( *sun ) ); memset( sun, 0, sizeof( *sun ) );
sun->photons = 0;
/* set style */ /* set style */
sun->style = IntForKey( e, "style" ); sun->style = IntForKey( e, "style" );
@ -284,6 +285,15 @@ void CreateEntityLights( void ){
sun->color[0] /= 255; sun->color[0] /= 255;
sun->color[1] /= 255; sun->color[1] /= 255;
sun->color[2] /= 255; sun->color[2] /= 255;
} else {
/* this may be a HL light_environment */
_color = ValueForKey( e, "_light" );
if ( _color && _color[ 0 ] ) {
sscanf( _color, "%f %f %f %f", &sun->color[ 0 ], &sun->color[ 1 ], &sun->color[ 2 ], &sun->photons );
sun->color[0] /= 255;
sun->color[1] /= 255;
sun->color[2] /= 255;
sun->photons *= 0.5f;
} else { } else {
/* default to white color values */ /* default to white color values */
sun->color[ 0 ] = sun->color[ 0 ] =
@ -291,6 +301,7 @@ void CreateEntityLights( void ){
sun->color[ 2 ] = 1.0f; sun->color[ 2 ] = 1.0f;
} }
} }
}
/* global ambient */ /* global ambient */
_color = ValueForKey( e, "ambientcolor" ); _color = ValueForKey( e, "ambientcolor" );
@ -325,6 +336,7 @@ void CreateEntityLights( void ){
ColorNormalize( sun->color, sun->color ); ColorNormalize( sun->color, sun->color );
/* scale color by brightness */ /* scale color by brightness */
if (sun->photons == 0)
sun->photons = FloatForKey( e, "intensity" ) * 0.5f; sun->photons = FloatForKey( e, "intensity" ) * 0.5f;
/* get sun angle/elevation */ /* get sun angle/elevation */