Skip to content

Commit d6f5f9e

Browse files
committed
Don't cache defaulted textures in loader
CreateSolidColorTexture already caches these textures, and currently the caching here doesn't take into account defaultRGBA.
1 parent a46ea22 commit d6f5f9e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

shared/pbr/GltfLoader.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -204,14 +204,14 @@ namespace Gltf {
204204
Pbr::RGBAColor defaultRGBA) {
205205
// Find or load the image referenced by the texture.
206206
const ImageKey imageKey = std::make_tuple(texture.Image, sRGB);
207-
winrt::com_ptr<ID3D11ShaderResourceView> textureView = imageMap[imageKey];
207+
winrt::com_ptr<ID3D11ShaderResourceView> textureView =
208+
texture.Image != nullptr ? imageMap[imageKey] : pbrResources.CreateSolidColorTexture(defaultRGBA);
208209
if (!textureView) // If not cached, load the image and store it in the texture cache.
209210
{
210211
// TODO: Generate mipmaps if sampler's minification filter (minFilter) uses mipmapping.
211212
// TODO: If texture is not power-of-two and (sampler has wrapping=repeat/mirrored_repeat OR minFilter uses
212213
// mipmapping), resize to power-of-two.
213-
textureView = texture.Image != nullptr ? LoadImage(pbrResources.GetDevice().get(), *texture.Image, sRGB)
214-
: pbrResources.CreateSolidColorTexture(defaultRGBA);
214+
textureView = LoadImage(pbrResources.GetDevice().get(), *texture.Image, sRGB);
215215
imageMap[imageKey] = textureView;
216216
}
217217

0 commit comments

Comments
 (0)