public override void RenderNode(CommandBuffer cmd, PipelineLayout pipelineLayout, Node node, Matrix4x4 currentTransform, bool shadowPass = false) { Matrix4x4 localMat = node.localMatrix * currentTransform; cmd.PushConstant(pipelineLayout, VkShaderStageFlags.Vertex, localMat); if (node.Mesh != null) { foreach (Primitive p in node.Mesh.Primitives) { if (!shadowPass) { cmd.PushConstant(pipelineLayout, VkShaderStageFlags.Fragment, (int)p.material, (uint)Marshal.SizeOf <Matrix4x4> ()); } cmd.DrawIndexed(p.indexCount, 1, p.indexBase, p.vertexBase, 0); } } if (node.Children == null) { return; } foreach (Node child in node.Children) { RenderNode(cmd, pipelineLayout, child, localMat, shadowPass); } }
public void Draw(CommandBuffer cmd, PipelineLayout pipelineLayout, Buffer instanceBuf, bool shadowPass = false, params InstancedCmd[] instances) { cmd.BindVertexBuffer(instanceBuf, 1); uint firstInstance = 0; for (int i = 0; i < instances.Length; i++) { foreach (Primitive p in Meshes[instances[i].meshIdx].Primitives) { if (!shadowPass) { cmd.PushConstant(pipelineLayout, VkShaderStageFlags.Fragment, (int)p.material, (uint)Marshal.SizeOf <Matrix4x4>()); } cmd.DrawIndexed(p.indexCount, instances[i].count, p.indexBase, p.vertexBase, firstInstance); } firstInstance += instances[i].count; } }