title: Vulkan: Is there a way to draw multiple objects in different locations like in DirectX12?
body: <p>In DirectX12, you render multiple objects in different locations using the equivalent of a single uniform buffer for the world transform like:</p>
  
  <pre><code>// Basic simplified pseudocode
  SetRootSignature();
  SetPrimitiveTopology();
  SetPipelineState();
  SetDepthStencilTarget();
  SetViewportAndScissor();
  
  for (auto object : objects)
  {
      SetIndexBuffer();
      SetVertexBuffer();
  
      struct VSConstants
      {
          QEDx12::Math::Matrix4 modelToProjection;
      } vsConstants;
      vsConstants.modelToProjection = ViewProjMat * object-&gt;GetWorldProj();
      SetDynamicConstantBufferView(0, sizeof(vsConstants), &amp;vsConstants);
  
      DrawIndexed();
  }
  </code></pre>
  
  <p>However, in Vulkan, if you do something similar with a single uniform buffer, all the objects are rendered in the location of last world matrix:</p>
  
  <pre><code>for (auto object : objects)
  {
      SetIndexBuffer();
      SetVertexBuffer();
  
      UploadUniformBuffer(object-&gt;GetWorldProj());
  
      DrawIndexed();
  }
  </code></pre>
  
  <p>Is there a way to draw multiple objects with a single uniform buffer in Vulkan, just like in DirectX12?</p>
  
  <p>I'm aware of Sascha Willem's Dynamic uniform buffer example (<a href="https://github.com/SaschaWillems/Vulkan/tree/master/dynamicuniformbuffer" rel="nofollow noreferrer">https://github.com/SaschaWillems/Vulkan/tree/master/dynamicuniformbuffer</a>) where he packs many matrices in one big uniform buffer, and while useful, is not exactly what I am looking for.</p>
  
  <p>Thanks in advance for any help.</p>