Renders the bake data visualizer
| 1011 | |
| 1012 | // Renders the bake data visualizer |
| 1013 | void MeshRenderer::RenderBakeDataVisualizer(ID3D11DeviceContext* context, const Camera& camera, const MeshBakerStatus& status) |
| 1014 | { |
| 1015 | PIXEvent event(L"Bake Data Visualizer"); |
| 1016 | |
| 1017 | // Set states |
| 1018 | float blendFactor[4] = {1, 1, 1, 1}; |
| 1019 | context->OMSetBlendState(blendStates.BlendDisabled(), blendFactor, 0xFFFFFFFF); |
| 1020 | context->OMSetDepthStencilState(depthStencilStates.DepthWriteEnabled(), 0); |
| 1021 | context->RSSetState(rasterizerStates.NoCull()); |
| 1022 | |
| 1023 | // Set constant buffers |
| 1024 | visualizerConstants.Data.ViewProjection = Float4x4::Transpose(camera.ViewProjectionMatrix()); |
| 1025 | for(uint64 i = 0; i < ArraySize_(status.SGDirections); ++i) |
| 1026 | visualizerConstants.Data.SGDirections[i] = Float4(status.SGDirections[i], 0.0f); |
| 1027 | visualizerConstants.Data.SGSharpness = status.SGSharpness; |
| 1028 | visualizerConstants.ApplyChanges(context); |
| 1029 | visualizerConstants.SetVS(context, 0); |
| 1030 | visualizerConstants.SetPS(context, 0); |
| 1031 | |
| 1032 | // Set shaders |
| 1033 | context->DSSetShader(nullptr, nullptr, 0); |
| 1034 | context->HSSetShader(nullptr, nullptr, 0); |
| 1035 | context->GSSetShader(nullptr, nullptr, 0); |
| 1036 | context->VSSetShader(visualizerVS , nullptr, 0); |
| 1037 | context->PSSetShader(visualizerPS, nullptr, 0); |
| 1038 | |
| 1039 | ID3D11ShaderResourceView* vsSrvs[] = { status.BakePoints }; |
| 1040 | context->VSSetShaderResources(0, ArraySize_(vsSrvs), vsSrvs); |
| 1041 | |
| 1042 | ID3D11ShaderResourceView* psSrvs[1] = { status.LightMap }; |
| 1043 | context->PSSetShaderResources(0, 1, psSrvs); |
| 1044 | |
| 1045 | // Draw the visualizer hemispheres for all sample points |
| 1046 | ID3D11Buffer* vertexBuffers[1] = { hemisphereVB }; |
| 1047 | uint32 vertexStrides[1] = { sizeof(Float3) }; |
| 1048 | uint32 offsets[1] = { 0 }; |
| 1049 | context->IASetVertexBuffers(0, 1, vertexBuffers, vertexStrides, offsets); |
| 1050 | context->IASetIndexBuffer(hemisphereIB, DXGI_FORMAT_R32_UINT, 0); |
| 1051 | context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); |
| 1052 | context->IASetInputLayout(visualizerInputLayout); |
| 1053 | |
| 1054 | // Draw |
| 1055 | context->DrawIndexedInstanced(uint32(numHemisphereIndices), uint32(status.NumBakePoints), 0, 0, 0); |
| 1056 | |
| 1057 | ID3D11ShaderResourceView* nullSRVs[] = { nullptr }; |
| 1058 | context->VSSetShaderResources(0, 1, nullSRVs); |
| 1059 | context->PSSetShaderResources(0, 1, nullSRVs); |
| 1060 | } |
no test coverage detected