Codestyle fixes and some nodes docs

This commit is contained in:
Wojtek Figat
2024-06-11 08:43:31 +02:00
parent 735aa70b53
commit f95e7e96bf
2 changed files with 45 additions and 49 deletions

View File

@@ -594,23 +594,22 @@ void MaterialGenerator::ProcessGroupMaterial(Box* box, Node* node, Value& value)
// Cycle Gradient
case 45:
{
//float gradient = 1 - lenght(uv * 2);
//float gradient = 1 - length(uv * 2);
const auto uv = tryGetValue(node->GetBox(0), getUVs).AsFloat2();
value = writeLocal(ValueType::Float, String::Format(TEXT("1 - length({0} * 2)"), uv.Value), node);
break;
}
//Falloff and Offset
// Falloff and Offset
case 46:
{
//float out = clamp((((Value - (1 - Offset)) + Falloff) / Falloff),0,1)
const auto Value = tryGetValue(node->GetBox(0), ShaderGraphValue(0.0f));
const auto Offset = tryGetValue(node->GetBox(1), node->Values[0].AsFloat);
const auto Falloff = tryGetValue(node->GetBox(2), node->Values[1].AsFloat);
value = writeLocal(ValueType::Float, String::Format(TEXT("clamp(((({0} - (1 - {1})) + {2}) / {2}),0,1)"), Value.Value, Offset.Value, Falloff.Value), node);
const auto in = tryGetValue(node->GetBox(0), ShaderGraphValue::Zero);
const auto graphValue = tryGetValue(node->GetBox(1), node->Values[0].AsFloat);
const auto falloff = tryGetValue(node->GetBox(2), node->Values[1].AsFloat);
value = writeLocal(ValueType::Float, String::Format(TEXT("saturate(((({0} - (1.0 - {1})) + {2}) / {2}))"), in.Value, graphValue.Value, falloff.Value), node);
break;
}
//Linear Gradient
// Linear Gradient
case 47:
{
// float2 uv = Input0.xy;
@@ -620,19 +619,16 @@ void MaterialGenerator::ProcessGroupMaterial(Box* box, Node* node, Value& value)
const auto uv = tryGetValue(node->GetBox(0), getUVs).AsFloat2();
const auto rotationAngle = tryGetValue(node->GetBox(1), node->Values[0].AsFloat).AsFloat();
const auto Mirror = tryGetValue(node->GetBox(2), node->Values[1].AsBool).AsBool();
const auto mirror = tryGetValue(node->GetBox(2), node->Values[1].AsBool).AsBool();
auto c = writeLocal(ValueType::Float, String::Format(TEXT("cos({0})"), rotationAngle.Value), node);
auto s = writeLocal(ValueType::Float, String::Format(TEXT("sin({0})"), rotationAngle.Value), node);
auto A = writeLocal(ValueType::Float2, String::Format(TEXT("1.0 - float2({1} * {0}.x + {2} * {0}.y,{1} * {0}.y - {2} * {0}.x)"), uv.Value, c.Value, s.Value), node);
auto a = writeLocal(ValueType::Float2, String::Format(TEXT("1.0 - float2({1} * {0}.x + {2} * {0}.y,{1} * {0}.y - {2} * {0}.x)"), uv.Value, c.Value, s.Value), node);
value = writeLocal(
ValueType::Float2,
String::Format(TEXT
(
"float2({0} ? abs({1}.x < 1.0 ? ({1}.x - 0.5) * 2 : (2 - (({1}.x - 0.5) * 2)) * -1) : {1}.x < 1.0 ? ({1}.x - 0.5) * 2 : 1,{0} ? abs({1}.y < 1.0 ? ({1}.y - 0.5) * 2 : (2 - (({1}.y - 0.5) * 2)) * -1) : {1}.y < 1.0 ? ({1}.y - 0.5) * 2 : 1)"
),
Mirror.Value,
A.Value),
ValueType::Float2, String::Format(TEXT
(
"float2({0} ? abs({1}.x < 1.0 ? ({1}.x - 0.5) * 2 : (2 - (({1}.x - 0.5) * 2)) * -1) : {1}.x < 1.0 ? ({1}.x - 0.5) * 2 : 1,{0} ? abs({1}.y < 1.0 ? ({1}.y - 0.5) * 2 : (2 - (({1}.y - 0.5) * 2)) * -1) : {1}.y < 1.0 ? ({1}.y - 0.5) * 2 : 1)"
), mirror.Value, a.Value),
node);
break;
}
@@ -654,23 +650,23 @@ void MaterialGenerator::ProcessGroupMaterial(Box* box, Node* node, Value& value)
// float OuterMask = FalloffAndOffset(1-c,1-InnerBounds,Falloff)
// float Mask = OuterMask * InnerMask;
//ToDo: cheak if there is some useless operetors
// TODO: check if there is some useless operators
//expanded
//float cycleGradient = 1 - lenght(uv * 2);
//float cycleGradient = 1 - length(uv * 2);
//float InnerMask = clamp((((c - (1 - (OuterBounds - Falloff))) + Falloff) / Falloff),0,1)
//float OuterMask = clamp(((((1-c) - (1 - (1-InnerBounds))) + Falloff) / Falloff),0,1)
//float Mask = OuterMask * InnerMask;
const auto uv = tryGetValue(node->GetBox(0), getUVs).AsFloat2();
const auto OuterBounds = tryGetValue(node->GetBox(1), node->Values[0].AsFloat).AsFloat();
const auto InnerBounds = tryGetValue(node->GetBox(2), node->Values[1].AsFloat).AsFloat();
const auto Falloff = tryGetValue(node->GetBox(3), node->Values[2].AsFloat).AsFloat();
const auto uv = tryGetValue(node->GetBox(0), getUVs).AsFloat2();
const auto outerBounds = tryGetValue(node->GetBox(1), node->Values[0].AsFloat).AsFloat();
const auto innerBounds = tryGetValue(node->GetBox(2), node->Values[1].AsFloat).AsFloat();
const auto falloff = tryGetValue(node->GetBox(3), node->Values[2].AsFloat).AsFloat();
auto c = writeLocal(ValueType::Float, String::Format(TEXT("1 - length({0} * 2)"), uv.Value), node);
auto InnerMask = writeLocal(ValueType::Float, String::Format(TEXT("clamp(((({0} - (1 - ({1} - {2}))) + {2}) / {2}),0,1)"), c.Value, OuterBounds.Value, Falloff.Value), node);
auto OuterMask = writeLocal(ValueType::Float, String::Format(TEXT("clamp(((((1-{0}) - (1 - (1-{1}))) + {2}) / {2}),0,1)"), c.Value, InnerBounds.Value, Falloff.Value), node);
auto Mask = writeLocal(ValueType::Float, String::Format(TEXT("{0} * {1}"), InnerMask.Value, OuterMask.Value), node);
value = writeLocal(ValueType::Float3, String::Format(TEXT("float3({0},{1},{2})"), InnerMask.Value, OuterMask.Value, Mask.Value), node);
auto innerMask = writeLocal(ValueType::Float, String::Format(TEXT("clamp(((({0} - (1 - ({1} - {2}))) + {2}) / {2}),0,1)"), c.Value, outerBounds.Value, falloff.Value), node);
auto outerMask = writeLocal(ValueType::Float, String::Format(TEXT("clamp(((((1-{0}) - (1 - (1-{1}))) + {2}) / {2}),0,1)"), c.Value, innerBounds.Value, falloff.Value), node);
auto mask = writeLocal(ValueType::Float, String::Format(TEXT("{0} * {1}"), innerMask.Value, outerMask.Value), node);
value = writeLocal(ValueType::Float3, String::Format(TEXT("float3({0},{1},{2})"), innerMask.Value, outerMask.Value, mask.Value), node);
break;
}
default: