27 const auto& material =
object->GetMaterialReference();
28 if (material ==
nullptr)
return;
30 const auto& shaders = material->GetShaders();
31 if (shaders ==
nullptr)
return;
33 auto handlerPair = m_depthObjects.find(shaders);
34 if (handlerPair != m_depthObjects.end()) {
35 auto& layerVector = handlerPair->second;
36 layerVector.erase(std::remove(layerVector.begin(), layerVector.end(),
object),
40 if (layerVector.empty()) m_depthObjects.erase(handlerPair);
45 const auto cameraMatrix = camera.GetCameraMatrixStruct();
46 const auto& frameBuffer = camera.GetFrameBuffer();
47 if (frameBuffer ==
nullptr) {
48 m_renderMgr->GetMainBuffer()->AttachFrameBuffer();
50 frameBuffer->AttachFrameBuffer();
53 glClear(GL_DEPTH_BUFFER_BIT);
54 for (
const auto& shadowObject : m_depthObjects) {
55 const auto& handle = shadowObject.first->GetDepthOnlyHandle();
56 glUseProgram(handle->Program);
57 for(
const auto& render : shadowObject.second) {
58 if (!render->isRenderActive)
continue;
59 const auto& shadowTransform =
static_cast<RenderComponent*
>(render)->GetGameObject()->GetTransform();
64 render->SetMatrix(cameraMatrix, handle);
65 render->Render(handle);
68 glBindFramebuffer(GL_FRAMEBUFFER, 0);