Added initial remap node

This commit is contained in:
W2.Wizard
2021-01-25 00:51:47 +01:00
parent f714afc180
commit ee166bafed
3 changed files with 55 additions and 0 deletions

View File

@@ -401,6 +401,22 @@ void ShaderGenerator::ProcessGroupMath(Box* box, Node* node, Value& value)
{
value = writeFunction1(node, tryGetValue(node->GetBox(0), Value::Zero), TEXT("radians"));
break;
}
// Remap
case 48:
{
auto inVal = tryGetValue(node->GetBox(0), node->Values[0]);
auto rangeA = tryGetValue(node->GetBox(1), node->Values[1]);
auto rangeB = tryGetValue(node->GetBox(2), node->Values[2]);
// Clamp value?
if (node->Values[3].AsBool)
{
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;
}
default:
break;