mirror of
https://github.com/KillzXGaming/Switch-Toolbox
synced 2024-11-22 20:43:09 +00:00
Improve cubemap exporting for DDS
This commit is contained in:
parent
fa6ddbf3bd
commit
6913054fc7
2 changed files with 22 additions and 4 deletions
|
@ -1098,13 +1098,20 @@ namespace Toolbox.Library
|
|||
return TEX_FORMAT.R8G8B8A8_UNORM;
|
||||
}
|
||||
}
|
||||
public void SetFlags(DXGI_FORMAT Format, bool UseDX10 = false)
|
||||
public void SetFlags(DXGI_FORMAT Format, bool UseDX10 = false, bool isCubeMap = false)
|
||||
{
|
||||
header.flags = (uint)(DDSD.CAPS | DDSD.HEIGHT | DDSD.WIDTH | DDSD.PIXELFORMAT | DDSD.MIPMAPCOUNT | DDSD.LINEARSIZE);
|
||||
header.caps = (uint)DDSCAPS.TEXTURE;
|
||||
if (header.mipmapCount > 1)
|
||||
header.caps |= (uint)(DDSCAPS.COMPLEX | DDSCAPS.MIPMAP);
|
||||
|
||||
if (isCubeMap)
|
||||
{
|
||||
header.caps2 |= (uint)(DDSCAPS2.CUBEMAP | DDSCAPS2.CUBEMAP_POSITIVEX | DDSCAPS2.CUBEMAP_NEGATIVEX |
|
||||
DDSCAPS2.CUBEMAP_POSITIVEY | DDSCAPS2.CUBEMAP_NEGATIVEY |
|
||||
DDSCAPS2.CUBEMAP_POSITIVEZ | DDSCAPS2.CUBEMAP_NEGATIVEZ);
|
||||
}
|
||||
|
||||
if (UseDX10)
|
||||
{
|
||||
header.ddspf.flags = (uint)DDPF.FOURCC;
|
||||
|
@ -1114,6 +1121,11 @@ namespace Toolbox.Library
|
|||
|
||||
IsDX10 = true;
|
||||
DX10header.DXGI_Format = Format;
|
||||
if (isCubeMap)
|
||||
{
|
||||
DX10header.arrayFlag = (ArrayCount / 6);
|
||||
DX10header.miscFlag = 0x4;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -992,10 +992,12 @@ namespace Toolbox.Library
|
|||
dds.header.ddspf.ABitMask = components[(int)AlphaChannel];*/
|
||||
}
|
||||
|
||||
bool isCubeMap = ArrayCount == 6;
|
||||
|
||||
if (surfaces.Count > 1) //Use DX10 format for array surfaces as it can do custom amounts
|
||||
dds.SetFlags((DDS.DXGI_FORMAT)Format, true);
|
||||
dds.SetFlags((DDS.DXGI_FORMAT)Format, true, isCubeMap);
|
||||
else
|
||||
dds.SetFlags((DDS.DXGI_FORMAT)Format);
|
||||
dds.SetFlags((DDS.DXGI_FORMAT)Format, false, isCubeMap);
|
||||
|
||||
if (dds.IsDX10)
|
||||
{
|
||||
|
@ -1003,7 +1005,11 @@ namespace Toolbox.Library
|
|||
dds.DX10header = new DDS.DX10Header();
|
||||
|
||||
dds.DX10header.ResourceDim = 3;
|
||||
dds.DX10header.arrayFlag = (uint)surfaces.Count;
|
||||
|
||||
if (isCubeMap)
|
||||
dds.DX10header.arrayFlag = (uint)(surfaces.Count / 6);
|
||||
else
|
||||
dds.DX10header.arrayFlag = (uint)surfaces.Count;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue