Hello!
I have been working a bit with DX12 the last week and I encountered a problem.
I came from an OpenGL background so let me give you an example:
In opengl I could "use" a material and then use that material to render multiple geometries,I coul also change the params of the material (uniforms) between Draw calls.
With DX12 I also have 1 material that I would like to use for multiple geometries:
void Terrain::Render(ID3D12GraphicsCommandList* cmdList) { m_material->Use(cmdList); for (unsigned int i = 0; i < m_chunks.size(); i++) { m_material->SetModel(m_chunks[i]->GetModel()); m_chunks[i]->Render(m_material->mCbvHeap); } }
void Material::SetModel(XMFLOAT4X4 model) { m_objConstantsData.Model = model; mObjectCB->CopyData(0, m_objConstantsData); }
The problem is,that the geometry is being rendered with the last applyed model, and I understand that.
Because I am recording to the Command List it will keep the last applied model.
How can I solve this?
See you!