From b20407354c6a3b4840b45c88f2b9ca7d1eb91ade Mon Sep 17 00:00:00 2001 From: deccer Date: Fri, 4 Nov 2022 00:34:52 +0100 Subject: [PATCH] Texture2dArrays should generate mipmaps --- src/EngineKit/Graphics/TextureLibrary.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/EngineKit/Graphics/TextureLibrary.cs b/src/EngineKit/Graphics/TextureLibrary.cs index e28d0c3..53e4bd8 100644 --- a/src/EngineKit/Graphics/TextureLibrary.cs +++ b/src/EngineKit/Graphics/TextureLibrary.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Linq; using EngineKit.Mathematics; @@ -68,7 +69,7 @@ public IReadOnlyCollection PrepareTextureArrays( Label = $"TA_{textureIndex.Key}_{imageWidth}x{imageHeight}x{textureIndex.Value.Count}", Size = new Int3(imageWidth, imageHeight, 1), ArrayLayers = (uint)textureIndex.Value.Count, - MipLevels = 1, + MipLevels = 1 + (uint)MathF.Ceiling(MathF.Log2(MathF.Max(imageWidth, imageHeight))), SampleCount = SampleCount.OneSample }; @@ -90,13 +91,14 @@ public IReadOnlyCollection PrepareTextureArrays( { case Image imageRgb24 when imageRgb24.DangerousTryGetSinglePixelMemory(out var pixelSpan24): - texture.Update(textureUploadDescriptor, pixelSpan24.Pin()); + texture!.Update(textureUploadDescriptor, pixelSpan24.Pin()); break; case Image imageRgba32 when imageRgba32.DangerousTryGetSinglePixelMemory(out var pixelSpan32): - texture.Update(textureUploadDescriptor, pixelSpan32.Pin()); + texture!.Update(textureUploadDescriptor, pixelSpan32.Pin()); break; } + texture!.GenerateMipmaps(); if (!textureArrayIndices.TryGetValue(layer.ImageName, out var textureId)) {