Skip to content

Commit

Permalink
Don't cache defaulted textures in loader
Browse files Browse the repository at this point in the history
CreateSolidColorTexture already caches these textures, and currently
the caching here doesn't take into account defaultRGBA.
  • Loading branch information
SafariMonkey committed Jun 20, 2023
1 parent a46ea22 commit d6f5f9e
Showing 1 changed file with 3 additions and 3 deletions.
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

0 comments on commit d6f5f9e

Please sign in to comment.