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

Function SaveEXRScreenshot

BakingLab/BakingLab.cpp:222–272  ·  view source on GitHub ↗

Save a skydome texture as a DDS file

Source from the content-addressed store, hash-verified

220
221// Save a skydome texture as a DDS file
222static void SaveEXRScreenshot(HWND parentWindow, ID3D11ShaderResourceView* screenSRV)
223{
224 // Read the texture data, and apply the inverse exposure scale
225 ID3D11DevicePtr device;
226 screenSRV->GetDevice(&device);
227
228 TextureData<Float4> textureData;
229 GetTextureData(device, screenSRV, textureData);
230
231 const uint64 numTexels = textureData.Texels.size();
232 for(uint64 i = 0; i < numTexels; ++i)
233 {
234 textureData.Texels[i] *= 1.0f / FP16Scale;
235 textureData.Texels[i] = Float4::Clamp(textureData.Texels[i], 0.0f, FP16Max);
236 }
237
238 wchar currDirectory[MAX_PATH] = { 0 };
239 GetCurrentDirectory(ArraySize_(currDirectory), currDirectory);
240
241 wchar filePath[MAX_PATH] = { 0 };
242
243 OPENFILENAME ofn;
244 ZeroMemory(&ofn , sizeof(ofn));
245 ofn.lStructSize = sizeof(ofn);
246 ofn.hwndOwner = parentWindow;
247 ofn.lpstrFile = filePath;
248 ofn.nMaxFile = ArraySize_(filePath);
249 ofn.lpstrFilter = L"All Files (*.*)\0*.*\0EXR Files (*.exr)\0*.exr\0";
250 ofn.nFilterIndex = 2;
251 ofn.lpstrFileTitle = nullptr;
252 ofn.nMaxFileTitle = 0;
253 ofn.lpstrInitialDir = nullptr;
254 ofn.lpstrTitle = L"Save Screenshot As..";
255 ofn.lpstrDefExt = L"exr";
256 ofn.Flags = OFN_OVERWRITEPROMPT;
257 bool succeeded = GetSaveFileName(&ofn) != 0;
258 SetCurrentDirectory(currDirectory);
259
260 if(succeeded)
261 {
262 try
263 {
264 SaveTextureAsEXR(textureData, filePath);
265 }
266 catch(Exception e)
267 {
268 std::wstring errorString = L"Error occured while saving screenshot as an EXR file:\n" + e.GetMessage();
269 MessageBox(parentWindow, errorString.c_str(), L"Error", MB_OK | MB_ICONERROR);
270 }
271 }
272}
273
274// Bakes lookup textures for computing environment specular from radiance encoded as spherical harmonics.
275static void GenerateSHSpecularLookupTextures(ID3D11Device* device)

Callers 1

RenderMethod · 0.85

Calls 4

GetTextureDataFunction · 0.85
ClampFunction · 0.85
SaveTextureAsEXRFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected