Add Particle Radius to in-built particle attributes
This commit is contained in:
@@ -925,6 +925,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
GetParticleAttribute(ModuleType.Initialize, 260, "Set Ribbon Width", "Sets the ribbon width", typeof(float), 20.0f),
|
||||
GetParticleAttribute(ModuleType.Initialize, 261, "Set Ribbon Twist", "Sets the ribbon twist angle (in degrees)", typeof(float), 0.0f),
|
||||
GetParticleAttribute(ModuleType.Initialize, 262, "Set Ribbon Facing Vector", "Sets the ribbon particles facing vector", typeof(Vector3), Vector3.Up),
|
||||
GetParticleAttribute(ModuleType.Initialize, 263, "Set Radius", "Sets the particle radius", typeof(float), 100.0f),
|
||||
|
||||
// Update Modules
|
||||
new NodeArchetype
|
||||
@@ -1374,6 +1375,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
GetParticleAttribute(ModuleType.Update, 360, "Set Ribbon Width", "Sets the ribbon width", typeof(float), 20.0f),
|
||||
GetParticleAttribute(ModuleType.Update, 361, "Set Ribbon Twist", "Sets the ribbon twist angle (in degrees)", typeof(float), 0.0f),
|
||||
GetParticleAttribute(ModuleType.Update, 362, "Set Ribbon Facing Vector", "Sets the ribbon particles facing vector", typeof(Vector3), Vector3.Up),
|
||||
GetParticleAttribute(ModuleType.Update, 363, "Set Radius", "Sets the particle radius", typeof(float), 100.0f),
|
||||
|
||||
// Render Modules
|
||||
new NodeArchetype
|
||||
|
||||
@@ -535,6 +535,18 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
NodeElementArchetype.Factory.Output(0, string.Empty, typeof(float), 0),
|
||||
}
|
||||
},
|
||||
new NodeArchetype
|
||||
{
|
||||
TypeID = 111,
|
||||
Title = "Particle Radius",
|
||||
Description = "Particle radius.",
|
||||
Flags = NodeFlags.MaterialGraph | NodeFlags.ParticleEmitterGraph,
|
||||
Size = new Vector2(200, 30),
|
||||
Elements = new[]
|
||||
{
|
||||
NodeElementArchetype.Factory.Output(0, string.Empty, typeof(float), 0),
|
||||
}
|
||||
},
|
||||
|
||||
// Simulation data access nodes
|
||||
new NodeArchetype
|
||||
|
||||
@@ -615,6 +615,7 @@ void ParticleEmitterGraphCPUExecutor::ProcessModule(ParticleEmitterGraphCPUNode*
|
||||
case 260:
|
||||
case 261:
|
||||
case 262:
|
||||
case 263:
|
||||
case 350:
|
||||
case 351:
|
||||
case 352:
|
||||
@@ -628,6 +629,7 @@ void ParticleEmitterGraphCPUExecutor::ProcessModule(ParticleEmitterGraphCPUNode*
|
||||
case 360:
|
||||
case 361:
|
||||
case 362:
|
||||
case 363:
|
||||
{
|
||||
auto& attribute = _data->Buffer->Layout->Attributes[node->Attributes[0]];
|
||||
byte* dataPtr = start + attribute.Offset;
|
||||
|
||||
@@ -286,6 +286,12 @@ void ParticleEmitterGraphCPUExecutor::ProcessGroupParticles(Box* box, Node* node
|
||||
const float lifetime = GET_PARTICLE_ATTRIBUTE(1, float);
|
||||
value = age / Math::Max(lifetime, ZeroTolerance);
|
||||
break;
|
||||
}
|
||||
// Particle Radius
|
||||
case 111:
|
||||
{
|
||||
value = GET_PARTICLE_ATTRIBUTE(0, float);
|
||||
break;
|
||||
}
|
||||
// Effect Position
|
||||
case 200:
|
||||
|
||||
@@ -248,6 +248,7 @@ void ParticleEmitterGPUGenerator::ProcessModule(Node* node)
|
||||
case 260:
|
||||
case 261:
|
||||
case 262:
|
||||
case 263:
|
||||
case 350:
|
||||
case 351:
|
||||
case 352:
|
||||
@@ -261,6 +262,7 @@ void ParticleEmitterGPUGenerator::ProcessModule(Node* node)
|
||||
case 360:
|
||||
case 361:
|
||||
case 362:
|
||||
case 363:
|
||||
{
|
||||
auto attribute = AccessParticleAttribute(node, nodeGpu->Attributes[0], AccessMode::Write);
|
||||
auto box = node->GetBox(0);
|
||||
|
||||
@@ -346,6 +346,12 @@ void ParticleEmitterGPUGenerator::ProcessGroupParticles(Box* box, Node* node, Va
|
||||
const auto lifetime = AccessParticleAttribute(node, TEXT("Lifetime"), ParticleAttribute::ValueTypes::Float, AccessMode::Read);
|
||||
value = writeOperation2(node, age, lifetime, '/');
|
||||
break;
|
||||
}
|
||||
// Particle Radius
|
||||
case 111:
|
||||
{
|
||||
value = AccessParticleAttribute(node, TEXT("Radius"), ParticleAttribute::ValueTypes::Float, AccessMode::Read);
|
||||
break;
|
||||
}
|
||||
// Effect Position
|
||||
case 200:
|
||||
|
||||
@@ -291,6 +291,13 @@ protected:
|
||||
USE_ATTRIBUTE(Age, Float, 0);
|
||||
USE_ATTRIBUTE(Lifetime, Float, 1);
|
||||
break;
|
||||
}
|
||||
// Particle Mass
|
||||
case GRAPH_NODE_MAKE_TYPE(14, 111):
|
||||
{
|
||||
node->UsesParticleData = true;
|
||||
USE_ATTRIBUTE(Radius, Float, 0);
|
||||
break;
|
||||
}
|
||||
// Random
|
||||
case GRAPH_NODE_MAKE_TYPE(14, 208):
|
||||
@@ -425,6 +432,7 @@ protected:
|
||||
CASE_SET_PARTICLE_ATTRIBUTE(260, 360, RibbonWidth, Float);
|
||||
CASE_SET_PARTICLE_ATTRIBUTE(261, 361, RibbonTwist, Float);
|
||||
CASE_SET_PARTICLE_ATTRIBUTE(262, 362, RibbonFacingVector, Vector3);
|
||||
CASE_SET_PARTICLE_ATTRIBUTE(263, 363, Radius, Float);
|
||||
#undef CASE_SET_PARTICLE_ATTRIBUTE
|
||||
// Conform to Sphere
|
||||
case GRAPH_NODE_MAKE_TYPE(15, 305):
|
||||
|
||||
@@ -173,6 +173,12 @@ void MaterialGenerator::ProcessGroupParticles(Box* box, Node* node, Value& value
|
||||
const auto lifetime = AccessParticleAttribute(node, TEXT("Lifetime"), ParticleAttributeValueTypes::Float);
|
||||
value = writeOperation2(node, age, lifetime, '/');
|
||||
break;
|
||||
}
|
||||
// Particle Radius
|
||||
case 111:
|
||||
{
|
||||
value = AccessParticleAttribute(node, TEXT("Radius"), ParticleAttributeValueTypes::Float);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user