Skip to content
This repository has been archived by the owner on Dec 31, 2024. It is now read-only.

Commit

Permalink
Fix adding new textures to BFRES
Browse files Browse the repository at this point in the history
  • Loading branch information
KillzXGaming committed May 16, 2024
1 parent b48c09b commit 66d3d50
Showing 1 changed file with 39 additions and 43 deletions.
82 changes: 39 additions & 43 deletions File_Format_Library/GUI/BFRES/Materials/SamplerEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -376,50 +376,46 @@ private string GetSamplerName(string Sampler)

private void btnAdd_Click(object sender, EventArgs e)
{
var result = MessageBox.Show("NOTE! Texture maps are adjusted by shader options which link by shaders. These are not possible to edit yet, do you want to continue?", "Material Editor", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation);
if (result == DialogResult.OK)
var tex = new MatTexture();
tex.SamplerName = GetSamplerName("_a0");
tex.FragShaderSampler = "_a0";
tex.Name = "Untitled";
tex.Type = Toolbox.Library.STGenericMatTexture.TextureType.Unknown;
tex.WrapModeS = STTextureWrapMode.Repeat;
tex.WrapModeT = STTextureWrapMode.Repeat;
tex.WrapModeW = STTextureWrapMode.Clamp;

if (material.GetResFileU() != null)
{
var tex = new MatTexture();
tex.SamplerName = GetSamplerName("_a0");
tex.FragShaderSampler = "_a0";
tex.Name = "Untitled";
tex.Type = Toolbox.Library.STGenericMatTexture.TextureType.Unknown;
tex.WrapModeS = STTextureWrapMode.Repeat;
tex.WrapModeT = STTextureWrapMode.Repeat;
tex.WrapModeW = STTextureWrapMode.Clamp;

if (material.GetResFileU() != null)
{
var texSampler = new ResUGX2.TexSampler();
texSampler.BorderType = ResUGX2.GX2TexBorderType.ClearBlack;
texSampler.ClampX = ResUGX2.GX2TexClamp.Wrap;
texSampler.ClampY = ResUGX2.GX2TexClamp.Wrap;
texSampler.ClampZ = ResUGX2.GX2TexClamp.Clamp;
texSampler.DepthCompareEnabled = false;
texSampler.DepthCompareFunc = ResUGX2.GX2CompareFunction.Never;
texSampler.MagFilter = ResUGX2.GX2TexXYFilterType.Point;
texSampler.MaxAnisotropicRatio = ResUGX2.GX2TexAnisoRatio.Ratio_1_1;
texSampler.MinFilter = ResUGX2.GX2TexXYFilterType.Point;
texSampler.MipFilter = ResUGX2.GX2TexMipFilterType.Linear;
texSampler.ZFilter = 0;
texSampler.MaxLod = 13;
texSampler.MinLod = 0;
texSampler.LodBias = 0;
tex.wiiUSampler = texSampler;
}
else
{
var texSampler = new ResNX.Sampler();
tex.switchSampler = texSampler;
}
material.TextureMaps.Add(tex);

var item = new ListViewItem();
item.Text = "Untitled";
item.SubItems.Add(tex.SamplerName);
item.SubItems.Add(tex.FragShaderSampler);
textureRefListView.Items.Add(item);
var texSampler = new ResUGX2.TexSampler();
texSampler.BorderType = ResUGX2.GX2TexBorderType.ClearBlack;
texSampler.ClampX = ResUGX2.GX2TexClamp.Wrap;
texSampler.ClampY = ResUGX2.GX2TexClamp.Wrap;
texSampler.ClampZ = ResUGX2.GX2TexClamp.Clamp;
texSampler.DepthCompareEnabled = false;
texSampler.DepthCompareFunc = ResUGX2.GX2CompareFunction.Never;
texSampler.MagFilter = ResUGX2.GX2TexXYFilterType.Point;
texSampler.MaxAnisotropicRatio = ResUGX2.GX2TexAnisoRatio.Ratio_1_1;
texSampler.MinFilter = ResUGX2.GX2TexXYFilterType.Point;
texSampler.MipFilter = ResUGX2.GX2TexMipFilterType.Linear;
texSampler.ZFilter = 0;
texSampler.MaxLod = 13;
texSampler.MinLod = 0;
texSampler.LodBias = 0;
tex.wiiUSampler = texSampler;
}
else
{
var texSampler = new ResNX.Sampler();
tex.switchSampler = texSampler;
}
material.TextureMaps.Add(tex);

var item = new ListViewItem();
item.Text = "Untitled";
item.SubItems.Add(tex.SamplerName);
item.SubItems.Add(tex.FragShaderSampler);
textureRefListView.Items.Add(item);
}

private void btnRemove_Click(object sender, EventArgs e)
Expand All @@ -428,7 +424,7 @@ private void btnRemove_Click(object sender, EventArgs e)
{
string FirstSelecteItem = textureRefListView.SelectedItems[0].Text;

var result = MessageBox.Show("NOTE! Texture maps are adjusted by shader options which link by shaders. These are not possible to edit yet, do you want to continue?", "Material Editor", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation);
var result = MessageBox.Show("NOTE! Removing texture maps could cause issues with shaders, do you want to continue?", "Material Editor", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation);

if (result == DialogResult.Yes)
{
Expand Down

0 comments on commit 66d3d50

Please sign in to comment.