Implemented color decay, color range emission and custom VS and FS for particles #447
|
@ -1,3 +1,4 @@
|
||||||
|
- NavData: 0
|
||||||
- EID: 0
|
- EID: 0
|
||||||
Name: Default
|
Name: Default
|
||||||
IsActive: true
|
IsActive: true
|
||||||
|
@ -170,8 +171,11 @@
|
||||||
Angular Ranges And Offset: {x: 6.19999981, y: 1.10000002, z: 0, w: 0.100000001}
|
Angular Ranges And Offset: {x: 6.19999981, y: 1.10000002, z: 0, w: 0.100000001}
|
||||||
Rotation Speed: 0.0309999995
|
Rotation Speed: 0.0309999995
|
||||||
Rotation Decay: 0.0199999996
|
Rotation Decay: 0.0199999996
|
||||||
Texture Asset ID: 63456868
|
Texture Asset ID: 0
|
||||||
Custom Update Shader Asset ID: 0
|
Custom Update Shader Asset ID: 0
|
||||||
Color Tint: {x: 1, y: 0, z: 0, w: 1}
|
Color Tint: {x: 0, y: 1, z: 0.56387639, w: 1}
|
||||||
|
Color Tint Range: {x: 0.5, y: 0.5, z: 0.5, w: 0}
|
||||||
|
Color Decay: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
Acceleration: {x: 0, y: 0, z: 0}
|
||||||
IsActive: true
|
IsActive: true
|
||||||
Scripts: ~
|
Scripts: ~
|
|
@ -14,6 +14,8 @@ struct EmitterParameters
|
||||||
float rotationDecay;
|
float rotationDecay;
|
||||||
vec4 lifeAndSizeRange; // min life, max life, min size, max size
|
vec4 lifeAndSizeRange; // min life, max life, min size, max size
|
||||||
vec4 colorTint;
|
vec4 colorTint;
|
||||||
|
vec4 colorTintRange;
|
||||||
|
vec4 colorDecay;
|
||||||
float sizeDecay;
|
float sizeDecay;
|
||||||
uint textureIndex;
|
uint textureIndex;
|
||||||
float padding[2];
|
float padding[2];
|
||||||
|
@ -27,6 +29,7 @@ struct ParticleData
|
||||||
vec4 acceleration;
|
vec4 acceleration;
|
||||||
vec4 scaleAndDecay;
|
vec4 scaleAndDecay;
|
||||||
vec4 colorTint;
|
vec4 colorTint;
|
||||||
|
vec4 colorDecay;
|
||||||
float life;
|
float life;
|
||||||
uint textureIndex;
|
uint textureIndex;
|
||||||
};
|
};
|
||||||
|
@ -175,9 +178,18 @@ void main()
|
||||||
particle.scaleAndDecay.y = particleSize;
|
particle.scaleAndDecay.y = particleSize;
|
||||||
particle.scaleAndDecay.z = emitterParams.data.sizeDecay;
|
particle.scaleAndDecay.z = emitterParams.data.sizeDecay;
|
||||||
particle.scaleAndDecay.w = emitterParams.data.sizeDecay;
|
particle.scaleAndDecay.w = emitterParams.data.sizeDecay;
|
||||||
|
particle.colorDecay = emitterParams.data.colorDecay;
|
||||||
|
|
||||||
|
float randRange = rand(seed) * 2.0f - 1.0f;
|
||||||
|
|
||||||
// Set particle color tint
|
// Set particle color tint
|
||||||
particle.colorTint = emitterParams.data.colorTint;
|
particle.colorTint = emitterParams.data.colorTint + vec4 (randRange * emitterParams.data.colorTintRange.x,
|
||||||
|
randRange * emitterParams.data.colorTintRange.y,
|
||||||
|
randRange * emitterParams.data.colorTintRange.z,
|
||||||
|
randRange * emitterParams.data.colorTintRange.w);
|
||||||
|
|
||||||
|
// particle.colorTint = emitterParams.data.colorTint;
|
||||||
|
|
||||||
|
|
||||||
// Set the texture for the particle
|
// Set the texture for the particle
|
||||||
particle.textureIndex = emitterParams.data.textureIndex;
|
particle.textureIndex = emitterParams.data.textureIndex;
|
||||||
|
|
Binary file not shown.
|
@ -18,6 +18,7 @@ struct ParticleData
|
||||||
vec4 acceleration;
|
vec4 acceleration;
|
||||||
vec4 scaleAndDecay;
|
vec4 scaleAndDecay;
|
||||||
vec4 colorTint;
|
vec4 colorTint;
|
||||||
|
vec4 colorDecay;
|
||||||
float life;
|
float life;
|
||||||
uint textureIndex;
|
uint textureIndex;
|
||||||
};
|
};
|
||||||
|
|
|
@ -17,6 +17,8 @@ struct ParticleData
|
||||||
vec4 velocity;
|
vec4 velocity;
|
||||||
vec4 acceleration;
|
vec4 acceleration;
|
||||||
vec4 scaleAndDecay;
|
vec4 scaleAndDecay;
|
||||||
|
vec4 colorTint;
|
||||||
|
vec4 colorDecay;
|
||||||
float life;
|
float life;
|
||||||
uint textureIndex;
|
uint textureIndex;
|
||||||
};
|
};
|
||||||
|
|
|
@ -18,6 +18,7 @@ struct ParticleData
|
||||||
vec4 acceleration;
|
vec4 acceleration;
|
||||||
vec4 scaleAndDecay;
|
vec4 scaleAndDecay;
|
||||||
vec4 colorTint;
|
vec4 colorTint;
|
||||||
|
vec4 colorDecay;
|
||||||
float life;
|
float life;
|
||||||
uint textureIndex;
|
uint textureIndex;
|
||||||
};
|
};
|
||||||
|
|
|
@ -18,6 +18,7 @@ struct ParticleData
|
||||||
vec4 acceleration;
|
vec4 acceleration;
|
||||||
vec4 scaleAndDecay;
|
vec4 scaleAndDecay;
|
||||||
vec4 colorTint;
|
vec4 colorTint;
|
||||||
|
vec4 colorDecay;
|
||||||
float life;
|
float life;
|
||||||
uint textureIndex;
|
uint textureIndex;
|
||||||
};
|
};
|
||||||
|
@ -126,6 +127,7 @@ void main()
|
||||||
particle.orientationSpeedDecay.x += particle.orientationSpeedDecay.y;
|
particle.orientationSpeedDecay.x += particle.orientationSpeedDecay.y;
|
||||||
particle.scaleAndDecay.x *= particle.scaleAndDecay.z;
|
particle.scaleAndDecay.x *= particle.scaleAndDecay.z;
|
||||||
particle.scaleAndDecay.y *= particle.scaleAndDecay.w;
|
particle.scaleAndDecay.y *= particle.scaleAndDecay.w;
|
||||||
|
particle.colorTint -= particle.colorDecay * genericDataBuffer.data.dt;
|
||||||
|
|
||||||
if (particle.orientationSpeedDecay.y > 0.0f)
|
if (particle.orientationSpeedDecay.y > 0.0f)
|
||||||
{
|
{
|
||||||
|
|
Binary file not shown.
|
@ -15,7 +15,6 @@ struct GenericData
|
||||||
uint viewportHeight;
|
uint viewportHeight;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct ParticleData
|
struct ParticleData
|
||||||
{
|
{
|
||||||
vec4 position;
|
vec4 position;
|
||||||
|
@ -24,6 +23,7 @@ struct ParticleData
|
||||||
vec4 acceleration;
|
vec4 acceleration;
|
||||||
vec4 scaleAndDecay;
|
vec4 scaleAndDecay;
|
||||||
vec4 colorTint;
|
vec4 colorTint;
|
||||||
|
vec4 colorDecay;
|
||||||
float life;
|
float life;
|
||||||
uint textureIndex;
|
uint textureIndex;
|
||||||
};
|
};
|
||||||
|
|
Binary file not shown.
|
@ -903,6 +903,26 @@ namespace SHADE
|
||||||
comp->SetColorTint(val);
|
comp->SetColorTint(val);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
SHEditorWidgets::DragVec4("Color Decay", {"x", "y", "z", "w"},
|
||||||
|
[comp = component]()
|
||||||
|
{
|
||||||
|
return comp->GetColorDecay();
|
||||||
|
},
|
||||||
|
[comp = component](SHVec4 const& val)
|
||||||
|
{
|
||||||
|
comp->SetColorDecay(val);
|
||||||
|
});
|
||||||
|
|
||||||
|
SHEditorWidgets::DragVec4("Color Tint Range", { "x", "y", "z", "w" },
|
||||||
|
[comp = component]()
|
||||||
|
{
|
||||||
|
return comp->GetColorTintRange();
|
||||||
|
},
|
||||||
|
[comp = component](SHVec4 const& val)
|
||||||
|
{
|
||||||
|
comp->SetColorTintRange(val);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
SHEditorWidgets::DragInt("Texture Index",
|
SHEditorWidgets::DragInt("Texture Index",
|
||||||
[comp = component]()
|
[comp = component]()
|
||||||
|
|
|
@ -156,11 +156,45 @@ namespace SHADE
|
||||||
cpuEmitterData.colorTint.z = tint.z;
|
cpuEmitterData.colorTint.z = tint.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SHParticleEmitterComponent::SetColorDecayRGB(SHVec3 const& decay) noexcept
|
||||||
|
{
|
||||||
|
cpuEmitterData.colorDecay.x = decay.x;
|
||||||
|
cpuEmitterData.colorDecay.y = decay.y;
|
||||||
|
cpuEmitterData.colorDecay.z = decay.z;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHParticleEmitterComponent::SetColorDecayAlpha(float alpha) noexcept
|
||||||
|
{
|
||||||
|
cpuEmitterData.colorDecay.w = alpha;
|
||||||
|
}
|
||||||
|
|
||||||
void SHParticleEmitterComponent::SetColorTintAlpha(float alpha) noexcept
|
void SHParticleEmitterComponent::SetColorTintAlpha(float alpha) noexcept
|
||||||
{
|
{
|
||||||
cpuEmitterData.colorTint.w = alpha;
|
cpuEmitterData.colorTint.w = alpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SHParticleEmitterComponent::SetColorTintRange(SHVec4 const& tintRange) noexcept
|
||||||
|
{
|
||||||
|
cpuEmitterData.colorTintRange = tintRange;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHParticleEmitterComponent::SetColorTintRangeRGB(SHVec3 const& tintRange) noexcept
|
||||||
|
{
|
||||||
|
cpuEmitterData.colorTintRange.x = tintRange.x;
|
||||||
|
cpuEmitterData.colorTintRange.y = tintRange.y;
|
||||||
|
cpuEmitterData.colorTintRange.z = tintRange.z;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHParticleEmitterComponent::SetColorTintRangeAlpha(float alpha) noexcept
|
||||||
|
{
|
||||||
|
cpuEmitterData.colorTintRange.w = alpha;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHParticleEmitterComponent::SetColorDecay(SHVec4 const& decay) noexcept
|
||||||
|
{
|
||||||
|
cpuEmitterData.colorDecay = decay;
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t SHParticleEmitterComponent::GetEmissionCount(void) const noexcept
|
uint32_t SHParticleEmitterComponent::GetEmissionCount(void) const noexcept
|
||||||
{
|
{
|
||||||
return emissionCount;
|
return emissionCount;
|
||||||
|
@ -273,9 +307,39 @@ namespace SHADE
|
||||||
return SHVec3 (cpuEmitterData.colorTint.x, cpuEmitterData.colorTint.y, cpuEmitterData.colorTint.z);
|
return SHVec3 (cpuEmitterData.colorTint.x, cpuEmitterData.colorTint.y, cpuEmitterData.colorTint.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SHVec3 SHParticleEmitterComponent::GetColorDecayRGB(void) const noexcept
|
||||||
|
{
|
||||||
|
return SHVec3(cpuEmitterData.colorDecay.x, cpuEmitterData.colorDecay.y, cpuEmitterData.colorDecay.z);
|
||||||
|
}
|
||||||
|
|
||||||
|
float SHParticleEmitterComponent::GetColorDecayAlpha(void) const noexcept
|
||||||
|
{
|
||||||
|
return cpuEmitterData.colorDecay.w;
|
||||||
|
}
|
||||||
|
|
||||||
float SHParticleEmitterComponent::GetColorTintAlpha(void) const noexcept
|
float SHParticleEmitterComponent::GetColorTintAlpha(void) const noexcept
|
||||||
{
|
{
|
||||||
return cpuEmitterData.colorTint.w;
|
return cpuEmitterData.colorTint.w;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SHVec4 const& SHParticleEmitterComponent::GetColorTintRange(void) const noexcept
|
||||||
|
{
|
||||||
|
return cpuEmitterData.colorTintRange;
|
||||||
|
}
|
||||||
|
|
||||||
|
SHVec3 SHParticleEmitterComponent::GetColorTintRangeRGB(void) const noexcept
|
||||||
|
{
|
||||||
|
return SHVec3(cpuEmitterData.colorTintRange.x, cpuEmitterData.colorTintRange.y, cpuEmitterData.colorTintRange.z);
|
||||||
|
}
|
||||||
|
|
||||||
|
float SHParticleEmitterComponent::GetColorTintRangeAlpha(void) const noexcept
|
||||||
|
{
|
||||||
|
return cpuEmitterData.colorTintRange.w;
|
||||||
|
}
|
||||||
|
|
||||||
|
SHVec4 const& SHParticleEmitterComponent::GetColorDecay(void) const noexcept
|
||||||
|
{
|
||||||
|
return cpuEmitterData.colorDecay;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -46,6 +46,12 @@ namespace SHADE
|
||||||
//! Color tint to assign to particles
|
//! Color tint to assign to particles
|
||||||
SHVec4 colorTint;
|
SHVec4 colorTint;
|
||||||
|
|
||||||
|
//! Color tint range to assign to particles
|
||||||
|
SHVec4 colorTintRange;
|
||||||
|
|
||||||
|
//! Color decay for particle
|
||||||
|
SHVec4 colorDecay;
|
||||||
|
|
||||||
//! Size decay for particles
|
//! Size decay for particles
|
||||||
float sizeDecayMult;
|
float sizeDecayMult;
|
||||||
|
|
||||||
|
@ -77,6 +83,9 @@ namespace SHADE
|
||||||
//! Color tinting for particle
|
//! Color tinting for particle
|
||||||
SHVec4 colorTint;
|
SHVec4 colorTint;
|
||||||
|
|
||||||
|
//! Color tinting for particle
|
||||||
|
SHVec4 colorDecay;
|
||||||
|
|
||||||
//! Life of the particle
|
//! Life of the particle
|
||||||
float life;
|
float life;
|
||||||
|
|
||||||
|
@ -172,6 +181,13 @@ namespace SHADE
|
||||||
void SetColorTint (SHVec4 tint) noexcept;
|
void SetColorTint (SHVec4 tint) noexcept;
|
||||||
void SetColorTintRGB (SHVec3 tint) noexcept;
|
void SetColorTintRGB (SHVec3 tint) noexcept;
|
||||||
void SetColorTintAlpha (float alpha) noexcept;
|
void SetColorTintAlpha (float alpha) noexcept;
|
||||||
|
void SetColorTintRange (SHVec4 const& tintRange) noexcept;
|
||||||
|
void SetColorTintRangeRGB (SHVec3 const& tintRange) noexcept;
|
||||||
|
void SetColorTintRangeAlpha (float alpha) noexcept;
|
||||||
|
|
||||||
|
void SetColorDecay (SHVec4 const& decay) noexcept;
|
||||||
|
void SetColorDecayRGB (SHVec3 const& decay) noexcept;
|
||||||
|
void SetColorDecayAlpha (float alpha) noexcept;
|
||||||
|
|
||||||
uint32_t GetEmissionCount (void) const noexcept;
|
uint32_t GetEmissionCount (void) const noexcept;
|
||||||
bool GetPassive (void) const noexcept;
|
bool GetPassive (void) const noexcept;
|
||||||
|
@ -194,6 +210,12 @@ namespace SHADE
|
||||||
SHVec4 const& GetColorTint (void) const noexcept;
|
SHVec4 const& GetColorTint (void) const noexcept;
|
||||||
SHVec3 GetColorTintRGB (void) const noexcept;
|
SHVec3 GetColorTintRGB (void) const noexcept;
|
||||||
float GetColorTintAlpha (void) const noexcept;
|
float GetColorTintAlpha (void) const noexcept;
|
||||||
|
SHVec4 const& GetColorTintRange (void) const noexcept;
|
||||||
|
SHVec3 GetColorTintRangeRGB (void) const noexcept;
|
||||||
|
float GetColorTintRangeAlpha (void) const noexcept;
|
||||||
|
SHVec4 const& GetColorDecay (void) const noexcept;
|
||||||
|
SHVec3 GetColorDecayRGB (void) const noexcept;
|
||||||
|
float GetColorDecayAlpha (void) const noexcept;
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
/* NON-INTERFACE FUNCTIONS */
|
/* NON-INTERFACE FUNCTIONS */
|
||||||
|
|
|
@ -520,6 +520,8 @@ namespace YAML
|
||||||
static constexpr std::string_view TEXTURE_ASSET_ID_TAG = "Texture Asset ID";
|
static constexpr std::string_view TEXTURE_ASSET_ID_TAG = "Texture Asset ID";
|
||||||
static constexpr std::string_view CUSTOM_UPDATE_SHADER_ASSET_ID_TAG = "Custom Update Shader Asset ID";
|
static constexpr std::string_view CUSTOM_UPDATE_SHADER_ASSET_ID_TAG = "Custom Update Shader Asset ID";
|
||||||
static constexpr std::string_view COLOR_TINT_TAG = "Color Tint";
|
static constexpr std::string_view COLOR_TINT_TAG = "Color Tint";
|
||||||
|
static constexpr std::string_view COLOR_TINT_RANGE_TAG = "Color Tint Range";
|
||||||
|
static constexpr std::string_view COLOR_DECAY_TAG = "Color Decay";
|
||||||
static constexpr std::string_view ACCELERATION_TAG = "Acceleration";
|
static constexpr std::string_view ACCELERATION_TAG = "Acceleration";
|
||||||
|
|
||||||
static YAML::Node encode(SHParticleEmitterComponent const& rhs)
|
static YAML::Node encode(SHParticleEmitterComponent const& rhs)
|
||||||
|
@ -541,6 +543,8 @@ namespace YAML
|
||||||
node[TEXTURE_ASSET_ID_TAG.data()] = rhs.GetTextureAssetID();
|
node[TEXTURE_ASSET_ID_TAG.data()] = rhs.GetTextureAssetID();
|
||||||
node[CUSTOM_UPDATE_SHADER_ASSET_ID_TAG.data()] = rhs.GetCustomUpdateShaderAssetID();
|
node[CUSTOM_UPDATE_SHADER_ASSET_ID_TAG.data()] = rhs.GetCustomUpdateShaderAssetID();
|
||||||
node[COLOR_TINT_TAG.data()] = rhs.GetColorTint();
|
node[COLOR_TINT_TAG.data()] = rhs.GetColorTint();
|
||||||
|
node[COLOR_TINT_RANGE_TAG.data()] = rhs.GetColorTintRange();
|
||||||
|
node[COLOR_DECAY_TAG.data()] = rhs.GetColorDecay();
|
||||||
node[ACCELERATION_TAG.data()] = rhs.GetAcceleration();
|
node[ACCELERATION_TAG.data()] = rhs.GetAcceleration();
|
||||||
|
|
||||||
return node;
|
return node;
|
||||||
|
@ -591,6 +595,12 @@ namespace YAML
|
||||||
if (node[COLOR_TINT_TAG.data()].IsDefined())
|
if (node[COLOR_TINT_TAG.data()].IsDefined())
|
||||||
rhs.SetColorTint(node[COLOR_TINT_TAG.data()].as<SHVec4>());
|
rhs.SetColorTint(node[COLOR_TINT_TAG.data()].as<SHVec4>());
|
||||||
|
|
||||||
|
if (node[COLOR_TINT_RANGE_TAG.data()].IsDefined())
|
||||||
|
rhs.SetColorTintRange(node[COLOR_TINT_RANGE_TAG.data()].as<SHVec4>());
|
||||||
|
|
||||||
|
if (node[COLOR_DECAY_TAG.data()].IsDefined())
|
||||||
|
rhs.SetColorDecay(node[COLOR_DECAY_TAG.data()].as<SHVec4>());
|
||||||
|
|
||||||
if (node[ACCELERATION_TAG.data()].IsDefined())
|
if (node[ACCELERATION_TAG.data()].IsDefined())
|
||||||
rhs.SetAcceleration(node[ACCELERATION_TAG.data()].as<SHVec3>());
|
rhs.SetAcceleration(node[ACCELERATION_TAG.data()].as<SHVec3>());
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue