Switch-Toolbox/Switch_Toolbox_Library/Generics/Materials/GenericMatTexture.cs
KillzXGaming cb13c0a00a Some fixes
Fixed loading files from clicked on when a single instance of the tool is used.
Fixed the UV editor, which loads materails and texture maps properly.
Adjusted loading archives which produced some duplicate file issues when the archive loads the file, and a tree node is clicked on. Ie bntx clearing, but another one would stay in memory.
Fixed bntx replacing.
2019-08-12 15:19:30 -04:00

116 lines
3.8 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenTK.Graphics.OpenGL;
namespace Toolbox.Library
{
public enum STTextureWrapMode
{
Repeat,
Mirror,
Clamp,
}
public enum STTextureMagFilter
{
Nearest,
Linear,
}
public enum STTextureMinFilter
{
LinearMipMapNearest,
Nearest,
Linear,
NearestMipmapLinear,
NearestMipmapNearest,
}
public class STGenericMatTexture
{
public int mapMode = 0;
public STTextureWrapMode WrapModeS = STTextureWrapMode.Repeat;
public STTextureWrapMode WrapModeT = STTextureWrapMode.Repeat;
public STTextureWrapMode WrapModeW = STTextureWrapMode.Clamp;
public STTextureMinFilter MinFilter = STTextureMinFilter.Linear;
public STTextureMagFilter MagFilter = STTextureMagFilter.Linear;
public string Name;
public string SamplerName;
public int textureUnit;
public TextureState textureState = TextureState.Unbinded;
//Determine the state the texture is in.
//If the texture is binded we don't need to bind it again unless it's animated or replaced
public enum TextureState
{
Unbinded,
Binded,
Animated,
Replaced,
}
/// <summary>
/// Gets the texture that links to this material texture map
/// Used for UV editor
/// </summary>
/// <returns></returns>
public virtual STGenericTexture GetTexture()
{
return null;
}
public TextureType Type;
//An enum for the assumed texture type by sampler
//Many games have a consistant type of samplers and type. _a0 for diffuse, _n0 for normal, ect
public enum TextureType
{
Unknown = 0,
Diffuse = 1,
Normal = 2,
Specular = 3,
Emission = 4,
DiffuseLayer2 = 5,
TeamColor = 6,
Transparency = 7,
Shadow = 8,
AO = 9,
Light = 10,
Roughness = 11,
Metalness = 12,
MRA = 13, //Combined pbr texture HAL uses for KSA
SphereMap = 14,
SubSurfaceScattering = 15,
}
public static readonly Dictionary<STTextureMinFilter, TextureMinFilter> minfilter = new Dictionary<STTextureMinFilter, TextureMinFilter>()
{
{ STTextureMinFilter.LinearMipMapNearest, TextureMinFilter.LinearMipmapLinear},
{ STTextureMinFilter.Nearest, TextureMinFilter.Nearest},
{ STTextureMinFilter.Linear, TextureMinFilter.Linear},
{ STTextureMinFilter.NearestMipmapLinear, TextureMinFilter.NearestMipmapLinear},
{ STTextureMinFilter.NearestMipmapNearest, TextureMinFilter.NearestMipmapNearest},
};
public static readonly Dictionary<STTextureMagFilter, TextureMagFilter> magfilter = new Dictionary<STTextureMagFilter, TextureMagFilter>()
{
{ STTextureMagFilter.Linear, TextureMagFilter.Linear},
{ STTextureMagFilter.Nearest, TextureMagFilter.Nearest},
{ (STTextureMagFilter)3, TextureMagFilter.Linear},
};
public static Dictionary<STTextureWrapMode, TextureWrapMode> wrapmode = new Dictionary<STTextureWrapMode, TextureWrapMode>(){
{ STTextureWrapMode.Repeat, TextureWrapMode.Repeat},
{ STTextureWrapMode.Mirror, TextureWrapMode.MirroredRepeat},
{ STTextureWrapMode.Clamp, TextureWrapMode.ClampToEdge},
{ (STTextureWrapMode)3, TextureWrapMode.ClampToEdge},
{ (STTextureWrapMode)4, TextureWrapMode.ClampToEdge},
{ (STTextureWrapMode)5, TextureWrapMode.ClampToEdge},
};
}
}