Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't cache defaulted textures in loader #122

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all 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
6 changes: 3 additions & 3 deletions shared/pbr/GltfLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,14 +204,14 @@ namespace Gltf {
Pbr::RGBAColor defaultRGBA) {
// Find or load the image referenced by the texture.
const ImageKey imageKey = std::make_tuple(texture.Image, sRGB);
winrt::com_ptr<ID3D11ShaderResourceView> textureView = imageMap[imageKey];
winrt::com_ptr<ID3D11ShaderResourceView> textureView =
texture.Image != nullptr ? imageMap[imageKey] : pbrResources.CreateSolidColorTexture(defaultRGBA);
if (!textureView) // If not cached, load the image and store it in the texture cache.
{
// TODO: Generate mipmaps if sampler's minification filter (minFilter) uses mipmapping.
// TODO: If texture is not power-of-two and (sampler has wrapping=repeat/mirrored_repeat OR minFilter uses
// mipmapping), resize to power-of-two.
textureView = texture.Image != nullptr ? LoadImage(pbrResources.GetDevice().get(), *texture.Image, sRGB)
: pbrResources.CreateSolidColorTexture(defaultRGBA);
textureView = LoadImage(pbrResources.GetDevice().get(), *texture.Image, sRGB);
imageMap[imageKey] = textureView;
}

Expand Down