Merge branch 'milek-dev' into gfx-work

This commit is contained in:
milek7
2019-09-07 02:40:38 +02:00
27 changed files with 2315 additions and 626 deletions

View File

@@ -80,6 +80,9 @@ std::vector<std::pair<glm::vec3, glm::vec2>> const billboard_vertices {
void
opengl_particles::update( opengl_camera const &Camera ) {
if (!Global.Smoke)
return;
m_particlevertices.clear();
// build a list of visible smoke sources
// NOTE: arranged by distance to camera, if we ever need sorting and/or total amount cap-based culling
@@ -100,6 +103,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() };
@@ -107,9 +116,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.r =
vertex.color.g =
vertex.color.b = Global.fLuminance * 0.125f;
vertex.color[ 0 ] = static_cast<std::uint8_t>( particlecolor.r );
vertex.color[ 1 ] = static_cast<std::uint8_t>( particlecolor.g );
vertex.color[ 2 ] = static_cast<std::uint8_t>( particlecolor.b );
vertex.color.a = std::clamp(particle.opacity, 0.0f, 1.0f);
auto const offset { glm::vec3{ particle.position - Camera.position() } };
@@ -145,6 +154,9 @@ opengl_particles::update( opengl_camera const &Camera ) {
void
opengl_particles::render() {
if (!Global.Smoke)
return;
if( m_buffercapacity == 0 ) { return; }
if( m_particlevertices.empty() ) { return; }