UTexture2DArray support
Some checks failed
FModel QA Builder / build (push) Has been cancelled

This commit is contained in:
LongerWarrior 2024-12-08 22:39:19 +02:00
parent c07dc02714
commit 0882062a96
6 changed files with 21 additions and 12 deletions

@ -1 +1 @@
Subproject commit 61365034c395794512d29145c2cb052f3cb5427a
Subproject commit d9e236a759d0815cf701cb92d14124658a60b2be

View File

@ -647,6 +647,7 @@ public class CUE4ParseViewModel : ViewModel
case "bat":
case "dat":
case "cfg":
case "ddr":
case "ide":
case "ipl":
case "zon":

View File

@ -58,7 +58,7 @@ public class SearchViewModel : ViewModel
return filters.All(x => assetItem.FullPath.Contains(x, HasMatchCaseEnabled ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase));
var o = RegexOptions.None;
if (HasMatchCaseEnabled) o |= RegexOptions.IgnoreCase;
if (!HasMatchCaseEnabled) o |= RegexOptions.IgnoreCase;
return new Regex(FilterText, o).Match(assetItem.FullPath).Success;
}
}
}

View File

@ -9,6 +9,7 @@ using FModel.Views.Snooper.Animations;
using FModel.Views.Snooper.Lights;
using FModel.Views.Snooper.Models;
using FModel.Views.Snooper.Shading;
using SkiaSharp;
namespace FModel.Views.Snooper;
@ -185,17 +186,26 @@ public class Options
model.UpdateMorph(SelectedMorph);
}
public bool TryGetTexture(UTexture2D o, bool fix, out Texture texture)
public bool TryGetTexture(UTexture o, bool fix, out Texture texture)
{
var guid = o.LightingGuid;
if (!Textures.TryGetValue(guid, out texture) &&
o.Decode(UserSettings.Default.PreviewMaxTextureSize, UserSettings.Default.CurrentDir.TexturePlatform) is { } bitmap)
if (Textures.TryGetValue(guid, out texture)) return texture != null;
SKBitmap bitmap = o switch
{
UTexture2D texture2D => texture2D.Decode(UserSettings.Default.PreviewMaxTextureSize, UserSettings.Default.CurrentDir.TexturePlatform),
UTexture2DArray texture2DArray => texture2DArray.DecodeTextureArray(UserSettings.Default.CurrentDir.TexturePlatform)?.FirstOrDefault(),
_ => o.Decode(UserSettings.Default.CurrentDir.TexturePlatform)
};
if (bitmap is not null)
{
texture = new Texture(bitmap, o);
if (fix) TextureHelper.FixChannels(_game, texture);
Textures[guid] = texture;
bitmap.Dispose();
}
return texture != null;
}

View File

@ -158,9 +158,9 @@ public class Material : IDisposable
/// <param name="triggers">list of texture parameter names by uv channel</param>
/// <param name="fallback">fallback texture name to use if no top texture found</param>
/// <param name="first">if no top texture, no fallback texture, then use the first texture found</param>
private Texture[] FillTextures(Options options, int uvCount, bool top, IReadOnlyList<string[]> triggers, string fallback, bool first = false)
private Texture[] FillTextures(Options options, int uvCount, bool top, string[][] triggers, string fallback, bool first = false)
{
UTexture2D original;
UTexture original;
Texture transformed;
var fix = fallback == CMaterialParams2.FallbackSpecularMasks;
var textures = new Texture[uvCount];
@ -192,7 +192,7 @@ public class Material : IDisposable
/// <param name="textures">reference array</param>
/// <param name="triggers">list of color parameter names by uv channel</param>
/// <param name="fallback">fallback color to use if no trigger was found</param>
private Vector4[] FillColors(int uvCount, IReadOnlyList<Texture> textures, IReadOnlyList<string[]> triggers, Vector4 fallback)
private Vector4[] FillColors(int uvCount, Texture[] textures, string[][] triggers, Vector4 fallback)
{
var colors = new Vector4[uvCount];
for (int i = 0; i < colors.Length; i++)

View File

@ -79,15 +79,13 @@ public class Texture : IDisposable
GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment0, _target, _handle, 0);
}
public Texture(SKBitmap bitmap, UTexture2D texture2D) : this(TextureType.Normal)
public Texture(SKBitmap bitmap, UTexture texture2D) : this(TextureType.Normal)
{
Type = texture2D.ExportType;
Guid = texture2D.LightingGuid;
Name = texture2D.Name;
Path = texture2D.GetPathName();
Format = texture2D.Format;
ImportedWidth = texture2D.ImportedSize.X;
ImportedHeight = texture2D.ImportedSize.Y;
Width = bitmap.Width;
Height = bitmap.Height;
Bind(TextureUnit.Texture0);