Add reverse and scalar for ColorByDistance
This commit is contained in:
@@ -28,6 +28,7 @@ struct ExplosionEffectJob : ModelJob
|
||||
ColorByDistance = (bool)explosionEffectComponent["ColorByDistance"];
|
||||
ExponentialAccelaration = (bool)explosionEffectComponent["ExponentialAccelaration"];
|
||||
Reverse = (bool)explosionEffectComponent["Reverse"];
|
||||
ColorDistanceScalar = (double)explosionEffectComponent["ColorDistanceScalar"];
|
||||
};
|
||||
|
||||
glm::vec3 ExplosionOrigin;
|
||||
@@ -39,13 +40,14 @@ struct ExplosionEffectJob : ModelJob
|
||||
glm::vec4 EndColor;
|
||||
bool Randomness = false;
|
||||
|
||||
float RandomnessScalar = 1.f;
|
||||
double RandomnessScalar = 1.f;
|
||||
glm::vec2 Velocity;
|
||||
bool ColorByDistance = false;
|
||||
//bool ReverseAnimation = false;
|
||||
//bool Wireframe = false;
|
||||
bool ExponentialAccelaration = false;
|
||||
bool Reverse = false;
|
||||
double ColorDistanceScalar = 1.f;
|
||||
|
||||
std::array<float, 50> RandomNumbers = {
|
||||
0.3257552917701f,
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
<RandomnessScalar>1</RandomnessScalar>
|
||||
<Velocity X="2" Y="2"/>
|
||||
<ColorByDistance>0</ColorByDistance>
|
||||
<!--<ReverseAnimation>0</ReverseAnimation>-->
|
||||
<!--<Wireframe>0</Wireframe>-->
|
||||
<ExponentialAccelaration>0</ExponentialAccelaration>
|
||||
<Pulsate>0</Pulsate>
|
||||
<Reverse>0</Reverse>
|
||||
<ColorDistanceScalar>1</ColorDistanceScalar>
|
||||
</ExplosionEffect>
|
||||
@@ -42,9 +42,6 @@
|
||||
<xs:element name="ColorByDistance" type="t:bool" minOccurs="0">
|
||||
<xs:annotation><xs:documentation>Change the color by its moved distance instead of by its time</xs:documentation></xs:annotation>
|
||||
</xs:element>
|
||||
<!--<xs:element name="ReverseAnimation" type="t:bool" minOccurs="0">
|
||||
<xs:annotation><xs:documentation>Implosions are cooler</xs:documentation></xs:annotation>
|
||||
</xs:element>-->
|
||||
<!--<xs:element name="Wireframe" type="t:bool" minOccurs="0">
|
||||
<xs:annotation><xs:documentation>Enable/disable wireframe</xs:documentation></xs:annotation>
|
||||
</xs:element>-->
|
||||
@@ -57,6 +54,9 @@
|
||||
<xs:element name="Reverse" type="t:bool" minOccurs="0">
|
||||
<xs:annotation><xs:documentation>Reverse the effect</xs:documentation></xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="ColorDistanceScalar" type="t:double" minOccurs="0">
|
||||
<xs:annotation><xs:documentation>Scale the distance of the color change</xs:documentation></xs:annotation>
|
||||
</xs:element>
|
||||
</xs:all>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
@@ -14,10 +14,10 @@ uniform vec2 Velocity;
|
||||
uniform bool ColorByDistance;
|
||||
uniform bool ExponentialAccelaration;
|
||||
uniform bool Reverse;
|
||||
uniform float ColorDistanceScalar;
|
||||
//uniform bool Gravity;
|
||||
//uniform bool Rotation;
|
||||
//uniform bool MaxRadius;
|
||||
//uniform bool Pulsate;
|
||||
|
||||
in VertexData{
|
||||
vec3 Position;
|
||||
@@ -146,7 +146,7 @@ void main()
|
||||
// if explosion color should be affected by distance instead of time...
|
||||
if (ColorByDistance == true)
|
||||
{
|
||||
Output.ExplosionPercentageElapsed = (length(triangleCenter2ExplosionRadius) / maxDistance) * isInsideBlastRadius;
|
||||
Output.ExplosionPercentageElapsed = (length(triangleCenter2ExplosionRadius) / maxDistance) * isInsideBlastRadius * ColorDistanceScalar;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -157,21 +157,8 @@ void main()
|
||||
for (int i = 0; i < gl_in.length(); i++)
|
||||
{
|
||||
// move the triangle to the blast radius
|
||||
//if(Reverse == false)
|
||||
//{
|
||||
ExplodedPosition = Input[i].Position + (triangleCenter2ExplosionRadius * isInsideBlastRadius);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// // TODO:
|
||||
// // Remove ifs
|
||||
// // account for randomness
|
||||
// // account for velocity
|
||||
// // account for color
|
||||
//
|
||||
// ExplodedPosition = Input[i].Position + (triangleCenter2ExplosionRadius * maxDistance /** (ExplosionDuration - TimeSinceDeath)*/);
|
||||
//}
|
||||
|
||||
ExplodedPosition = Input[i].Position + (triangleCenter2ExplosionRadius * isInsideBlastRadius);
|
||||
|
||||
// pass through vertex data
|
||||
PassThingsThrough(i);
|
||||
|
||||
|
||||
@@ -1047,7 +1047,12 @@ void DrawFinalPass::BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr<E
|
||||
|
||||
glUniform3fv(glGetUniformLocation(shaderHandle, "ExplosionOrigin"), 1, glm::value_ptr(job->ExplosionOrigin));
|
||||
GLERROR("Bind 6 uniform");
|
||||
glUniform1f(glGetUniformLocation(shaderHandle, "TimeSinceDeath"), job->TimeSinceDeath);
|
||||
if (job->Reverse == false) {
|
||||
glUniform1f(glGetUniformLocation(shaderHandle, "TimeSinceDeath"), job->TimeSinceDeath);
|
||||
}
|
||||
else {
|
||||
glUniform1f(glGetUniformLocation(shaderHandle, "TimeSinceDeath"), (job->ExplosionDuration - job->TimeSinceDeath));
|
||||
}
|
||||
GLERROR("Bind 7 uniform");
|
||||
glUniform1f(glGetUniformLocation(shaderHandle, "ExplosionDuration"), job->ExplosionDuration);
|
||||
GLERROR("Bind 8 uniform");
|
||||
@@ -1067,6 +1072,8 @@ void DrawFinalPass::BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr<E
|
||||
GLERROR("Bind 15 uniform");
|
||||
glUniform1i(glGetUniformLocation(shaderHandle, "Reverse"), job->Reverse);
|
||||
GLERROR("Bind 15-2 uniform");
|
||||
glUniform1f(glGetUniformLocation(shaderHandle, "ColorDistanceScalar"), job->ColorDistanceScalar);
|
||||
GLERROR("Bind 15-3 uniform");
|
||||
|
||||
glUniform4fv(glGetUniformLocation(shaderHandle, "Color"), 1, glm::value_ptr(job->Color));
|
||||
GLERROR("Bind 16 uniform");
|
||||
|
||||
@@ -9,7 +9,7 @@ void ExplosionEffectSystem::UpdateComponent(EntityWrapper& entity, ComponentWrap
|
||||
}
|
||||
}
|
||||
|
||||
//((glm::vec2)component["Velocity"]).x = min(((glm::vec2)component["Velocity"]).x, ((glm::vec2)component["Velocity"]).y);
|
||||
//((glm::vec2&)component["Velocity"]).x = glm::min(((glm::vec2)component["Velocity"]).x, ((glm::vec2)component["Velocity"]).y);
|
||||
|
||||
(double&)component["TimeSinceDeath"] += dt;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user