heating power source fix, particle color support

This commit is contained in:
tmj-fstate
2019-08-20 12:37:24 +02:00
parent 7e91a52646
commit 4dddf2dc45
5 changed files with 48 additions and 21 deletions

View File

@@ -142,6 +142,12 @@ opengl_particles::update( opengl_camera const &Camera ) {
particle_vertex vertex;
for( auto const &source : sources ) {
auto const particlecolor {
glm::clamp(
source.second.color()
* ( glm::vec3 { Global.DayLight.ambient } + 0.35f * glm::vec3{ Global.DayLight.diffuse } )
* 255.f,
glm::vec3{ 0.f }, glm::vec3{ 255.f } ) };
auto const &particles { source.second.sequence() };
// TODO: put sanity cap on the overall amount of particles that can be drawn
auto const sizestep { 256.0 * billboard_vertices.size() };
@@ -149,9 +155,9 @@ opengl_particles::update( opengl_camera const &Camera ) {
sizestep * std::ceil( m_particlevertices.size() + ( particles.size() * billboard_vertices.size() ) / sizestep ) );
for( auto const &particle : particles ) {
// TODO: particle color support
vertex.color[ 0 ] =
vertex.color[ 1 ] =
vertex.color[ 2 ] = static_cast<std::uint8_t>( Global.fLuminance * 32 );
vertex.color[ 0 ] = static_cast<std::uint_fast8_t>( particlecolor.r );
vertex.color[ 1 ] = static_cast<std::uint_fast8_t>( particlecolor.g );
vertex.color[ 2 ] = static_cast<std::uint_fast8_t>( particlecolor.b );
vertex.color[ 3 ] = clamp<std::uint8_t>( particle.opacity * 255, 0, 255 );
auto const offset { glm::vec3{ particle.position - Camera.position() } };
@@ -3157,6 +3163,10 @@ opengl_renderer::Render_particles() {
Bind_Texture( m_smoketexture );
m_particlerenderer.render( m_diffusetextureunit );
if( Global.bUseVBO ) {
// shouldn't be strictly necessary but, eh
gfx::opengl_vbogeometrybank::reset();
}
::glDepthMask( GL_TRUE );
::glEnable( GL_LIGHTING );