Add Noise sampling nodes to graphs
This commit is contained in:
@@ -793,6 +793,41 @@ void ShaderGenerator::ProcessGroupTools(Box* box, Node* node, Value& value)
|
||||
case 29:
|
||||
value = tryGetValue(node->GetBox(0), Value::Zero);
|
||||
break;
|
||||
// Noises
|
||||
case 30:
|
||||
case 31:
|
||||
case 32:
|
||||
case 33:
|
||||
case 34:
|
||||
{
|
||||
_includes.Add(TEXT("./Flax/Noise.hlsl"));
|
||||
const Char* format;
|
||||
ValueType pointType = VariantType::Float2;
|
||||
ValueType resultType = VariantType::Float;
|
||||
switch (node->TypeID)
|
||||
{
|
||||
case 30:
|
||||
format = TEXT("PerlinNoise({0})");
|
||||
break;
|
||||
case 31:
|
||||
format = TEXT("SimplexNoise({0})");
|
||||
break;
|
||||
case 32:
|
||||
format = TEXT("WorleyNoise({0})");
|
||||
resultType = VariantType::Float2;
|
||||
break;
|
||||
case 33:
|
||||
format = TEXT("VoronoiNoise({0})");
|
||||
resultType = VariantType::Float3;
|
||||
break;
|
||||
case 34:
|
||||
format = TEXT("CustomNoise({0})");
|
||||
pointType = VariantType::Float3;
|
||||
break;
|
||||
}
|
||||
value = writeLocal(resultType, String::Format(format, tryGetValue(node->GetBox(0), Value::Zero).Cast(pointType).Value), node);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "Engine/Scripting/ManagedCLR/MUtils.h"
|
||||
#include "Engine/Serialization/MemoryReadStream.h"
|
||||
#include "Engine/Utilities/StringConverter.h"
|
||||
#include "Engine/Utilities/Noise.h"
|
||||
|
||||
#define RAND Random::Rand()
|
||||
#define ENSURE(condition, errorMsg) if (!(condition)) { OnError(node, box, errorMsg); return; }
|
||||
@@ -1052,6 +1053,22 @@ void VisjectExecutor::ProcessGroupTools(Box* box, Node* node, Value& value)
|
||||
case 29:
|
||||
value = tryGetValue(node->GetBox(0), Value::Zero);
|
||||
break;
|
||||
// Noises
|
||||
case 30:
|
||||
value = Noise::PerlinNoise((Float2)tryGetValue(node->GetBox(0)));
|
||||
break;
|
||||
case 31:
|
||||
value = Noise::SimplexNoise((Float2)tryGetValue(node->GetBox(0)));
|
||||
break;
|
||||
case 32:
|
||||
value = Noise::WorleyNoise((Float2)tryGetValue(node->GetBox(0)));
|
||||
break;
|
||||
case 33:
|
||||
value = Noise::VoronoiNoise((Float2)tryGetValue(node->GetBox(0)));
|
||||
break;
|
||||
case 34:
|
||||
value = Noise::CustomNoise((Float3)tryGetValue(node->GetBox(0)));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -259,6 +259,11 @@ protected:
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
FORCE_INLINE Value tryGetValue(Box* box)
|
||||
{
|
||||
return box && box->HasConnection() ? eatBox(box->GetParent<Node>(), box->FirstConnection()) : Value::Zero;
|
||||
}
|
||||
|
||||
FORCE_INLINE Value tryGetValue(Box* box, const Value& defaultValue)
|
||||
{
|
||||
return box && box->HasConnection() ? eatBox(box->GetParent<Node>(), box->FirstConnection()) : defaultValue;
|
||||
|
||||
Reference in New Issue
Block a user