Fixed issues after merging

This commit is contained in:
Michel Fedde 2021-03-17 19:39:29 +01:00
parent cf22c67e6f
commit c933f04f26
10 changed files with 33 additions and 63 deletions

View file

@ -15,44 +15,42 @@ namespace SM.Base.PostEffects
{
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 static readonly BezierCurve _defaultCurve = new BezierCurve(Vector2.UnitY, new Vector2(0.32f, 1),
new Vector2(0.432f, 0), new Vector2(1, 0));
private Framebuffer _source;
private Framebuffer _bloomBuffer1;
private Framebuffer _bloomBuffer2;
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 BezierCurve _weightCurve;
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 Power = 1;
public bool Enable = true;
public int Iterations = 1;
public float MaxAmount = 1;
public float MinAmount = 0;
public float Power = 1;
public float Threshold = .8f;
public int WeightCurvePickAmount = 4;

View file

@ -12,7 +12,7 @@ namespace SM.Base.PostEffects
/// <summary>
/// This class has some utility for render pipelines
/// </summary>
public static class PostProcessFinals
public static class PostProcessUtility
{
private static readonly PostProcessShader _hdrExposureShader =
new PostProcessShader(AssemblyUtility.ReadAssemblyFile(SMRenderer.PostProcessPath + ".finalize_hdr.glsl"));

View file

@ -64,7 +64,7 @@
<Compile Include="Drawing\Instance.cs" />
<Compile Include="Drawing\ShaderArguments.cs" />
<Compile Include="Drawing\TextureTransformation.cs" />
<Compile Include="PostEffects\PostProcessFinals.cs" />
<Compile Include="PostEffects\PostProcessUtility.cs" />
<Compile Include="Scene\IFixedScriptable.cs" />
<Compile Include="Shaders\MaterialShader.cs" />
<Compile Include="Drawing\Particles\ParticleContext.cs" />

View file

@ -3,7 +3,8 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using SM.Base.Drawing;
using SM.Base.Windows;
using SM.Base.Window;
using SM.Base.Window.Contexts;
#endregion
@ -15,6 +16,7 @@ namespace SM.Base.Scene
public abstract class GenericItemCollection : List<IShowItem>, IShowItem, IShowCollection, IScriptable, IFixedScriptable
{
private List<IScriptable> _scriptableObjects = new List<IScriptable>();
private List<IFixedScriptable> _fixedScriptables = new List<IFixedScriptable>();
/// <summary>
/// Currently active script objects.

View file

@ -4,6 +4,7 @@ using System;
using System.Collections.Generic;
using SM.Base.Utility;
using SM.Base.Window;
using SM.Base.Window.Contexts;
#endregion

View file

@ -1,14 +1,17 @@
#region usings
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Threading;
using System.Windows.Forms;
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Input;
using SM.Base.Scene;
using SM.Base.Utility;
using SM.Base.Window.Contexts;
using SM.OGL;
using SM.Utility;
using Mouse = SM.Base.Controls.Mouse;
#endregion
@ -55,40 +58,6 @@ namespace SM.Base.Window
public GenericScene CurrentScene { 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()
{
Load?.Invoke(this);
@ -155,7 +124,7 @@ namespace SM.Base.Window
protected override void OnClosing(CancelEventArgs e)
{
base.OnClosing(e);
_fixedUpdateThread.Abort();
_fixedUpdateThread?.Abort();
}
public void Update(UpdateContext context)

View file

@ -24,7 +24,7 @@ namespace SM.OGL.Shaders
}
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);
Add(key, u);
return u;

View file

@ -11,4 +11,5 @@ layout(location = 0) out vec4 color;
void main() {
color = v_Color * Tint;
if (UseTexture) color *= texture(Texture, v_TexCoords);
color *= 1.2;
}

View file

@ -1,4 +1,5 @@
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Input;
using SM.Base;
using SM.Base.Window;
@ -56,7 +57,7 @@ namespace SM_TEST
DrawText text = new DrawText(font, "Test Text");
text.Transform.Position.Set(50, 0);
text.Transform.Size.Set(2);
scene.Objects.Add(text);
scene.HUD.Add(text);
//particles.Trigger();
}

View file

@ -13,11 +13,11 @@ namespace SM_TEST
public override void Initialization()
{
MainFramebuffer = CreateWindowFramebuffer(2);
MainFramebuffer = CreateWindowFramebuffer(0);
_postBuffer = CreateWindowFramebuffer();
Framebuffers.Add(_postBuffer);
_bloom = new BloomEffect(hdr: true)
_bloom = new BloomEffect(MainFramebuffer, hdr: true, .5f)
{
Threshold = .8f,
};
@ -34,8 +34,6 @@ namespace SM_TEST
context.Scene.DrawMainObjects(context);
context.Scene.DrawHUD(context);
PostProcessFinals.ResolveMultisampledBuffers(MainFramebuffer, _postBuffer);
Framebuffer.Screen.Activate(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
_bloom.Draw(context);