Image Editor : Add gamma control and addtional UI to cubemap viewer

This commit is contained in:
KillzXGaming 2021-04-09 21:02:20 -04:00
parent c9aef08482
commit f98cb66feb
6 changed files with 86 additions and 31 deletions

View file

@ -29,29 +29,87 @@
private void InitializeComponent()
{
this.stPanel1 = new Toolbox.Library.Forms.STPanel();
this.encodeHDRAlphaChk = new Toolbox.Library.Forms.STCheckBox();
this.gammaUD = new Toolbox.Library.Forms.NumericUpDownFloat();
this.stLabel1 = new Toolbox.Library.Forms.STLabel();
this.contentContainer.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.gammaUD)).BeginInit();
this.SuspendLayout();
//
// contentContainer
//
this.contentContainer.Controls.Add(this.stLabel1);
this.contentContainer.Controls.Add(this.gammaUD);
this.contentContainer.Controls.Add(this.encodeHDRAlphaChk);
this.contentContainer.Controls.Add(this.stPanel1);
this.contentContainer.Size = new System.Drawing.Size(314, 332);
this.contentContainer.Size = new System.Drawing.Size(583, 455);
this.contentContainer.Controls.SetChildIndex(this.stPanel1, 0);
this.contentContainer.Controls.SetChildIndex(this.encodeHDRAlphaChk, 0);
this.contentContainer.Controls.SetChildIndex(this.gammaUD, 0);
this.contentContainer.Controls.SetChildIndex(this.stLabel1, 0);
//
// stPanel1
//
this.stPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.stPanel1.Location = new System.Drawing.Point(0, 25);
this.stPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.stPanel1.Location = new System.Drawing.Point(0, 51);
this.stPanel1.Name = "stPanel1";
this.stPanel1.Size = new System.Drawing.Size(314, 307);
this.stPanel1.Size = new System.Drawing.Size(580, 404);
this.stPanel1.TabIndex = 11;
//
// encodeHDRAlphaChk
//
this.encodeHDRAlphaChk.AutoSize = true;
this.encodeHDRAlphaChk.Location = new System.Drawing.Point(10, 32);
this.encodeHDRAlphaChk.Name = "encodeHDRAlphaChk";
this.encodeHDRAlphaChk.Size = new System.Drawing.Size(125, 17);
this.encodeHDRAlphaChk.TabIndex = 12;
this.encodeHDRAlphaChk.Text = "View Encoded Alpha";
this.encodeHDRAlphaChk.UseVisualStyleBackColor = true;
this.encodeHDRAlphaChk.CheckedChanged += new System.EventHandler(this.encodeHDRAlphaChk_CheckedChanged);
//
// gammaUD
//
this.gammaUD.DecimalPlaces = 5;
this.gammaUD.Increment = new decimal(new int[] {
5,
0,
0,
196608});
this.gammaUD.Location = new System.Drawing.Point(193, 29);
this.gammaUD.Maximum = new decimal(new int[] {
1000000000,
0,
0,
0});
this.gammaUD.Minimum = new decimal(new int[] {
100000000,
0,
0,
-2147483648});
this.gammaUD.Name = "gammaUD";
this.gammaUD.Size = new System.Drawing.Size(120, 20);
this.gammaUD.TabIndex = 13;
this.gammaUD.ValueChanged += new System.EventHandler(this.gammaUD_ValueChanged);
//
// stLabel1
//
this.stLabel1.AutoSize = true;
this.stLabel1.Location = new System.Drawing.Point(141, 31);
this.stLabel1.Name = "stLabel1";
this.stLabel1.Size = new System.Drawing.Size(46, 13);
this.stLabel1.TabIndex = 14;
this.stLabel1.Text = "Gamma:";
//
// CubeMapFaceViewer3D
//
this.ClientSize = new System.Drawing.Size(320, 337);
this.ClientSize = new System.Drawing.Size(589, 460);
this.Name = "CubeMapFaceViewer3D";
this.Text = "CubeMapFaceViewer3D";
this.contentContainer.ResumeLayout(false);
this.contentContainer.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.gammaUD)).EndInit();
this.ResumeLayout(false);
}
@ -59,5 +117,8 @@
#endregion
private STPanel stPanel1;
private STLabel stLabel1;
private NumericUpDownFloat gammaUD;
private STCheckBox encodeHDRAlphaChk;
}
}

