mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-03-22 15:05:03 +01:00
Merge branch 'milek-dev' into gfx-work
This commit is contained in:
18
renderer.cpp
18
renderer.cpp
@@ -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; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user