Merge branch 'tmj-dev' into milek-dev

This commit is contained in:
milek7
2019-05-23 22:26:31 +02:00
28 changed files with 775 additions and 392 deletions

View File

@@ -32,17 +32,18 @@ int const EU07_ENVIRONMENTBUFFERSIZE { 256 }; // size of (square) environmental
void
opengl_light::apply_intensity( float const Factor ) {
if( Factor == 1.0 ) {
if( Factor == 1.f ) {
::glLightfv( id, GL_AMBIENT, glm::value_ptr( ambient ) );
::glLightfv( id, GL_DIFFUSE, glm::value_ptr( diffuse ) );
::glLightfv( id, GL_SPECULAR, glm::value_ptr( specular ) );
}
else {
auto const factor{ clamp( Factor, 0.05f, 1.f ) };
// temporary light scaling mechanics (ultimately this work will be left to the shaders
glm::vec4 scaledambient( ambient.r * Factor, ambient.g * Factor, ambient.b * Factor, ambient.a );
glm::vec4 scaleddiffuse( diffuse.r * Factor, diffuse.g * Factor, diffuse.b * Factor, diffuse.a );
glm::vec4 scaledspecular( specular.r * Factor, specular.g * Factor, specular.b * Factor, specular.a );
glm::vec4 scaledambient( ambient.r * factor, ambient.g * factor, ambient.b * factor, ambient.a );
glm::vec4 scaleddiffuse( diffuse.r * factor, diffuse.g * factor, diffuse.b * factor, diffuse.a );
glm::vec4 scaledspecular( specular.r * factor, specular.g * factor, specular.b * factor, specular.a );
glLightfv( id, GL_AMBIENT, glm::value_ptr( scaledambient ) );
glLightfv( id, GL_DIFFUSE, glm::value_ptr( scaleddiffuse ) );
glLightfv( id, GL_SPECULAR, glm::value_ptr( scaledspecular ) );
@@ -2194,34 +2195,36 @@ opengl_renderer::Render( TDynamicObject *Dynamic ) {
m_renderspecular = true; // vehicles are rendered with specular component. static models without, at least for the time being
// render
if( Dynamic->mdLowPolyInt ) {
// low poly interior
/*
if( ( true == FreeFlyModeFlag )
|| ( ( Dynamic->mdKabina == nullptr ) || ( false == Dynamic->bDisplayCab ) ) ) {
*/
/*
// enable cab light if needed
if( Dynamic->InteriorLightLevel > 0.0f ) {
// HACK: reduce light level for vehicle interior if there's strong global lighting source
auto const luminance { static_cast<float>( 0.5 * ( std::max( 0.3, Global.fLuminance - Global.Overcast ) ) ) };
m_sunlight.apply_intensity(
clamp( (
Dynamic->fShade > 0.f ?
Dynamic->fShade :
1.f )
- luminance,
0.f, 1.f ) );
// crude way to light the cabin, until we have something more complete in place
::glLightModelfv( GL_LIGHT_MODEL_AMBIENT, glm::value_ptr( Dynamic->InteriorLight * Dynamic->InteriorLightLevel ) );
}
*/
Render( Dynamic->mdLowPolyInt, Dynamic->Material(), squaredistance );
/*
if( Dynamic->InteriorLightLevel > 0.0f ) {
// reset the overall ambient
::glLightModelfv( GL_LIGHT_MODEL_AMBIENT, glm::value_ptr( m_baseambient ) );
}
*/
/*
// low poly interior
Render( Dynamic->mdLowPolyInt, Dynamic->Material(), squaredistance );
// HACK: if the model has low poly interior, we presume the load is placed inside and also affected by reduced light level
if( Dynamic->mdLoad ) {
// renderowanie nieprzezroczystego ładunku
Render( Dynamic->mdLoad, Dynamic->Material(), squaredistance, { 0.f, Dynamic->LoadOffset, 0.f }, {} );
}
*/
m_sunlight.apply_intensity( Dynamic->fShade > 0.f ? Dynamic->fShade : 1.f );
}
if( Dynamic->mdModel )
else {
// HACK: if the model lacks low poly interior, we presume the load is placed outside
if( Dynamic->mdLoad ) {
// renderowanie nieprzezroczystego ładunku
Render( Dynamic->mdLoad, Dynamic->Material(), squaredistance, { 0.f, Dynamic->LoadOffset, 0.f }, {} );
}
}
if( Dynamic->mdModel ) {
Render( Dynamic->mdModel, Dynamic->Material(), squaredistance );
if( Dynamic->mdLoad ) // renderowanie nieprzezroczystego ładunku
Render( Dynamic->mdLoad, Dynamic->Material(), squaredistance, { 0.f, Dynamic->LoadOffset, 0.f }, {} );
}
// post-render cleanup
m_renderspecular = false;
if( Dynamic->fShade > 0.0f ) {