Add Position (Global SDF) particle module
This commit is contained in:
@@ -888,7 +888,6 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
NodeElementArchetype.Factory.ComboBox(0, -10.0f, 160, 2, typeof(ParticleModelFacingMode)),
|
||||
},
|
||||
},
|
||||
|
||||
new NodeArchetype
|
||||
{
|
||||
TypeID = 214,
|
||||
@@ -912,6 +911,20 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
NodeElementArchetype.Factory.Input(-0.5f + 2.0f, "Velocity Scale", true, typeof(float), 2, 4),
|
||||
},
|
||||
},
|
||||
new NodeArchetype
|
||||
{
|
||||
TypeID = 215,
|
||||
Create = CreateParticleModuleNode,
|
||||
Title = "Position (Global SDF)",
|
||||
Description = "Places the particles on Global SDF surface (uses current particle position to snap it to SDF)",
|
||||
Flags = DefaultModuleFlags,
|
||||
Size = new Vector2(200, 0 * Surface.Constants.LayoutOffsetY),
|
||||
DefaultValues = new object[]
|
||||
{
|
||||
true,
|
||||
(int)ModuleType.Initialize,
|
||||
},
|
||||
},
|
||||
GetParticleAttribute(ModuleType.Initialize, 250, "Set Position", "Sets the particle position", typeof(Vector3), Vector3.Zero),
|
||||
GetParticleAttribute(ModuleType.Initialize, 251, "Set Lifetime", "Sets the particle lifetime (in seconds)", typeof(float), 10.0f),
|
||||
GetParticleAttribute(ModuleType.Initialize, 252, "Set Age", "Sets the particle age (in seconds)", typeof(float), 0.0f),
|
||||
|
||||
@@ -1204,6 +1204,12 @@ void ParticleEmitterGraphCPUExecutor::ProcessModule(ParticleEmitterGraphCPUNode*
|
||||
#undef LOGIC
|
||||
break;
|
||||
}
|
||||
// Position (Global SDF)
|
||||
case 215:
|
||||
{
|
||||
// Not supported
|
||||
break;
|
||||
}
|
||||
|
||||
// Helper macros for collision modules to share the code
|
||||
#define COLLISION_BEGIN() \
|
||||
|
||||
@@ -610,6 +610,27 @@ void ParticleEmitterGPUGenerator::ProcessModule(Node* node)
|
||||
), positionAttr.Value, velocityAttr.Value, center.Value, rotationSpeed.Value, velocityScale.Value, customDataOffset);
|
||||
break;
|
||||
}
|
||||
// Position (Global SDF)
|
||||
case 215:
|
||||
{
|
||||
auto position = AccessParticleAttribute(node, nodeGpu->Attributes[0], AccessMode::ReadWrite);
|
||||
auto param = findOrAddGlobalSDF();
|
||||
String wsPos = position.Value;
|
||||
if (((ParticleEmitterGraphGPU*)_graphStack.Peek())->SimulationSpace == ParticlesSimulationSpace::Local)
|
||||
wsPos = String::Format(TEXT("mul(float4({0}, 1), WorldMatrix).xyz"), wsPos);
|
||||
_includes.Add(TEXT("./Flax/GlobalSignDistanceField.hlsl"));
|
||||
_writer.Write(
|
||||
TEXT(
|
||||
" {{\n"
|
||||
" // Position (Global SDF)\n"
|
||||
" float3 wsPos = {2};\n"
|
||||
" float dist;\n"
|
||||
" float3 dir = -normalize(SampleGlobalSDFGradient({1}, {1}_Tex, wsPos, dist));\n"
|
||||
" {0} += dir * dist;\n"
|
||||
" }}\n"
|
||||
), position.Value, param.ShaderName, wsPos);
|
||||
break;
|
||||
}
|
||||
|
||||
// Helper macros for collision modules to share the code
|
||||
#define COLLISION_BEGIN() \
|
||||
|
||||
@@ -355,7 +355,7 @@ public:
|
||||
USE_ATTRIBUTE(Mass, Float, 2);
|
||||
break;
|
||||
}
|
||||
// Position (plane/box surface/box volume/cylinder/line/sphere/circle/disc/torus)
|
||||
// Position (plane/box surface/box volume/cylinder/line/sphere/circle/disc/torus/Global SDF)
|
||||
case GRAPH_NODE_MAKE_TYPE(15, 202):
|
||||
case GRAPH_NODE_MAKE_TYPE(15, 203):
|
||||
case GRAPH_NODE_MAKE_TYPE(15, 204):
|
||||
@@ -366,6 +366,7 @@ public:
|
||||
case GRAPH_NODE_MAKE_TYPE(15, 209):
|
||||
case GRAPH_NODE_MAKE_TYPE(15, 210):
|
||||
case GRAPH_NODE_MAKE_TYPE(15, 211):
|
||||
case GRAPH_NODE_MAKE_TYPE(15, 215):
|
||||
{
|
||||
USE_ATTRIBUTE(Position, Vector3, 0);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user