Merge remote-tracking branch 'origin/1.1' into linux-editor
# Conflicts: # Source/FlaxEngine.Gen.cs # Source/Tools/Flax.Build/Utilities/Utilities.cs
This commit is contained in:
@@ -380,6 +380,15 @@ void ShaderGenerator::ProcessGroupMath(Box* box, Node* node, Value& value)
|
||||
Value v2 = tryGetValue(node->GetBox(1), Value::Zero);
|
||||
value = writeFunction2(node, v1, v2, TEXT("atan2"));
|
||||
break;
|
||||
}
|
||||
// Near Equal
|
||||
case 42:
|
||||
{
|
||||
Value v1 = tryGetValue(node->GetBox(0), Value::Zero);
|
||||
Value v2 = tryGetValue(node->GetBox(1), Value::Zero).Cast(v1.Type);
|
||||
Value epsilon = tryGetValue(node->GetBox(2), 2, Value::Zero);
|
||||
value = writeLocal(ValueType::Bool, String::Format(TEXT("distance({0},{1}) < {2}"), v1.Value, v2.Value, epsilon.Value), node);
|
||||
break;
|
||||
}
|
||||
// Degrees
|
||||
case 43:
|
||||
@@ -392,6 +401,18 @@ void ShaderGenerator::ProcessGroupMath(Box* box, Node* node, Value& value)
|
||||
{
|
||||
value = writeFunction1(node, tryGetValue(node->GetBox(0), Value::Zero), TEXT("radians"));
|
||||
break;
|
||||
}
|
||||
// Remap
|
||||
case 48:
|
||||
{
|
||||
const auto inVal = tryGetValue(node->GetBox(0), node->Values[0].AsFloat);
|
||||
const auto rangeA = tryGetValue(node->GetBox(1), node->Values[1].AsVector2());
|
||||
const auto rangeB = tryGetValue(node->GetBox(2), node->Values[2].AsVector2());
|
||||
const auto clamp = tryGetValue(node->GetBox(3), node->Values[3]).AsBool();
|
||||
|
||||
const auto mapFunc = String::Format(TEXT("{2}.x + ({0} - {1}.x) * ({2}.y - {2}.x) / ({1}.y - {1}.x)"), inVal.Value, rangeA.Value, rangeB.Value);
|
||||
value = writeLocal(ValueType::Float, String::Format(TEXT("{2} ? clamp({0}, {1}.x, {1}.y) : {0}"), mapFunc, rangeB.Value, clamp.Value), node);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
@@ -911,7 +932,7 @@ void ShaderGenerator::ProcessGroupComparisons(Box* box, Node* node, Value& value
|
||||
const Value condition = tryGetValue(node->GetBox(0), Value::False).AsBool();
|
||||
const Value onTrue = tryGetValue(node->GetBox(2), 1, Value::Zero);
|
||||
const Value onFalse = tryGetValue(node->GetBox(1), 0, Value::Zero).Cast(onTrue.Type);
|
||||
value = writeLocal(onTrue.Type, String::Format(TEXT("({0}) ? ({1}) : ({2})"), condition.Value, onTrue.Value, onFalse.Value), node);
|
||||
value = writeLocal(onTrue.Type, String::Format(TEXT("{0} ? {1} : {2}"), condition.Value, onTrue.Value, onFalse.Value), node);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,10 +177,6 @@ const Char* ShaderGraphUtilities::GenerateShaderResources(TextWriterUnicode& wri
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (startRegister != registerIndex)
|
||||
writer.WriteLine();
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -371,6 +371,20 @@ void VisjectExecutor::ProcessGroupMath(Box* box, Node* node, Value& value)
|
||||
if (value.Type.Type == VariantType::Enum)
|
||||
value.AsUint64 = value.AsUint64 | (uint64)tryGetValue(node->GetBox(1), Value::Zero);
|
||||
break;
|
||||
// Remap
|
||||
case 48:
|
||||
{
|
||||
const float inVal = tryGetValue(node->GetBox(0), node->Values[0]).AsFloat;
|
||||
const Vector2 rangeA = tryGetValue(node->GetBox(1), node->Values[1]).AsVector2();
|
||||
const Vector2 rangeB = tryGetValue(node->GetBox(2), node->Values[2]).AsVector2();
|
||||
const bool clamp = tryGetValue(node->GetBox(3), node->Values[3]).AsBool;
|
||||
|
||||
auto mapFunc = rangeB.X + (inVal - rangeA.X) * (rangeB.Y - rangeB.X) / (rangeA.Y - rangeA.X);
|
||||
|
||||
// Clamp value?
|
||||
value = clamp ? Math::Clamp(mapFunc, rangeB.X, rangeB.Y) : mapFunc;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user