diff --git a/Switch_Toolbox_Library/Forms/Editors/ImageEditor/CubeMapFaceViewer3D.cs b/Switch_Toolbox_Library/Forms/Editors/ImageEditor/CubeMapFaceViewer3D.cs index 9c9207f6..51fc81e0 100644 --- a/Switch_Toolbox_Library/Forms/Editors/ImageEditor/CubeMapFaceViewer3D.cs +++ b/Switch_Toolbox_Library/Forms/Editors/ImageEditor/CubeMapFaceViewer3D.cs @@ -17,6 +17,8 @@ namespace Toolbox.Library.Forms { public partial class CubeMapFaceViewer3D : STForm { + public bool HDREncoded = false; + private GL_ControlBase glControl; public CubeMapFaceViewer3D() { @@ -41,6 +43,7 @@ namespace Toolbox.Library.Forms var skybox = new DrawableSkybox(); skybox.ForceDisplay = true; skybox.LoadCustomTexture(ActiveTexture); + skybox.HDREncoded = HDREncoded; glControl.MainDrawable = skybox; } diff --git a/Switch_Toolbox_Library/Forms/Editors/ImageEditor/ImageEditorBase.Designer.cs b/Switch_Toolbox_Library/Forms/Editors/ImageEditor/ImageEditorBase.Designer.cs index 8664369e..50c0a0a3 100644 --- a/Switch_Toolbox_Library/Forms/Editors/ImageEditor/ImageEditorBase.Designer.cs +++ b/Switch_Toolbox_Library/Forms/Editors/ImageEditor/ImageEditorBase.Designer.cs @@ -31,9 +31,9 @@ this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ImageEditorBase)); this.splitContainer1 = new System.Windows.Forms.SplitContainer(); - this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); this.stPanel2 = new Toolbox.Library.Forms.STPanel(); this.stPanel1 = new Toolbox.Library.Forms.STPanel(); + this.backgroundPB = new System.Windows.Forms.PictureBox(); this.stPanel4 = new Toolbox.Library.Forms.STPanel(); this.noteifcationLbl = new Toolbox.Library.Forms.STLabel(); this.stPanel5 = new Toolbox.Library.Forms.STPanel(); @@ -42,7 +42,6 @@ this.stContextMenuStrip2 = new Toolbox.Library.Forms.STContextMenuStrip(this.components); this.copyImageToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.stPanel3 = new Toolbox.Library.Forms.STPanel(); - this.backgroundPB = new System.Windows.Forms.PictureBox(); this.alphaBtn = new Toolbox.Library.Forms.STButton(); this.editBtn = new Toolbox.Library.Forms.STButton(); this.saveBtn = new Toolbox.Library.Forms.STButton(); @@ -87,16 +86,18 @@ this.rToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.adjustmentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.gammaFixToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); this.stContextMenuStrip3 = new Toolbox.Library.Forms.STContextMenuStrip(this.components); + this.previewCubemap3DHDRAlphaToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.SuspendLayout(); this.stPanel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.backgroundPB)).BeginInit(); this.stPanel4.SuspendLayout(); this.stPanel5.SuspendLayout(); this.stContextMenuStrip2.SuspendLayout(); this.stPanel3.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.backgroundPB)).BeginInit(); this.stContextMenuStrip1.SuspendLayout(); this.SuspendLayout(); // @@ -143,6 +144,15 @@ this.stPanel1.Size = new System.Drawing.Size(389, 502); this.stPanel1.TabIndex = 2; // + // backgroundPB + // + this.backgroundPB.Location = new System.Drawing.Point(363, 0); + this.backgroundPB.Name = "backgroundPB"; + this.backgroundPB.Size = new System.Drawing.Size(23, 24); + this.backgroundPB.TabIndex = 18; + this.backgroundPB.TabStop = false; + this.backgroundPB.MouseClick += new System.Windows.Forms.MouseEventHandler(this.imageBGComboBox_MouseClick); + // // stPanel4 // this.stPanel4.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) @@ -225,15 +235,6 @@ this.stPanel3.TabIndex = 3; this.stPanel3.Paint += new System.Windows.Forms.PaintEventHandler(this.stPanel3_Paint); // - // backgroundPB - // - this.backgroundPB.Location = new System.Drawing.Point(363, 0); - this.backgroundPB.Name = "backgroundPB"; - this.backgroundPB.Size = new System.Drawing.Size(23, 24); - this.backgroundPB.TabIndex = 18; - this.backgroundPB.TabStop = false; - this.backgroundPB.MouseClick += new System.Windows.Forms.MouseEventHandler(this.imageBGComboBox_MouseClick); - // // alphaBtn // this.alphaBtn.BackColor = System.Drawing.Color.Transparent; @@ -484,6 +485,7 @@ this.useComponentSelectorToolStripMenuItem, this.previewCubemapToolStripMenuItem, this.previewCubemap3DToolStripMenuItem, + this.previewCubemap3DHDRAlphaToolStripMenuItem, this.previewGammaFixSmashUltimateToolStripMenuItem}); this.viewToolStripMenuItem.Name = "viewToolStripMenuItem"; this.viewToolStripMenuItem.Size = new System.Drawing.Size(44, 20); @@ -641,6 +643,13 @@ this.stContextMenuStrip3.Name = "stContextMenuStrip3"; this.stContextMenuStrip3.Size = new System.Drawing.Size(61, 4); // + // previewCubemap3DHDRAlphaToolStripMenuItem + // + this.previewCubemap3DHDRAlphaToolStripMenuItem.Name = "previewCubemap3DHDRAlphaToolStripMenuItem"; + this.previewCubemap3DHDRAlphaToolStripMenuItem.Size = new System.Drawing.Size(272, 22); + this.previewCubemap3DHDRAlphaToolStripMenuItem.Text = "Preview Cubemap (3D HDR Alpha)"; + this.previewCubemap3DHDRAlphaToolStripMenuItem.Click += new System.EventHandler(this.previewCubemap3DHDRToolStripMenuItem_Click); + // // ImageEditorBase // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -653,6 +662,7 @@ this.splitContainer1.ResumeLayout(false); this.stPanel1.ResumeLayout(false); this.stPanel1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.backgroundPB)).EndInit(); this.stPanel4.ResumeLayout(false); this.stPanel4.PerformLayout(); this.stPanel5.ResumeLayout(false); @@ -660,7 +670,6 @@ this.stContextMenuStrip2.ResumeLayout(false); this.stPanel3.ResumeLayout(false); this.stPanel3.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.backgroundPB)).EndInit(); this.stContextMenuStrip1.ResumeLayout(false); this.stContextMenuStrip1.PerformLayout(); this.ResumeLayout(false); @@ -726,5 +735,6 @@ private STLabel noteifcationLbl; private System.Windows.Forms.ToolStripMenuItem gammaFixToolStripMenuItem; private System.Windows.Forms.PictureBox backgroundPB; + private System.Windows.Forms.ToolStripMenuItem previewCubemap3DHDRAlphaToolStripMenuItem; } } \ No newline at end of file diff --git a/Switch_Toolbox_Library/Forms/Editors/ImageEditor/ImageEditorBase.cs b/Switch_Toolbox_Library/Forms/Editors/ImageEditor/ImageEditorBase.cs index 50da0654..1835ab38 100644 --- a/Switch_Toolbox_Library/Forms/Editors/ImageEditor/ImageEditorBase.cs +++ b/Switch_Toolbox_Library/Forms/Editors/ImageEditor/ImageEditorBase.cs @@ -1383,6 +1383,15 @@ namespace Toolbox.Library.Forms private void previewCubemap3DToolStripMenuItem_Click(object sender, EventArgs e) { CubeMapFaceViewer3D viewer = new CubeMapFaceViewer3D(); + viewer.HDREncoded = false; + viewer.LoadTexture(ActiveTexture); + viewer.Show(); + } + + private void previewCubemap3DHDRToolStripMenuItem_Click(object sender, EventArgs e) + { + CubeMapFaceViewer3D viewer = new CubeMapFaceViewer3D(); + viewer.HDREncoded = true; viewer.LoadTexture(ActiveTexture); viewer.Show(); } diff --git a/Switch_Toolbox_Library/Forms/Editors/ImageEditor/ImageEditorBase.resx b/Switch_Toolbox_Library/Forms/Editors/ImageEditor/ImageEditorBase.resx index 9815dd7d..431e9390 100644 --- a/Switch_Toolbox_Library/Forms/Editors/ImageEditor/ImageEditorBase.resx +++ b/Switch_Toolbox_Library/Forms/Editors/ImageEditor/ImageEditorBase.resx @@ -117,6 +117,9 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 184, 17 + @@ -736,9 +739,6 @@ 17, 17 - - 184, 17 - 448, 21 diff --git a/Switch_Toolbox_Library/Rendering/DrawableSkybox.cs b/Switch_Toolbox_Library/Rendering/DrawableSkybox.cs index 8eb846c8..d5d491dc 100644 --- a/Switch_Toolbox_Library/Rendering/DrawableSkybox.cs +++ b/Switch_Toolbox_Library/Rendering/DrawableSkybox.cs @@ -14,6 +14,8 @@ namespace Toolbox.Library.Rendering { public class DrawableSkybox : AbstractGlDrawable { + public bool HDREncoded = false; + public bool ForceDisplay = false; ShaderProgram defaultShaderProgram; @@ -83,6 +85,8 @@ namespace Toolbox.Library.Rendering defaultShaderProgram.SetMatrix4x4("projection", ref proj); defaultShaderProgram.SetMatrix4x4("rotView", ref rot); + defaultShaderProgram.SetBoolToInt("hdrEncoded", HDREncoded); + if (CustomCubemap != null) { GL.ActiveTexture(TextureUnit.Texture0); diff --git a/Toolbox/Shader/HDRSkyBox/HDRSkyBox.frag b/Toolbox/Shader/HDRSkyBox/HDRSkyBox.frag index a797fcba..5e60cc63 100644 --- a/Toolbox/Shader/HDRSkyBox/HDRSkyBox.frag +++ b/Toolbox/Shader/HDRSkyBox/HDRSkyBox.frag @@ -4,13 +4,19 @@ out vec4 FragColor; in vec3 TexCoords; uniform samplerCube environmentMap; - +uniform int hdrEncoded; + void main() { - vec3 envColor = textureLod(environmentMap, TexCoords, 0.0).rgb; + vec4 envTexture = textureLod(environmentMap, TexCoords, 0.0).rgba; + vec3 envColor = envTexture.rgb; - envColor = envColor / (envColor + vec3(1.0)); - envColor = pow(envColor, vec3(1.0/2.2)); + if (hdrEncoded == 1) + { + envColor = envTexture.rgb * pow(envTexture.a, 4) * 1024; + envColor = envColor / (envColor + vec3(1.0)); + envColor = pow(envColor, vec3(1.0/2.2)); + } FragColor = vec4(envColor, 1.0); } \ No newline at end of file