Convert to an EVSM map
| 505 | |
| 506 | // Convert to an EVSM map |
| 507 | void MeshRenderer::ConvertToEVSM(ID3D11DeviceContext* context, uint32 cascadeIdx, Float3 cascadeScale) |
| 508 | { |
| 509 | PIXEvent event(L"EVSM Conversion"); |
| 510 | |
| 511 | float blendFactor[4] = {1, 1, 1, 1}; |
| 512 | context->OMSetBlendState(blendStates.BlendDisabled(), blendFactor, 0xFFFFFFFF); |
| 513 | context->RSSetState(rasterizerStates.NoCull()); |
| 514 | context->OMSetDepthStencilState(depthStencilStates.DepthDisabled(), 0); |
| 515 | ID3D11Buffer* vbs[1] = { NULL }; |
| 516 | uint32 strides[1] = { 0 }; |
| 517 | uint32 offsets[1] = { 0 }; |
| 518 | context->IASetVertexBuffers(0, 1, vbs, strides, offsets); |
| 519 | context->IASetIndexBuffer(NULL, DXGI_FORMAT_R32_UINT, 0); |
| 520 | context->IASetInputLayout(NULL); |
| 521 | |
| 522 | SetViewport(context, sunVSM.Width, sunVSM.Height); |
| 523 | |
| 524 | evsmConstants.Data.PositiveExponent = PositiveExponent; |
| 525 | evsmConstants.Data.NegativeExponent = NegativeExponent; |
| 526 | evsmConstants.Data.CascadeScale = meshPSConstants.Data.CascadeScales[cascadeIdx].To3D(); |
| 527 | evsmConstants.Data.FilterSize = 1.0f; |
| 528 | evsmConstants.Data.ShadowMapSize.x = float(sunVSM.Width); |
| 529 | evsmConstants.Data.ShadowMapSize.y = float(sunVSM.Height); |
| 530 | evsmConstants.ApplyChanges(context); |
| 531 | evsmConstants.SetPS(context, 0); |
| 532 | |
| 533 | context->VSSetShader(fullScreenVS, NULL, 0); |
| 534 | context->PSSetShader(evsmConvertPS, NULL, 0); |
| 535 | |
| 536 | ID3D11RenderTargetView* rtvs[1] = { sunVSM.RTVArraySlices[cascadeIdx] }; |
| 537 | context->OMSetRenderTargets(1, rtvs, NULL); |
| 538 | |
| 539 | ID3D11ShaderResourceView* srvs[1] = { sunShadowDepthMap.SRView }; |
| 540 | context->PSSetShaderResources(0, 1, srvs); |
| 541 | |
| 542 | context->Draw(3, 0); |
| 543 | |
| 544 | srvs[0] = NULL; |
| 545 | context->PSSetShaderResources(0, 1, srvs); |
| 546 | |
| 547 | const float FilterSizeU = std::max(FilterSize * cascadeScale.x, 1.0f); |
| 548 | const float FilterSizeV = std::max(FilterSize * cascadeScale.y, 1.0f); |
| 549 | |
| 550 | if(FilterSizeU > 1.0f || FilterSizeV > 1.0f) |
| 551 | { |
| 552 | // Horizontal pass |
| 553 | evsmConstants.Data.FilterSize = FilterSizeU; |
| 554 | evsmConstants.ApplyChanges(context); |
| 555 | |
| 556 | uint32 sampleRadiusU = static_cast<uint32>((FilterSizeU / 2) + 0.499f); |
| 557 | |
| 558 | rtvs[0] = tempVSM.RTView; |
| 559 | context->OMSetRenderTargets(1, rtvs, NULL); |
| 560 | |
| 561 | srvs[0] = sunVSM.SRVArraySlices[cascadeIdx]; |
| 562 | context->PSSetShaderResources(0, 1, srvs); |
| 563 | |
| 564 | context->PSSetShader(evsmBlurH, NULL, 0); |
nothing calls this directly
no test coverage detected