Refactored
This commit is contained in:
@@ -405,17 +405,12 @@ void ShaderGenerator::ProcessGroupMath(Box* box, Node* node, Value& value)
|
|||||||
// Remap
|
// Remap
|
||||||
case 48:
|
case 48:
|
||||||
{
|
{
|
||||||
auto inVal = tryGetValue(node->GetBox(0), node->Values[0].AsFloat);
|
const auto inVal = tryGetValue(node->GetBox(0), node->Values[0].AsFloat);
|
||||||
auto rangeA = tryGetValue(node->GetBox(1), node->Values[1].AsVector2());
|
const auto rangeA = tryGetValue(node->GetBox(1), node->Values[1].AsVector2());
|
||||||
auto rangeB = tryGetValue(node->GetBox(2), node->Values[2].AsVector2());
|
const auto rangeB = tryGetValue(node->GetBox(2), node->Values[2].AsVector2());
|
||||||
|
|
||||||
// Clamp value?
|
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);
|
||||||
if (node->Values[3].AsBool)
|
value = writeLocal(ValueType::Float, node->Values[3].AsBool ? String::Format(TEXT("clamp({0}, {1}.x, {1}.y)"), mapFunc, rangeB.Value) : mapFunc, node);
|
||||||
{
|
|
||||||
value = writeLocal(ValueType::Float, String::Format(TEXT("clamp({2}.x + ({0} - {1}.x) * ({2}.y - {2}.x) / ({1}.y - {1}.x), {2}.x, {2}.y)"), inVal.Value, rangeA.Value, rangeB.Value), node);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
value = writeLocal(ValueType::Float, String::Format(TEXT("{2}.x + ({0} - {1}.x) * ({2}.y - {2}.x) / ({1}.y - {1}.x)"), inVal.Value, rangeA.Value, rangeB.Value), node);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -378,13 +378,10 @@ void VisjectExecutor::ProcessGroupMath(Box* box, Node* node, Value& value)
|
|||||||
const Vector2 rangeA = tryGetValue(node->GetBox(1), node->Values[1]).AsVector2();
|
const Vector2 rangeA = tryGetValue(node->GetBox(1), node->Values[1]).AsVector2();
|
||||||
const Vector2 rangeB = tryGetValue(node->GetBox(2), node->Values[2]).AsVector2();
|
const Vector2 rangeB = tryGetValue(node->GetBox(2), node->Values[2]).AsVector2();
|
||||||
|
|
||||||
|
auto mapFunc = rangeB.X + (inVal - rangeA.X) * (rangeB.Y - rangeB.X) / (rangeA.Y - rangeA.X);
|
||||||
|
|
||||||
// Clamp value?
|
// Clamp value?
|
||||||
if (node->Values[3].AsBool)
|
value = node->Values[3].AsBool ? Math::Clamp(mapFunc, rangeB.X, rangeB.Y) : mapFunc;
|
||||||
{
|
|
||||||
value = Math::Clamp(rangeB.X + (inVal - rangeA.X) * (rangeB.Y - rangeB.X) / (rangeA.Y - rangeA.X), rangeB.X, rangeB.Y);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
value = rangeB.X + (inVal - rangeA.X) * (rangeB.Y - rangeB.X) / (rangeA.Y - rangeA.X);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|||||||
Reference in New Issue
Block a user