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

Function ExtractBakePoints

BakingLab/MeshBaker.cpp:804–1044  ·  view source on GitHub ↗

Computes lightmap sample points and gutter texels

Source from the content-addressed store, hash-verified

802
803// Computes lightmap sample points and gutter texels
804static void ExtractBakePoints(const BakeInputData& bakeInput, std::vector<BakePoint>& bakePoints,
805 std::vector<GutterTexel>& gutterTexels)
806{
807 const uint32 LightMapSize = AppSettings::LightMapResolution;
808 const uint64 NumTexels = LightMapSize * LightMapSize;
809
810 bakePoints.clear();
811 bakePoints.resize(NumTexels);
812 gutterTexels.clear();
813
814 Timer timer;
815 PrintString("Extracting light map sample points...");
816
817 ID3D11Device* device = bakeInput.Device;
818 ID3D11DeviceContextPtr context;
819 device->GetImmediateContext(&context);
820
821 // Rasterize the mesh to the lightmap in UV space
822 const uint32 NumTargets = 5;
823 const DXGI_FORMAT RTFormats[NumTargets] =
824 {
825 DXGI_FORMAT_R32G32B32A32_FLOAT,
826 DXGI_FORMAT_R32G32B32A32_FLOAT,
827 DXGI_FORMAT_R32G32B32A32_FLOAT,
828 DXGI_FORMAT_R32G32B32A32_FLOAT,
829 DXGI_FORMAT_R32_UINT,
830 };
831
832 RenderTarget2D targets[NumTargets];
833 RenderTarget2D msaaTargets[NumTargets];
834 for(uint64 i = 0; i < NumTargets; ++i)
835 {
836 targets[i].Initialize(bakeInput.Device, LightMapSize, LightMapSize, RTFormats[i]);
837 msaaTargets[i].Initialize(bakeInput.Device, LightMapSize, LightMapSize, RTFormats[i], 1, 8, 0);
838 }
839
840 ID3D11RenderTargetView* rtViews[NumTargets];
841 for(uint64 i = 0; i < NumTargets; ++i)
842 rtViews[i] = msaaTargets[i].RTView;
843
844 context->OMSetRenderTargets(NumTargets, rtViews, nullptr);
845
846 float clearColor[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
847 for(uint64 i = 0; i < NumTargets; ++i)
848 context->ClearRenderTargetView(rtViews[i], clearColor);
849
850 VertexShaderPtr vs = CompileVSFromFile(device, L"LightMapRasterization.hlsl");
851 PixelShaderPtr ps = CompilePSFromFile(device, L"LightMapRasterization.hlsl");
852
853 context->VSSetShader(vs, nullptr, 0);
854 context->GSSetShader(nullptr, nullptr, 0);
855 context->PSSetShader(ps, nullptr, 0);
856 context->HSSetShader(nullptr, nullptr, 0);
857 context->DSSetShader(nullptr, nullptr, 0);
858
859 RasterizerStates rasterizerStates;
860 rasterizerStates.Initialize(device);
861 context->RSSetState(rasterizerStates.NoCull());

Callers 1

UpdateMethod · 0.85

Calls 15

PrintStringFunction · 0.85
CompileVSFromFileFunction · 0.85
CompilePSFromFileFunction · 0.85
DXCallFunction · 0.85
Float2Class · 0.85
Uint2Class · 0.85
NoCullMethod · 0.80
BlendDisabledMethod · 0.80
DepthDisabledMethod · 0.80
SetPSMethod · 0.80
InputElementsMethod · 0.80
NumInputElementsMethod · 0.80

Tested by

no test coverage detected