MCPcopy Create free account
hub / github.com/TheRealMJP/MSAAFilter / RenderDepth

Method RenderDepth

MSAAFilter/MeshRenderer.cpp:496–549  ·  view source on GitHub ↗

Renders all meshes using depth-only rendering

Source from the content-addressed store, hash-verified

494
495// Renders all meshes using depth-only rendering
496void MeshRenderer::RenderDepth(ID3D11DeviceContext* context, const Camera& camera,
497 const Float4x4& world, bool shadowRendering)
498{
499 PIXEvent event(L"Mesh Depth Rendering");
500
501 // Set states
502 float blendFactor[4] = {1, 1, 1, 1};
503 context->OMSetBlendState(blendStates.ColorWriteDisabled(), blendFactor, 0xFFFFFFFF);
504 context->OMSetDepthStencilState(depthStencilStates.DepthWriteEnabled(), 0);
505
506 if(shadowRendering)
507 context->RSSetState(shadowRSState);
508 else
509 context->RSSetState(rasterizerStates.BackFaceCull());
510
511 // Set constant buffers
512 meshVSConstants.Data.World = Float4x4::Transpose(world);
513 meshVSConstants.Data.View = Float4x4::Transpose(camera.ViewMatrix());
514 meshVSConstants.Data.WorldViewProjection = Float4x4::Transpose(world * camera.ViewProjectionMatrix());
515 meshVSConstants.ApplyChanges(context);
516 meshVSConstants.SetVS(context, 0);
517
518 // Set shaders
519 context->VSSetShader(meshDepthVS, nullptr, 0);
520 context->PSSetShader(nullptr, nullptr, 0);
521 context->GSSetShader(nullptr, nullptr, 0);
522 context->DSSetShader(nullptr, nullptr, 0);
523 context->HSSetShader(nullptr, nullptr, 0);
524
525
526 uint32 partCount = 0;
527 for(uint32 meshIdx = 0; meshIdx < model->Meshes().size(); ++meshIdx)
528 {
529 const Mesh& mesh = model->Meshes()[meshIdx];
530
531 // Set the vertices and indices
532 ID3D11Buffer* vertexBuffers[1] = { mesh.VertexBuffer() };
533 UINT vertexStrides[1] = { mesh.VertexStride() };
534 UINT offsets[1] = { 0 };
535 context->IASetVertexBuffers(0, 1, vertexBuffers, vertexStrides, offsets);
536 context->IASetIndexBuffer(mesh.IndexBuffer(), mesh.IndexBufferFormat(), 0);
537 context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
538
539 // Set the input layout
540 context->IASetInputLayout(meshDepthInputLayouts[meshIdx]);
541
542 // Draw all parts
543 for(uint64 partIdx = 0; partIdx < mesh.MeshParts().size(); ++partIdx)
544 {
545 const MeshPart& part = mesh.MeshParts()[partIdx];
546 context->DrawIndexed(part.IndexCount, part.IndexStart, 0);
547 }
548 }
549}
550
551// Renders meshes using cascaded shadow mapping
552void MeshRenderer::RenderShadowMap(ID3D11DeviceContext* context, const Camera& camera,

Callers 1

RenderSceneMethod · 0.80

Calls 9

ColorWriteDisabledMethod · 0.80
DepthWriteEnabledMethod · 0.80
BackFaceCullMethod · 0.80
ApplyChangesMethod · 0.80
SetVSMethod · 0.80
VertexBufferMethod · 0.80
VertexStrideMethod · 0.80
IndexBufferMethod · 0.80
IndexBufferFormatMethod · 0.80

Tested by

no test coverage detected