mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 16:19: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) +
|
||||||
|
|||||||
63
renderer.cpp
63
renderer.cpp
@@ -619,45 +619,50 @@ 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) );
|
||||||
|
|
||||||
::glPushAttrib( GL_ENABLE_BIT | GL_CURRENT_BIT | GL_COLOR_BUFFER_BIT );
|
if( glarelevel > 0.0f ) {
|
||||||
Bind( m_glaretextureid );
|
|
||||||
::glColor4f( Submodel->f4Diffuse[ 0 ], Submodel->f4Diffuse[ 1 ], Submodel->f4Diffuse[ 2 ], fadelevel );
|
|
||||||
::glDisable( GL_LIGHTING );
|
|
||||||
::glBlendFunc( GL_SRC_ALPHA, GL_ONE );
|
|
||||||
|
|
||||||
::glPushMatrix();
|
::glPushAttrib( GL_ENABLE_BIT | GL_CURRENT_BIT | GL_COLOR_BUFFER_BIT );
|
||||||
::glLoadIdentity(); // macierz jedynkowa
|
Bind( m_glaretextureid );
|
||||||
::glTranslatef( lightcenter.x, lightcenter.y, lightcenter.z ); // początek układu zostaje bez zmian
|
::glColor4f( Submodel->f4Diffuse[ 0 ], Submodel->f4Diffuse[ 1 ], Submodel->f4Diffuse[ 2 ], glarelevel );
|
||||||
::glRotated( atan2( lightcenter.x, lightcenter.z ) * 180.0 / M_PI, 0.0, 1.0, 0.0 ); // jedynie obracamy w pionie o kąt
|
::glDisable( GL_LIGHTING );
|
||||||
|
::glBlendFunc( GL_SRC_ALPHA, GL_ONE );
|
||||||
|
|
||||||
::glMaterialfv( GL_FRONT, GL_EMISSION, Submodel->f4Diffuse ); // zeby swiecilo na kolorowo
|
::glPushMatrix();
|
||||||
|
::glLoadIdentity(); // macierz jedynkowa
|
||||||
|
::glTranslatef( lightcenter.x, lightcenter.y, lightcenter.z ); // początek układu zostaje bez zmian
|
||||||
|
::glRotated( atan2( lightcenter.x, lightcenter.z ) * 180.0 / M_PI, 0.0, 1.0, 0.0 ); // jedynie obracamy w pionie o kąt
|
||||||
|
|
||||||
::glBegin( GL_TRIANGLE_STRIP );
|
::glMaterialfv( GL_FRONT, GL_EMISSION, Submodel->f4Diffuse ); // zeby swiecilo na kolorowo
|
||||||
float const size = 2.5f;
|
|
||||||
::glTexCoord2f( 1.0f, 1.0f ); ::glVertex3f( -size, size, 0.0f );
|
// TODO: turn the drawing instructions into a compiled call / array
|
||||||
::glTexCoord2f( 0.0f, 1.0f ); ::glVertex3f( size, size, 0.0f );
|
::glBegin( GL_TRIANGLE_STRIP );
|
||||||
::glTexCoord2f( 1.0f, 0.0f ); ::glVertex3f( -size, -size, 0.0f );
|
float const size = 2.5f;
|
||||||
::glTexCoord2f( 0.0f, 0.0f ); ::glVertex3f( size, -size, 0.0f );
|
::glTexCoord2f( 1.0f, 1.0f ); ::glVertex3f( -size, size, 0.0f );
|
||||||
|
::glTexCoord2f( 0.0f, 1.0f ); ::glVertex3f( size, size, 0.0f );
|
||||||
|
::glTexCoord2f( 1.0f, 0.0f ); ::glVertex3f( -size, -size, 0.0f );
|
||||||
|
::glTexCoord2f( 0.0f, 0.0f ); ::glVertex3f( size, -size, 0.0f );
|
||||||
/*
|
/*
|
||||||
// NOTE: we could do simply...
|
// NOTE: we could do simply...
|
||||||
vec3 vertexPosition_worldspace =
|
vec3 vertexPosition_worldspace =
|
||||||
particleCenter_wordspace
|
particleCenter_wordspace
|
||||||
+ CameraRight_worldspace * squareVertices.x * BillboardSize.x
|
+ CameraRight_worldspace * squareVertices.x * BillboardSize.x
|
||||||
+ CameraUp_worldspace * squareVertices.y * BillboardSize.y;
|
+ CameraUp_worldspace * squareVertices.y * BillboardSize.y;
|
||||||
// ...etc instead IF we had easy access to camera's forward and right vectors. TODO: check if Camera matrix is accessible
|
// ...etc instead IF we had easy access to camera's forward and right vectors. TODO: check if Camera matrix is accessible
|
||||||
*/
|
*/
|
||||||
::glEnd();
|
::glEnd();
|
||||||
|
|
||||||
float4 const noemission( 0.0f, 0.0f, 0.0f, 1.0f );
|
float4 const noemission( 0.0f, 0.0f, 0.0f, 1.0f );
|
||||||
::glMaterialfv( GL_FRONT, GL_EMISSION, &noemission.x );
|
::glMaterialfv( GL_FRONT, GL_EMISSION, &noemission.x );
|
||||||
|
|
||||||
::glPopMatrix();
|
::glPopMatrix();
|
||||||
::glPopAttrib();
|
::glPopAttrib();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user