MCPcopy Create free account
hub / github.com/TheRealMJP/BakingLab / RenderBakeDataVisualizer

Method RenderBakeDataVisualizer

BakingLab/MeshRenderer.cpp:1013–1060  ·  view source on GitHub ↗

Renders the bake data visualizer

Source from the content-addressed store, hash-verified

1011
1012// Renders the bake data visualizer
1013void 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}

Callers 1

RenderMainPassMethod · 0.80

Calls 8

BlendDisabledMethod · 0.80
DepthWriteEnabledMethod · 0.80
NoCullMethod · 0.80
ApplyChangesMethod · 0.80
SetVSMethod · 0.80
SetPSMethod · 0.80
TransposeClass · 0.50
Float4Class · 0.50

Tested by

no test coverage detected