1
0
mirror of synced 2024-11-30 18:24:39 +01:00

Add improvements from yesterday.

PBR shader slghtly improved.
Skyobx toggle now works while viewport is active,
Cubemaps now have a check wether or not the file given is a valid cube map dds.
Update column sizing so forms load much faster
Option to right click and clear paths in settings if set
This commit is contained in:
KillzXGaming 2019-05-15 15:35:05 -04:00
parent dbf12e5fdc
commit cd57a856fc
31 changed files with 383 additions and 110 deletions

Binary file not shown.

View File

@ -1075,7 +1075,8 @@ namespace FirstPlugin
default:
setting.LoadBitMap(FileName);
importer.LoadSetting(setting);
setting.Format = GenericToBntxSurfaceFormat(DefaultFormat);
if (!IsAtscFormat(DefaultFormat))
setting.Format = GenericToBntxSurfaceFormat(DefaultFormat);
if (MaxMipLevel != 0)
{

View File

@ -230,13 +230,17 @@ namespace FirstPlugin
{
current.Text += $" : <Dictionary> {dictionaryIndex++}";
current.Tag = node[k];
current.Nodes.Add("✯✯dummy✯✯"); //a text that can't be in a byml
if (HasDynamicListChildren(current))
current.Nodes.Add("✯✯dummy✯✯"); //a text that can't be in a byml
}
else if (node[k] is IList<dynamic>)
{
current.Text += $" : <Array> {arrayIndex++}";
current.Tag = ((IList<dynamic>)node[k]);
current.Nodes.Add("✯✯dummy✯✯");
if (HasDynamicListChildren(current))
current.Nodes.Add("✯✯dummy✯✯");
}
else if (node[k] is IList<ByamlPathPoint>)
{
@ -277,7 +281,9 @@ namespace FirstPlugin
{
TreeNode current = addto.Add($"<Dictionary> {dictionaryIndex++}");
current.Tag = ((IDictionary<string, dynamic>)k);
current.Nodes.Add("✯✯dummy✯✯");
if (HasDynamicListChildren(current))
current.Nodes.Add("✯✯dummy✯✯");
}
else if (k is IList<dynamic>)
{
@ -296,6 +302,49 @@ namespace FirstPlugin
}
}
//Search through the properties of a dictionary or list and see if it contains a list/dictionary
//Then use this information to add tree nodes.
//This is so nodes can be added on click but visually have children
private bool HasDynamicListChildren(TreeNode Node)
{
if (Node.Tag != null)
{
if (((dynamic)Node.Tag).Count > 0)
{
if (Node.Tag is IList<dynamic>)
return ListHasListChild((IList<dynamic>)Node.Tag);
if (Node.Tag is IDictionary<string, dynamic>)
return DictionaryHasListChild((IDictionary<string, dynamic>)Node.Tag);
}
}
return false;
}
private bool ListHasListChild(IList<dynamic> list)
{
foreach (dynamic k in list)
{
if (k is IDictionary<string, dynamic>)
return true;
else if (k is IList<dynamic>)
return true;
}
return false;
}
private bool DictionaryHasListChild(IDictionary<string, dynamic> node)
{
foreach (string k in node.Keys)
{
if (node[k] is IDictionary<string, dynamic>)
return true;
else if (node[k] is IList<dynamic>)
return true;
}
return false;
}
private void BeforeExpand(object sender, TreeViewCancelEventArgs e)
{
if (e.Node.Tag != null && e.Node.Nodes.Count == 1 && e.Node.Nodes[0].Text == "✯✯dummy✯✯")

View File

@ -28,15 +28,15 @@ namespace FirstPlugin.Forms
foreach (string dir in Directory.GetFiles($"{GamePath}\\ObjectData", "Mario*"))
{
string filename = Path.GetFileNameWithoutExtension(dir);
listViewCustom1.BeginUpdate();
bool Exluded = ExcludeFileList.Any(filename.Contains);
if (Exluded == false)
{
listViewCustom1.Items.Add(new ListViewItem(filename) { Tag = dir });
}
listViewCustom1.EndUpdate();
}
}

View File

@ -238,8 +238,6 @@ namespace FirstPlugin
DialogResult = DialogResult.OK;
}
}
}
}
}

View File

