diff --git a/src/ShaderNode/DataModels/Cast.inl b/src/ShaderNode/DataModels/Cast.inl index f52efbb74..e6ea83960 100644 --- a/src/ShaderNode/DataModels/Cast.inl +++ b/src/ShaderNode/DataModels/Cast.inl @@ -31,7 +31,7 @@ Nz::ShaderAst::NodePtr CastVec::BuildNode(Nz::ShaderAst::Expre std::size_t overflowComponentCount = ToComponentCount - fromComponentCount; std::vector params; - params.emplace_back(std::move(params[0])); + params.emplace_back(std::move(expressions[0])); for (std::size_t i = 0; i < overflowComponentCount; ++i) params.emplace_back(Nz::ShaderBuilder::Constant(m_overflowComponents[i])); diff --git a/src/ShaderNode/DataModels/PositionOutputValue.cpp b/src/ShaderNode/DataModels/PositionOutputValue.cpp index 14745fb45..dd82ac2b2 100644 --- a/src/ShaderNode/DataModels/PositionOutputValue.cpp +++ b/src/ShaderNode/DataModels/PositionOutputValue.cpp @@ -21,7 +21,7 @@ Nz::ShaderAst::NodePtr PositionOutputValue::BuildNode(Nz::ShaderAst::ExpressionP assert(count == 1); assert(outputIndex == 0); - auto output = Nz::ShaderBuilder::AccessMember(Nz::ShaderBuilder::Identifier("OutputData"), { "position" }); + auto output = Nz::ShaderBuilder::AccessMember(Nz::ShaderBuilder::Identifier("output"), { "position" }); return ShaderBuilder::Assign(ShaderAst::AssignType::Simple, std::move(output), std::move(expressions[0])); } diff --git a/src/ShaderNode/ShaderGraph.cpp b/src/ShaderNode/ShaderGraph.cpp index 44af436a0..932e83935 100644 --- a/src/ShaderNode/ShaderGraph.cpp +++ b/src/ShaderNode/ShaderGraph.cpp @@ -488,7 +488,7 @@ Nz::ShaderAst::StatementPtr ShaderGraph::ToAst() const auto& extVar = external->externalVars.emplace_back(); extVar.bindingIndex = buffer.bindingIndex; extVar.name = buffer.name; - extVar.type = Nz::ShaderAst::IdentifierType{ structInfo.name }; + extVar.type = Nz::ShaderAst::UniformType{ Nz::ShaderAst::IdentifierType{ structInfo.name } }; } for (const auto& texture : m_textures) @@ -536,6 +536,7 @@ Nz::ShaderAst::StatementPtr ShaderGraph::ToAst() const if (m_type == ShaderType::Vertex) { auto& position = structDesc.members.emplace_back(); + position.builtin = Nz::ShaderAst::BuiltinEntry::VertexPosition; position.name = "position"; position.type = Nz::ShaderAst::VectorType{ 4, Nz::ShaderAst::PrimitiveType::Float32 }; } @@ -802,7 +803,7 @@ std::unique_ptr ShaderGraph::ToFunction parameters.push_back({ "input", Nz::ShaderAst::IdentifierType{ "InputData" } - }); + }); } Nz::ShaderAst::ExpressionType returnType; @@ -944,5 +945,8 @@ std::unique_ptr ShaderGraph::ToFunction statements.emplace_back(static_unique_pointer_cast(std::move(astNode))); } + if (!m_outputs.empty()) + statements.push_back(Nz::ShaderBuilder::Return(Nz::ShaderBuilder::Identifier("output"))); + return Nz::ShaderBuilder::DeclareFunction(ToShaderStageType(m_type), "main", std::move(parameters), std::move(statements), std::move(returnType)); }