Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions src/Features/DynamicCubemaps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,28 @@ void DynamicCubemaps::DrawSettings()
DirectX::ScratchImage image;
DX::ThrowIfFailed(CaptureTexture(device, context, tempTexture, image));

std::string filename = std::format("Data\\Textures\\DynamicCubemaps\\{:.2f}{:.2f}{:.2f}R{:.2f}.dds", settings.CubemapColor.x, settings.CubemapColor.y, settings.CubemapColor.z, settings.CubemapColor.w);
bool defaultDynamicCubeMapSavePathSafe = true;
try {
if (std::filesystem::create_directories(defaultDynamicCubeMapSavePath)) {
logger::info("Missing DynamicCubeMap Creator directory created: {}", defaultDynamicCubeMapSavePath);
}
} catch (const std::exception) {
logger::error("Failed to create missing DynamicCubeMap Creator directory: {}", defaultDynamicCubeMapSavePath);
defaultDynamicCubeMapSavePathSafe = false;
}

std::wstring wfilename = std::wstring(filename.begin(), filename.end());
DX::ThrowIfFailed(SaveToDDSFile(image.GetImages(), image.GetImageCount(), image.GetMetadata(), DirectX::DDS_FLAGS::DDS_FLAGS_NONE, wfilename.c_str()));
if (defaultDynamicCubeMapSavePathSafe) {
Comment thread
langfod marked this conversation as resolved.
Outdated
std::filesystem::path DynamicCubeMapSavePath = defaultDynamicCubeMapSavePath;
std::filesystem::path filename(std::format("R{:03d}G{:03d}B{:03d}A{:03d}.dds", colorPixel.r, colorPixel.g, colorPixel.b, colorPixel.a));
DynamicCubeMapSavePath /= filename;

if (std::filesystem::exists(DynamicCubeMapSavePath)) {
logger::info("DynamicCubeMap Creator file for {} already exists, skipping.", filename.string());
} else {
DX::ThrowIfFailed(SaveToDDSFile(image.GetImages(), image.GetImageCount(), image.GetMetadata(), DirectX::DDS_FLAGS::DDS_FLAGS_NONE, DynamicCubeMapSavePath.c_str()));
logger::info("DynamicCubeMap Creator file for {} written", filename.string());
Comment thread
langfod marked this conversation as resolved.
}
}
image.Release();
tempTexture->Release();
}
Expand Down
2 changes: 2 additions & 0 deletions src/Features/DynamicCubemaps.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ struct DynamicCubemaps : Feature
return &singleton;
}

const std::string defaultDynamicCubeMapSavePath = "Data\\textures\\DynamicCubemaps";

// Specular irradiance

ID3D11SamplerState* computeSampler = nullptr;
Expand Down