Particle system improvements + Emissive materials

Added option for Global particle positions
Added material property for particles
Added Emissive rendering
This commit is contained in:
Antoine Pilote
2023-09-23 20:31:50 -04:00
parent 50bc020f6e
commit 2cb0ca4f29
17 changed files with 242 additions and 26 deletions

View File

@@ -13,6 +13,11 @@ namespace Nuake
}
void ParticleEmitter::SetGlobalOrigin(const Vector3& origin)
{
GlobalOrigin = origin;
}
void ParticleEmitter::SpawnParticle()
{
const bool canSpawnParticle = Particles.size() < Amount;
@@ -23,11 +28,16 @@ namespace Nuake
if (Rate == 0.0f || RateTimer > Rate)
{
const auto initialPosition = Vector3(m_Random(m_MT), m_Random(m_MT), m_Random(m_MT));
auto initialPosition = Vector3(m_Random(m_MT), m_Random(m_MT), m_Random(m_MT));
const auto initialVelocity = Vector3();
const auto initialColor = ParticleColor;
const float initialLife = Life;
if (IsGlobalSpace)
{
initialPosition = initialPosition + GlobalOrigin;
}
Particles.push_back({
initialPosition,
initialVelocity,

View File

@@ -22,6 +22,9 @@ namespace Nuake
float Rate = 0.0f;
Color ParticleColor;
bool IsGlobalSpace = false;
Vector3 GlobalOrigin;
private:
float RateTimer = 0.0f;
std::mt19937 m_MT;
@@ -33,6 +36,8 @@ namespace Nuake
ParticleEmitter();
~ParticleEmitter() = default;
void SetGlobalOrigin(const Vector3& origin);
void SpawnParticle();
void Update(Timestep ts);

View File

@@ -34,6 +34,8 @@ namespace Nuake
emitter.SetRadius(emitterComponent.Radius);
emitter.Life = emitterComponent.Life;
emitter.Rate = emitterComponent.Rate;
emitter.IsGlobalSpace = emitterComponent.GlobalSpace;
emitter.GlobalOrigin = transformComponent.GetGlobalTransform()[3];
// Spawn particle if possible
emitterComponent.Emitter.SpawnParticle();