Merge remote-tracking branch 'origin/gi' into large-worlds
# Conflicts: # Source/Engine/Core/Math/Vector3.h
This commit is contained in:
@@ -121,14 +121,14 @@ int32 ParticleEmitterGraphCPUExecutor::ProcessSpawnModule(int32 index)
|
||||
// Calculate particles to spawn during this frame
|
||||
switch (node->TypeID)
|
||||
{
|
||||
// Constant Spawn Rate
|
||||
// Constant Spawn Rate
|
||||
case 100:
|
||||
{
|
||||
const float rate = Math::Max((float)TryGetValue(node->GetBox(0), node->Values[2]), 0.0f);
|
||||
spawnCount += rate * context.DeltaTime;
|
||||
break;
|
||||
}
|
||||
// Single Burst
|
||||
// Single Burst
|
||||
case 101:
|
||||
{
|
||||
const bool isFirstUpdate = (context.Data->Time - context.DeltaTime) <= 0.0f;
|
||||
@@ -139,7 +139,7 @@ int32 ParticleEmitterGraphCPUExecutor::ProcessSpawnModule(int32 index)
|
||||
}
|
||||
break;
|
||||
}
|
||||
// Periodic
|
||||
// Periodic
|
||||
case 102:
|
||||
{
|
||||
float& nextSpawnTime = data.NextSpawnTime;
|
||||
@@ -152,7 +152,7 @@ int32 ParticleEmitterGraphCPUExecutor::ProcessSpawnModule(int32 index)
|
||||
}
|
||||
break;
|
||||
}
|
||||
// Periodic Burst (range)
|
||||
// Periodic Burst (range)
|
||||
case 103:
|
||||
{
|
||||
float& nextSpawnTime = data.NextSpawnTime;
|
||||
@@ -186,7 +186,7 @@ void ParticleEmitterGraphCPUExecutor::ProcessModule(ParticleEmitterGraphCPUNode*
|
||||
|
||||
switch (node->TypeID)
|
||||
{
|
||||
// Orient Sprite
|
||||
// Orient Sprite
|
||||
case 201:
|
||||
case 303:
|
||||
{
|
||||
@@ -229,7 +229,7 @@ void ParticleEmitterGraphCPUExecutor::ProcessModule(ParticleEmitterGraphCPUNode*
|
||||
}
|
||||
break;
|
||||
}
|
||||
// Orient Model
|
||||
// Orient Model
|
||||
case 213:
|
||||
case 309:
|
||||
{
|
||||
@@ -246,7 +246,7 @@ void ParticleEmitterGraphCPUExecutor::ProcessModule(ParticleEmitterGraphCPUNode*
|
||||
}
|
||||
break;
|
||||
}
|
||||
// Update Age
|
||||
// Update Age
|
||||
case 300:
|
||||
{
|
||||
PARTICLE_EMITTER_MODULE("Update Age");
|
||||
@@ -259,7 +259,7 @@ void ParticleEmitterGraphCPUExecutor::ProcessModule(ParticleEmitterGraphCPUNode*
|
||||
}
|
||||
break;
|
||||
}
|
||||
// Gravity/Force
|
||||
// Gravity/Force
|
||||
case 301:
|
||||
case 304:
|
||||
{
|
||||
@@ -288,7 +288,7 @@ void ParticleEmitterGraphCPUExecutor::ProcessModule(ParticleEmitterGraphCPUNode*
|
||||
}
|
||||
break;
|
||||
}
|
||||
// Conform to Sphere
|
||||
// Conform to Sphere
|
||||
case 305:
|
||||
{
|
||||
PARTICLE_EMITTER_MODULE("Conform to Sphere");
|
||||
@@ -351,7 +351,7 @@ void ParticleEmitterGraphCPUExecutor::ProcessModule(ParticleEmitterGraphCPUNode*
|
||||
#undef LOGIC
|
||||
break;
|
||||
}
|
||||
// Kill (sphere)
|
||||
// Kill (sphere)
|
||||
case 306:
|
||||
{
|
||||
PARTICLE_EMITTER_MODULE("Kill");
|
||||
@@ -400,7 +400,7 @@ void ParticleEmitterGraphCPUExecutor::ProcessModule(ParticleEmitterGraphCPUNode*
|
||||
#undef LOGIC
|
||||
break;
|
||||
}
|
||||
// Kill (box)
|
||||
// Kill (box)
|
||||
case 307:
|
||||
{
|
||||
PARTICLE_EMITTER_MODULE("Kill");
|
||||
@@ -454,7 +454,7 @@ void ParticleEmitterGraphCPUExecutor::ProcessModule(ParticleEmitterGraphCPUNode*
|
||||
#undef LOGIC
|
||||
break;
|
||||
}
|
||||
// Kill (custom)
|
||||
// Kill (custom)
|
||||
case 308:
|
||||
{
|
||||
PARTICLE_EMITTER_MODULE("Kill (custom)");
|
||||
@@ -492,7 +492,7 @@ void ParticleEmitterGraphCPUExecutor::ProcessModule(ParticleEmitterGraphCPUNode*
|
||||
#undef LOGIC
|
||||
break;
|
||||
}
|
||||
// Linear Drag
|
||||
// Linear Drag
|
||||
case 310:
|
||||
{
|
||||
PARTICLE_EMITTER_MODULE("Linear Drag");
|
||||
@@ -538,7 +538,7 @@ void ParticleEmitterGraphCPUExecutor::ProcessModule(ParticleEmitterGraphCPUNode*
|
||||
#undef LOGIC
|
||||
break;
|
||||
}
|
||||
// Turbulence
|
||||
// Turbulence
|
||||
case 311:
|
||||
{
|
||||
PARTICLE_EMITTER_MODULE("Turbulence");
|
||||
@@ -598,7 +598,7 @@ void ParticleEmitterGraphCPUExecutor::ProcessModule(ParticleEmitterGraphCPUNode*
|
||||
#undef LOGIC
|
||||
break;
|
||||
}
|
||||
// Set Attribute
|
||||
// Set Attribute
|
||||
case 200:
|
||||
case 302:
|
||||
{
|
||||
@@ -630,7 +630,7 @@ void ParticleEmitterGraphCPUExecutor::ProcessModule(ParticleEmitterGraphCPUNode*
|
||||
}
|
||||
break;
|
||||
}
|
||||
// Set Position/Lifetime/Age/..
|
||||
// Set Position/Lifetime/Age/..
|
||||
case 250:
|
||||
case 251:
|
||||
case 252:
|
||||
@@ -688,7 +688,7 @@ void ParticleEmitterGraphCPUExecutor::ProcessModule(ParticleEmitterGraphCPUNode*
|
||||
}
|
||||
break;
|
||||
}
|
||||
// Position (sphere surface)
|
||||
// Position (sphere surface)
|
||||
case 202:
|
||||
{
|
||||
PARTICLE_EMITTER_MODULE("Position");
|
||||
@@ -734,7 +734,7 @@ void ParticleEmitterGraphCPUExecutor::ProcessModule(ParticleEmitterGraphCPUNode*
|
||||
#undef LOGIC
|
||||
break;
|
||||
}
|
||||
// Position (plane)
|
||||
// Position (plane)
|
||||
case 203:
|
||||
{
|
||||
PARTICLE_EMITTER_MODULE("Position");
|
||||
@@ -773,7 +773,7 @@ void ParticleEmitterGraphCPUExecutor::ProcessModule(ParticleEmitterGraphCPUNode*
|
||||
#undef LOGIC
|
||||
break;
|
||||
}
|
||||
// Position (circle)
|
||||
// Position (circle)
|
||||
case 204:
|
||||
{
|
||||
PARTICLE_EMITTER_MODULE("Position");
|
||||
@@ -817,7 +817,7 @@ void ParticleEmitterGraphCPUExecutor::ProcessModule(ParticleEmitterGraphCPUNode*
|
||||
#undef LOGIC
|
||||
break;
|
||||
}
|
||||
// Position (disc)
|
||||
// Position (disc)
|
||||
case 205:
|
||||
{
|
||||
PARTICLE_EMITTER_MODULE("Position");
|
||||
@@ -861,7 +861,7 @@ void ParticleEmitterGraphCPUExecutor::ProcessModule(ParticleEmitterGraphCPUNode*
|
||||
#undef LOGIC
|
||||
break;
|
||||
}
|
||||
// Position (box surface)
|
||||
// Position (box surface)
|
||||
case 206:
|
||||
{
|
||||
PARTICLE_EMITTER_MODULE("Position");
|
||||
@@ -912,7 +912,7 @@ void ParticleEmitterGraphCPUExecutor::ProcessModule(ParticleEmitterGraphCPUNode*
|
||||
#undef LOGIC
|
||||
break;
|
||||
}
|
||||
// Position (box volume)
|
||||
// Position (box volume)
|
||||
case 207:
|
||||
{
|
||||
PARTICLE_EMITTER_MODULE("Position");
|
||||
@@ -951,7 +951,7 @@ void ParticleEmitterGraphCPUExecutor::ProcessModule(ParticleEmitterGraphCPUNode*
|
||||
#undef LOGIC
|
||||
break;
|
||||
}
|
||||
// Position (cylinder)
|
||||
// Position (cylinder)
|
||||
case 208:
|
||||
{
|
||||
PARTICLE_EMITTER_MODULE("Position");
|
||||
@@ -997,7 +997,7 @@ void ParticleEmitterGraphCPUExecutor::ProcessModule(ParticleEmitterGraphCPUNode*
|
||||
#undef LOGIC
|
||||
break;
|
||||
}
|
||||
// Position (line)
|
||||
// Position (line)
|
||||
case 209:
|
||||
{
|
||||
PARTICLE_EMITTER_MODULE("Position");
|
||||
@@ -1036,7 +1036,7 @@ void ParticleEmitterGraphCPUExecutor::ProcessModule(ParticleEmitterGraphCPUNode*
|
||||
#undef LOGIC
|
||||
break;
|
||||
}
|
||||
// Position (torus)
|
||||
// Position (torus)
|
||||
case 210:
|
||||
{
|
||||
PARTICLE_EMITTER_MODULE("Position");
|
||||
@@ -1101,7 +1101,7 @@ void ParticleEmitterGraphCPUExecutor::ProcessModule(ParticleEmitterGraphCPUNode*
|
||||
#undef LOGIC
|
||||
break;
|
||||
}
|
||||
// Position (sphere volume)
|
||||
// Position (sphere volume)
|
||||
case 211:
|
||||
{
|
||||
PARTICLE_EMITTER_MODULE("Position");
|
||||
@@ -1147,13 +1147,13 @@ void ParticleEmitterGraphCPUExecutor::ProcessModule(ParticleEmitterGraphCPUNode*
|
||||
#undef LOGIC
|
||||
break;
|
||||
}
|
||||
// Position (depth)
|
||||
// Position (depth)
|
||||
case 212:
|
||||
{
|
||||
// Not supported
|
||||
break;
|
||||
}
|
||||
// Position (spiral)
|
||||
// Position (spiral)
|
||||
case 214:
|
||||
{
|
||||
PARTICLE_EMITTER_MODULE("Position");
|
||||
@@ -1204,8 +1204,14 @@ void ParticleEmitterGraphCPUExecutor::ProcessModule(ParticleEmitterGraphCPUNode*
|
||||
#undef LOGIC
|
||||
break;
|
||||
}
|
||||
// Position (Global SDF)
|
||||
case 215:
|
||||
{
|
||||
// Not supported
|
||||
break;
|
||||
}
|
||||
|
||||
// Helper macros for collision modules to share the code
|
||||
// Helper macros for collision modules to share the code
|
||||
#define COLLISION_BEGIN() \
|
||||
PARTICLE_EMITTER_MODULE("Collision"); \
|
||||
auto& positionAttr = context.Data->Buffer->Layout->Attributes[node->Attributes[0]]; \
|
||||
@@ -1245,7 +1251,7 @@ void ParticleEmitterGraphCPUExecutor::ProcessModule(ParticleEmitterGraphCPUNode*
|
||||
velocityPtr += stride; \
|
||||
agePtr += stride
|
||||
|
||||
// Collision (plane)
|
||||
// Collision (plane)
|
||||
case 330:
|
||||
{
|
||||
COLLISION_BEGIN();
|
||||
@@ -1287,7 +1293,7 @@ void ParticleEmitterGraphCPUExecutor::ProcessModule(ParticleEmitterGraphCPUNode*
|
||||
#undef LOGIC
|
||||
break;
|
||||
}
|
||||
// Collision (sphere)
|
||||
// Collision (sphere)
|
||||
case 331:
|
||||
{
|
||||
COLLISION_BEGIN();
|
||||
@@ -1332,7 +1338,7 @@ void ParticleEmitterGraphCPUExecutor::ProcessModule(ParticleEmitterGraphCPUNode*
|
||||
#undef LOGIC
|
||||
break;
|
||||
}
|
||||
// Collision (box)
|
||||
// Collision (box)
|
||||
case 332:
|
||||
{
|
||||
COLLISION_BEGIN();
|
||||
@@ -1392,7 +1398,7 @@ void ParticleEmitterGraphCPUExecutor::ProcessModule(ParticleEmitterGraphCPUNode*
|
||||
#undef LOGIC
|
||||
break;
|
||||
}
|
||||
// Collision (cylinder)
|
||||
// Collision (cylinder)
|
||||
case 333:
|
||||
{
|
||||
COLLISION_BEGIN();
|
||||
@@ -1457,12 +1463,24 @@ void ParticleEmitterGraphCPUExecutor::ProcessModule(ParticleEmitterGraphCPUNode*
|
||||
#undef LOGIC
|
||||
break;
|
||||
}
|
||||
// Collision (depth)
|
||||
// Collision (depth)
|
||||
case 334:
|
||||
{
|
||||
// Not supported
|
||||
break;
|
||||
}
|
||||
// Conform to Global SDF
|
||||
case 335:
|
||||
{
|
||||
// Not supported
|
||||
break;
|
||||
}
|
||||
// Collision (Global SDF)
|
||||
case 336:
|
||||
{
|
||||
// Not supported
|
||||
break;
|
||||
}
|
||||
|
||||
#undef COLLISION_BEGIN
|
||||
#undef COLLISION_INPUTS_FETCH
|
||||
|
||||
@@ -15,7 +15,7 @@ void ParticleEmitterGraphCPUExecutor::ProcessGroupParameters(Box* box, Node* nod
|
||||
auto& context = Context.Get();
|
||||
switch (node->TypeID)
|
||||
{
|
||||
// Get
|
||||
// Get
|
||||
case 2:
|
||||
{
|
||||
int32 paramIndex;
|
||||
@@ -96,34 +96,41 @@ void ParticleEmitterGraphCPUExecutor::ProcessGroupTextures(Box* box, Node* node,
|
||||
{
|
||||
switch (node->TypeID)
|
||||
{
|
||||
// Scene Texture
|
||||
// Scene Texture
|
||||
case 6:
|
||||
{
|
||||
// Not supported
|
||||
value = Value::Zero;
|
||||
break;
|
||||
}
|
||||
// Scene Depth
|
||||
// Scene Depth
|
||||
case 8:
|
||||
{
|
||||
// Not supported
|
||||
value = Value::Zero;
|
||||
break;
|
||||
}
|
||||
// Texture
|
||||
// Texture
|
||||
case 11:
|
||||
{
|
||||
// TODO: support sampling textures in CPU particles
|
||||
value = Value::Zero;
|
||||
break;
|
||||
}
|
||||
// Load Texture
|
||||
// Load Texture
|
||||
case 13:
|
||||
{
|
||||
// TODO: support sampling textures in CPU particles
|
||||
value = Value::Zero;
|
||||
break;
|
||||
}
|
||||
// Sample Global SDF
|
||||
case 14:
|
||||
{
|
||||
// Not supported
|
||||
value = Value::Zero;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -134,18 +141,18 @@ void ParticleEmitterGraphCPUExecutor::ProcessGroupTools(Box* box, Node* node, Va
|
||||
auto& context = Context.Get();
|
||||
switch (node->TypeID)
|
||||
{
|
||||
// Linearize Depth
|
||||
// Linearize Depth
|
||||
case 7:
|
||||
{
|
||||
// TODO: support Linearize Depth in CPU particles
|
||||
value = Value::Zero;
|
||||
break;
|
||||
}
|
||||
// Time
|
||||
// Time
|
||||
case 8:
|
||||
value = box->ID == 0 ? context.Data->Time : context.DeltaTime;
|
||||
break;
|
||||
// Transform Position To Screen UV
|
||||
// Transform Position To Screen UV
|
||||
case 9:
|
||||
{
|
||||
GET_VIEW();
|
||||
@@ -169,7 +176,7 @@ void ParticleEmitterGraphCPUExecutor::ProcessGroupParticles(Box* box, Node* node
|
||||
auto node = (ParticleEmitterGraphCPUNode*)nodeBase;
|
||||
switch (node->TypeID)
|
||||
{
|
||||
// Particle Attribute
|
||||
// Particle Attribute
|
||||
case 100:
|
||||
{
|
||||
byte* ptr = ACCESS_PARTICLE_ATTRIBUTE(0);
|
||||
@@ -197,7 +204,7 @@ void ParticleEmitterGraphCPUExecutor::ProcessGroupParticles(Box* box, Node* node
|
||||
}
|
||||
break;
|
||||
}
|
||||
// Particle Attribute (by index)
|
||||
// Particle Attribute (by index)
|
||||
case 303:
|
||||
{
|
||||
const auto particleIndex = tryGetValue(node->GetBox(1), context.ParticleIndex);
|
||||
@@ -226,61 +233,61 @@ void ParticleEmitterGraphCPUExecutor::ProcessGroupParticles(Box* box, Node* node
|
||||
}
|
||||
break;
|
||||
}
|
||||
// Particle Position
|
||||
// Particle Position
|
||||
case 101:
|
||||
{
|
||||
value = GET_PARTICLE_ATTRIBUTE(0, Vector3);
|
||||
break;
|
||||
}
|
||||
// Particle Lifetime
|
||||
// Particle Lifetime
|
||||
case 102:
|
||||
{
|
||||
value = GET_PARTICLE_ATTRIBUTE(0, float);
|
||||
break;
|
||||
}
|
||||
// Particle Age
|
||||
// Particle Age
|
||||
case 103:
|
||||
{
|
||||
value = GET_PARTICLE_ATTRIBUTE(0, float);
|
||||
break;
|
||||
}
|
||||
// Particle Color
|
||||
// Particle Color
|
||||
case 104:
|
||||
{
|
||||
value = GET_PARTICLE_ATTRIBUTE(0, Vector4);
|
||||
break;
|
||||
}
|
||||
// Particle Velocity
|
||||
// Particle Velocity
|
||||
case 105:
|
||||
{
|
||||
value = GET_PARTICLE_ATTRIBUTE(0, Vector3);
|
||||
break;
|
||||
}
|
||||
// Particle Sprite Size
|
||||
// Particle Sprite Size
|
||||
case 106:
|
||||
{
|
||||
value = GET_PARTICLE_ATTRIBUTE(0, Vector2);
|
||||
break;
|
||||
}
|
||||
// Particle Mass
|
||||
// Particle Mass
|
||||
case 107:
|
||||
{
|
||||
value = GET_PARTICLE_ATTRIBUTE(0, float);
|
||||
break;
|
||||
}
|
||||
// Particle Rotation
|
||||
// Particle Rotation
|
||||
case 108:
|
||||
{
|
||||
value = GET_PARTICLE_ATTRIBUTE(0, Vector3);
|
||||
break;
|
||||
}
|
||||
// Particle Angular Velocity
|
||||
// Particle Angular Velocity
|
||||
case 109:
|
||||
{
|
||||
value = GET_PARTICLE_ATTRIBUTE(0, Vector3);
|
||||
break;
|
||||
}
|
||||
// Particle Normalized Age
|
||||
// Particle Normalized Age
|
||||
case 110:
|
||||
{
|
||||
const float age = GET_PARTICLE_ATTRIBUTE(0, float);
|
||||
@@ -288,55 +295,55 @@ void ParticleEmitterGraphCPUExecutor::ProcessGroupParticles(Box* box, Node* node
|
||||
value = age / Math::Max(lifetime, ZeroTolerance);
|
||||
break;
|
||||
}
|
||||
// Particle Radius
|
||||
// Particle Radius
|
||||
case 111:
|
||||
{
|
||||
value = GET_PARTICLE_ATTRIBUTE(0, float);
|
||||
break;
|
||||
}
|
||||
// Effect Position
|
||||
// Effect Position
|
||||
case 200:
|
||||
{
|
||||
value = context.Effect->GetPosition();
|
||||
break;
|
||||
}
|
||||
// Effect Rotation
|
||||
// Effect Rotation
|
||||
case 201:
|
||||
{
|
||||
value = context.Effect->GetOrientation();
|
||||
break;
|
||||
}
|
||||
// Effect Scale
|
||||
// Effect Scale
|
||||
case 202:
|
||||
{
|
||||
value = context.Effect->GetScale();
|
||||
break;
|
||||
}
|
||||
// Simulation Mode
|
||||
// Simulation Mode
|
||||
case 203:
|
||||
{
|
||||
value = box->ID == 0;
|
||||
break;
|
||||
}
|
||||
// View Position
|
||||
// View Position
|
||||
case 204:
|
||||
{
|
||||
value = context.ViewTask ? context.ViewTask->View.Position : Vector3::Zero;
|
||||
break;
|
||||
}
|
||||
// View Direction
|
||||
// View Direction
|
||||
case 205:
|
||||
{
|
||||
value = context.ViewTask ? context.ViewTask->View.Direction : Vector3::Forward;
|
||||
break;
|
||||
}
|
||||
// View Far Plane
|
||||
// View Far Plane
|
||||
case 206:
|
||||
{
|
||||
value = context.ViewTask ? context.ViewTask->View.Far : 0.0f;
|
||||
break;
|
||||
}
|
||||
// Screen Size
|
||||
// Screen Size
|
||||
case 207:
|
||||
{
|
||||
const Vector4 size = context.ViewTask ? context.ViewTask->View.ScreenSize : Vector4::Zero;
|
||||
@@ -346,13 +353,13 @@ void ParticleEmitterGraphCPUExecutor::ProcessGroupParticles(Box* box, Node* node
|
||||
value = Vector2(size.Z, size.W);
|
||||
break;
|
||||
}
|
||||
// Particle Position (world space)
|
||||
// Particle Position (world space)
|
||||
case 212:
|
||||
value = GET_PARTICLE_ATTRIBUTE(0, Vector3);
|
||||
if (context.Emitter->SimulationSpace == ParticlesSimulationSpace::Local)
|
||||
value.AsVector3() = context.Effect->GetTransform().LocalToWorld(value.AsVector3());
|
||||
break;
|
||||
// Particle Emitter Function
|
||||
// Particle Emitter Function
|
||||
case 300:
|
||||
{
|
||||
// Load function asset
|
||||
@@ -399,11 +406,11 @@ void ParticleEmitterGraphCPUExecutor::ProcessGroupParticles(Box* box, Node* node
|
||||
context.GraphStack.Pop();
|
||||
break;
|
||||
}
|
||||
// Particle Index
|
||||
// Particle Index
|
||||
case 301:
|
||||
value = context.ParticleIndex;
|
||||
break;
|
||||
// Particles Count
|
||||
// Particles Count
|
||||
case 302:
|
||||
value = (uint32)context.Data->Buffer->CPU.Count;
|
||||
break;
|
||||
@@ -418,7 +425,7 @@ void ParticleEmitterGraphCPUExecutor::ProcessGroupFunction(Box* box, Node* node,
|
||||
auto& context = Context.Get();
|
||||
switch (node->TypeID)
|
||||
{
|
||||
// Function Input
|
||||
// Function Input
|
||||
case 1:
|
||||
{
|
||||
// Find the function call
|
||||
|
||||
@@ -102,7 +102,7 @@ void ParticleEmitterGraphCPU::InitializeNode(Node* node)
|
||||
|
||||
switch (node->Type)
|
||||
{
|
||||
// Position (spiral)
|
||||
// Position (spiral)
|
||||
case GRAPH_NODE_MAKE_TYPE(15, 214):
|
||||
node->CustomDataOffset = CustomDataSize;
|
||||
CustomDataSize += sizeof(float);
|
||||
@@ -226,7 +226,7 @@ bool ParticleEmitterGraphCPUExecutor::ComputeBounds(ParticleEmitter* emitter, Pa
|
||||
const auto module = emitter->Graph.RenderModules[moduleIndex];
|
||||
switch (module->TypeID)
|
||||
{
|
||||
// Sprite Rendering
|
||||
// Sprite Rendering
|
||||
case 400:
|
||||
{
|
||||
if (_graph._attrSpriteSize != -1)
|
||||
@@ -246,7 +246,7 @@ bool ParticleEmitterGraphCPUExecutor::ComputeBounds(ParticleEmitter* emitter, Pa
|
||||
}
|
||||
break;
|
||||
}
|
||||
// Light Rendering
|
||||
// Light Rendering
|
||||
case 401:
|
||||
{
|
||||
// Prepare graph data
|
||||
@@ -269,7 +269,7 @@ bool ParticleEmitterGraphCPUExecutor::ComputeBounds(ParticleEmitter* emitter, Pa
|
||||
|
||||
break;
|
||||
}
|
||||
// Model Rendering
|
||||
// Model Rendering
|
||||
case 403:
|
||||
{
|
||||
const auto modelAsset = (Model*)module->Assets[0].Get();
|
||||
@@ -297,7 +297,7 @@ bool ParticleEmitterGraphCPUExecutor::ComputeBounds(ParticleEmitter* emitter, Pa
|
||||
}
|
||||
break;
|
||||
}
|
||||
// Ribbon Rendering
|
||||
// Ribbon Rendering
|
||||
case 404:
|
||||
{
|
||||
if (_graph._attrRibbonWidth != -1)
|
||||
@@ -317,7 +317,7 @@ bool ParticleEmitterGraphCPUExecutor::ComputeBounds(ParticleEmitter* emitter, Pa
|
||||
}
|
||||
break;
|
||||
}
|
||||
// Volumetric Fog Rendering
|
||||
// Volumetric Fog Rendering
|
||||
case 405:
|
||||
{
|
||||
// Find the maximum radius of the particle
|
||||
|
||||
@@ -10,7 +10,7 @@ void ParticleEmitterGPUGenerator::ProcessModule(Node* node)
|
||||
auto nodeGpu = (ParticleEmitterGraphGPUNode*)node;
|
||||
switch (node->TypeID)
|
||||
{
|
||||
// Orient Sprite
|
||||
// Orient Sprite
|
||||
case 201:
|
||||
case 303:
|
||||
{
|
||||
@@ -28,7 +28,7 @@ void ParticleEmitterGPUGenerator::ProcessModule(Node* node)
|
||||
}
|
||||
break;
|
||||
}
|
||||
// Orient Model
|
||||
// Orient Model
|
||||
case 213:
|
||||
case 309:
|
||||
{
|
||||
@@ -39,14 +39,14 @@ void ParticleEmitterGPUGenerator::ProcessModule(Node* node)
|
||||
}
|
||||
break;
|
||||
}
|
||||
// Update Age
|
||||
// Update Age
|
||||
case 300:
|
||||
{
|
||||
auto attribute = AccessParticleAttribute(node, nodeGpu->Attributes[0], AccessMode::ReadWrite);
|
||||
_writer.Write(TEXT("\t{0} += DeltaTime;\n"), attribute.Value);
|
||||
break;
|
||||
}
|
||||
// Gravity/Force
|
||||
// Gravity/Force
|
||||
case 301:
|
||||
case 304:
|
||||
{
|
||||
@@ -55,7 +55,7 @@ void ParticleEmitterGPUGenerator::ProcessModule(Node* node)
|
||||
_writer.Write(TEXT("\t{0} += {1} * DeltaTime;\n"), attribute.Value, force.Value);
|
||||
break;
|
||||
}
|
||||
// Conform to Sphere
|
||||
// Conform to Sphere
|
||||
case 305:
|
||||
{
|
||||
auto position = AccessParticleAttribute(node, nodeGpu->Attributes[0], AccessMode::Read);
|
||||
@@ -94,7 +94,7 @@ void ParticleEmitterGPUGenerator::ProcessModule(Node* node)
|
||||
), position.Value, velocity.Value, mass.Value, sphereCenter.Value, sphereRadius.Value, attractionSpeed.Value, attractionForce.Value, stickDistance.Value, stickForce.Value);
|
||||
break;
|
||||
}
|
||||
// Kill (sphere)
|
||||
// Kill (sphere)
|
||||
case 306:
|
||||
{
|
||||
UseKill();
|
||||
@@ -119,7 +119,7 @@ void ParticleEmitterGPUGenerator::ProcessModule(Node* node)
|
||||
), position.Value, sphereCenter.Value, sphereRadius.Value, sign);
|
||||
break;
|
||||
}
|
||||
// Kill (box)
|
||||
// Kill (box)
|
||||
case 307:
|
||||
{
|
||||
UseKill();
|
||||
@@ -149,7 +149,7 @@ void ParticleEmitterGPUGenerator::ProcessModule(Node* node)
|
||||
), position.Value, boxCenter.Value, boxSize.Value, invert);
|
||||
break;
|
||||
}
|
||||
// Kill (custom)
|
||||
// Kill (custom)
|
||||
case 308:
|
||||
{
|
||||
UseKill();
|
||||
@@ -162,7 +162,7 @@ void ParticleEmitterGPUGenerator::ProcessModule(Node* node)
|
||||
), kill.Value);
|
||||
break;
|
||||
}
|
||||
// Linear Drag
|
||||
// Linear Drag
|
||||
case 310:
|
||||
{
|
||||
const bool useSpriteSize = node->Values[3].AsBool;
|
||||
@@ -195,7 +195,7 @@ void ParticleEmitterGPUGenerator::ProcessModule(Node* node)
|
||||
}
|
||||
break;
|
||||
}
|
||||
// Turbulence
|
||||
// Turbulence
|
||||
case 311:
|
||||
{
|
||||
auto position = AccessParticleAttribute(node, nodeGpu->Attributes[0], AccessMode::Read);
|
||||
@@ -225,7 +225,7 @@ void ParticleEmitterGPUGenerator::ProcessModule(Node* node)
|
||||
), position.Value, velocity.Value, mass.Value, fieldPosition.Value, fieldRotation.Value, fieldScale.Value, roughness.Value, intensity.Value, octavesCount.Value);
|
||||
break;
|
||||
}
|
||||
// Set Attribute
|
||||
// Set Attribute
|
||||
case 200:
|
||||
case 302:
|
||||
{
|
||||
@@ -235,7 +235,7 @@ void ParticleEmitterGPUGenerator::ProcessModule(Node* node)
|
||||
SET_ATTRIBUTE(attribute, value.Value);
|
||||
break;
|
||||
}
|
||||
// Set Position/Lifetime/Age/..
|
||||
// Set Position/Lifetime/Age/..
|
||||
case 250:
|
||||
case 251:
|
||||
case 252:
|
||||
@@ -271,7 +271,7 @@ void ParticleEmitterGPUGenerator::ProcessModule(Node* node)
|
||||
SET_ATTRIBUTE(attribute, value.Value);
|
||||
break;
|
||||
}
|
||||
// Position (sphere surface)
|
||||
// Position (sphere surface)
|
||||
case 202:
|
||||
{
|
||||
auto positionAttr = AccessParticleAttribute(node, nodeGpu->Attributes[0], AccessMode::Write);
|
||||
@@ -298,7 +298,7 @@ void ParticleEmitterGPUGenerator::ProcessModule(Node* node)
|
||||
), positionAttr.Value, 0, center.Value, radius.Value, arc.Value);
|
||||
break;
|
||||
}
|
||||
// Position (plane)
|
||||
// Position (plane)
|
||||
case 203:
|
||||
{
|
||||
auto positionAttr = AccessParticleAttribute(node, nodeGpu->Attributes[0], AccessMode::Write);
|
||||
@@ -318,7 +318,7 @@ void ParticleEmitterGPUGenerator::ProcessModule(Node* node)
|
||||
), positionAttr.Value, center.Value, size.Value);
|
||||
break;
|
||||
}
|
||||
// Position (circle)
|
||||
// Position (circle)
|
||||
case 204:
|
||||
{
|
||||
auto positionAttr = AccessParticleAttribute(node, nodeGpu->Attributes[0], AccessMode::Write);
|
||||
@@ -343,7 +343,7 @@ void ParticleEmitterGPUGenerator::ProcessModule(Node* node)
|
||||
), positionAttr.Value, 0, center.Value, radius.Value, arc.Value);
|
||||
break;
|
||||
}
|
||||
// Position (disc)
|
||||
// Position (disc)
|
||||
case 205:
|
||||
{
|
||||
auto positionAttr = AccessParticleAttribute(node, nodeGpu->Attributes[0], AccessMode::Write);
|
||||
@@ -368,7 +368,7 @@ void ParticleEmitterGPUGenerator::ProcessModule(Node* node)
|
||||
), positionAttr.Value, 0, center.Value, radius.Value, arc.Value);
|
||||
break;
|
||||
}
|
||||
// Position (box surface)
|
||||
// Position (box surface)
|
||||
case 206:
|
||||
{
|
||||
auto positionAttr = AccessParticleAttribute(node, nodeGpu->Attributes[0], AccessMode::Write);
|
||||
@@ -400,7 +400,7 @@ void ParticleEmitterGPUGenerator::ProcessModule(Node* node)
|
||||
), positionAttr.Value, center.Value, size.Value);
|
||||
break;
|
||||
}
|
||||
// Position (box volume)
|
||||
// Position (box volume)
|
||||
case 207:
|
||||
{
|
||||
auto positionAttr = AccessParticleAttribute(node, nodeGpu->Attributes[0], AccessMode::Write);
|
||||
@@ -420,7 +420,7 @@ void ParticleEmitterGPUGenerator::ProcessModule(Node* node)
|
||||
), positionAttr.Value, center.Value, size.Value);
|
||||
break;
|
||||
}
|
||||
// Position (cylinder)
|
||||
// Position (cylinder)
|
||||
case 208:
|
||||
{
|
||||
auto positionAttr = AccessParticleAttribute(node, nodeGpu->Attributes[0], AccessMode::Write);
|
||||
@@ -447,7 +447,7 @@ void ParticleEmitterGPUGenerator::ProcessModule(Node* node)
|
||||
), positionAttr.Value, center.Value, radius.Value, height.Value, arc.Value);
|
||||
break;
|
||||
}
|
||||
// Position (line)
|
||||
// Position (line)
|
||||
case 209:
|
||||
{
|
||||
auto positionAttr = AccessParticleAttribute(node, nodeGpu->Attributes[0], AccessMode::Write);
|
||||
@@ -467,7 +467,7 @@ void ParticleEmitterGPUGenerator::ProcessModule(Node* node)
|
||||
), positionAttr.Value, start.Value, end.Value);
|
||||
break;
|
||||
}
|
||||
// Position (torus)
|
||||
// Position (torus)
|
||||
case 210:
|
||||
{
|
||||
auto positionAttr = AccessParticleAttribute(node, nodeGpu->Attributes[0], AccessMode::Write);
|
||||
@@ -513,7 +513,7 @@ void ParticleEmitterGPUGenerator::ProcessModule(Node* node)
|
||||
), positionAttr.Value, 0, center.Value, radius.Value, thickness.Value, arc.Value);
|
||||
break;
|
||||
}
|
||||
// Position (sphere volume)
|
||||
// Position (sphere volume)
|
||||
case 211:
|
||||
{
|
||||
auto positionAttr = AccessParticleAttribute(node, nodeGpu->Attributes[0], AccessMode::Write);
|
||||
@@ -540,7 +540,7 @@ void ParticleEmitterGPUGenerator::ProcessModule(Node* node)
|
||||
), positionAttr.Value, 0, center.Value, radius.Value, arc.Value);
|
||||
break;
|
||||
}
|
||||
// Position (depth)
|
||||
// Position (depth)
|
||||
case 212:
|
||||
{
|
||||
auto positionAttr = AccessParticleAttribute(node, nodeGpu->Attributes[0], AccessMode::Write);
|
||||
@@ -574,7 +574,7 @@ void ParticleEmitterGPUGenerator::ProcessModule(Node* node)
|
||||
), positionAttr.Value, uv.Value, depthCullRange.Value, depthOffset.Value, linearDepth.Value, lifetimeAttr.Value);
|
||||
break;
|
||||
}
|
||||
// Position (spiral)
|
||||
// Position (spiral)
|
||||
case 214:
|
||||
{
|
||||
auto positionAttr = AccessParticleAttribute(node, nodeGpu->Attributes[0], AccessMode::Write);
|
||||
@@ -610,8 +610,29 @@ 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 (IsLocalSimulationSpace())
|
||||
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
|
||||
// Helper macros for collision modules to share the code
|
||||
#define COLLISION_BEGIN() \
|
||||
auto positionAttr = AccessParticleAttribute(node, nodeGpu->Attributes[0], AccessMode::ReadWrite); \
|
||||
auto velocityAttr = AccessParticleAttribute(node, nodeGpu->Attributes[1], AccessMode::ReadWrite); \
|
||||
@@ -641,17 +662,12 @@ void ParticleEmitterGPUGenerator::ProcessModule(Node* node)
|
||||
" {2} += {9};\n" \
|
||||
" }}\n"
|
||||
|
||||
// Collision (plane)
|
||||
// Collision (plane)
|
||||
case 330:
|
||||
{
|
||||
COLLISION_BEGIN();
|
||||
|
||||
auto planePositionBox = node->GetBox(5);
|
||||
auto planeNormalBox = node->GetBox(6);
|
||||
|
||||
const Value planePosition = GetValue(planePositionBox, 8).AsVector3();
|
||||
const Value planeNormal = GetValue(planeNormalBox, 9).AsVector3();
|
||||
|
||||
const Value planePosition = GetValue(node->GetBox(5), 8).AsVector3();
|
||||
const Value planeNormal = GetValue(node->GetBox(6), 9).AsVector3();
|
||||
_writer.Write(
|
||||
TEXT(
|
||||
" {{\n"
|
||||
@@ -674,17 +690,12 @@ void ParticleEmitterGPUGenerator::ProcessModule(Node* node)
|
||||
);
|
||||
break;
|
||||
}
|
||||
// Collision (sphere)
|
||||
// Collision (sphere)
|
||||
case 331:
|
||||
{
|
||||
COLLISION_BEGIN();
|
||||
|
||||
auto spherePositionBox = node->GetBox(5);
|
||||
auto sphereRadiusBox = node->GetBox(6);
|
||||
|
||||
const Value spherePosition = GetValue(spherePositionBox, 8).AsVector3();
|
||||
const Value sphereRadius = GetValue(sphereRadiusBox, 9).AsFloat();
|
||||
|
||||
const Value spherePosition = GetValue(node->GetBox(5), 8).AsVector3();
|
||||
const Value sphereRadius = GetValue(node->GetBox(6), 9).AsFloat();
|
||||
_writer.Write(
|
||||
TEXT(
|
||||
" {{\n"
|
||||
@@ -710,17 +721,12 @@ void ParticleEmitterGPUGenerator::ProcessModule(Node* node)
|
||||
);
|
||||
break;
|
||||
}
|
||||
// Collision (box)
|
||||
// Collision (box)
|
||||
case 332:
|
||||
{
|
||||
COLLISION_BEGIN();
|
||||
|
||||
auto boxPositionBox = node->GetBox(5);
|
||||
auto boxSizeBox = node->GetBox(6);
|
||||
|
||||
const Value boxPosition = GetValue(boxPositionBox, 8).AsVector3();
|
||||
const Value boxSize = GetValue(boxSizeBox, 9).AsVector3();
|
||||
|
||||
const Value boxPosition = GetValue(node->GetBox(5), 8).AsVector3();
|
||||
const Value boxSize = GetValue(node->GetBox(6), 9).AsVector3();
|
||||
_writer.Write(
|
||||
TEXT(
|
||||
" {{\n"
|
||||
@@ -761,19 +767,13 @@ void ParticleEmitterGPUGenerator::ProcessModule(Node* node)
|
||||
);
|
||||
break;
|
||||
}
|
||||
// Collision (cylinder)
|
||||
// Collision (cylinder)
|
||||
case 333:
|
||||
{
|
||||
COLLISION_BEGIN();
|
||||
|
||||
auto cylinderPositionBox = node->GetBox(5);
|
||||
auto cylinderHeightBox = node->GetBox(6);
|
||||
auto cylinderRadiusBox = node->GetBox(7);
|
||||
|
||||
const Value cylinderPosition = GetValue(cylinderPositionBox, 8).AsVector3();
|
||||
const Value cylinderHeight = GetValue(cylinderHeightBox, 9).AsFloat();
|
||||
const Value cylinderRadius = GetValue(cylinderRadiusBox, 10).AsFloat();
|
||||
|
||||
const Value cylinderPosition = GetValue(node->GetBox(5), 8).AsVector3();
|
||||
const Value cylinderHeight = GetValue(node->GetBox(6), 9).AsFloat();
|
||||
const Value cylinderRadius = GetValue(node->GetBox(7), 10).AsFloat();
|
||||
_writer.Write(
|
||||
TEXT(
|
||||
" {{\n"
|
||||
@@ -817,17 +817,12 @@ void ParticleEmitterGPUGenerator::ProcessModule(Node* node)
|
||||
);
|
||||
break;
|
||||
}
|
||||
// Collision (depth)
|
||||
// Collision (depth)
|
||||
case 334:
|
||||
{
|
||||
COLLISION_BEGIN();
|
||||
|
||||
auto surfaceThicknessBox = node->GetBox(5);
|
||||
|
||||
const Value surfaceThickness = GetValue(surfaceThicknessBox, 8).AsFloat();
|
||||
|
||||
const Value surfaceThickness = GetValue(node->GetBox(5), 8).AsFloat();
|
||||
const auto sceneDepthTexture = findOrAddSceneTexture(MaterialSceneTextures::SceneDepth);
|
||||
|
||||
_writer.Write(
|
||||
TEXT(
|
||||
" {{\n"
|
||||
@@ -877,6 +872,82 @@ void ParticleEmitterGPUGenerator::ProcessModule(Node* node)
|
||||
);
|
||||
break;
|
||||
}
|
||||
// Conform to Global SDF
|
||||
case 335:
|
||||
{
|
||||
auto position = AccessParticleAttribute(node, nodeGpu->Attributes[0], AccessMode::Read);
|
||||
auto velocity = AccessParticleAttribute(node, nodeGpu->Attributes[1], AccessMode::ReadWrite);
|
||||
auto mass = AccessParticleAttribute(node, nodeGpu->Attributes[2], AccessMode::Read);
|
||||
|
||||
const Value attractionSpeed = GetValue(node->GetBox(0), 2).AsFloat();
|
||||
const Value attractionForce = GetValue(node->GetBox(1), 3).AsFloat();
|
||||
const Value stickDistance = GetValue(node->GetBox(2), 4).AsFloat();
|
||||
const Value stickForce = GetValue(node->GetBox(3), 5).AsFloat();
|
||||
|
||||
auto param = findOrAddGlobalSDF();
|
||||
_includes.Add(TEXT("./Flax/GlobalSignDistanceField.hlsl"));
|
||||
_writer.Write(
|
||||
TEXT(
|
||||
" {{\n"
|
||||
" // Conform to Global SDF\n"
|
||||
" float dist;\n"
|
||||
" float3 dir = normalize(SampleGlobalSDFGradient({3}, {3}_Tex, {0}, dist));\n"
|
||||
" if (dist > 0) dir *= -1;\n"
|
||||
" float distToSurface = abs(dist);\n"
|
||||
" float spdNormal = dot(dir, {1});\n"
|
||||
" float ratio = smoothstep(0.0f, {6} * 2.0f, distToSurface);\n"
|
||||
" float tgtSpeed = {4} * ratio;\n"
|
||||
" float deltaSpeed = tgtSpeed - spdNormal;\n"
|
||||
" float3 deltaVelocity = dir * (sign(deltaSpeed) * min(abs(deltaSpeed), DeltaTime * lerp({7}, {5}, ratio)) / max({2}, PARTICLE_THRESHOLD));\n"
|
||||
" {1} += deltaVelocity;\n"
|
||||
" }}\n"
|
||||
), position.Value, velocity.Value, mass.Value, param.ShaderName, attractionSpeed.Value, attractionForce.Value, stickDistance.Value, stickForce.Value);
|
||||
break;
|
||||
}
|
||||
// Collision (Global SDF)
|
||||
case 336:
|
||||
{
|
||||
COLLISION_BEGIN();
|
||||
auto param = findOrAddGlobalSDF();
|
||||
_includes.Add(TEXT("./Flax/GlobalSignDistanceField.hlsl"));
|
||||
const Char* format = IsLocalSimulationSpace()
|
||||
? TEXT(
|
||||
" {{\n"
|
||||
" // Collision (Global SDF)\n"
|
||||
" float3 nextPos = {0} + {1} * DeltaTime;\n"
|
||||
" nextPos = mul(float4(nextPos, 1), WorldMatrix).xyz;\n"
|
||||
" float dist = SampleGlobalSDF({10}, {10}_Tex, nextPos);\n"
|
||||
" if (dist < {5})\n"
|
||||
" {{\n"
|
||||
" {0} = mul(float4({0}, 1), WorldMatrix).xyz;\n"
|
||||
" float3 n = normalize(SampleGlobalSDFGradient({10}, {10}_Tex, {0}, dist));\n"
|
||||
" {0} += n * -dist;\n"
|
||||
" {0} = mul(float4({0}, 1), InvWorldMatrix).xyz;\n"
|
||||
COLLISION_LOGIC()
|
||||
" }}\n"
|
||||
)
|
||||
: TEXT(
|
||||
" {{\n"
|
||||
" // Collision (Global SDF)\n"
|
||||
" float3 nextPos = {0} + {1} * DeltaTime;\n"
|
||||
" float dist = SampleGlobalSDF({10}, {10}_Tex, nextPos);\n"
|
||||
" if (dist < {5})\n"
|
||||
" {{\n"
|
||||
" float3 n = normalize(SampleGlobalSDFGradient({10}, {10}_Tex, {0}, dist));\n"
|
||||
" {0} += n * -dist;\n"
|
||||
COLLISION_LOGIC()
|
||||
" }}\n"
|
||||
);
|
||||
_writer.Write(format,
|
||||
// 0-4
|
||||
positionAttr.Value, velocityAttr.Value, ageAttr.Value, invert, sign,
|
||||
// 5-9
|
||||
radius.Value, roughness.Value, elasticity.Value, friction.Value, lifetimeLoss.Value,
|
||||
// 10
|
||||
param.ShaderName
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
#undef COLLISION_BEGIN
|
||||
#undef COLLISION_LOGIC
|
||||
|
||||
@@ -117,7 +117,7 @@ void ParticleEmitterGPUGenerator::ProcessGroupParameters(Box* box, Node* node, V
|
||||
{
|
||||
switch (node->TypeID)
|
||||
{
|
||||
// Get
|
||||
// Get
|
||||
case 1:
|
||||
case 2:
|
||||
{
|
||||
@@ -188,7 +188,7 @@ void ParticleEmitterGPUGenerator::ProcessGroupParameters(Box* box, Node* node, V
|
||||
value = Value(VariantType::Object, param->ShaderName);
|
||||
break;
|
||||
default:
|
||||
CRASH;
|
||||
CRASH;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -208,7 +208,7 @@ void ParticleEmitterGPUGenerator::ProcessGroupTools(Box* box, Node* node, Value&
|
||||
{
|
||||
switch (node->TypeID)
|
||||
{
|
||||
// Linearize Depth
|
||||
// Linearize Depth
|
||||
case 7:
|
||||
{
|
||||
// Get input
|
||||
@@ -218,11 +218,11 @@ void ParticleEmitterGPUGenerator::ProcessGroupTools(Box* box, Node* node, Value&
|
||||
linearizeSceneDepth(node, depth, value);
|
||||
break;
|
||||
}
|
||||
// Time
|
||||
// Time
|
||||
case 8:
|
||||
value = box->ID == 0 ? Value(VariantType::Float, TEXT("Time")) : Value(VariantType::Float, TEXT("DeltaTime"));
|
||||
break;
|
||||
// Transform Position To Screen UV
|
||||
// Transform Position To Screen UV
|
||||
case 9:
|
||||
{
|
||||
const Value position = tryGetValue(node->GetBox(0), Value::Zero).AsVector3();
|
||||
@@ -242,13 +242,11 @@ void ParticleEmitterGPUGenerator::ProcessGroupParticles(Box* box, Node* node, Va
|
||||
{
|
||||
switch (node->TypeID)
|
||||
{
|
||||
// Particle Attribute
|
||||
// Particle Attribute
|
||||
case 100:
|
||||
{
|
||||
value = AccessParticleAttribute(node, (StringView)node->Values[0], static_cast<ParticleAttribute::ValueTypes>(node->Values[1].AsInt), AccessMode::Read);
|
||||
break;
|
||||
}
|
||||
// Particle Attribute (by index)
|
||||
// Particle Attribute (by index)
|
||||
case 303:
|
||||
{
|
||||
const Char* format;
|
||||
@@ -285,61 +283,43 @@ void ParticleEmitterGPUGenerator::ProcessGroupParticles(Box* box, Node* node, Va
|
||||
value = writeLocal(type, String::Format(format, attribute.Offset, particleIndex.Value), node);
|
||||
break;
|
||||
}
|
||||
// Particle Position
|
||||
// Particle Position
|
||||
case 101:
|
||||
{
|
||||
value = AccessParticleAttribute(node, TEXT("Position"), ParticleAttribute::ValueTypes::Vector3, AccessMode::Read);
|
||||
break;
|
||||
}
|
||||
// Particle Lifetime
|
||||
// Particle Lifetime
|
||||
case 102:
|
||||
{
|
||||
value = AccessParticleAttribute(node, TEXT("Lifetime"), ParticleAttribute::ValueTypes::Float, AccessMode::Read);
|
||||
break;
|
||||
}
|
||||
// Particle Age
|
||||
// Particle Age
|
||||
case 103:
|
||||
{
|
||||
value = AccessParticleAttribute(node, TEXT("Age"), ParticleAttribute::ValueTypes::Float, AccessMode::Read);
|
||||
break;
|
||||
}
|
||||
// Particle Color
|
||||
// Particle Color
|
||||
case 104:
|
||||
{
|
||||
value = AccessParticleAttribute(node, TEXT("Color"), ParticleAttribute::ValueTypes::Vector4, AccessMode::Read);
|
||||
break;
|
||||
}
|
||||
// Particle Velocity
|
||||
// Particle Velocity
|
||||
case 105:
|
||||
{
|
||||
value = AccessParticleAttribute(node, TEXT("Velocity"), ParticleAttribute::ValueTypes::Vector3, AccessMode::Read);
|
||||
break;
|
||||
}
|
||||
// Particle Sprite Size
|
||||
// Particle Sprite Size
|
||||
case 106:
|
||||
{
|
||||
value = AccessParticleAttribute(node, TEXT("SpriteSize"), ParticleAttribute::ValueTypes::Vector2, AccessMode::Read);
|
||||
break;
|
||||
}
|
||||
// Particle Mass
|
||||
// Particle Mass
|
||||
case 107:
|
||||
{
|
||||
value = AccessParticleAttribute(node, TEXT("Mass"), ParticleAttribute::ValueTypes::Float, AccessMode::Read);
|
||||
break;
|
||||
}
|
||||
// Particle Rotation
|
||||
// Particle Rotation
|
||||
case 108:
|
||||
{
|
||||
value = AccessParticleAttribute(node, TEXT("Rotation"), ParticleAttribute::ValueTypes::Vector3, AccessMode::Read);
|
||||
break;
|
||||
}
|
||||
// Particle Angular Velocity
|
||||
// Particle Angular Velocity
|
||||
case 109:
|
||||
{
|
||||
value = AccessParticleAttribute(node, TEXT("AngularVelocity"), ParticleAttribute::ValueTypes::Vector3, AccessMode::Read);
|
||||
break;
|
||||
}
|
||||
// Particle Normalized Age
|
||||
// Particle Normalized Age
|
||||
case 110:
|
||||
{
|
||||
const auto age = AccessParticleAttribute(node, TEXT("Age"), ParticleAttribute::ValueTypes::Float, AccessMode::Read);
|
||||
@@ -347,95 +327,65 @@ void ParticleEmitterGPUGenerator::ProcessGroupParticles(Box* box, Node* node, Va
|
||||
value = writeOperation2(node, age, lifetime, '/');
|
||||
break;
|
||||
}
|
||||
// Particle Radius
|
||||
// Particle Radius
|
||||
case 111:
|
||||
{
|
||||
value = AccessParticleAttribute(node, TEXT("Radius"), ParticleAttribute::ValueTypes::Float, AccessMode::Read);
|
||||
break;
|
||||
}
|
||||
// Effect Position
|
||||
// Effect Position
|
||||
case 200:
|
||||
{
|
||||
value = Value(VariantType::Vector3, TEXT("EffectPosition"));
|
||||
break;
|
||||
}
|
||||
// Effect Rotation
|
||||
// Effect Rotation
|
||||
case 201:
|
||||
{
|
||||
value = Value(VariantType::Quaternion, TEXT("EffectRotation"));
|
||||
break;
|
||||
}
|
||||
// Effect Scale
|
||||
// Effect Scale
|
||||
case 202:
|
||||
{
|
||||
value = Value(VariantType::Vector3, TEXT("EffectScale"));
|
||||
break;
|
||||
}
|
||||
// Simulation Mode
|
||||
// Simulation Mode
|
||||
case 203:
|
||||
{
|
||||
value = Value(box->ID == 1);
|
||||
break;
|
||||
}
|
||||
// View Position
|
||||
// View Position
|
||||
case 204:
|
||||
{
|
||||
value = Value(VariantType::Vector3, TEXT("ViewPos"));
|
||||
break;
|
||||
}
|
||||
// View Direction
|
||||
// View Direction
|
||||
case 205:
|
||||
{
|
||||
value = Value(VariantType::Vector3, TEXT("ViewDir"));
|
||||
break;
|
||||
}
|
||||
// View Far Plane
|
||||
// View Far Plane
|
||||
case 206:
|
||||
{
|
||||
value = Value(VariantType::Float, TEXT("ViewFar"));
|
||||
break;
|
||||
}
|
||||
// Screen Size
|
||||
// Screen Size
|
||||
case 207:
|
||||
{
|
||||
value = Value(VariantType::Vector2, box->ID == 0 ? TEXT("ScreenSize.xy") : TEXT("ScreenSize.zw"));
|
||||
break;
|
||||
}
|
||||
// Random Float
|
||||
// Random Float
|
||||
case 208:
|
||||
{
|
||||
value = writeLocal(VariantType::Float, TEXT("RAND"), node);
|
||||
break;
|
||||
}
|
||||
// Random Vector2
|
||||
// Random Vector2
|
||||
case 209:
|
||||
{
|
||||
value = writeLocal(VariantType::Vector2, TEXT("RAND2"), node);
|
||||
break;
|
||||
}
|
||||
// Random Vector3
|
||||
// Random Vector3
|
||||
case 210:
|
||||
{
|
||||
value = writeLocal(VariantType::Vector3, TEXT("RAND3"), node);
|
||||
break;
|
||||
}
|
||||
// Random Vector4
|
||||
// Random Vector4
|
||||
case 211:
|
||||
{
|
||||
value = writeLocal(VariantType::Vector4, TEXT("RAND4"), node);
|
||||
break;
|
||||
}
|
||||
// Particle Position (world space)
|
||||
// Particle Position (world space)
|
||||
case 212:
|
||||
{
|
||||
value = AccessParticleAttribute(node, TEXT("Position"), ParticleAttribute::ValueTypes::Vector3, AccessMode::Read);
|
||||
if (((ParticleEmitterGraphGPU*)_graphStack.Peek())->SimulationSpace == ParticlesSimulationSpace::Local)
|
||||
{
|
||||
if (IsLocalSimulationSpace())
|
||||
value = writeLocal(VariantType::Vector3, String::Format(TEXT("mul(float4({0}, 1), WorldMatrix).xyz"), value.Value), node);
|
||||
}
|
||||
break;
|
||||
}
|
||||
// Random Float Range
|
||||
// Random Float Range
|
||||
case 213:
|
||||
{
|
||||
auto& a = node->Values[0].AsFloat;
|
||||
@@ -443,7 +393,7 @@ void ParticleEmitterGPUGenerator::ProcessGroupParticles(Box* box, Node* node, Va
|
||||
value = writeLocal(VariantType::Float, String::Format(TEXT("lerp({0}, {1}, RAND)"), a, b), node);
|
||||
break;
|
||||
}
|
||||
// Random Vector2 Range
|
||||
// Random Vector2 Range
|
||||
case 214:
|
||||
{
|
||||
auto& a = node->Values[0].AsVector2();
|
||||
@@ -451,7 +401,7 @@ void ParticleEmitterGPUGenerator::ProcessGroupParticles(Box* box, Node* node, Va
|
||||
value = writeLocal(VariantType::Vector2, String::Format(TEXT("float2(lerp({0}, {1}, RAND), lerp({2}, {3}, RAND))"), a.X, b.X, a.Y, b.Y), node);
|
||||
break;
|
||||
}
|
||||
// Random Vector3 Range
|
||||
// Random Vector3 Range
|
||||
case 215:
|
||||
{
|
||||
auto& a = node->Values[0].AsVector3();
|
||||
@@ -459,7 +409,7 @@ void ParticleEmitterGPUGenerator::ProcessGroupParticles(Box* box, Node* node, Va
|
||||
value = writeLocal(VariantType::Vector3, String::Format(TEXT("float3(lerp({0}, {1}, RAND), lerp({2}, {3}, RAND), lerp({4}, {5}, RAND))"), a.X, b.X, a.Y, b.Y, a.Z, b.Z), node);
|
||||
break;
|
||||
}
|
||||
// Random Vector4 Range
|
||||
// Random Vector4 Range
|
||||
case 216:
|
||||
{
|
||||
auto& a = node->Values[0].AsVector4();
|
||||
@@ -467,7 +417,7 @@ void ParticleEmitterGPUGenerator::ProcessGroupParticles(Box* box, Node* node, Va
|
||||
value = writeLocal(VariantType::Vector4, String::Format(TEXT("float4(lerp({0}, {1}, RAND), lerp({2}, {3}, RAND), lerp({4}, {5}, RAND), lerp({6}, {7}, RAND))"), a.X, b.X, a.Y, b.Y, a.Z, b.Z, a.W, b.W), node);
|
||||
break;
|
||||
}
|
||||
// Particle Emitter Function
|
||||
// Particle Emitter Function
|
||||
case 300:
|
||||
{
|
||||
// Load function asset
|
||||
@@ -522,11 +472,11 @@ void ParticleEmitterGPUGenerator::ProcessGroupParticles(Box* box, Node* node, Va
|
||||
_graphStack.Pop();
|
||||
break;
|
||||
}
|
||||
// Particle Index
|
||||
// Particle Index
|
||||
case 301:
|
||||
value = Value(VariantType::Uint, TEXT("context.ParticleIndex"));
|
||||
break;
|
||||
// Particles Count
|
||||
// Particles Count
|
||||
case 302:
|
||||
value = Value(VariantType::Uint, TEXT("context.ParticlesCount"));
|
||||
break;
|
||||
@@ -539,7 +489,7 @@ void ParticleEmitterGPUGenerator::ProcessGroupFunction(Box* box, Node* node, Val
|
||||
{
|
||||
switch (node->TypeID)
|
||||
{
|
||||
// Function Input
|
||||
// Function Input
|
||||
case 1:
|
||||
{
|
||||
// Find the function call
|
||||
@@ -599,7 +549,6 @@ void ParticleEmitterGPUGenerator::ProcessGroupFunction(Box* box, Node* node, Val
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ bool ParticleEmitterGPUGenerator::sampleSceneTexture(Node* caller, Box* box, con
|
||||
result = Value(VariantType::Float, valueBox->Cache.Value + _subs[3]);
|
||||
break;
|
||||
default:
|
||||
CRASH;
|
||||
CRASH;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ void ParticleEmitterGPUGenerator::ProcessGroupTextures(Box* box, Node* node, Val
|
||||
{
|
||||
switch (node->TypeID)
|
||||
{
|
||||
// Scene Texture
|
||||
// Scene Texture
|
||||
case 6:
|
||||
{
|
||||
// Get texture type
|
||||
@@ -255,11 +255,11 @@ void ParticleEmitterGPUGenerator::ProcessGroupTextures(Box* box, Node* node, Val
|
||||
}
|
||||
break;
|
||||
}
|
||||
// Scene Depth
|
||||
// Scene Depth
|
||||
case 8:
|
||||
sampleSceneDepth(node, value, box);
|
||||
break;
|
||||
// Texture
|
||||
// Texture
|
||||
case 11:
|
||||
{
|
||||
// Check if texture has been selected
|
||||
@@ -276,7 +276,7 @@ void ParticleEmitterGPUGenerator::ProcessGroupTextures(Box* box, Node* node, Val
|
||||
}
|
||||
break;
|
||||
}
|
||||
// Load Texture
|
||||
// Load Texture
|
||||
case 13:
|
||||
{
|
||||
// Get input texture
|
||||
@@ -303,6 +303,15 @@ void ParticleEmitterGPUGenerator::ProcessGroupTextures(Box* box, Node* node, Val
|
||||
loadTexture(node, box, copy, value);
|
||||
break;
|
||||
}
|
||||
// Sample Global SDF
|
||||
case 14:
|
||||
{
|
||||
auto param = findOrAddGlobalSDF();
|
||||
Value worldPosition = tryGetValue(node->GetBox(1), Value(VariantType::Vector3, TEXT("input.WorldPosition.xyz"))).Cast(VariantType::Vector3);
|
||||
value = writeLocal(VariantType::Float, String::Format(TEXT("SampleGlobalSDF({0}, {0}_Tex, {1})"), param.ShaderName, worldPosition.Value), node);
|
||||
_includes.Add(TEXT("./Flax/GlobalSignDistanceField.hlsl"));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ bool ParticleEmitterGPUGenerator::Generate(WriteStream& source, BytesContainer&
|
||||
typeName = TEXT("uint");
|
||||
break;
|
||||
default:
|
||||
CRASH;
|
||||
CRASH;
|
||||
}
|
||||
_writer.Write(TEXT("// {0:^6} | {1:^6} | {2}\n"), a.Offset, typeName, a.Name);
|
||||
}
|
||||
|
||||
@@ -156,6 +156,16 @@ private:
|
||||
{
|
||||
return box->HasConnection() ? eatBox(box->GetParent<Node>(), box->FirstConnection()) : Value::Zero;
|
||||
}
|
||||
|
||||
bool IsLocalSimulationSpace() const
|
||||
{
|
||||
return ((ParticleEmitterGraphGPU*)_graphStack.Peek())->SimulationSpace == ParticlesSimulationSpace::Local;
|
||||
}
|
||||
|
||||
bool IsWorldSimulationSpace() const
|
||||
{
|
||||
return ((ParticleEmitterGraphGPU*)_graphStack.Peek())->SimulationSpace == ParticlesSimulationSpace::World;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -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;
|
||||
@@ -415,6 +416,7 @@ public:
|
||||
#undef CASE_SET_PARTICLE_ATTRIBUTE
|
||||
// Conform to Sphere
|
||||
case GRAPH_NODE_MAKE_TYPE(15, 305):
|
||||
case GRAPH_NODE_MAKE_TYPE(15, 335): // Conform to Global SDF
|
||||
{
|
||||
USE_ATTRIBUTE(Position, Vector3, 0);
|
||||
USE_ATTRIBUTE(Velocity, Vector3, 1);
|
||||
@@ -428,12 +430,13 @@ public:
|
||||
USE_ATTRIBUTE(Position, Vector3, 0);
|
||||
break;
|
||||
}
|
||||
// Collision (plane/sphere/box/cylinder/depth)
|
||||
// Collision (plane/sphere/box/cylinder/depth/Global SDF)
|
||||
case GRAPH_NODE_MAKE_TYPE(15, 330):
|
||||
case GRAPH_NODE_MAKE_TYPE(15, 331):
|
||||
case GRAPH_NODE_MAKE_TYPE(15, 332):
|
||||
case GRAPH_NODE_MAKE_TYPE(15, 333):
|
||||
case GRAPH_NODE_MAKE_TYPE(15, 334):
|
||||
case GRAPH_NODE_MAKE_TYPE(15, 336):
|
||||
{
|
||||
USE_ATTRIBUTE(Position, Vector3, 0);
|
||||
USE_ATTRIBUTE(Velocity, Vector3, 1);
|
||||
|
||||
@@ -312,7 +312,7 @@ void ParticleEffect::UpdateBounds()
|
||||
_box = bounds;
|
||||
BoundingSphere::FromBox(bounds, _sphere);
|
||||
if (_sceneRenderingKey != -1)
|
||||
GetSceneRendering()->UpdateGeometry(this, _sceneRenderingKey);
|
||||
GetSceneRendering()->UpdateActor(this, _sceneRenderingKey);
|
||||
}
|
||||
|
||||
void ParticleEffect::Sync()
|
||||
@@ -494,15 +494,12 @@ bool ParticleEffect::HasContentLoaded() const
|
||||
|
||||
void ParticleEffect::Draw(RenderContext& renderContext)
|
||||
{
|
||||
if (renderContext.View.Pass == DrawPass::GlobalSDF || renderContext.View.Pass == DrawPass::GlobalSurfaceAtlas)
|
||||
return;
|
||||
_lastMinDstSqr = Math::Min(_lastMinDstSqr, Vector3::DistanceSquared(GetPosition(), renderContext.View.Position));
|
||||
Particles::DrawParticles(renderContext, this);
|
||||
}
|
||||
|
||||
void ParticleEffect::DrawGeneric(RenderContext& renderContext)
|
||||
{
|
||||
Draw(renderContext);
|
||||
}
|
||||
|
||||
#if USE_EDITOR
|
||||
|
||||
#include "Engine/Debug/DebugDraw.h"
|
||||
@@ -520,7 +517,7 @@ void ParticleEffect::OnDebugDrawSelected()
|
||||
void ParticleEffect::OnLayerChanged()
|
||||
{
|
||||
if (_sceneRenderingKey != -1)
|
||||
GetSceneRendering()->UpdateGeometry(this, _sceneRenderingKey);
|
||||
GetSceneRendering()->UpdateActor(this, _sceneRenderingKey);
|
||||
}
|
||||
|
||||
void ParticleEffect::Serialize(SerializeStream& stream, const void* otherObj)
|
||||
@@ -699,7 +696,7 @@ void ParticleEffect::EndPlay()
|
||||
void ParticleEffect::OnEnable()
|
||||
{
|
||||
GetScene()->Ticking.Update.AddTick<ParticleEffect, &ParticleEffect::Update>(this);
|
||||
_sceneRenderingKey = GetSceneRendering()->AddGeometry(this);
|
||||
GetSceneRendering()->AddActor(this, _sceneRenderingKey);
|
||||
#if USE_EDITOR
|
||||
GetSceneRendering()->AddViewportIcon(this);
|
||||
GetScene()->Ticking.Update.AddTickExecuteInEditor<ParticleEffect, &ParticleEffect::UpdateExecuteInEditor>(this);
|
||||
@@ -715,7 +712,7 @@ void ParticleEffect::OnDisable()
|
||||
GetScene()->Ticking.Update.RemoveTickExecuteInEditor(this);
|
||||
GetSceneRendering()->RemoveViewportIcon(this);
|
||||
#endif
|
||||
GetSceneRendering()->RemoveGeometry(this, _sceneRenderingKey);
|
||||
GetSceneRendering()->RemoveActor(this, _sceneRenderingKey);
|
||||
GetScene()->Ticking.Update.RemoveTick(this);
|
||||
|
||||
// Base
|
||||
|
||||
@@ -385,7 +385,6 @@ public:
|
||||
// [Actor]
|
||||
bool HasContentLoaded() const override;
|
||||
void Draw(RenderContext& renderContext) override;
|
||||
void DrawGeneric(RenderContext& renderContext) override;
|
||||
#if USE_EDITOR
|
||||
void OnDebugDrawSelected() override;
|
||||
#endif
|
||||
|
||||
@@ -461,7 +461,7 @@ void ParticleSystem::unload(bool isReloading)
|
||||
FramesPerSecond = 0.0f;
|
||||
DurationFrames = 0;
|
||||
Emitters.Resize(0);
|
||||
EmittersParametersOverrides.Cleanup();
|
||||
EmittersParametersOverrides.SetCapacity(0);
|
||||
Tracks.Resize(0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user