Fix normal map when importing materials for model files
This commit is contained in:
@@ -61,13 +61,13 @@ namespace
|
|||||||
return &node;
|
return &node;
|
||||||
}
|
}
|
||||||
|
|
||||||
ShaderGraphNode<>* AddTextureNode(MaterialLayer* layer, const Guid& textureId)
|
ShaderGraphNode<>* AddTextureNode(MaterialLayer* layer, const Guid& textureId, bool normalMap = false)
|
||||||
{
|
{
|
||||||
if (!textureId.IsValid())
|
if (!textureId.IsValid())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
auto& node = layer->Graph.Nodes.AddOne();
|
auto& node = layer->Graph.Nodes.AddOne();
|
||||||
node.ID = layer->Graph.Nodes.Count();
|
node.ID = layer->Graph.Nodes.Count();
|
||||||
node.Type = GRAPH_NODE_MAKE_TYPE(5, 1);
|
node.Type = GRAPH_NODE_MAKE_TYPE(5, normalMap ? 4 : 1);
|
||||||
node.Boxes.Resize(7);
|
node.Boxes.Resize(7);
|
||||||
node.Boxes[0] = MaterialGraphBox(&node, 0, VariantType::Vector2); // UVs
|
node.Boxes[0] = MaterialGraphBox(&node, 0, VariantType::Vector2); // UVs
|
||||||
node.Boxes[6] = MaterialGraphBox(&node, 6, VariantType::Object); // Texture Reference
|
node.Boxes[6] = MaterialGraphBox(&node, 6, VariantType::Object); // Texture Reference
|
||||||
@@ -178,7 +178,7 @@ CreateAssetResult CreateMaterial::Create(CreateAssetContext& context)
|
|||||||
CONNECT(layer->Root->Boxes[static_cast<int32>(MaterialGraphBoxes::Emissive)], emissiveColor->Boxes[0]);
|
CONNECT(layer->Root->Boxes[static_cast<int32>(MaterialGraphBoxes::Emissive)], emissiveColor->Boxes[0]);
|
||||||
SET_POS(emissiveColor, Vector2(-493.5272f, -2.926111f));
|
SET_POS(emissiveColor, Vector2(-493.5272f, -2.926111f));
|
||||||
}
|
}
|
||||||
auto normalMap = AddTextureNode(layer, options.Normals.Texture);
|
auto normalMap = AddTextureNode(layer, options.Normals.Texture, true);
|
||||||
if (normalMap)
|
if (normalMap)
|
||||||
{
|
{
|
||||||
CONNECT(layer->Root->Boxes[static_cast<int32>(MaterialGraphBoxes::Normal)], normalMap->Boxes[1]);
|
CONNECT(layer->Root->Boxes[static_cast<int32>(MaterialGraphBoxes::Normal)], normalMap->Boxes[1]);
|
||||||
|
|||||||
Reference in New Issue
Block a user