Merge branch 'W2Wizard-UVTilingOffset'

This commit is contained in:
Wojtek Figat
2021-01-26 21:48:14 +01:00
2 changed files with 30 additions and 0 deletions

View File

@@ -701,6 +701,26 @@ namespace FlaxEditor.Surface.Archetypes
NodeElementArchetype.Factory.Output(0, string.Empty, typeof(float), 5),
}
},
new NodeArchetype
{
TypeID = 29,
Title = "UV Tiling & Offset",
Description = "Takes UVs and applies tiling and offset",
Flags = NodeFlags.MaterialGraph,
Size = new Vector2(175, 60),
DefaultValues = new object[]
{
Vector2.One,
Vector2.Zero
},
Elements = new[]
{
NodeElementArchetype.Factory.Input(0, "UV", true, typeof(Vector2), 0),
NodeElementArchetype.Factory.Input(1, "Tiling", true, typeof(Vector2), 1, 0),
NodeElementArchetype.Factory.Input(2, "Offset", true, typeof(Vector2), 2, 1),
NodeElementArchetype.Factory.Output(0, string.Empty, typeof(Vector2), 3),
}
}
};
}
}

View File

@@ -381,6 +381,16 @@ void MaterialGenerator::ProcessGroupMaterial(Box* box, Node* node, Value& value)
value = writeLocal(ValueType::Float, String::Format(TEXT("{0} ? (1 - {1}) : {1}"), invert.Value, x2.Value), node);
break;
}
// Tiling & Offset
case 29:
{
auto uv = tryGetValue(node->GetBox(0), getUVs).AsVector2();
auto tiling = tryGetValue(node->GetBox(1), node->Values[0]).AsVector2();
auto offset = tryGetValue(node->GetBox(2), node->Values[1]).AsVector2();
value = writeLocal(ValueType::Vector2, String::Format(TEXT("{0} * {1} + {2}"), uv.Value, tiling.Value, offset.Value), node);
break;
}
default:
break;