Fixed issues after merging
This commit is contained in:
parent
cf22c67e6f
commit
c933f04f26
10 changed files with 33 additions and 63 deletions
|
|
@ -15,44 +15,42 @@ namespace SM.Base.PostEffects
|
||||||
{
|
{
|
||||||
public class BloomEffect : PostProcessEffect
|
public class BloomEffect : PostProcessEffect
|
||||||
{
|
{
|
||||||
private static BezierCurve _defaultCurve = new BezierCurve(Vector2.UnitY, new Vector2(0.32f, 1), new Vector2(0.432f, 0), new Vector2(1,0));
|
private static BezierCurve _defaultCurve = new BezierCurve(Vector2.UnitY, Vector2.Zero, new Vector2(0.4f, 0), new Vector2(.5f,0));
|
||||||
|
private static readonly PostProcessShader _mergeShader = new PostProcessShader(
|
||||||
|
AssemblyUtility.ReadAssemblyFile(SMRenderer.PostProcessPath + ".bloom_merge_vert.glsl"),
|
||||||
|
AssemblyUtility.ReadAssemblyFile(SMRenderer.PostProcessPath + ".bloom_merge.glsl"));
|
||||||
|
|
||||||
|
private static readonly PostProcessShader _shader =
|
||||||
|
new PostProcessShader(AssemblyUtility.ReadAssemblyFile(SMRenderer.PostProcessPath + ".bloom_blur.glsl"));
|
||||||
private const float _defaultTextureScale = .75f;
|
private const float _defaultTextureScale = .75f;
|
||||||
|
|
||||||
private static readonly BezierCurve _defaultCurve = new BezierCurve(Vector2.UnitY, new Vector2(0.32f, 1),
|
private Framebuffer _source;
|
||||||
new Vector2(0.432f, 0), new Vector2(1, 0));
|
|
||||||
|
|
||||||
private Framebuffer _bloomBuffer1;
|
private Framebuffer _bloomBuffer1;
|
||||||
private Framebuffer _bloomBuffer2;
|
private Framebuffer _bloomBuffer2;
|
||||||
|
|
||||||
private readonly bool _hdr;
|
private readonly bool _hdr;
|
||||||
|
|
||||||
private readonly PostProcessShader _mergeShader = new PostProcessShader(
|
|
||||||
AssemblyUtility.ReadAssemblyFile(SMRenderer.PostProcessPath + ".bloom_merge_vert.glsl"),
|
|
||||||
AssemblyUtility.ReadAssemblyFile(SMRenderer.PostProcessPath + ".bloom_merge.glsl"));
|
|
||||||
|
|
||||||
private readonly PostProcessShader _shader =
|
|
||||||
new PostProcessShader(AssemblyUtility.ReadAssemblyFile(SMRenderer.PostProcessPath + ".bloom_blur.glsl"));
|
|
||||||
|
|
||||||
private Framebuffer _source;
|
|
||||||
|
|
||||||
private readonly float _textureScale = .75f;
|
private readonly float _textureScale = .75f;
|
||||||
|
|
||||||
private BezierCurve _weightCurve;
|
private BezierCurve _weightCurve;
|
||||||
private float[] _weights;
|
private float[] _weights;
|
||||||
|
|
||||||
public int Iterations = 1;
|
private ColorAttachment _xBuffer;
|
||||||
|
private ColorAttachment _yBuffer;
|
||||||
|
|
||||||
|
public TextureBase AmountMap;
|
||||||
|
public TextureTransformation AmountTransform = new TextureTransformation();
|
||||||
|
|
||||||
|
public int Iterations = 8;
|
||||||
public float Threshold = .8f;
|
public float Threshold = .8f;
|
||||||
public float Power = 1;
|
public float Power = 1;
|
||||||
|
|
||||||
public bool Enable = true;
|
public bool Enable = true;
|
||||||
|
|
||||||
public int Iterations = 1;
|
|
||||||
public float MaxAmount = 1;
|
public float MaxAmount = 1;
|
||||||
|
|
||||||
public float MinAmount = 0;
|
public float MinAmount = 0;
|
||||||
public float Power = 1;
|
|
||||||
public float Threshold = .8f;
|
|
||||||
|
|
||||||
public int WeightCurvePickAmount = 4;
|
public int WeightCurvePickAmount = 4;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ namespace SM.Base.PostEffects
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This class has some utility for render pipelines
|
/// This class has some utility for render pipelines
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class PostProcessFinals
|
public static class PostProcessUtility
|
||||||
{
|
{
|
||||||
private static readonly PostProcessShader _hdrExposureShader =
|
private static readonly PostProcessShader _hdrExposureShader =
|
||||||
new PostProcessShader(AssemblyUtility.ReadAssemblyFile(SMRenderer.PostProcessPath + ".finalize_hdr.glsl"));
|
new PostProcessShader(AssemblyUtility.ReadAssemblyFile(SMRenderer.PostProcessPath + ".finalize_hdr.glsl"));
|
||||||
|
|
@ -64,7 +64,7 @@
|
||||||
<Compile Include="Drawing\Instance.cs" />
|
<Compile Include="Drawing\Instance.cs" />
|
||||||
<Compile Include="Drawing\ShaderArguments.cs" />
|
<Compile Include="Drawing\ShaderArguments.cs" />
|
||||||
<Compile Include="Drawing\TextureTransformation.cs" />
|
<Compile Include="Drawing\TextureTransformation.cs" />
|
||||||
<Compile Include="PostEffects\PostProcessFinals.cs" />
|
<Compile Include="PostEffects\PostProcessUtility.cs" />
|
||||||
<Compile Include="Scene\IFixedScriptable.cs" />
|
<Compile Include="Scene\IFixedScriptable.cs" />
|
||||||
<Compile Include="Shaders\MaterialShader.cs" />
|
<Compile Include="Shaders\MaterialShader.cs" />
|
||||||
<Compile Include="Drawing\Particles\ParticleContext.cs" />
|
<Compile Include="Drawing\Particles\ParticleContext.cs" />
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,8 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using SM.Base.Drawing;
|
using SM.Base.Drawing;
|
||||||
using SM.Base.Windows;
|
using SM.Base.Window;
|
||||||
|
using SM.Base.Window.Contexts;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
@ -15,6 +16,7 @@ namespace SM.Base.Scene
|
||||||
public abstract class GenericItemCollection : List<IShowItem>, IShowItem, IShowCollection, IScriptable, IFixedScriptable
|
public abstract class GenericItemCollection : List<IShowItem>, IShowItem, IShowCollection, IScriptable, IFixedScriptable
|
||||||
{
|
{
|
||||||
private List<IScriptable> _scriptableObjects = new List<IScriptable>();
|
private List<IScriptable> _scriptableObjects = new List<IScriptable>();
|
||||||
|
private List<IFixedScriptable> _fixedScriptables = new List<IFixedScriptable>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Currently active script objects.
|
/// Currently active script objects.
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using SM.Base.Utility;
|
using SM.Base.Utility;
|
||||||
using SM.Base.Window;
|
using SM.Base.Window;
|
||||||
|
using SM.Base.Window.Contexts;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,17 @@
|
||||||
#region usings
|
#region usings
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Threading;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
using OpenTK.Input;
|
using OpenTK.Input;
|
||||||
using SM.Base.Scene;
|
using SM.Base.Scene;
|
||||||
|
using SM.Base.Utility;
|
||||||
using SM.Base.Window.Contexts;
|
using SM.Base.Window.Contexts;
|
||||||
using SM.OGL;
|
using SM.OGL;
|
||||||
using SM.Utility;
|
|
||||||
using Mouse = SM.Base.Controls.Mouse;
|
using Mouse = SM.Base.Controls.Mouse;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
@ -54,41 +57,7 @@ namespace SM.Base.Window
|
||||||
|
|
||||||
public GenericScene CurrentScene { get; private set; }
|
public GenericScene CurrentScene { get; private set; }
|
||||||
public RenderPipeline CurrentRenderPipeline { get; private set; }
|
public RenderPipeline CurrentRenderPipeline { get; private set; }
|
||||||
|
|
||||||
public void Update(UpdateContext context)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ApplySetup(ISetup setup)
|
|
||||||
{
|
|
||||||
AppliedSetup = setup;
|
|
||||||
setup.Applied(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetScene(GenericScene scene)
|
|
||||||
{
|
|
||||||
if (Loading)
|
|
||||||
{
|
|
||||||
Loaded += window => SetScene(scene);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
WindowCode.PrepareScene(this, scene);
|
|
||||||
CurrentScene = scene;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetRenderPipeline(RenderPipeline renderPipeline)
|
|
||||||
{
|
|
||||||
if (Loading)
|
|
||||||
{
|
|
||||||
Loaded += window => SetRenderPipeline(renderPipeline);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
WindowCode.PreparePipeline(this, renderPipeline);
|
|
||||||
CurrentRenderPipeline = renderPipeline;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void TriggerLoad()
|
public void TriggerLoad()
|
||||||
{
|
{
|
||||||
Load?.Invoke(this);
|
Load?.Invoke(this);
|
||||||
|
|
@ -155,7 +124,7 @@ namespace SM.Base.Window
|
||||||
protected override void OnClosing(CancelEventArgs e)
|
protected override void OnClosing(CancelEventArgs e)
|
||||||
{
|
{
|
||||||
base.OnClosing(e);
|
base.OnClosing(e);
|
||||||
_fixedUpdateThread.Abort();
|
_fixedUpdateThread?.Abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Update(UpdateContext context)
|
public void Update(UpdateContext context)
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ namespace SM.OGL.Shaders
|
||||||
}
|
}
|
||||||
catch (KeyNotFoundException)
|
catch (KeyNotFoundException)
|
||||||
{
|
{
|
||||||
GLCustomActions.AtWarning?.Invoke("Uniform '" + KeyString + key + "' at '" + ParentShader.GetType().Name + "' was not found. Tried to recreate it.");
|
GLCustomActions.AtWarning?.Invoke("Uniform '" + KeyString + key + "' at '" + ParentShader.ToString() + "' was not found. Tried to recreate it.");
|
||||||
var u = new Uniform(GL.GetUniformLocation(ParentShader, KeyString + key), this);
|
var u = new Uniform(GL.GetUniformLocation(ParentShader, KeyString + key), this);
|
||||||
Add(key, u);
|
Add(key, u);
|
||||||
return u;
|
return u;
|
||||||
|
|
|
||||||
|
|
@ -11,4 +11,5 @@ layout(location = 0) out vec4 color;
|
||||||
void main() {
|
void main() {
|
||||||
color = v_Color * Tint;
|
color = v_Color * Tint;
|
||||||
if (UseTexture) color *= texture(Texture, v_TexCoords);
|
if (UseTexture) color *= texture(Texture, v_TexCoords);
|
||||||
|
color *= 1.2;
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
|
using OpenTK.Graphics;
|
||||||
using OpenTK.Input;
|
using OpenTK.Input;
|
||||||
using SM.Base;
|
using SM.Base;
|
||||||
using SM.Base.Window;
|
using SM.Base.Window;
|
||||||
|
|
@ -56,7 +57,7 @@ namespace SM_TEST
|
||||||
DrawText text = new DrawText(font, "Test Text");
|
DrawText text = new DrawText(font, "Test Text");
|
||||||
text.Transform.Position.Set(50, 0);
|
text.Transform.Position.Set(50, 0);
|
||||||
text.Transform.Size.Set(2);
|
text.Transform.Size.Set(2);
|
||||||
scene.Objects.Add(text);
|
scene.HUD.Add(text);
|
||||||
|
|
||||||
//particles.Trigger();
|
//particles.Trigger();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,11 +13,11 @@ namespace SM_TEST
|
||||||
public override void Initialization()
|
public override void Initialization()
|
||||||
{
|
{
|
||||||
|
|
||||||
MainFramebuffer = CreateWindowFramebuffer(2);
|
MainFramebuffer = CreateWindowFramebuffer(0);
|
||||||
|
|
||||||
_postBuffer = CreateWindowFramebuffer();
|
_postBuffer = CreateWindowFramebuffer();
|
||||||
Framebuffers.Add(_postBuffer);
|
Framebuffers.Add(_postBuffer);
|
||||||
_bloom = new BloomEffect(hdr: true)
|
_bloom = new BloomEffect(MainFramebuffer, hdr: true, .5f)
|
||||||
{
|
{
|
||||||
Threshold = .8f,
|
Threshold = .8f,
|
||||||
};
|
};
|
||||||
|
|
@ -33,9 +33,7 @@ namespace SM_TEST
|
||||||
context.Scene.DrawBackground(context);
|
context.Scene.DrawBackground(context);
|
||||||
context.Scene.DrawMainObjects(context);
|
context.Scene.DrawMainObjects(context);
|
||||||
context.Scene.DrawHUD(context);
|
context.Scene.DrawHUD(context);
|
||||||
|
|
||||||
PostProcessFinals.ResolveMultisampledBuffers(MainFramebuffer, _postBuffer);
|
|
||||||
|
|
||||||
Framebuffer.Screen.Activate(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
|
Framebuffer.Screen.Activate(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
|
||||||
_bloom.Draw(context);
|
_bloom.Draw(context);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue