Add Position (Global SDF) particle module
This commit is contained in:
@@ -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