@ -119,7 +119,6 @@ namespace FirstPlugin
private void OpenCostumeDialog(string GamePath)
{
var costumSelector = new OdysseyCostumeSelector(GamePath);
if (costumSelector.ShowDialog() == DialogResult.OK)
{
LoadCostumes(costumSelector.SelectedCostumeName);

View File

@ -497,7 +497,7 @@ namespace Switch_Toolbox.Library.Animations
return FrameCount;
}
public void NextFrame(STSkeleton skeleton, bool isChild = false)
public void NextFrame(STSkeleton skeleton, bool isChild = false, bool AdancedNextFrame = false)
{
if (Frame >= FrameCount) return;
@ -575,6 +575,13 @@ namespace Switch_Toolbox.Library.Animations
}
if (AdancedNextFrame)
{
Frame++;
if (Frame >= FrameCount)
Frame = 0;
}
if (!isChild && Updated)
{
skeleton.update();

View File

@ -13,13 +13,7 @@ namespace Switch_Toolbox.Library.Animations
anim.SetFrame(0);
for (int frame = 0; frame < anim.FrameCount; frame++)
{
anim.NextFrame(skeleton);
//Add frames to the playing animation
anim.Frame++;
//Reset it when it reaches the total frame count
if (anim.Frame >= anim.FrameCount)
anim.Frame = 0;
anim.NextFrame(skeleton, false, true);
foreach (Animation.KeyNode boneAnim in anim.Bones)
{

View File

@ -273,10 +273,7 @@ namespace Switch_Toolbox.Library.Animations
anim.SetFrame(0);
for (int i = 0; i <= anim.FrameCount; i++)
{
anim.NextFrame(Skeleton);
anim.Frame++;
if (anim.Frame >= anim.FrameCount)
anim.Frame = 0;
anim.NextFrame(Skeleton, false, true);
file.WriteLine("time " + i);

View File

@ -687,7 +687,7 @@ namespace Switch_Toolbox.Library
cubemap[0].mipmaps,
cubemap[1].mipmaps,
cubemap[2].mipmaps,
cubemap[3].mipmaps,
cubemap[3].mipmaps,
cubemap[4].mipmaps,
cubemap[5].mipmaps);
}

View File

@ -27,7 +27,6 @@ namespace Switch_Toolbox.Library.Forms
FillHeight(ctrl);
}
base.OnSizeChanged(e);
}

View File

@ -6,6 +6,7 @@ using System.Threading.Tasks;
using System.ComponentModel;
using System.Windows.Forms;
using System.Drawing;
using System.Runtime.InteropServices;
namespace Switch_Toolbox.Library.Forms
{
@ -55,8 +56,43 @@ namespace Switch_Toolbox.Library.Forms
}
[System.Runtime.InteropServices.DllImport("user32")]
private static extern IntPtr GetDC(IntPtr hwnd);
[System.Runtime.InteropServices.DllImport("user32")]
private static extern IntPtr ReleaseDC(IntPtr hwnd, IntPtr hdc);
public static IntPtr GetHeaderControl(ListView list)
{
const int LVM_GETHEADER = 0x1000 + 31;
return SendMessage(list.Handle, LVM_GETHEADER, 0, 0);
}
[System.Runtime.InteropServices.DllImport("user32.dll")]
public static extern IntPtr SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
private void ListViewCustom_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
{
/* if (e.ColumnIndex == 3) //last column index
{
ListView lv = e.Header.ListView;
IntPtr headerControl = NativeMethods.GetHeaderControl(lv);
IntPtr hdc = GetDC(headerControl);
Graphics g = Graphics.FromHdc(hdc);
// Do your extra drawing here
Rectangle rc = new Rectangle(e.Bounds.Right, //Right instead of Left - offsets the rectangle
e.Bounds.Top,
e.Bounds.Width,
e.Bounds.Height);
e.Graphics.FillRectangle(Brushes.Red, rc);
g.Dispose();
ReleaseDC(headerControl, hdc);
}*/
using (SolidBrush brush = new SolidBrush(FormThemes.BaseTheme.FormBackColor))
{
e.Graphics.FillRectangle(brush, e.Bounds);
@ -81,8 +117,12 @@ namespace Switch_Toolbox.Library.Forms
private void ListViewCustom_Resize(object sender, EventArgs e)
{
if (View == View.Details && CanResizeList)
if (View == View.Details && HeaderStyle != ColumnHeaderStyle.None && CanResizeList)
{
((ListView)sender).BeginUpdate();
SizeLastColumn((ListView)sender);
((ListView)sender).EndUpdate();
}
}
private void SizeLastColumn(ListView lv)
{

View File

@ -23,7 +23,7 @@ namespace Switch_Toolbox.Library.Forms
public STCheckBox()
{
this.BoxColor = FormThemes.BaseTheme.CheckBoxBackColor;
SetColor();
this.Paint += OnPaint;
this.CheckedChanged += new EventHandler(CheckedChangedEvent);
@ -52,6 +52,8 @@ namespace Switch_Toolbox.Library.Forms
/// <param name="e"></param>
private void OnPaint(object sender, PaintEventArgs e)
{
SetColor();
e.Graphics.FillRectangle(new SolidBrush(this.BoxColor), new Rectangle(0, 0, 15, 15));
if (this.Checked)
{
@ -81,14 +83,7 @@ namespace Switch_Toolbox.Library.Forms
{
value = Checked;
if (Checked)
{
BoxColor = FormThemes.BaseTheme.CheckBoxEnabledBackColor;
}
else
{
BoxColor = FormThemes.BaseTheme.CheckBoxBackColor;
}
SetColor();
this.Invalidate();
foreach (Binding data in DataBindings)
@ -96,5 +91,15 @@ namespace Switch_Toolbox.Library.Forms
data.WriteValue();
}
}
private void SetColor()
{
if (!Enabled)
this.BoxColor = FormThemes.BaseTheme.DisabledItemColor;
else if (Checked)
BoxColor = FormThemes.BaseTheme.CheckBoxEnabledBackColor;
else
BoxColor = FormThemes.BaseTheme.CheckBoxBackColor;
}
}
}

View File

@ -136,18 +136,13 @@ namespace Switch_Toolbox.Library
var xyzLnes = new DrawableXyzLines();
scene.staticObjects.Add(xyzLnes);
if (Runtime.PBR.UseSkybox)
{
var skybox = new DrawableSkybox();
scene.staticObjects.Add(skybox);
}
else if (Runtime.renderBackGround)
{
var background = new DrawableBackground();
scene.staticObjects.Add(background);
}
var skybox = new DrawableSkybox();
scene.staticObjects.Add(skybox);
// scene.objects.Add(new SingleObject(new Vector3(0, 0, 0)));
var background = new DrawableBackground();
scene.staticObjects.Add(background);
// scene.objects.Add(new SingleObject(new Vector3(0, 0, 0)));
// LoadFog();

View File

@ -9,6 +9,82 @@ namespace Switch_Toolbox.Library.IO
{
public static class MatrixExenstion
{
public static float Deg2Rad = (float)(System.Math.PI * 2) / 360;
public static float Rad2Deg = (float)(360 / (System.Math.PI * 2));
public static OpenTK.Vector3 QuaternionToEuler(OpenTK.Quaternion q1)
{
float sqw = q1.W * q1.W;
float sqx = q1.X * q1.X;
float sqy = q1.Y * q1.Y;
float sqz = q1.Z * q1.Z;
float unit = sqx + sqy + sqz + sqw; // if normalised is one, otherwise is correction factor
float test = q1.X * q1.W - q1.Y * q1.Z;
OpenTK.Vector3 v;
if (test > 0.4995f * unit)
{ // singularity at north pole
v.Y = 2f * (float)System.Math.Atan2(q1.X, q1.Y);
v.X = (float)System.Math.PI / 2;
v.Z = 0;
return NormalizeAngles(v * Rad2Deg);
}
if (test < -0.4995f * unit)
{ // singularity at south pole
v.Y = -2f * (float)System.Math.Atan2(q1.Y, q1.X);
v.X = (float)-System.Math.PI / 2;
v.Z = 0;
return NormalizeAngles(v * Rad2Deg);
}
Quaternion q = new Quaternion(q1.W, q1.Z, q1.X, q1.Y);
v.Y = (float)Math.Atan2(2f * q.X * q.W + 2f * q.Y * q.Z, 1 - 2f * (q.Z * q.Z + q.W * q.W)); // Yaw
v.X = (float)Math.Asin(2f * (q.X * q.Z - q.W * q.Y)); // Pitch
v.Z = (float)Math.Atan2(2f * q.X * q.Y + 2f * q.Z * q.W, 1 - 2f * (q.Y * q.Y + q.Z * q.Z)); // Roll
return NormalizeAngles(v * Rad2Deg);
}
static OpenTK.Vector3 NormalizeAngles(OpenTK.Vector3 angles)
{
angles.X = NormalizeAngle(angles.X);
angles.Y = NormalizeAngle(angles.Y);
angles.Z = NormalizeAngle(angles.Z);
return angles;
}
static float NormalizeAngle(float angle)
{
while (angle > 360)
angle -= 360;
while (angle < 0)
angle += 360;
return angle;
}
public static OpenTK.Quaternion EulerToQuaternion(float yaw, float pitch, float roll)
{
yaw *= Deg2Rad;
pitch *= Deg2Rad;
roll *= Deg2Rad;
float rollOver2 = roll * 0.5f;
float sinRollOver2 = (float)Math.Sin((double)rollOver2);
float cosRollOver2 = (float)Math.Cos((double)rollOver2);
float pitchOver2 = pitch * 0.5f;
float sinPitchOver2 = (float)Math.Sin((double)pitchOver2);
float cosPitchOver2 = (float)Math.Cos((double)pitchOver2);
float yawOver2 = yaw * 0.5f;
float sinYawOver2 = (float)Math.Sin((double)yawOver2);
float cosYawOver2 = (float)Math.Cos((double)yawOver2);
OpenTK.Quaternion result = OpenTK.Quaternion.Identity;
result.W = cosYawOver2 * cosPitchOver2 * cosRollOver2 + sinYawOver2 * sinPitchOver2 * sinRollOver2;
result.X = cosYawOver2 * sinPitchOver2 * cosRollOver2 + sinYawOver2 * cosPitchOver2 * sinRollOver2;
result.Y = sinYawOver2 * cosPitchOver2 * cosRollOver2 - cosYawOver2 * sinPitchOver2 * sinRollOver2;
result.Z = cosYawOver2 * cosPitchOver2 * sinRollOver2 - sinYawOver2 * sinPitchOver2 * cosRollOver2;
return result;
}
public static OpenTK.Matrix4 CreateRotation(OpenTK.Vector3 Normal, OpenTK.Vector3 Tangent)
{
var mat4 = OpenTK.Matrix4.Identity;

View File

@ -46,7 +46,7 @@ namespace Switch_Toolbox.Library.Rendering
public override void Draw(GL_ControlModern control, Pass pass)
{
if (pass == Pass.TRANSPARENT || solidColorShaderProgram == null)
if (pass == Pass.TRANSPARENT || Runtime.PBR.UseSkybox || solidColorShaderProgram == null)
return;
bool buffersWereInitialized = vbo_position != 0;

View File

@ -40,7 +40,7 @@ namespace Switch_Toolbox.Library.Rendering
SFGraphics.GLObjects.Textures.TextureCubeMap specularPbr;
public override void Draw(GL_ControlModern control, Pass pass)
{
if (!Runtime.OpenTKInitialized || pass == Pass.TRANSPARENT)
if (!Runtime.OpenTKInitialized || !Runtime.PBR.UseSkybox || pass == Pass.TRANSPARENT)
return;
GL.Enable(EnableCap.DepthTest);
@ -50,7 +50,7 @@ namespace Switch_Toolbox.Library.Rendering
GL.Enable(EnableCap.StencilTest);
GL.StencilOp(StencilOp.Keep, StencilOp.Keep, StencilOp.Replace);
control.CurrentShader = defaultShaderProgram;
// enable seamless cubemap sampling for lower mip levels in the pre-filter map.

View File

@ -50,7 +50,7 @@ namespace Switch_Toolbox.Library
{
if (diffusepbr == null)
{
if (System.IO.File.Exists(Runtime.PBR.SpecularCubeMapPath))
if (System.IO.File.Exists(Runtime.PBR.DiffuseCubeMapPath))
{
DDS diffuseSdr = new DDS(Runtime.PBR.DiffuseCubeMapPath);
diffusepbr = DDS.CreateGLCubeMap(diffuseSdr);

View File

@ -28,6 +28,7 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.label1 = new Switch_Toolbox.Library.Forms.STLabel();
this.chkBoxSpecular = new Switch_Toolbox.Library.Forms.STCheckBox();
this.chkBoxNormalMap = new Switch_Toolbox.Library.Forms.STCheckBox();
@ -101,12 +102,14 @@
this.stLabel10 = new Switch_Toolbox.Library.Forms.STLabel();
this.mk8PathTB = new Switch_Toolbox.Library.Forms.STTextBox();
this.tabPage4 = new System.Windows.Forms.TabPage();
this.chkDiffyseSkybox = new Switch_Toolbox.Library.Forms.STCheckBox();
this.stLabel16 = new Switch_Toolbox.Library.Forms.STLabel();
this.diffuseCubemapPathTB = new Switch_Toolbox.Library.Forms.STTextBox();
this.stContextMenuStrip1 = new Switch_Toolbox.Library.Forms.STContextMenuStrip(this.components);
this.clearSettingToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.chkUseSkyobx = new Switch_Toolbox.Library.Forms.STCheckBox();
this.stLabel15 = new Switch_Toolbox.Library.Forms.STLabel();
this.specularCubemapPathTB = new Switch_Toolbox.Library.Forms.STTextBox();
this.chkDiffyseSkybox = new Switch_Toolbox.Library.Forms.STCheckBox();
this.contentContainer.SuspendLayout();
this.panel2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.cameraMaxSpeedUD)).BeginInit();
@ -128,6 +131,7 @@
((System.ComponentModel.ISupportInitialize)(this.bgGradientTop)).BeginInit();
this.tabPage3.SuspendLayout();
this.tabPage4.SuspendLayout();
this.stContextMenuStrip1.SuspendLayout();
this.SuspendLayout();
//
// contentContainer
@ -977,6 +981,7 @@
// botwGamePathTB
//
this.botwGamePathTB.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.botwGamePathTB.ContextMenuStrip = this.stContextMenuStrip1;
this.botwGamePathTB.Location = new System.Drawing.Point(112, 120);
this.botwGamePathTB.Name = "botwGamePathTB";
this.botwGamePathTB.Size = new System.Drawing.Size(258, 20);
@ -995,6 +1000,7 @@
// tpGamePathTB
//
this.tpGamePathTB.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.tpGamePathTB.ContextMenuStrip = this.stContextMenuStrip1;
this.tpGamePathTB.Location = new System.Drawing.Point(112, 94);
this.tpGamePathTB.Name = "tpGamePathTB";
this.tpGamePathTB.Size = new System.Drawing.Size(258, 20);
@ -1013,6 +1019,7 @@
// SMOPathTB
//
this.SMOPathTB.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.SMOPathTB.ContextMenuStrip = this.stContextMenuStrip1;
this.SMOPathTB.Location = new System.Drawing.Point(112, 68);
this.SMOPathTB.Name = "SMOPathTB";
this.SMOPathTB.Size = new System.Drawing.Size(258, 20);
@ -1031,6 +1038,7 @@
// mk8DPathTB
//
this.mk8DPathTB.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.mk8DPathTB.ContextMenuStrip = this.stContextMenuStrip1;
this.mk8DPathTB.Location = new System.Drawing.Point(112, 42);
this.mk8DPathTB.Name = "mk8DPathTB";
this.mk8DPathTB.Size = new System.Drawing.Size(258, 20);
@ -1049,6 +1057,8 @@
// mk8PathTB
//
this.mk8PathTB.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.mk8PathTB.ContextMenuStrip = this.stContextMenuStrip1;
this.mk8PathTB.Cursor = System.Windows.Forms.Cursors.Default;
this.mk8PathTB.Location = new System.Drawing.Point(112, 16);
this.mk8PathTB.Name = "mk8PathTB";
this.mk8PathTB.Size = new System.Drawing.Size(258, 20);
@ -1071,6 +1081,18 @@
this.tabPage4.Text = "PBR";
this.tabPage4.UseVisualStyleBackColor = true;
//
// chkDiffyseSkybox
//
this.chkDiffyseSkybox.AutoSize = true;
this.chkDiffyseSkybox.Enabled = false;
this.chkDiffyseSkybox.Location = new System.Drawing.Point(108, 16);
this.chkDiffyseSkybox.Name = "chkDiffyseSkybox";
this.chkDiffyseSkybox.Size = new System.Drawing.Size(173, 17);
this.chkDiffyseSkybox.TabIndex = 5;
this.chkDiffyseSkybox.Text = "Display Diffuse Map on Skybox";
this.chkDiffyseSkybox.UseVisualStyleBackColor = true;
this.chkDiffyseSkybox.CheckedChanged += new System.EventHandler(this.chkDiffyseSkybox_CheckedChanged);
//
// stLabel16
//
this.stLabel16.AutoSize = true;
@ -1083,12 +1105,27 @@
// diffuseCubemapPathTB
//
this.diffuseCubemapPathTB.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.diffuseCubemapPathTB.ContextMenuStrip = this.stContextMenuStrip1;
this.diffuseCubemapPathTB.Location = new System.Drawing.Point(160, 71);
this.diffuseCubemapPathTB.Name = "diffuseCubemapPathTB";
this.diffuseCubemapPathTB.Size = new System.Drawing.Size(197, 20);
this.diffuseCubemapPathTB.TabIndex = 3;
this.diffuseCubemapPathTB.Click += new System.EventHandler(this.diffuseCubemapPathTBB_Click);
//
// stContextMenuStrip1
//
this.stContextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.clearSettingToolStripMenuItem});
this.stContextMenuStrip1.Name = "stContextMenuStrip1";
this.stContextMenuStrip1.Size = new System.Drawing.Size(142, 26);
//
// clearSettingToolStripMenuItem
//
this.clearSettingToolStripMenuItem.Name = "clearSettingToolStripMenuItem";
this.clearSettingToolStripMenuItem.Size = new System.Drawing.Size(141, 22);
this.clearSettingToolStripMenuItem.Text = "Clear Setting";
this.clearSettingToolStripMenuItem.Click += new System.EventHandler(this.clearSettingToolStripMenuItem_Click);
//
// chkUseSkyobx
//
this.chkUseSkyobx.AutoSize = true;
@ -1112,23 +1149,13 @@
// specularCubemapPathTB
//
this.specularCubemapPathTB.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.specularCubemapPathTB.ContextMenuStrip = this.stContextMenuStrip1;
this.specularCubemapPathTB.Location = new System.Drawing.Point(160, 45);
this.specularCubemapPathTB.Name = "specularCubemapPathTB";
this.specularCubemapPathTB.Size = new System.Drawing.Size(197, 20);
this.specularCubemapPathTB.TabIndex = 0;
this.specularCubemapPathTB.Click += new System.EventHandler(this.cubemapPathTB_Click);
//
// chkDiffyseSkybox
//
this.chkDiffyseSkybox.AutoSize = true;
this.chkDiffyseSkybox.Enabled = false;
this.chkDiffyseSkybox.Location = new System.Drawing.Point(108, 16);
this.chkDiffyseSkybox.Name = "chkDiffyseSkybox";
this.chkDiffyseSkybox.Size = new System.Drawing.Size(173, 17);
this.chkDiffyseSkybox.TabIndex = 5;
this.chkDiffyseSkybox.Text = "Display Diffuse Map on Skybox";
this.chkDiffyseSkybox.UseVisualStyleBackColor = true;
this.chkDiffyseSkybox.CheckedChanged += new System.EventHandler(this.chkDiffyseSkybox_CheckedChanged);
this.specularCubemapPathTB.TextChanged += new System.EventHandler(this.specularCubemapPathTB_TextChanged);
//
// Settings
//
@ -1139,6 +1166,7 @@
this.Name = "Settings";
this.Text = "Settings";
this.Load += new System.EventHandler(this.Settings_Load);
this.Controls.SetChildIndex(this.contentContainer, 0);
this.contentContainer.ResumeLayout(false);
this.panel2.ResumeLayout(false);
this.panel2.PerformLayout();
@ -1166,6 +1194,7 @@
this.tabPage3.PerformLayout();
this.tabPage4.ResumeLayout(false);
this.tabPage4.PerformLayout();
this.stContextMenuStrip1.ResumeLayout(false);
this.ResumeLayout(false);
}
@ -1251,5 +1280,7 @@
private Switch_Toolbox.Library.Forms.STLabel stLabel16;
private Switch_Toolbox.Library.Forms.STTextBox diffuseCubemapPathTB;
private Switch_Toolbox.Library.Forms.STCheckBox chkDiffyseSkybox;
private Switch_Toolbox.Library.Forms.STContextMenuStrip stContextMenuStrip1;
private System.Windows.Forms.ToolStripMenuItem clearSettingToolStripMenuItem;
}
}

View File

@ -422,8 +422,8 @@ namespace Toolbox
FolderSelectDialog sfd = new FolderSelectDialog();
if (sfd.ShowDialog() == DialogResult.OK)
{
SMOPathTB.Text = sfd.SelectedPath;
Runtime.TpGamePath = SMOPathTB.Text;
tpGamePathTB.Text = sfd.SelectedPath;
Runtime.TpGamePath = tpGamePathTB.Text;
}
}
@ -446,29 +446,111 @@ namespace Toolbox
private void cubemapPathTB_Click(object sender, EventArgs e) {
OpenFileDialog sfd = new OpenFileDialog();
sfd.Filter = "DDS |*.dds;";
if (sfd.ShowDialog() == DialogResult.OK)
{
specularCubemapPathTB.Text = System.IO.Path.GetFileName(sfd.FileName);
Runtime.PBR.SpecularCubeMapPath = sfd.FileName;
if (IsValidCubeMap(sfd.FileName))
{
specularCubemapPathTB.Text = System.IO.Path.GetFileName(sfd.FileName);
Runtime.PBR.SpecularCubeMapPath = sfd.FileName;
}
else
MessageBox.Show("Invalid cube map file. Make sure it is a DDS with a cube map.");
}
}
private void diffuseCubemapPathTBB_Click(object sender, EventArgs e) {
OpenFileDialog sfd = new OpenFileDialog();
sfd.Filter = "DDS |*.dds;";
if (sfd.ShowDialog() == DialogResult.OK)
{
diffuseCubemapPathTB.Text = System.IO.Path.GetFileName(sfd.FileName);
Runtime.PBR.DiffuseCubeMapPath = sfd.FileName;
if (IsValidCubeMap(sfd.FileName))
{
diffuseCubemapPathTB.Text = System.IO.Path.GetFileName(sfd.FileName);
Runtime.PBR.DiffuseCubeMapPath = sfd.FileName;
}
else
MessageBox.Show("Invalid cube map file. Make sure it is a DDS with a cube map.");
}
}
private bool IsValidCubeMap(string FilePath)
{
try
{
DDS dds = new DDS(FilePath);
if (dds.ArrayCount == 6)
return true;
return false;
}
catch
{
return false;
}
}
private void chkUseSkyobx_CheckedChanged(object sender, EventArgs e) {
Runtime.PBR.UseSkybox = chkUseSkyobx.Checked;
chkDiffyseSkybox.Enabled = chkUseSkyobx.Checked;
chkDiffyseSkybox.Enabled = chkUseSkyobx.Checked;
UpdateViewportSettings();
}
private void chkDiffyseSkybox_CheckedChanged(object sender, EventArgs e) {
Runtime.PBR.UseDiffuseSkyTexture = chkDiffyseSkybox.Checked;
UpdateViewportSettings();
}
private void clearSettingToolStripMenuItem_Click(object sender, EventArgs e)
{
// Try to cast the sender to a ToolStripItem
ToolStripItem menuItem = sender as ToolStripItem;
if (menuItem != null)
{
// Retrieve the ContextMenuStrip that owns this ToolStripItem
ContextMenuStrip owner = menuItem.Owner as ContextMenuStrip;
if (owner != null)
{
// Get the control that is displaying this context menu
Control sourceControl = owner.SourceControl;
switch (sourceControl.Name)
{
case "diffuseCubemapPathTB":
diffuseCubemapPathTB.Text = "";
Runtime.PBR.DiffuseCubeMapPath = "";
break;
case "specularCubemapPathTB":
specularCubemapPathTB.Text = "";
Runtime.PBR.SpecularCubeMapPath = "";
break;
case "mk8DPathTB":
mk8DPathTB.Text = "";
Runtime.Mk8dGamePath = "";
break;
case "mk8PathTB":
mk8PathTB.Text = "";
Runtime.Mk8GamePath = "";
break;
case "SMOPathTB":
SMOPathTB.Text = "";
Runtime.SmoGamePath = "";
break;
case "tpGamePathTB":
tpGamePathTB.Text = "";
Runtime.TpGamePath = "";
break;
case "botwGamePathTB":
botwGamePathTB.Text = "";
Runtime.BotwGamePath = "";
break;
}
}
}
}
private void specularCubemapPathTB_TextChanged(object sender, EventArgs e)
{
}
}
}

View File

@ -117,4 +117,7 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="stContextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@ -172,6 +172,38 @@ void main()
if (HasNormalMap == 1 && useNormalMap == 1)
N = CalcBumpedNormal(normal, NormalMap, vert, uking_texture2_texcoord);
float metallic = 0;
float roughness = 1;
float specIntensity = 1;
float ao = 1;
if (HasMRA == 1) //Kirby Star Allies PBR map
{
//Note KSA has no way to tell if one gets unused or not because shaders :(
//Usually it's just metalness with roughness and works fine
metallic = texture(MRA, f_texcoord0).r;
roughness = texture(MRA, f_texcoord0).g;
specIntensity = texture(MRA, f_texcoord0).b;
ao = texture(MRA, f_texcoord0).a;
}
else if (HasShadowMap == 1)
{
ao = texture(BakeShadowMap, f_texcoord1).r;
}
if (HasMetalnessMap == 1)
{
metallic = texture(MetalnessMap, displayTexCoord).r;
}
if (HasRoughnessMap == 1)
{
roughness = texture(RoughnessMap, displayTexCoord).r;
}
if (HasSpecularMap == 1)
{
specIntensity = texture(SpecularMap, f_texcoord0).r;
}
if (renderType == 1) // normals vertexColor
{
vec3 displayNormal = (N * 0.5) + 0.5;
@ -195,15 +227,7 @@ void main()
fragColor = vertexColor;
else if (renderType == 6) //Display Ambient Occlusion
{
if (HasShadowMap == 1)
{
float Shadow = texture(BakeShadowMap, f_texcoord1).r;
fragColor = vec4(vec3(Shadow), 1);
}
else
{
fragColor = vec4(1);
}
fragColor = vec4(vec3(ao), 1);
}
else if (renderType == 7) // uv coords
fragColor = vec4(displayTexCoord.x, displayTexCoord.y, 1, 1);
@ -246,15 +270,7 @@ void main()
}
else if (renderType == 13) //Specular
{
if (HasSpecularMap == 1)
{
vec3 Specular = texture(SpecularMap, f_texcoord0).rrr;
fragColor = vec4(Specular, 1);
}
else
{
fragColor = vec4(1);
}
fragColor = vec4(vec3(specIntensity), 1);
}
else if (renderType == 14) //Shadow
{
@ -270,27 +286,11 @@ void main()
}
else if (renderType == 15) //MetalnessMap
{
if (HasMetalnessMap == 1)
{
float mtl = texture(MetalnessMap, displayTexCoord).r;
fragColor = vec4(vec3(mtl), 1);
}
else
{
fragColor = vec4(1);
}
fragColor = vec4(vec3(metallic), 1);
}
else if (renderType == 16) //RoughnessMap
{
if (HasRoughnessMap == 1)
{
float rgh = texture(RoughnessMap, displayTexCoord).r;
fragColor = vec4(vec3(rgh), 1);
}
else
{
fragColor = vec4(1);
}
fragColor = vec4(vec3(roughness), 1);
}
else if (renderType == 17) //SubSurfaceScatteringMap
{

View File

@ -306,17 +306,15 @@ void main()
// Diffuse pass
vec3 diffuseIblColor = texture(irradianceMap, N).rgb;
vec3 diffuseTerm = diffuseIblColor * albedo;
diffuseTerm *= kD;
// diffuseTerm *= kD;
diffuseTerm *= cavity;
diffuseTerm *= ao;
diffuseTerm *= shadow;
diffuseTerm += LightingDiffuse;
// Adjust for metalness.
// diffuseTerm *= clamp(1 - metallic, 0, 1);
// diffuseTerm *= vec3(1) - kS.xxx;
diffuseTerm *= clamp(1 - metallic, 0, 1);
diffuseTerm *= vec3(1) - kS.xxx;
// Specular pass.
int maxSpecularLod = 8;
@ -349,7 +347,6 @@ void main()
float alpha = texture(DiffuseMap, f_texcoord0).a;
fragColor.a = alpha;
// Toggles rendering of individual color channels for all render modes.
fragColor.rgb *= vec3(renderR, renderG, renderB);
if (renderR == 1 && renderG == 0 && renderB == 0)