View file

@ -17,13 +17,13 @@ namespace Toolbox.Library.Forms
{
public partial class CubeMapFaceViewer3D : STForm
{
public bool HDREncoded = false;
private GL_ControlBase glControl;
public CubeMapFaceViewer3D()
{
InitializeComponent();
gammaUD.Value = 2.2m;
if (Runtime.UseLegacyGL)
glControl = new GL_ControlLegacy();
else
@ -36,16 +36,25 @@ namespace Toolbox.Library.Forms
}
private STGenericTexture ActiveTexture;
private DrawableSkybox skybox = new DrawableSkybox();
public void LoadTexture(STGenericTexture texture)
{
ActiveTexture = texture;
var skybox = new DrawableSkybox();
skybox.ForceDisplay = true;
skybox.LoadCustomTexture(ActiveTexture);
skybox.HDREncoded = HDREncoded;
glControl.MainDrawable = skybox;
}
private void encodeHDRAlphaChk_CheckedChanged(object sender, EventArgs e) {
skybox.HDREncoded = encodeHDRAlphaChk.Checked;
glControl?.Invalidate();
}
private void gammaUD_ValueChanged(object sender, EventArgs e) {
skybox.Gamma = (float)gammaUD.Value;
glControl?.Invalidate();
}
}
}

View file

@ -31,6 +31,7 @@
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();
@ -86,9 +87,7 @@
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();
@ -485,7 +484,6 @@
this.useComponentSelectorToolStripMenuItem,
this.previewCubemapToolStripMenuItem,
this.previewCubemap3DToolStripMenuItem,
this.previewCubemap3DHDRAlphaToolStripMenuItem,
this.previewGammaFixSmashUltimateToolStripMenuItem});
this.viewToolStripMenuItem.Name = "viewToolStripMenuItem";
this.viewToolStripMenuItem.Size = new System.Drawing.Size(44, 20);
@ -643,13 +641,6 @@
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);
@ -735,6 +726,5 @@
private STLabel noteifcationLbl;
private System.Windows.Forms.ToolStripMenuItem gammaFixToolStripMenuItem;
private System.Windows.Forms.PictureBox backgroundPB;
private System.Windows.Forms.ToolStripMenuItem previewCubemap3DHDRAlphaToolStripMenuItem;
}
}

View file

@ -1383,18 +1383,10 @@ 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();
}
private STColorDialog colorDlg;
private bool dialogActive = false;

View file

@ -15,6 +15,7 @@ namespace Toolbox.Library.Rendering
public class DrawableSkybox : AbstractGlDrawable
{
public bool HDREncoded = false;
public float Gamma = 2.2f;
public bool ForceDisplay = false;
@ -86,7 +87,8 @@ namespace Toolbox.Library.Rendering
defaultShaderProgram.SetMatrix4x4("rotView", ref rot);
defaultShaderProgram.SetBoolToInt("hdrEncoded", HDREncoded);
defaultShaderProgram.SetFloat("gamma", Gamma);
if (CustomCubemap != null)
{
GL.ActiveTexture(TextureUnit.Texture0);

View file

@ -5,6 +5,7 @@ in vec3 TexCoords;
uniform samplerCube environmentMap;
uniform int hdrEncoded;
uniform float gamma;
void main()
{
@ -15,7 +16,7 @@ void main()
{
envColor = envTexture.rgb * pow(envTexture.a, 4) * 1024;
envColor = envColor / (envColor + vec3(1.0));
envColor = pow(envColor, vec3(1.0/2.2));
envColor = pow(envColor, vec3(1.0/gamma));
}
FragColor = vec4(envColor, 1.0);