Skip to content

Commit

Permalink
renaming, and texmaptypes (wip)
Browse files Browse the repository at this point in the history
- TextureTypes -> TextureFormats
- Texture.TextureMapTypes dict
  • Loading branch information
floxay committed Aug 7, 2021
1 parent eacec1b commit da3bbac
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
3 changes: 1 addition & 2 deletions AssetCatalog/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using System.Windows.Input;
using AssetCatalog.Model;
using AssetCatalog.Render;
using CommandLine;
using Microsoft.Win32;
using ModernWpf.Controls;
using OpenTK.Graphics.OpenGL;
Expand Down Expand Up @@ -199,7 +198,7 @@ private void ModelViewport_OnRender(TimeSpan obj)
_modelRenderer.BuildTextureMesh(texture);
_modelRenderer.SetTexture(bmp);
_modelRenderer.SetPartBounds(Array.Empty<BoundingBox>());
statsTextBox.Text = $"Width\t: {texture.Width}\nHeight\t: {texture.Height}\nFormat\t: {DdsHelper.TextureTypes[texture.TexFormat]}\nType\t: {texture.TexType}";
statsTextBox.Text = $"Width\t: {texture.Width}\nHeight\t: {texture.Height}\nFormat\t: {DdsHelper.TextureFormats[texture.TexFormat]}\nType\t: {(Texture.TextureMapTypes.TryGetValue(texture.TexType, out var rType) ? rType : texture.TexType)}";
}
catch (Exception e)
{
Expand Down
4 changes: 2 additions & 2 deletions RainbowForge/Texture/DdsHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace RainbowForge.Texture

public class DdsHelper
{
public static readonly Dictionary<uint, DirectXTexUtil.DXGIFormat> TextureTypes = new()
public static readonly Dictionary<uint, DirectXTexUtil.DXGIFormat> TextureFormats = new()
{
{0x0, DirectXTexUtil.DXGIFormat.B8G8R8A8UNORM},
{0x2, DirectXTexUtil.DXGIFormat.BC1UNORM},
Expand All @@ -31,7 +31,7 @@ public class DdsHelper

public static MemoryStream GetDdsStream(Texture texture, byte[] surface)
{
var dxgiFormat = TextureTypes[texture.TexFormat];
var dxgiFormat = TextureFormats[texture.TexFormat];

var meta = DirectXTexUtil.GenerateMataData(texture.Width, texture.Height, (int) texture.Mips, dxgiFormat, false);
DirectXTexUtil.GenerateDDSHeader(meta, DirectXTexUtil.DDSFlags.NONE, out var header, out var dx10);
Expand Down
12 changes: 12 additions & 0 deletions RainbowForge/Texture/Texture.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.IO;
using System.Collections.Generic;

namespace RainbowForge.Texture
{
Expand Down Expand Up @@ -98,5 +99,16 @@ public byte[] ReadSurfaceBytes(BinaryReader r)
r.BaseStream.Seek(DdsStart, SeekOrigin.Begin);
return r.ReadBytes((int) Texsize);
}

// unfinished
public static readonly Dictionary<uint, string> TextureMapTypes = new()
{
{ 0x0, "Diffuse Map" }, // older GUI /skin preview?/ textures sometimes have this type
{ 0x1, "Normal Map" }, // not just yellow (RG = XY) ones, head detail (RGA = XYZ) as well
{ 0x2, "Specular Map (PBR)" }, // usually holds gloss, metalness and cavity
{ 0x3, "GUI/Cubemap/Spritesheet" }, // possibly more
{ 0x5, "Normal Map v2" }, // ?
{ 0x7, "ID Map" } // internally 'ColorMask'
};
}
}

0 comments on commit da3bbac

Please sign in to comment.