mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 20:59:19 +02:00
glare level influenced by global lighting level
This commit is contained in:
@@ -4005,9 +4005,8 @@ bool TGround::EventConditon(TEvent *e)
|
|||||||
ErrorLog( "Event " + e->asName + " trying conditional_memcompare with nonexistent memcell" );
|
ErrorLog( "Event " + e->asName + " trying conditional_memcompare with nonexistent memcell" );
|
||||||
return true; // though this is technically error, we report success to maintain backward compatibility
|
return true; // though this is technically error, we report success to maintain backward compatibility
|
||||||
}
|
}
|
||||||
if (tmpEvent->Params[9].asMemCell->Compare(e->Params[10].asText, e->Params[11].asdouble,
|
if (tmpEvent->Params[9].asMemCell->Compare( ( e->Params[ 10 ].asText != nullptr ? e->Params[10].asText : "" ), e->Params[11].asdouble, e->Params[12].asdouble, e->iFlags) ) {
|
||||||
e->Params[12].asdouble, e->iFlags))
|
//logowanie spełnionych warunków
|
||||||
{ //logowanie spełnionych warunków
|
|
||||||
LogComment = e->Params[9].asMemCell->Text() + " " +
|
LogComment = e->Params[9].asMemCell->Text() + " " +
|
||||||
to_string(e->Params[9].asMemCell->Value1(), 2, 8) + " " +
|
to_string(e->Params[9].asMemCell->Value1(), 2, 8) + " " +
|
||||||
to_string(tmpEvent->Params[9].asMemCell->Value2(), 2, 8) +
|
to_string(tmpEvent->Params[9].asMemCell->Value2(), 2, 8) +
|
||||||
|
|||||||
11
renderer.cpp
11
renderer.cpp
@@ -619,14 +619,17 @@ opengl_renderer::Render_Alpha( TSubModel *Submodel ) {
|
|||||||
auto const lightcenter = modelview * glm::vec4( 0.0f, 0.0f, -0.05f, 1.0f ); // pozycja punktu świecącego względem kamery
|
auto const lightcenter = modelview * glm::vec4( 0.0f, 0.0f, -0.05f, 1.0f ); // pozycja punktu świecącego względem kamery
|
||||||
Submodel->fCosViewAngle = glm::dot( glm::normalize( modelview * glm::vec4( 0.0f, 0.0f, -1.0f, 1.0f ) - lightcenter ), glm::normalize( -lightcenter ) );
|
Submodel->fCosViewAngle = glm::dot( glm::normalize( modelview * glm::vec4( 0.0f, 0.0f, -1.0f, 1.0f ) - lightcenter ), glm::normalize( -lightcenter ) );
|
||||||
|
|
||||||
float fadelevel = 0.5f;
|
float glarelevel = 0.6f; // luminosity at night is at level of ~0.1, so the overall resulting transparency is ~0.5 at full 'brightness'
|
||||||
if( ( Submodel->fCosViewAngle > 0.0 ) && ( Submodel->fCosViewAngle > Submodel->fCosFalloffAngle ) ) {
|
if( ( Submodel->fCosViewAngle > 0.0 ) && ( Submodel->fCosViewAngle > Submodel->fCosFalloffAngle ) ) {
|
||||||
|
|
||||||
fadelevel *= ( Submodel->fCosViewAngle - Submodel->fCosFalloffAngle ) / ( 1.0 - Submodel->fCosFalloffAngle );
|
glarelevel *= ( Submodel->fCosViewAngle - Submodel->fCosFalloffAngle ) / ( 1.0 - Submodel->fCosFalloffAngle );
|
||||||
|
glarelevel = std::max( 0.0f, glarelevel - static_cast<float>(Global::fLuminance) );
|
||||||
|
|
||||||
|
if( glarelevel > 0.0f ) {
|
||||||
|
|
||||||
::glPushAttrib( GL_ENABLE_BIT | GL_CURRENT_BIT | GL_COLOR_BUFFER_BIT );
|
::glPushAttrib( GL_ENABLE_BIT | GL_CURRENT_BIT | GL_COLOR_BUFFER_BIT );
|
||||||
Bind( m_glaretextureid );
|
Bind( m_glaretextureid );
|
||||||
::glColor4f( Submodel->f4Diffuse[ 0 ], Submodel->f4Diffuse[ 1 ], Submodel->f4Diffuse[ 2 ], fadelevel );
|
::glColor4f( Submodel->f4Diffuse[ 0 ], Submodel->f4Diffuse[ 1 ], Submodel->f4Diffuse[ 2 ], glarelevel );
|
||||||
::glDisable( GL_LIGHTING );
|
::glDisable( GL_LIGHTING );
|
||||||
::glBlendFunc( GL_SRC_ALPHA, GL_ONE );
|
::glBlendFunc( GL_SRC_ALPHA, GL_ONE );
|
||||||
|
|
||||||
@@ -637,6 +640,7 @@ opengl_renderer::Render_Alpha( TSubModel *Submodel ) {
|
|||||||
|
|
||||||
::glMaterialfv( GL_FRONT, GL_EMISSION, Submodel->f4Diffuse ); // zeby swiecilo na kolorowo
|
::glMaterialfv( GL_FRONT, GL_EMISSION, Submodel->f4Diffuse ); // zeby swiecilo na kolorowo
|
||||||
|
|
||||||
|
// TODO: turn the drawing instructions into a compiled call / array
|
||||||
::glBegin( GL_TRIANGLE_STRIP );
|
::glBegin( GL_TRIANGLE_STRIP );
|
||||||
float const size = 2.5f;
|
float const size = 2.5f;
|
||||||
::glTexCoord2f( 1.0f, 1.0f ); ::glVertex3f( -size, size, 0.0f );
|
::glTexCoord2f( 1.0f, 1.0f ); ::glVertex3f( -size, size, 0.0f );
|
||||||
@@ -661,6 +665,7 @@ opengl_renderer::Render_Alpha( TSubModel *Submodel ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if( Submodel->Child != NULL ) {
|
if( Submodel->Child != NULL ) {
|
||||||
if( Submodel->eType == TP_TEXT ) { // tekst renderujemy w specjalny sposób, zamiast submodeli z łańcucha Child
|
if( Submodel->eType == TP_TEXT ) { // tekst renderujemy w specjalny sposób, zamiast submodeli z łańcucha Child
|
||||||
|
|||||||
Reference in New Issue
Block a user