Added rotator node

This commit is contained in:
W2.Wizard
2021-01-24 15:10:38 +01:00
parent 3a33d6ff84
commit bcb38dc2ca
2 changed files with 32 additions and 0 deletions

View File

@@ -339,6 +339,7 @@ void MaterialGenerator::ProcessGroupMaterial(Box* box, Node* node, Value& value)
case 25:
value = Value(VariantType::Vector3, TEXT("GetObjectSize(input)"));
break;
// Normal blend
case 26:
{
const auto baseNormal = tryGetValue(node->GetBox(0), Value::Zero).AsVector3();
@@ -346,6 +347,22 @@ void MaterialGenerator::ProcessGroupMaterial(Box* box, Node* node, Value& value)
const String text = String::Format(TEXT("float3((float2({0}.xy) + float2({1}.xy) * 2.0), sqrt(saturate(1.0 - dot((float2({0}.xy) + float2({1}.xy) * 2.0).xy, (float2({0}.xy) + float2({1}.xy) * 2.0).xy))))"), baseNormal.Value, additionalNormal.Value);
value = writeLocal(ValueType::Vector3, text, node);
break;
}
// Rotator
case 27:
{
auto UV = tryGetValue(node->GetBox(0), Value::Zero).AsVector2();
auto center = tryGetValue(node->GetBox(1), Value::Zero).AsVector2();
auto rotationAngle = tryGetValue(node->GetBox(2), Value::Zero).AsFloat();
const auto x1 = writeLocal(ValueType::Vector2, String::Format(TEXT("({0} * -1) + {1}"), center.Value, UV.Value), node);
const auto RACosSin = writeLocal(ValueType::Vector2, String::Format(TEXT("float2(cos({0}), sin({0}))"), rotationAngle.Value), node);
const auto DotB1 = writeLocal(ValueType::Vector2, String::Format(TEXT("float2({0}.x, {0}.y * -1)"), RACosSin.Value), node);
const auto DotB2 = writeLocal(ValueType::Vector2, String::Format(TEXT("float2({0}.y, {0}.x)"), RACosSin.Value), node);
value = writeLocal(ValueType::Vector2, String::Format(TEXT("{3} + float2(dot({0},{1}), dot({0},{2}))"), x1.Value, DotB1.Value, DotB2.Value, center.Value), node);
break;
}
default:
break;