diff --git a/README.md b/README.md deleted file mode 100644 index 1ada262..0000000 --- a/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# SMRendererV3 -A performant and simple to use OpenGL-renderer. -It allows you to extend/changing the renderer as you wish, without changing the source file. - -## Installation -The distribution happens over the NuGet.org. - -You should be able to find the SMRenderer**2D** over your Nuget Package Manager. diff --git a/src/renderer/SM.Base/Animation/AnimationCurves.cs b/SMCode/SM.Base/Animation/AnimationCurves.cs similarity index 100% rename from src/renderer/SM.Base/Animation/AnimationCurves.cs rename to SMCode/SM.Base/Animation/AnimationCurves.cs diff --git a/src/renderer/SM.Base/Animation/InterpolationProcess.cs b/SMCode/SM.Base/Animation/InterpolationProcess.cs similarity index 100% rename from src/renderer/SM.Base/Animation/InterpolationProcess.cs rename to SMCode/SM.Base/Animation/InterpolationProcess.cs diff --git a/src/renderer/SM.Base/Controls/Keyboard.cs b/SMCode/SM.Base/Controls/Keyboard.cs similarity index 100% rename from src/renderer/SM.Base/Controls/Keyboard.cs rename to SMCode/SM.Base/Controls/Keyboard.cs diff --git a/src/renderer/SM.Base/Controls/Mouse.cs b/SMCode/SM.Base/Controls/Mouse.cs similarity index 76% rename from src/renderer/SM.Base/Controls/Mouse.cs rename to SMCode/SM.Base/Controls/Mouse.cs index 0a18ce9..1309818 100644 --- a/src/renderer/SM.Base/Controls/Mouse.cs +++ b/SMCode/SM.Base/Controls/Mouse.cs @@ -18,20 +18,10 @@ namespace SM.Base.Controls private static MouseState? _mouseState; private static List _lastButtonsPressed = new List(); - private static Vector2 _inScreen; - /// - /// Gets or sets the current position of the mouse in the screen. + /// The current position of the mouse in the screen. /// - public static Vector2 InScreen - { - get => _inScreen; - set - { - _inScreen = value; - UpdateNormalized(SMRenderer.CurrentWindow); - } - } + public static Vector2 InScreen { get; private set; } /// /// The current position of the mouse in the screen from 0..1. @@ -50,16 +40,6 @@ namespace SM.Base.Controls /// public static bool RightClick => IsDown(MouseButton.Right, true); - /// - /// If true, it disables the tracking of the mouse, allowing you to change the value, without the system replacing it again. - /// - public static bool StopTracking { get; set; } - - private static void UpdateNormalized(IGenericWindow window) - { - InScreenNormalized = new Vector2(_inScreen.X / (float)window.Width, _inScreen.Y / (float)window.Height); - } - /// /// The event to update the values. /// @@ -67,10 +47,8 @@ namespace SM.Base.Controls /// The window where the mouse is checked internal static void MouseMoveEvent(MouseMoveEventArgs mmea, IGenericWindow window) { - if (StopTracking) return; - InScreen = new Vector2(mmea.X, mmea.Y); - UpdateNormalized(window); + InScreenNormalized = new Vector2(mmea.X / (float) window.Width, mmea.Y / (float) window.Height); } internal static void SetState() diff --git a/src/renderer/SM.Base/Drawing/DrawingBasis.cs b/SMCode/SM.Base/Drawing/DrawingBasis.cs similarity index 100% rename from src/renderer/SM.Base/Drawing/DrawingBasis.cs rename to SMCode/SM.Base/Drawing/DrawingBasis.cs diff --git a/src/renderer/SM.Base/Drawing/GenericTransformation.cs b/SMCode/SM.Base/Drawing/GenericTransformation.cs similarity index 86% rename from src/renderer/SM.Base/Drawing/GenericTransformation.cs rename to SMCode/SM.Base/Drawing/GenericTransformation.cs index 8a3bcdf..3d3325a 100644 --- a/src/renderer/SM.Base/Drawing/GenericTransformation.cs +++ b/SMCode/SM.Base/Drawing/GenericTransformation.cs @@ -39,16 +39,9 @@ namespace SM.Base.Drawing /// /// Returns the current model matrix. /// - /// If set to true, it will always (re-)calculate the model matrix. /// - public Matrix4 GetMatrix(bool force = false) + public Matrix4 GetMatrix() { - if (force) - { - _lastFrame = SMRenderer.CurrentFrame; - return _modelMatrix = RequestMatrix(); - } - if (Ignore) return Matrix4.Identity; if (_lastFrame != SMRenderer.CurrentFrame) diff --git a/src/renderer/SM.Base/Drawing/Instance.cs b/SMCode/SM.Base/Drawing/Instance.cs similarity index 100% rename from src/renderer/SM.Base/Drawing/Instance.cs rename to SMCode/SM.Base/Drawing/Instance.cs diff --git a/src/renderer/SM.Base/Drawing/Material.cs b/SMCode/SM.Base/Drawing/Material.cs similarity index 61% rename from src/renderer/SM.Base/Drawing/Material.cs rename to SMCode/SM.Base/Drawing/Material.cs index c1d1663..3f14675 100644 --- a/src/renderer/SM.Base/Drawing/Material.cs +++ b/SMCode/SM.Base/Drawing/Material.cs @@ -2,7 +2,6 @@ using OpenTK.Graphics; using SM.Base.Shaders; -using SM.Base.Window; using SM.OGL.Texture; #endregion @@ -17,35 +16,26 @@ namespace SM.Base.Drawing /// /// A setting to enable Blending. /// - public virtual bool Blending { get; set; } = false; + public bool Blending = false; /// /// A custom shader, that is used to draw this material. /// - public virtual MaterialShader CustomShader { get; set; } + public MaterialShader CustomShader; /// /// The base texture. (aka. Diffuse Texture) /// - public virtual TextureBase Texture { get; set; } + public TextureBase Texture; /// /// The tint or color. /// - public virtual Color4 Tint { get; set; } = Color4.White; + public Color4 Tint = Color4.White; /// /// This allows custom shaders to use own shader arguments. /// public ShaderArguments ShaderArguments { get; internal set; } = new ShaderArguments(); - - /// - /// Draws the material with the provided context. - /// - /// - public virtual void Draw(DrawContext context) - { - context.Shader.Draw(context); - } } } \ No newline at end of file diff --git a/SMCode/SM.Base/Drawing/Particles/ParticleContext.cs b/SMCode/SM.Base/Drawing/Particles/ParticleContext.cs new file mode 100644 index 0000000..67f6e47 --- /dev/null +++ b/SMCode/SM.Base/Drawing/Particles/ParticleContext.cs @@ -0,0 +1,24 @@ +#region usings + +using SM.Base.Time; + +#endregion + +namespace SM.Base.Drawing.Particles +{ + /// + /// A context, with that the particle system sends the information for the movement function. + /// + public struct ParticleContext + { + /// + /// The Timer of the particles + /// + public Timer Timer; + + /// + /// The current speed of the particles. + /// + public float Speed; + } +} \ No newline at end of file diff --git a/SMCode/SM.Base/Drawing/Particles/ParticleDrawingBasis.cs b/SMCode/SM.Base/Drawing/Particles/ParticleDrawingBasis.cs new file mode 100644 index 0000000..24643db --- /dev/null +++ b/SMCode/SM.Base/Drawing/Particles/ParticleDrawingBasis.cs @@ -0,0 +1,139 @@ +#region usings + +using System; +using System.Collections.Generic; +using OpenTK; +using SM.Base.Scene; +using SM.Base.Time; +using SM.Base.Window; + +#endregion + +namespace SM.Base.Drawing.Particles +{ + /// + /// The (drawing) basis for particles + /// + public abstract class ParticleDrawingBasis : DrawingBasis, IScriptable + where TTransform : GenericTransformation, new() + where TDirection : struct + { + + /// + /// The amount of particles + /// + public int Amount = 32; + + /// + /// This contains the different instances for the particles. + /// + protected List instances; + + /// + /// The maximum speed of the particles + /// + public float MaxSpeed = 50; + + /// + /// This contains all important information for each particle. + /// + protected ParticleStruct[] particleStructs; + + /// + /// The stopwatch of the particles. + /// + protected Timer timer; + + /// + /// Sets up the timer. + /// + /// Duration how long the particles should live + protected ParticleDrawingBasis(TimeSpan duration) + { + timer = new Timer(duration); + } + + /// + /// Get/Sets the state of pausing. + /// + public bool Paused + { + get => timer.Paused; + set => timer.Paused = value; + } + + /// + /// Controls the movement of each particles. + /// + public abstract Func MovementCalculation { get; set; } + + /// + public bool UpdateActive { + get => timer.Active; + set { return; } + } + + /// + public void Update(UpdateContext context) + { + ParticleContext particleContext = new ParticleContext + { + Timer = timer + }; + + for (int i = 0; i < Amount; i++) + { + particleContext.Speed = particleStructs[i].Speed; + instances[i].ModelMatrix = CreateMatrix(particleStructs[i], + MovementCalculation(particleStructs[i].Direction, particleContext)); + } + } + + /// + /// Triggers the particles. + /// + public void Trigger() + { + timer.Start(); + + CreateParticles(); + } + + /// + protected override void DrawContext(ref DrawContext context) + { + if (!timer.Active) return; + + base.DrawContext(ref context); + + context.Instances = instances; + + context.Shader.Draw(context); + } + + /// + /// Creates the particles. + /// + protected virtual void CreateParticles() + { + particleStructs = new ParticleStruct[Amount]; + instances = new List(); + for (int i = 0; i < Amount; i++) + { + particleStructs[i] = CreateObject(i); + + instances.Add(new Instance()); + } + } + + /// + /// Creates a particle. + /// + protected abstract ParticleStruct CreateObject(int index); + + /// + /// Generates the desired matrix for drawing. + /// + protected abstract Matrix4 CreateMatrix(ParticleStruct Struct, TDirection relativePosition); + } +} \ No newline at end of file diff --git a/src/renderer/SM.Base/Drawing/Particles/ParticleMovement.cs b/SMCode/SM.Base/Drawing/Particles/ParticleMovement.cs similarity index 54% rename from src/renderer/SM.Base/Drawing/Particles/ParticleMovement.cs rename to SMCode/SM.Base/Drawing/Particles/ParticleMovement.cs index cccd773..6fdad6a 100644 --- a/src/renderer/SM.Base/Drawing/Particles/ParticleMovement.cs +++ b/SMCode/SM.Base/Drawing/Particles/ParticleMovement.cs @@ -14,17 +14,17 @@ namespace SM.Base.Drawing.Particles /// /// Default movement for 2D. /// - public static Vector2 Default2D(ParticleInstance particle) + public static Vector2 Default2D(Vector2 direction, ParticleContext context) { - return particle.Direction * ((particle.StartLifetime - particle.Lifetime) * particle.Speed); + return direction * (context.Timer.Elapsed * context.Speed); } /// /// Default movement for 3D. /// - public static Vector3 Default3D(ParticleInstance particle) + public static Vector3 Default3D(Vector3 direction, ParticleContext context) { - return particle.Direction * ((particle.StartLifetime - particle.Lifetime) * particle.Speed); + return direction * (context.Timer.Elapsed * context.Speed); } } } \ No newline at end of file diff --git a/SMCode/SM.Base/Drawing/Particles/ParticleStruct.cs b/SMCode/SM.Base/Drawing/Particles/ParticleStruct.cs new file mode 100644 index 0000000..eef2b53 --- /dev/null +++ b/SMCode/SM.Base/Drawing/Particles/ParticleStruct.cs @@ -0,0 +1,30 @@ +#region usings + +using OpenTK; + +#endregion + +namespace SM.Base.Drawing.Particles +{ + /// + /// A particle... + /// + public struct ParticleStruct + where TDirection : struct + { + /// + /// A direction, that the particle should travel. + /// + public TDirection Direction; + + /// + /// A matrix to store rotation and scale. + /// + public Matrix4 Matrix; + + /// + /// Speeeeeeeeeed + /// + public float Speed; + } +} \ No newline at end of file diff --git a/src/renderer/SM.Base/Drawing/ShaderArguments.cs b/SMCode/SM.Base/Drawing/ShaderArguments.cs similarity index 100% rename from src/renderer/SM.Base/Drawing/ShaderArguments.cs rename to SMCode/SM.Base/Drawing/ShaderArguments.cs diff --git a/src/renderer/SM.Base/Drawing/Text/CharParameter.cs b/SMCode/SM.Base/Drawing/Text/CharParameter.cs similarity index 100% rename from src/renderer/SM.Base/Drawing/Text/CharParameter.cs rename to SMCode/SM.Base/Drawing/Text/CharParameter.cs diff --git a/src/renderer/SM.Base/Drawing/Text/Font.cs b/SMCode/SM.Base/Drawing/Text/Font.cs similarity index 89% rename from src/renderer/SM.Base/Drawing/Text/Font.cs rename to SMCode/SM.Base/Drawing/Text/Font.cs index 102046a..f9c9667 100644 --- a/src/renderer/SM.Base/Drawing/Text/Font.cs +++ b/SMCode/SM.Base/Drawing/Text/Font.cs @@ -40,12 +40,6 @@ namespace SM.Base.Drawing.Text /// public float FontSize { get; set; } = 12; - /// - /// Allows to adjust the baseline to fix clipping issues. - /// Due to some issues with the calculations, this is a temporary fix. - /// - public float BaselineAdjust { get; set; } = 1f; - /// /// The character positions. /// @@ -70,8 +64,6 @@ namespace SM.Base.Drawing.Text public void RegenerateTexture() { Width = Height = 0; - - //Height = Math.Abs(_fontFace.BBox.Bottom) + _fontFace.BBox.Top; Positions = new Dictionary(); _fontFace.SetCharSize(0, FontSize, 0, 96); @@ -91,7 +83,7 @@ namespace SM.Base.Drawing.Text float bBoxHeight = (Math.Abs(_fontFace.BBox.Bottom) + _fontFace.BBox.Top); float bBoxTopScale = _fontFace.BBox.Top / bBoxHeight; - float baseline = (Height * bBoxTopScale) + BaselineAdjust; + float baseline = Height * bBoxTopScale + 1; Map = new Bitmap(Width, Height); using (Graphics g = Graphics.FromImage(Map)) @@ -103,7 +95,8 @@ namespace SM.Base.Drawing.Text { _fontFace.LoadChar(keyvalue.Key, LoadFlags.Render, LoadTarget.Normal); - int y = ((int)baseline - (int) _fontFace.Glyph.Metrics.HorizontalBearingY); + int y = ((int)baseline - (int)_fontFace.Glyph.Metrics.HorizontalBearingY); + g.DrawImageUnscaled(_fontFace.Glyph.Bitmap.ToGdipBitmap(Color.White), (int)keyvalue.Value[1], y); Vector2 offset = new Vector2(keyvalue.Value[1] / Width, 0); diff --git a/src/renderer/SM.Base/Drawing/Text/FontCharStorage.cs b/SMCode/SM.Base/Drawing/Text/FontCharStorage.cs similarity index 100% rename from src/renderer/SM.Base/Drawing/Text/FontCharStorage.cs rename to SMCode/SM.Base/Drawing/Text/FontCharStorage.cs diff --git a/src/renderer/SM.Base/Drawing/Text/TextDrawingBasis.cs b/SMCode/SM.Base/Drawing/Text/TextDrawingBasis.cs similarity index 76% rename from src/renderer/SM.Base/Drawing/Text/TextDrawingBasis.cs rename to SMCode/SM.Base/Drawing/Text/TextDrawingBasis.cs index 9879639..206a63c 100644 --- a/src/renderer/SM.Base/Drawing/Text/TextDrawingBasis.cs +++ b/SMCode/SM.Base/Drawing/Text/TextDrawingBasis.cs @@ -1,8 +1,6 @@ #region usings using System; -using System.Collections.Generic; -using System.Linq; using OpenTK; using OpenTK.Graphics; using SM.Base.Objects.Static; @@ -132,13 +130,9 @@ namespace SM.Base.Drawing.Text { if (!Font.WasCompiled) Font.RegenerateTexture(); - if (string.IsNullOrEmpty(_text)) return; - _text = _text.Replace("\r\n", "\n").Replace("\t", " "); _instances = new Instance[_text.Length]; - List> lines = new List>(); - List currentLineInstances = new List(); float x = 0; float y = 0; @@ -152,13 +146,8 @@ namespace SM.Base.Drawing.Text if (_text[i] == '\n') { - if (currentLineInstances.Count > 0) - { - lines.Add(new Tuple(new Vector2(x, y), currentLineInstances.ToArray())); - currentLineInstances.Clear(); - } - y += Font.Height; + Width = Math.Max(Width, x); x = 0; continue; } @@ -181,41 +170,32 @@ namespace SM.Base.Drawing.Text var matrix = Matrix4.CreateScale(parameter.Width, Font.Height, 1) * Matrix4.CreateTranslation(x + parameter.Width / 2, -y, 0); - currentLineInstances.Add(_instances[i] = new Instance + _instances[i] = new Instance { ModelMatrix = matrix, TextureMatrix = parameter.TextureMatrix - }); + }; x += parameter.Advance; } - if (currentLineInstances.Count > 0) - lines.Add(new Tuple(new Vector2(x, y), currentLineInstances.ToArray())); - Height = y + Font.Height; - Width = lines.Max(a => a.Item1.X); + Width = x; if (Origin != TextOrigin.Left) { - foreach (Tuple line in lines) + foreach (Instance i in _instances) { - - foreach (Instance i in line.Item2) + if (i == null) continue; + switch (Origin) { - if (i == null) continue; - switch (Origin) - { - case TextOrigin.Center: - i.ModelMatrix *= Matrix4.CreateTranslation(-line.Item1.X / 2, 0, 0); - break; - case TextOrigin.Right: - i.ModelMatrix *= Matrix4.CreateTranslation(-line.Item1.X, 0, 0); - break; - } + case TextOrigin.Center: + i.ModelMatrix *= Matrix4.CreateTranslation(-Width / 2, 0, 0); + break; + case TextOrigin.Right: + i.ModelMatrix *= Matrix4.CreateTranslation(-Width, 0, 0); + break; } } - - } } } diff --git a/src/renderer/SM.Base/Drawing/TextureTransformation.cs b/SMCode/SM.Base/Drawing/TextureTransformation.cs similarity index 100% rename from src/renderer/SM.Base/Drawing/TextureTransformation.cs rename to SMCode/SM.Base/Drawing/TextureTransformation.cs diff --git a/SMCode/SM.Base/Legacy/Font.cs b/SMCode/SM.Base/Legacy/Font.cs new file mode 100644 index 0000000..1cebcb6 --- /dev/null +++ b/SMCode/SM.Base/Legacy/Font.cs @@ -0,0 +1,144 @@ +#region usings + +using System.Collections.Generic; +using System.Drawing; +using System.Drawing.Text; +using OpenTK.Graphics.OpenGL4; +using SM.Base.Textures; + +#endregion + +namespace SM.Base.Drawing.Text +{ + /// + /// Represents a font. + /// + public class Font : Texture + { + /// + /// The char set for the font. + /// Default: + /// + public ICollection CharSet = FontCharStorage.SimpleUTF8; + + /// + /// The font family, that is used to find the right font. + /// + public FontFamily FontFamily; + + /// + /// The font size. + /// Default: 12 + /// + public float FontSize = 12; + + public float SpaceWidth { get; private set; } + + public float Spacing = 1; + + /// + /// The font style. + /// Default: + /// + public FontStyle FontStyle = FontStyle.Regular; + + /// + /// This contains all information for the different font character. + /// + public Dictionary Positions = new Dictionary(); + + /// + /// Generates a font from a font family from the specified path. + /// + /// The specified path + public Font(string path) + { + var pfc = new PrivateFontCollection(); + pfc.AddFontFile(path); + FontFamily = pfc.Families[0]; + } + + /// + /// Generates a font from a specified font family. + /// + /// Font-Family + public Font(FontFamily font) + { + FontFamily = font; + } + + /// + public override TextureWrapMode WrapMode { get; set; } = TextureWrapMode.ClampToEdge; + + /// + /// Regenerates the texture. + /// + public void RegenerateTexture() + { + Width = 0; + Height = 0; + Positions = new Dictionary(); + + + var map = new Bitmap(1000, 20); + var charParams = new Dictionary(); + using (var f = new System.Drawing.Font(FontFamily, FontSize, FontStyle)) + { + using (var g = Graphics.FromImage(map)) + { + g.Clear(Color.Transparent); + + foreach (var c in CharSet) + { + var s = c.ToString(); + var size = g.MeasureString(s, f, 0, StringFormat.GenericTypographic); + try + { + charParams.Add(c, new[] {size.Width, Width}); + } + catch + { + // ignored + } + + if (Height < size.Height) Height = (int) size.Height; + Width += (int) size.Width + 1; + } + + SpaceWidth = g.MeasureString("_", f, 0, StringFormat.GenericTypographic).Width; + } + + map = new Bitmap(Width, Height); + using (var g = Graphics.FromImage(map)) + { + foreach (var keyValuePair in charParams) + { + var normalizedX = (keyValuePair.Value[1]+ 0.00001f) / Width; + var normalizedWidth = keyValuePair.Value[0] / Width; + + CharParameter parameter; + Positions.Add(keyValuePair.Key, parameter = new CharParameter + { + NormalizedWidth = normalizedWidth, + NormalizedX = normalizedX, + Width = keyValuePair.Value[0], + X = (int) keyValuePair.Value[1] + }); + + g.DrawString(keyValuePair.Key.ToString(), f, Brushes.White, parameter.X, 0, StringFormat.GenericTypographic); + } + } + } + + Map = map; + Recompile(); + } + + /// + public override void Compile() + { + RegenerateTexture(); + base.Compile(); + } + } +} \ No newline at end of file diff --git a/src/renderer/SM.Base/Log.cs b/SMCode/SM.Base/Log.cs similarity index 93% rename from src/renderer/SM.Base/Log.cs rename to SMCode/SM.Base/Log.cs index 176a85c..8477937 100644 --- a/src/renderer/SM.Base/Log.cs +++ b/SMCode/SM.Base/Log.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.IO.Compression; -using System.Reflection; using System.Windows.Forms; using OpenTK.Graphics.OpenGL4; using SM.OGL; @@ -83,14 +82,14 @@ namespace SM.Base /// /// Presets for the log targets. /// - public static Dictionary Preset = new Dictionary() + public static Dictionary Preset = new() { {LogTarget.Console, "[%type%] %msg%"}, {LogTarget.Debugger, "[%type%] %msg%"}, {LogTarget.File, "<%date%, %time%> [%type%] %msg%"} }; - private static readonly Dictionary Colors = new Dictionary() + private static readonly Dictionary Colors = new() { {LogType.Info, ConsoleColor.Green}, {LogType.Warning, ConsoleColor.Yellow}, @@ -146,10 +145,7 @@ namespace SM.Base { if (_init) return; - if (!Debugger.IsAttached) - { - AppDomain.CurrentDomain.UnhandledException += ExceptionHandler; - } + AppDomain.CurrentDomain.UnhandledException += ExceptionHandler; AppDomain.CurrentDomain.DomainUnload += (sender, args) => { _logStream.WriteLine("Unload application"); @@ -176,12 +172,9 @@ namespace SM.Base Write(e.IsTerminating ? "Terminating Error" : LogType.Error.ToString(), e.IsTerminating ? ConsoleColor.DarkRed : ConsoleColor.Red, e.ExceptionObject); - MethodBase info = (e.ExceptionObject as Exception).TargetSite; - string name = $"{info.ReflectedType.Namespace}.{info.ReflectedType.Name}.{info.Name}".Replace(".", "::"); - if (e.IsTerminating) { - MessageBox.Show($"Critical error occured at {name}.\n\n{e.ExceptionObject}", + MessageBox.Show($"Critical error occured.\n\n{e.ExceptionObject}", $"Terminating Error: {e.ExceptionObject.GetType().Name}"); _logStream?.Close(); } diff --git a/src/renderer/SM.Base/Objects/InstancedMesh.cs b/SMCode/SM.Base/Objects/InstancedMesh.cs similarity index 100% rename from src/renderer/SM.Base/Objects/InstancedMesh.cs rename to SMCode/SM.Base/Objects/InstancedMesh.cs diff --git a/src/renderer/SM.Base/Objects/Mesh.cs b/SMCode/SM.Base/Objects/Mesh.cs similarity index 100% rename from src/renderer/SM.Base/Objects/Mesh.cs rename to SMCode/SM.Base/Objects/Mesh.cs diff --git a/src/renderer/SM.Base/Objects/Static/AxisHelper.cs b/SMCode/SM.Base/Objects/Static/AxisHelper.cs similarity index 100% rename from src/renderer/SM.Base/Objects/Static/AxisHelper.cs rename to SMCode/SM.Base/Objects/Static/AxisHelper.cs diff --git a/src/renderer/SM.Base/Objects/Static/Plate.cs b/SMCode/SM.Base/Objects/Static/Plate.cs similarity index 100% rename from src/renderer/SM.Base/Objects/Static/Plate.cs rename to SMCode/SM.Base/Objects/Static/Plate.cs diff --git a/src/optionals/SM.Intergrations/OpenTK.dll.config b/SMCode/SM.Base/OpenTK.dll.config similarity index 100% rename from src/optionals/SM.Intergrations/OpenTK.dll.config rename to SMCode/SM.Base/OpenTK.dll.config diff --git a/src/renderer/SM.Base/Legacy/PostProcessing/BloomEffectOld.cs b/SMCode/SM.Base/PostEffects/BloomEffect.cs similarity index 66% rename from src/renderer/SM.Base/Legacy/PostProcessing/BloomEffectOld.cs rename to SMCode/SM.Base/PostEffects/BloomEffect.cs index 4a7366c..9b3d279 100644 --- a/src/renderer/SM.Base/Legacy/PostProcessing/BloomEffectOld.cs +++ b/SMCode/SM.Base/PostEffects/BloomEffect.cs @@ -1,7 +1,5 @@ #region usings -using System; -using System.Drawing; using OpenTK; using OpenTK.Graphics.OpenGL4; using SM.Base.Drawing; @@ -9,31 +7,28 @@ using SM.Base.PostProcess; using SM.Base.Utility; using SM.Base.Window; using SM.OGL.Framebuffer; -using SM.OGL.Shaders; using SM.OGL.Texture; #endregion -namespace SM.Base.Legacy.PostProcessing +namespace SM.Base.PostEffects { /// /// A bloom post process effect. /// - [Obsolete("This bloom effect isn't good. Please use SM.Base.PostEffects.BloomEffect, if you want a good bloom effect.")] - public class BloomEffectOld : PostProcessEffect + public class BloomEffect : PostProcessEffect { 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( - new ShaderFile(AssemblyUtility.ReadAssemblyFile("SM.Base.Legacy.PostProcessing.bloom_merge.vert")), - AssemblyUtility.ReadAssemblyFile("SM.Base.Legacy.PostProcessing.bloom_merge.glsl")); + AssemblyUtility.ReadAssemblyFile(SMRenderer.PostProcessPath + ".bloom_merge_vert.glsl"), + AssemblyUtility.ReadAssemblyFile(SMRenderer.PostProcessPath + ".bloom_merge.glsl")); private static readonly PostProcessShader _shader = - new PostProcessShader(AssemblyUtility.ReadAssemblyFile("SM.Base.Legacy.PostProcessing.bloom_blur.glsl")); + new PostProcessShader(AssemblyUtility.ReadAssemblyFile(SMRenderer.PostProcessPath + ".bloom_blur.glsl")); private const float _defaultTextureScale = .75f; private Framebuffer _source; - private Framebuffer _tempColorBuffer; private Framebuffer _bloomBuffer1; private Framebuffer _bloomBuffer2; @@ -88,6 +83,12 @@ namespace SM.Base.Legacy.PostProcessing /// public float Radius = 1; + /// + /// This can disable the bloom calculation. + /// Default: true + /// + public bool Enable = true; + /// /// This defines the weight curve. /// @@ -100,7 +101,6 @@ namespace SM.Base.Legacy.PostProcessing UpdateWeights(); } } - /// /// This defines how many picks the effect should pick from the weight curve. /// @@ -112,7 +112,7 @@ namespace SM.Base.Legacy.PostProcessing /// This can specify a own source framebuffer. If not set, it will take the Pipeline MainFramebuffer. /// This allows to enable hdr returns. /// This allows for a increase in performance, by lowering the calculating texture scale. - public BloomEffectOld(Framebuffer source = null, bool hdr = false, float? textureScale = null) + public BloomEffect(Framebuffer source = null, bool hdr = false, float? textureScale = null) { _source = source; _hdr = hdr; @@ -137,10 +137,6 @@ namespace SM.Base.Legacy.PostProcessing _source.ColorAttachments["color"].PixelInformation = PixelInformation.RGBA_HDR; - _tempColorBuffer = new Framebuffer(Pipeline.ConnectedWindow, 1); - _tempColorBuffer.Append("color", new ColorAttachment(0, PixelInformation.RGBA_HDR)); - _tempColorBuffer.Compile(); - _bloomBuffer1 = new Framebuffer(Pipeline.ConnectedWindow, _textureScale) { Name = "BloomX" @@ -154,62 +150,61 @@ namespace SM.Base.Legacy.PostProcessing _bloomBuffer2.Append("yBuffer", _yBuffer = new ColorAttachment(0, PixelInformation.RGBA_HDR)); _bloomBuffer2.Compile(); - Pipeline.Framebuffers.Add(_tempColorBuffer); Pipeline.Framebuffers.Add(_bloomBuffer1); Pipeline.Framebuffers.Add(_bloomBuffer2); } /// - protected override void Drawing(ColorAttachment source, DrawContext context) + public override void Draw(DrawContext context) { - GL.Viewport(0, 0, (int) (Pipeline.ConnectedWindow.Width * _textureScale), - (int) (Pipeline.ConnectedWindow.Height * _textureScale)); - - Framebuffer target = Framebuffer.GetCurrentlyActive(); - - source.ConnectedFramebuffer.CopyTo(_tempColorBuffer); - - bool first = true, hoz = true; - int iter = Iterations * 2; - for (int i = 0; i < iter; i++) + if (Enable) { - (hoz ? _bloomBuffer1 : _bloomBuffer2).Activate(false); + GL.Viewport(0, 0, (int) (Pipeline.ConnectedWindow.Width * _textureScale), + (int) (Pipeline.ConnectedWindow.Height * _textureScale)); - _shader.Draw(collection => + Framebuffer target = Framebuffer.GetCurrentlyActive(); + bool first = true, hoz = true; + int iter = Iterations * 2; + for (int i = 0; i < iter; i++) { - collection["renderedTexture"].SetTexture(first ? source : (hoz ? _yBuffer : _xBuffer)); + (hoz ? _bloomBuffer1 : _bloomBuffer2).Activate(false); - collection["First"].SetBool(first); - collection["Threshold"].SetFloat(Threshold); + _shader.Draw(collection => + { + collection["renderedTexture"].SetTexture(first ? _source.ColorAttachments["color"] : (hoz ? _yBuffer : _xBuffer)); - collection["Horizontal"].SetBool(hoz); + collection["First"].SetUniform1(first); + collection["Threshold"].SetUniform1(Threshold); - collection["Weights"].SetFloat(_weights); - collection["WeightCount"].SetFloat(WeightCurvePickAmount); - collection["Power"].SetFloat(Power); + collection["Horizontal"].SetUniform1(hoz); - collection["Radius"].SetFloat(_textureScale * Radius); - }); + collection["Weights"].SetUniform1(_weights); + collection["WeightCount"].SetUniform1(WeightCurvePickAmount); + collection["Power"].SetUniform1(Power); - hoz = !hoz; - if (first) first = false; + collection["Radius"].SetUniform1(_textureScale * Radius); + }); + + hoz = !hoz; + if (first) first = false; + } + + GL.Viewport(Pipeline.ConnectedWindow.ClientRectangle); + target.Activate(); } - GL.Viewport(Pipeline.ConnectedWindow.ClientRectangle); - target.Activate(); - _mergeShader.Draw(collection => { - collection["Scene"].SetTexture(_tempColorBuffer["color"]); + collection["Scene"].SetTexture(_source.ColorAttachments["color"]); collection["Bloom"].SetTexture(_yBuffer); - collection["MinAmount"].SetFloat(MinAmount); - collection["MaxAmount"].SetFloat(MaxAmount); + collection["MinAmount"].SetUniform1(MinAmount); + collection["MaxAmount"].SetUniform1(MaxAmount); collection["AmountMap"].SetTexture(AmountMap, collection["HasAmountMap"]); collection["TextureTransform"].SetMatrix3(AmountTransform.GetMatrix()); - collection["Exposure"].SetFloat(context.UseCamera.Exposure); - collection["HDR"].SetBool(_hdr); + collection["Exposure"].SetUniform1(context.UseCamera.Exposure); + collection["HDR"].SetUniform1(_hdr); }); } } diff --git a/src/renderer/SM.Base/PostEffects/PostProcessUtility.cs b/SMCode/SM.Base/PostEffects/PostProcessUtility.cs similarity index 61% rename from src/renderer/SM.Base/PostEffects/PostProcessUtility.cs rename to SMCode/SM.Base/PostEffects/PostProcessUtility.cs index 0d77ac4..55bef36 100644 --- a/src/renderer/SM.Base/PostEffects/PostProcessUtility.cs +++ b/SMCode/SM.Base/PostEffects/PostProcessUtility.cs @@ -4,34 +4,18 @@ using OpenTK.Graphics.OpenGL4; using SM.Base.PostProcess; using SM.Base.Utility; using SM.OGL.Framebuffer; -using SM.OGL.Shaders; -using System.Collections.Generic; #endregion namespace SM.Base.PostEffects { - public enum HDRColorCurve - { - OnlyExposure, - Reinhard, - ACES - } - /// /// This class has some utility for render pipelines /// public static class PostProcessUtility { - public static readonly ShaderFile HDRCurves = new ShaderFile(AssemblyUtility.ReadAssemblyFile(SMRenderer.PostProcessPath + ".hdr_curves.frag")); - private static readonly string _finalizeHdrCode = AssemblyUtility.ReadAssemblyFile(SMRenderer.PostProcessPath + ".finalize_hdr.glsl"); - - private static readonly Dictionary _hdrExposureShader = new Dictionary() - { - { HDRColorCurve.OnlyExposure, new PostProcessShader(new ShaderFile(_finalizeHdrCode) {GLSLExtensions = { HDRCurves } }) }, - { HDRColorCurve.Reinhard, new PostProcessShader(new ShaderFile(_finalizeHdrCode) { GLSLExtensions = { HDRCurves }, Defines = { "TYPE_REINHARD" } }) }, - { HDRColorCurve.ACES, new PostProcessShader(new ShaderFile(_finalizeHdrCode) { GLSLExtensions = { HDRCurves }, Defines = { "TYPE_ACES" } }) }, - }; + private static readonly PostProcessShader _hdrExposureShader = + new PostProcessShader(AssemblyUtility.ReadAssemblyFile(SMRenderer.PostProcessPath + ".finalize_hdr.glsl")); private static readonly PostProcessShader _gammaShader = new PostProcessShader( @@ -54,7 +38,7 @@ namespace SM.Base.PostEffects target.Activate(FramebufferTarget.DrawFramebuffer); GL.BlitFramebuffer(0, 0, (int) multisampledBuffers.Size.X, (int) multisampledBuffers.Size.Y, 0, 0, (int) target.Size.X, (int) target.Size.Y, ClearBufferMask.ColorBufferBit, - BlitFramebufferFilter.Linear); + BlitFramebufferFilter.Nearest); target.Activate(); } @@ -64,12 +48,12 @@ namespace SM.Base.PostEffects /// /// /// - public static void FinalizeHDR(ColorAttachment attachment, HDRColorCurve colorCurve = HDRColorCurve.ACES, float exposure = 1) + public static void FinalizeHDR(ColorAttachment attachment, float exposure) { - _hdrExposureShader[colorCurve].Draw(u => + _hdrExposureShader.Draw(u => { - u["Gamma"].SetFloat(Gamma); - u["Exposure"].SetFloat(exposure); + u["Gamma"].SetUniform1(Gamma); + u["Exposure"].SetUniform1(exposure); u["Scene"].SetTexture(attachment); }); } @@ -82,7 +66,7 @@ namespace SM.Base.PostEffects { _gammaShader.Draw(u => { - u["Gamma"].SetFloat(Gamma); + u["Gamma"].SetUniform1(Gamma); u["Scene"].SetTexture(attachment); }); } diff --git a/src/renderer/SM.Base/Legacy/PostProcessing/bloom_blur.glsl b/SMCode/SM.Base/PostEffects/Shaders/bloom_blur.glsl similarity index 92% rename from src/renderer/SM.Base/Legacy/PostProcessing/bloom_blur.glsl rename to SMCode/SM.Base/PostEffects/Shaders/bloom_blur.glsl index c6bb97a..834ad23 100644 --- a/src/renderer/SM.Base/Legacy/PostProcessing/bloom_blur.glsl +++ b/SMCode/SM.Base/PostEffects/Shaders/bloom_blur.glsl @@ -1,4 +1,5 @@ #version 330 +#define PI 3.14159265359 uniform sampler2D renderedTexture; uniform float RenderScale; @@ -15,7 +16,6 @@ uniform float Power; uniform float Radius; layout(location = 0) out vec4 color; -layout(location = 1) out vec4 scene; vec4 GetRenderColorOffset(vec2 offset); @@ -31,8 +31,6 @@ float GetWeight(int dif) { } void main() { - if (First) scene = GetRenderColorOffset(vec2(0)); - vec3 thres = vec3(First ? Threshold : 0); vec2 tex_offset = 1.0 / textureSize(renderedTexture, 0) * vec2(Horizontal ? 1 : 0, Horizontal ? 0 : 1); diff --git a/src/renderer/SM.Base/Legacy/PostProcessing/bloom_merge.glsl b/SMCode/SM.Base/PostEffects/Shaders/bloom_merge.glsl similarity index 79% rename from src/renderer/SM.Base/Legacy/PostProcessing/bloom_merge.glsl rename to SMCode/SM.Base/PostEffects/Shaders/bloom_merge.glsl index 77a8937..cef9313 100644 --- a/src/renderer/SM.Base/Legacy/PostProcessing/bloom_merge.glsl +++ b/SMCode/SM.Base/PostEffects/Shaders/bloom_merge.glsl @@ -18,7 +18,7 @@ layout(location = 0) out vec4 color; void main() { vec3 result = texture(Bloom, vTexture).rgb; - //if (HasAmountMap) result *= clamp(length(texture(AmountMap, TransformedTexture).rgb) * (MaxAmount - MinAmount) + MinAmount, 0, 1); + if (HasAmountMap) result *= clamp(length(texture(AmountMap, TransformedTexture).rgb) * (MaxAmount - MinAmount) + MinAmount, 0, 1); if (!HDR) { result = vec3(1.0) - exp(-result * Exposure); } diff --git a/src/renderer/SM.Base/Legacy/PostProcessing/bloom_merge.vert b/SMCode/SM.Base/PostEffects/Shaders/bloom_merge_vert.glsl similarity index 55% rename from src/renderer/SM.Base/Legacy/PostProcessing/bloom_merge.vert rename to SMCode/SM.Base/PostEffects/Shaders/bloom_merge_vert.glsl index 4d20506..127a8b5 100644 --- a/src/renderer/SM.Base/Legacy/PostProcessing/bloom_merge.vert +++ b/SMCode/SM.Base/PostEffects/Shaders/bloom_merge_vert.glsl @@ -1,18 +1,11 @@ #version 330 -layout(location = 0) in vec3 aPos; layout(location = 1) in vec2 aTex; -uniform mat4 MVP; uniform mat3 TextureTransform; -out vec2 vTexture; out vec2 TransformedTexture; - -void main() { - vTexture = aTex; +void vertex() { TransformedTexture = vec2(TextureTransform * vec3(aTex, 1)); - - gl_Position = MVP * vec4(aPos, 1); } \ No newline at end of file diff --git a/src/renderer/SM.Base/PostEffects/Shaders/finalize_gamma.glsl b/SMCode/SM.Base/PostEffects/Shaders/finalize_gamma.glsl similarity index 100% rename from src/renderer/SM.Base/PostEffects/Shaders/finalize_gamma.glsl rename to SMCode/SM.Base/PostEffects/Shaders/finalize_gamma.glsl diff --git a/SMCode/SM.Base/PostEffects/Shaders/finalize_hdr.glsl b/SMCode/SM.Base/PostEffects/Shaders/finalize_hdr.glsl new file mode 100644 index 0000000..59406bc --- /dev/null +++ b/SMCode/SM.Base/PostEffects/Shaders/finalize_hdr.glsl @@ -0,0 +1,15 @@ +#version 330 + +in vec2 vTexture; + +uniform sampler2D Scene; +uniform float Exposure; +uniform float Gamma; + +layout(location = 0) out vec4 color; + +void main() { + vec3 result = vec3(1) - exp(-texture(Scene, vTexture).rgb * Exposure); + + color = vec4(pow(result, vec3(1 / Gamma)), 1); +} \ No newline at end of file diff --git a/src/renderer/SM.Base/PostProcess/DefaultFiles/extensions.frag b/SMCode/SM.Base/PostProcess/DefaultFiles/extensions.frag similarity index 100% rename from src/renderer/SM.Base/PostProcess/DefaultFiles/extensions.frag rename to SMCode/SM.Base/PostProcess/DefaultFiles/extensions.frag diff --git a/src/renderer/SM.Base/PostProcess/DefaultFiles/vertexFile.vert b/SMCode/SM.Base/PostProcess/DefaultFiles/vertexFile.vert similarity index 100% rename from src/renderer/SM.Base/PostProcess/DefaultFiles/vertexFile.vert rename to SMCode/SM.Base/PostProcess/DefaultFiles/vertexFile.vert diff --git a/src/renderer/SM.Base/PostProcess/DefaultFiles/vertexWithExt.vert b/SMCode/SM.Base/PostProcess/DefaultFiles/vertexWithExt.vert similarity index 100% rename from src/renderer/SM.Base/PostProcess/DefaultFiles/vertexWithExt.vert rename to SMCode/SM.Base/PostProcess/DefaultFiles/vertexWithExt.vert diff --git a/src/renderer/SM.Base/PostProcess/PostProcessEffect.cs b/SMCode/SM.Base/PostProcess/PostProcessEffect.cs similarity index 61% rename from src/renderer/SM.Base/PostProcess/PostProcessEffect.cs rename to SMCode/SM.Base/PostProcess/PostProcessEffect.cs index d60d22b..5a522cb 100644 --- a/src/renderer/SM.Base/PostProcess/PostProcessEffect.cs +++ b/SMCode/SM.Base/PostProcess/PostProcessEffect.cs @@ -3,7 +3,6 @@ using OpenTK; using SM.Base.Scene; using SM.Base.Window; -using SM.OGL.Framebuffer; #endregion @@ -24,12 +23,6 @@ namespace SM.Base.PostProcess /// protected RenderPipeline Pipeline; - /// - /// Enables the effect. - /// Default: true - /// - public bool Enable = true; - /// /// Initialize the effect. /// @@ -47,20 +40,11 @@ namespace SM.Base.PostProcess { } - /// - /// This executes - /// - /// - /// - public void Draw(ColorAttachment source, DrawContext context) - { - if (Enable) Drawing(source, context); - } /// /// Method to draw the actual effect. /// - protected abstract void Drawing(ColorAttachment source, DrawContext context); + public abstract void Draw(DrawContext context); /// /// Event, when the scene changed. @@ -68,14 +52,5 @@ namespace SM.Base.PostProcess public virtual void SceneChanged(GenericScene scene) { } - - /// - /// Event, when the screen size changed. - /// - /// Window that changed - public virtual void ScreenSizeChanged(IGenericWindow window) - { - - } } } \ No newline at end of file diff --git a/SMCode/SM.Base/PostProcess/PostProcessShader.cs b/SMCode/SM.Base/PostProcess/PostProcessShader.cs new file mode 100644 index 0000000..c364588 --- /dev/null +++ b/SMCode/SM.Base/PostProcess/PostProcessShader.cs @@ -0,0 +1,72 @@ +#region usings + +using System; +using System.Collections.Generic; +using OpenTK.Graphics.OpenGL4; +using SM.Base.Objects.Static; +using SM.Base.Utility; +using SM.OGL.Shaders; + +#endregion + +namespace SM.Base.PostProcess +{ + /// + /// Specific shader for post processing. + /// + public class PostProcessShader : GenericShader + { + private static readonly ShaderFile _fragExtensions = + new ShaderFile(AssemblyUtility.ReadAssemblyFile("SM.Base.PostProcess.DefaultFiles.extensions.frag")); + + private static readonly ShaderFile _normalVertex = + new ShaderFile(AssemblyUtility.ReadAssemblyFile("SM.Base.PostProcess.DefaultFiles.vertexFile.vert")); + + private static readonly string _normalVertexWithExt = + AssemblyUtility.ReadAssemblyFile("SM.Base.PostProcess.DefaultFiles.vertexWithExt.vert"); + + /// + /// Creates the shader with the default vertex shader and custom fragment. + /// + public PostProcessShader(string fragment) : this(_normalVertex, + new ShaderFile(fragment)) + { + } + + /// + /// Creates the shader with an vertex extension and custom fragment. + /// + /// + /// + public PostProcessShader(string vertexExt, string fragment) : this(new ShaderFile(_normalVertexWithExt) + { + GLSLExtensions = new List {new ShaderFile(vertexExt)} + }, new ShaderFile(fragment)) + { + } + + private PostProcessShader(ShaderFile vertex, ShaderFile fragment) : base( + new ShaderFileCollection(vertex, fragment)) + { + fragment.GLSLExtensions.Add(_fragExtensions); + } + + /// + /// Draws the shader with special uniforms. + /// + /// + public void Draw(Action setUniformAction) + { + Activate(); + Plate.Object.Activate(); + + Uniforms["MVP"].SetMatrix4(PostProcessEffect.Mvp); + + setUniformAction(Uniforms); + + GL.DrawArrays(PrimitiveType.Quads, 0, 4); + + CleanUp(); + } + } +} \ No newline at end of file diff --git a/src/renderer/SM.Base/Properties/AssemblyInfo.cs b/SMCode/SM.Base/Properties/AssemblyInfo.cs similarity index 100% rename from src/renderer/SM.Base/Properties/AssemblyInfo.cs rename to SMCode/SM.Base/Properties/AssemblyInfo.cs diff --git a/src/renderer/SM.Base/SM.Base.csproj b/SMCode/SM.Base/SM.Base.csproj similarity index 79% rename from src/renderer/SM.Base/SM.Base.csproj rename to SMCode/SM.Base/SM.Base.csproj index 2f713e0..5e201f9 100644 --- a/src/renderer/SM.Base/SM.Base.csproj +++ b/SMCode/SM.Base/SM.Base.csproj @@ -1,7 +1,5 @@  - - @@ -18,7 +16,6 @@ true - true @@ -40,6 +37,23 @@ 4 latest + + + ..\..\packages\OpenTK.3.3.1\lib\net20\OpenTK.dll + + + + ..\..\..\IAmTwo - Kopie\packages\SharpFont.4.0.1\lib\net45\SharpFont.dll + + + + + + + + + + @@ -48,23 +62,21 @@ - - + + - - @@ -75,7 +87,7 @@ - + @@ -115,16 +127,25 @@ + + + {f604d684-bc1d-4819-88b5-8b5d03a17be0} + SM.OGL + + - - + + + + + @@ -133,50 +154,12 @@ - - - {f604d684-bc1d-4819-88b5-8b5d03a17be0} - SM.OGL - - - - - ..\..\..\packages\OpenTK.3.3.1\lib\net20\OpenTK.dll - - - ..\..\..\packages\SharpFont.4.0.1\lib\net45\SharpFont.dll - True - - - - - - - - - - - - - - - - - - - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + \ No newline at end of file diff --git a/src/renderer/SM.Base/SM.Base.csproj.DotSettings b/SMCode/SM.Base/SM.Base.csproj.DotSettings similarity index 100% rename from src/renderer/SM.Base/SM.Base.csproj.DotSettings rename to SMCode/SM.Base/SM.Base.csproj.DotSettings diff --git a/src/renderer/SM.Base/SMRenderer.cs b/SMCode/SM.Base/SMRenderer.cs similarity index 100% rename from src/renderer/SM.Base/SMRenderer.cs rename to SMCode/SM.Base/SMRenderer.cs diff --git a/src/renderer/SM.Base/Scene/GenericCamera.cs b/SMCode/SM.Base/Scene/GenericCamera.cs similarity index 100% rename from src/renderer/SM.Base/Scene/GenericCamera.cs rename to SMCode/SM.Base/Scene/GenericCamera.cs diff --git a/src/renderer/SM.Base/Scene/GenericItemCollection.cs b/SMCode/SM.Base/Scene/GenericItemCollection.cs similarity index 100% rename from src/renderer/SM.Base/Scene/GenericItemCollection.cs rename to SMCode/SM.Base/Scene/GenericItemCollection.cs diff --git a/src/renderer/SM.Base/Scene/GenericScene.cs b/SMCode/SM.Base/Scene/GenericScene.cs similarity index 100% rename from src/renderer/SM.Base/Scene/GenericScene.cs rename to SMCode/SM.Base/Scene/GenericScene.cs diff --git a/src/renderer/SM.Base/Scene/IBackgroundItem.cs b/SMCode/SM.Base/Scene/IBackgroundItem.cs similarity index 100% rename from src/renderer/SM.Base/Scene/IBackgroundItem.cs rename to SMCode/SM.Base/Scene/IBackgroundItem.cs diff --git a/src/renderer/SM.Base/Scene/ICollectionItem.cs b/SMCode/SM.Base/Scene/ICollectionItem.cs similarity index 100% rename from src/renderer/SM.Base/Scene/ICollectionItem.cs rename to SMCode/SM.Base/Scene/ICollectionItem.cs diff --git a/src/renderer/SM.Base/Scene/IFixedScriptable.cs b/SMCode/SM.Base/Scene/IFixedScriptable.cs similarity index 100% rename from src/renderer/SM.Base/Scene/IFixedScriptable.cs rename to SMCode/SM.Base/Scene/IFixedScriptable.cs diff --git a/src/renderer/SM.Base/Scene/IScriptable.cs b/SMCode/SM.Base/Scene/IScriptable.cs similarity index 100% rename from src/renderer/SM.Base/Scene/IScriptable.cs rename to SMCode/SM.Base/Scene/IScriptable.cs diff --git a/src/renderer/SM.Base/Scene/IShowCollection.cs b/SMCode/SM.Base/Scene/IShowCollection.cs similarity index 100% rename from src/renderer/SM.Base/Scene/IShowCollection.cs rename to SMCode/SM.Base/Scene/IShowCollection.cs diff --git a/src/renderer/SM.Base/Scene/IShowItem.cs b/SMCode/SM.Base/Scene/IShowItem.cs similarity index 100% rename from src/renderer/SM.Base/Scene/IShowItem.cs rename to SMCode/SM.Base/Scene/IShowItem.cs diff --git a/src/renderer/SM.Base/Shaders/Extensions/ExtensionManager.cs b/SMCode/SM.Base/Shaders/Extensions/ExtensionManager.cs similarity index 100% rename from src/renderer/SM.Base/Shaders/Extensions/ExtensionManager.cs rename to SMCode/SM.Base/Shaders/Extensions/ExtensionManager.cs diff --git a/src/renderer/SM.Base/Shaders/Extensions/fragment/noise.glsl b/SMCode/SM.Base/Shaders/Extensions/fragment/noise.glsl similarity index 100% rename from src/renderer/SM.Base/Shaders/Extensions/fragment/noise.glsl rename to SMCode/SM.Base/Shaders/Extensions/fragment/noise.glsl diff --git a/src/renderer/SM.Base/Shaders/Extensions/fragment/textureGamma.glsl b/SMCode/SM.Base/Shaders/Extensions/fragment/textureGamma.glsl similarity index 100% rename from src/renderer/SM.Base/Shaders/Extensions/fragment/textureGamma.glsl rename to SMCode/SM.Base/Shaders/Extensions/fragment/textureGamma.glsl diff --git a/src/renderer/SM.Base/Shaders/Extensions/vertex/basic.vert b/SMCode/SM.Base/Shaders/Extensions/vertex/basic.vert similarity index 100% rename from src/renderer/SM.Base/Shaders/Extensions/vertex/basic.vert rename to SMCode/SM.Base/Shaders/Extensions/vertex/basic.vert diff --git a/src/renderer/SM.Base/Shaders/MaterialShader.cs b/SMCode/SM.Base/Shaders/MaterialShader.cs similarity index 88% rename from src/renderer/SM.Base/Shaders/MaterialShader.cs rename to SMCode/SM.Base/Shaders/MaterialShader.cs index 10c3387..470ad01 100644 --- a/src/renderer/SM.Base/Shaders/MaterialShader.cs +++ b/SMCode/SM.Base/Shaders/MaterialShader.cs @@ -37,7 +37,6 @@ namespace SM.Base.Shaders /// The context public virtual void Draw(DrawContext context) { - if (ErrorInShader) return; context.Shader.Activate(); context.Mesh.Activate(); @@ -46,7 +45,9 @@ namespace SM.Base.Shaders { try { - if (context.Material.ShaderArguments.ContainsKey("LineWidth")) + if (context.Mesh is ILineMesh lineMesh) + GL.LineWidth(context.Material.ShaderArguments.Get("LineWidth", lineMesh.LineWidth)); + else if (context.Material.ShaderArguments.ContainsKey("LineWidth")) GL.LineWidth((float)context.Material.ShaderArguments["LineWidth"]); } catch diff --git a/src/renderer/SM.Base/Shaders/SimpleShader.cs b/SMCode/SM.Base/Shaders/SimpleShader.cs similarity index 96% rename from src/renderer/SM.Base/Shaders/SimpleShader.cs rename to SMCode/SM.Base/Shaders/SimpleShader.cs index 5db13b4..e068e12 100644 --- a/src/renderer/SM.Base/Shaders/SimpleShader.cs +++ b/SMCode/SM.Base/Shaders/SimpleShader.cs @@ -101,19 +101,17 @@ namespace SM.Base.Shaders .SetMatrix4(context.Instances[0].ModelMatrix * context.ModelMatrix * context.View * context.World); uniforms["MasterTextureMatrix"].SetMatrix3(context.Instances[0].TextureMatrix * context.TextureMatrix); uniforms["HasVColor"] - .SetBool(context.Mesh.Attributes.Has("color")); + .SetUniform1(context.Mesh.Attributes.Has("color")); DrawObject(context.ForcedType.GetValueOrDefault(context.Mesh.PrimitiveType), context.Mesh); } private static void InstancedSetUniforms(UniformCollection uniforms, DrawContext context) { - if (context.Instances == null || context.Instances.Count < 1) return; - uniforms["MVP"].SetMatrix4(context.ModelMatrix * context.View * context.World); uniforms["MasterTextureMatrix"].SetMatrix3(context.TextureMatrix); uniforms["HasVColor"] - .SetBool(context.Mesh.Attributes.Has("color")); + .SetUniform1(context.Mesh.Attributes.Has("color")); UniformArray instances = uniforms.GetArray("Instances"); diff --git a/src/renderer/SM.Base/Shaders/SimpleShaderPresets/basic_vertex.glsl b/SMCode/SM.Base/Shaders/SimpleShaderPresets/basic_vertex.glsl similarity index 75% rename from src/renderer/SM.Base/Shaders/SimpleShaderPresets/basic_vertex.glsl rename to SMCode/SM.Base/Shaders/SimpleShaderPresets/basic_vertex.glsl index 5dd3936..503fb5a 100644 --- a/src/renderer/SM.Base/Shaders/SimpleShaderPresets/basic_vertex.glsl +++ b/SMCode/SM.Base/Shaders/SimpleShaderPresets/basic_vertex.glsl @@ -1,4 +1,5 @@ #version 330 +#define SM_SIMPLE_EXTENSION //!extension layout(location = 0) in vec3 a_Position; layout(location = 1) in vec2 a_Texture; @@ -12,6 +13,10 @@ out vec3 v_VertexPosition; out vec2 v_TexCoords; out vec4 v_Color; +#if (SM_SIMPLE_EXTENSION == 1) +void v_Extension(); +#endif + void main() { v_Color = vec4(1); if (HasVColor) v_Color = a_Color; @@ -21,5 +26,7 @@ void main() { v_VertexPosition = a_Position; gl_Position = MVP * vec4(a_Position, 1); - + #if (SM_SIMPLE_EXTENSION == 1) + v_Extension(); + #endif } \ No newline at end of file diff --git a/src/renderer/SM.Base/Shaders/SimpleShaderPresets/instanced_vertex.glsl b/SMCode/SM.Base/Shaders/SimpleShaderPresets/instanced_vertex.glsl similarity index 81% rename from src/renderer/SM.Base/Shaders/SimpleShaderPresets/instanced_vertex.glsl rename to SMCode/SM.Base/Shaders/SimpleShaderPresets/instanced_vertex.glsl index 1f594ae..3565cf6 100644 --- a/src/renderer/SM.Base/Shaders/SimpleShaderPresets/instanced_vertex.glsl +++ b/SMCode/SM.Base/Shaders/SimpleShaderPresets/instanced_vertex.glsl @@ -1,5 +1,6 @@ #version 330 #define maxInstances //!instanceMax +#define SM_SIMPLE_EXTENSION //!extension struct Instance { mat4 ModelMatrix; @@ -19,6 +20,10 @@ out vec3 v_VertexPosition; out vec2 v_TexCoords; out vec4 v_Color; +#if (SM_SIMPLE_EXTENSION == 1) +void v_Extension(); +#endif + void main() { v_Color = vec4(1); if (HasVColor) v_Color = a_Color; @@ -28,4 +33,7 @@ void main() { v_VertexPosition = a_Position; gl_Position = MVP * Instances[gl_InstanceID].ModelMatrix * vec4(a_Position, 1); + #if (SM_SIMPLE_EXTENSION == 1) + v_Extension(); + #endif } \ No newline at end of file diff --git a/src/renderer/SM.Base/Textures/Texture.cs b/SMCode/SM.Base/Textures/Texture.cs similarity index 100% rename from src/renderer/SM.Base/Textures/Texture.cs rename to SMCode/SM.Base/Textures/Texture.cs diff --git a/src/renderer/SM.Base/Time/Interval.cs b/SMCode/SM.Base/Time/Interval.cs similarity index 100% rename from src/renderer/SM.Base/Time/Interval.cs rename to SMCode/SM.Base/Time/Interval.cs diff --git a/src/renderer/SM.Base/Time/Stopwatch.cs b/SMCode/SM.Base/Time/Stopwatch.cs similarity index 100% rename from src/renderer/SM.Base/Time/Stopwatch.cs rename to SMCode/SM.Base/Time/Stopwatch.cs diff --git a/src/renderer/SM.Base/Time/Timer.cs b/SMCode/SM.Base/Time/Timer.cs similarity index 97% rename from src/renderer/SM.Base/Time/Timer.cs rename to SMCode/SM.Base/Time/Timer.cs index 15ff2bd..f6e3c37 100644 --- a/src/renderer/SM.Base/Time/Timer.cs +++ b/SMCode/SM.Base/Time/Timer.cs @@ -33,7 +33,7 @@ namespace SM.Base.Time /// /// The target time in seconds. /// - public float Target { get; set; } + public float Target { get; } /// /// The already elapsed time but normalized to the target. diff --git a/src/renderer/SM.Base/Types/CVector1.cs b/SMCode/SM.Base/Types/CVector1.cs similarity index 71% rename from src/renderer/SM.Base/Types/CVector1.cs rename to SMCode/SM.Base/Types/CVector1.cs index 891e8ea..b2a80f9 100644 --- a/src/renderer/SM.Base/Types/CVector1.cs +++ b/SMCode/SM.Base/Types/CVector1.cs @@ -28,6 +28,21 @@ namespace SM.Base.Types /// public float X { get; set; } + /// + /// Interpolates the motion to the target. + /// + /// How long the interpolation should take. + /// The value it should interpolate. + /// The curve how he interpolates. Preset values can be found under . Default: + /// A handle to control the interpolation process. + public InterpolationProcess Interpolate(TimeSpan duration, float to, BezierCurve? interpolationCurve = null) + { + InterpolationProcess process = new InterpolationProcess(this, duration, ConvertToVector4(), new Vector4(to, 0, 0, 0), interpolationCurve.GetValueOrDefault(AnimationCurves.Linear)); + process.Start(); + + return process; + } + /// /// Sets the X-Component. /// diff --git a/src/renderer/SM.Base/Types/CVector2.cs b/SMCode/SM.Base/Types/CVector2.cs similarity index 77% rename from src/renderer/SM.Base/Types/CVector2.cs rename to SMCode/SM.Base/Types/CVector2.cs index 5f89219..8063c6b 100644 --- a/src/renderer/SM.Base/Types/CVector2.cs +++ b/SMCode/SM.Base/Types/CVector2.cs @@ -34,7 +34,26 @@ namespace SM.Base.Types /// Y-component /// public float Y { get; set; } - + + /// + /// Interpolates the motion to the target. + /// + /// How long the interpolation should take. + /// The value it should interpolate. + /// The curve how he interpolates. + /// When creating a curve, its recommended the Y-component is always between 0 -> 1. But it could make cool effects if not... + /// Preset curves can be found under . + /// Default: + /// + /// A handle to control the interpolation process. + public InterpolationProcess Interpolate(TimeSpan duration, Vector2 to, BezierCurve? interpolationCurve = null) + { + InterpolationProcess process = new InterpolationProcess(this, duration, ConvertToVector4(), new Vector4(to), interpolationCurve.GetValueOrDefault(AnimationCurves.Linear)); + process.Start(); + + return process; + } + /// public override string ToString() { diff --git a/src/renderer/SM.Base/Types/CVector3.cs b/SMCode/SM.Base/Types/CVector3.cs similarity index 81% rename from src/renderer/SM.Base/Types/CVector3.cs rename to SMCode/SM.Base/Types/CVector3.cs index e5dfd92..64231f0 100644 --- a/src/renderer/SM.Base/Types/CVector3.cs +++ b/SMCode/SM.Base/Types/CVector3.cs @@ -34,7 +34,22 @@ namespace SM.Base.Types /// Z-component /// public float Z { get; set; } - + + /// + /// Interpolates the motion to the target. + /// + /// How long the interpolation should take. + /// The value it should interpolate. + /// The curve how he interpolates. Preset values can be found under . Default: + /// A handle to control the interpolation process. + public InterpolationProcess Interpolate(TimeSpan duration, Vector3 to, BezierCurve? interpolationCurve = null) + { + InterpolationProcess process = new InterpolationProcess(this, duration, ConvertToVector4(), new Vector4(to, 0), interpolationCurve.GetValueOrDefault(AnimationCurves.Linear)); + process.Start(); + + return process; + } + /// public override string ToString() diff --git a/src/renderer/SM.Base/Types/CVector4.cs b/SMCode/SM.Base/Types/CVector4.cs similarity index 80% rename from src/renderer/SM.Base/Types/CVector4.cs rename to SMCode/SM.Base/Types/CVector4.cs index 90addab..2f88938 100644 --- a/src/renderer/SM.Base/Types/CVector4.cs +++ b/SMCode/SM.Base/Types/CVector4.cs @@ -1,4 +1,5 @@ using System; +using System.Windows.Forms; using OpenTK; using SM.Base.Animation; @@ -23,7 +24,22 @@ namespace SM.Base.Types { W = w; } - + + /// + /// Interpolates the motion to the target. + /// + /// How long the interpolation should take. + /// The value it should interpolate. + /// The curve how he interpolates. Preset values can be found under . Default: + /// A handle to control the interpolation process. + public InterpolationProcess Interpolate(TimeSpan duration, Vector4 to, BezierCurve? interpolationCurve = null) + { + InterpolationProcess process = new InterpolationProcess(this, duration, ConvertToVector4(), to, interpolationCurve.GetValueOrDefault(AnimationCurves.Linear)); + process.Start(); + + return process; + } + /// public override void Set(float uniform, bool triggerChanged = true) { diff --git a/SMCode/SM.Base/Types/CVectorBase.cs b/SMCode/SM.Base/Types/CVectorBase.cs new file mode 100644 index 0000000..2340b84 --- /dev/null +++ b/SMCode/SM.Base/Types/CVectorBase.cs @@ -0,0 +1,83 @@ +using System; +using OpenTK; + +namespace SM.Base.Types +{ + /// + /// Basis for the CVector classes + /// + public abstract class CVectorBase + { + /// + /// This event triggers when a component changed. + /// + public event Action Changed; + + /// + /// The length/magnitute of the vector. + /// + public float Length => GetLength(); + + /// + /// Gets the square of the vector length (magnitude). + /// + /// + /// This property avoids the costly square root operation required by the Length property. This makes it more suitable + /// for comparisons. + /// + public float LengthSquared => GetLength(true); + + /// + /// Get the length of the vector. + /// + /// If true, it will return the squared product. + /// + public float GetLength(bool squared = false) + { + float length = GetLengthProcess(); + if (squared) return length; + return (float)Math.Sqrt(length); + } + + /// + /// Normalizes the vector. + /// + public void Normalize() + { + float length = GetLength(); + NormalizationProcess(length); + } + + /// + /// Sets the values of the vector, by providing the values over an array. + /// + /// + public abstract void SetRaw(params float[] parameters); + + /// + /// This triggers the event. + /// + protected void TriggerChanged() + { + Changed?.Invoke(); + } + + /// + /// Conversion from to One-dimensional Vector. + /// + /// + protected abstract float GetLengthProcess(); + + /// + /// Normalizes the vector. + /// + /// + protected abstract void NormalizationProcess(float length); + + /// + /// Converts the vector to a + /// + /// + protected abstract Vector4 ConvertToVector4(); + } +} \ No newline at end of file diff --git a/src/renderer/SM.Base/Utility/Assembly.cs b/SMCode/SM.Base/Utility/Assembly.cs similarity index 100% rename from src/renderer/SM.Base/Utility/Assembly.cs rename to SMCode/SM.Base/Utility/Assembly.cs diff --git a/src/renderer/SM.Base/Utility/Deltatime.cs b/SMCode/SM.Base/Utility/Deltatime.cs similarity index 100% rename from src/renderer/SM.Base/Utility/Deltatime.cs rename to SMCode/SM.Base/Utility/Deltatime.cs diff --git a/src/renderer/SM.Base/Utility/IInitializable.cs b/SMCode/SM.Base/Utility/IInitializable.cs similarity index 100% rename from src/renderer/SM.Base/Utility/IInitializable.cs rename to SMCode/SM.Base/Utility/IInitializable.cs diff --git a/src/renderer/SM.Base/Utility/Randomize.cs b/SMCode/SM.Base/Utility/Randomize.cs similarity index 100% rename from src/renderer/SM.Base/Utility/Randomize.cs rename to SMCode/SM.Base/Utility/Randomize.cs diff --git a/src/renderer/SM.Base/Utility/Ray.cs b/SMCode/SM.Base/Utility/Ray.cs similarity index 100% rename from src/renderer/SM.Base/Utility/Ray.cs rename to SMCode/SM.Base/Utility/Ray.cs diff --git a/src/renderer/SM.Base/Utility/RotationUtility.cs b/SMCode/SM.Base/Utility/RotationUtility.cs similarity index 100% rename from src/renderer/SM.Base/Utility/RotationUtility.cs rename to SMCode/SM.Base/Utility/RotationUtility.cs diff --git a/src/renderer/SM.Base/Utility/Util.cs b/SMCode/SM.Base/Utility/Util.cs similarity index 100% rename from src/renderer/SM.Base/Utility/Util.cs rename to SMCode/SM.Base/Utility/Util.cs diff --git a/src/renderer/SM.Base/Window/Contexts/DrawContext.cs b/SMCode/SM.Base/Window/Contexts/DrawContext.cs similarity index 100% rename from src/renderer/SM.Base/Window/Contexts/DrawContext.cs rename to SMCode/SM.Base/Window/Contexts/DrawContext.cs diff --git a/src/renderer/SM.Base/Window/Contexts/FixedUpdateContext.cs b/SMCode/SM.Base/Window/Contexts/FixedUpdateContext.cs similarity index 100% rename from src/renderer/SM.Base/Window/Contexts/FixedUpdateContext.cs rename to SMCode/SM.Base/Window/Contexts/FixedUpdateContext.cs diff --git a/src/renderer/SM.Base/Window/Contexts/UpdateContext.cs b/SMCode/SM.Base/Window/Contexts/UpdateContext.cs similarity index 100% rename from src/renderer/SM.Base/Window/Contexts/UpdateContext.cs rename to SMCode/SM.Base/Window/Contexts/UpdateContext.cs diff --git a/src/renderer/SM.Base/Window/GLWindow.cs b/SMCode/SM.Base/Window/GLWindow.cs similarity index 100% rename from src/renderer/SM.Base/Window/GLWindow.cs rename to SMCode/SM.Base/Window/GLWindow.cs diff --git a/src/renderer/SM.Base/Window/IGenericWindow.cs b/SMCode/SM.Base/Window/IGenericWindow.cs similarity index 100% rename from src/renderer/SM.Base/Window/IGenericWindow.cs rename to SMCode/SM.Base/Window/IGenericWindow.cs diff --git a/src/renderer/SM.Base/Window/ISetup.cs b/SMCode/SM.Base/Window/ISetup.cs similarity index 100% rename from src/renderer/SM.Base/Window/ISetup.cs rename to SMCode/SM.Base/Window/ISetup.cs diff --git a/src/renderer/SM.Base/Window/RenderPipeline.cs b/SMCode/SM.Base/Window/RenderPipeline.cs similarity index 70% rename from src/renderer/SM.Base/Window/RenderPipeline.cs rename to SMCode/SM.Base/Window/RenderPipeline.cs index 19afdb0..b9f89dd 100644 --- a/src/renderer/SM.Base/Window/RenderPipeline.cs +++ b/SMCode/SM.Base/Window/RenderPipeline.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Threading; using SM.Base.Drawing; -using SM.Base.PostProcess; using SM.Base.Shaders; using SM.Base.Utility; using SM.OGL.Framebuffer; @@ -18,11 +17,6 @@ namespace SM.Base.Window /// public abstract class RenderPipeline : IInitializable { - /// - /// All post processing effects should go here, that should be automaticly managed. - /// - protected List PostProcessEffects = new List(); - /// /// This contains the windows its connected to. /// @@ -53,26 +47,19 @@ namespace SM.Base.Window /// public virtual void Activate() - { } - public void Initialization() { - InitializationProcess(); + } - InitizePostProcessing(); - if (MainFramebuffer != null) - { + /// + public virtual void Initialization() + { + if (MainFramebuffer != null) { Framebuffers.Add(MainFramebuffer); MainFramebuffer.Name = GetType().Name + ".MainFramebuffer"; } DefaultShader ??= SMRenderer.DefaultMaterialShader; } - /// - protected virtual void InitializationProcess() - { - - } - internal void Render(ref DrawContext context) { RenderProcess(ref context); @@ -86,26 +73,11 @@ namespace SM.Base.Window /// /// The event when resizing. /// - public virtual void Resize(IGenericWindow window) + public virtual void Resize() { Recompile(); - - foreach (PostProcessEffect effect in PostProcessEffects) - { - effect.ScreenSizeChanged(window); - } } - /// - /// Initilizes the collected post processing effects. - /// - protected void InitizePostProcessing() - { - foreach (PostProcessEffect effect in PostProcessEffects) - { - effect.Initilize(this); - } - } /// /// Compiles the framebuffers. @@ -141,20 +113,14 @@ namespace SM.Base.Window /// /// This creates a finished setup for a framebuffer. /// - public Framebuffer CreateWindowFramebuffer(int multisamples = 0, PixelInformation? pixelInformation = null, bool depth = true) => - CreateWindowFramebuffer(ConnectedWindow, multisamples, pixelInformation, depth); - - /// - /// This creates a finished setup for a framebuffer. - /// - public static Framebuffer CreateWindowFramebuffer(IFramebufferWindow window, int multisamples = 0, PixelInformation? pixelInformation = null, bool depth = true) + public Framebuffer CreateWindowFramebuffer(int multisamples = 0, PixelInformation? pixelInformation = null, bool depth = true) { - Framebuffer framebuffer = new Framebuffer(window); - framebuffer.Append("color", new ColorAttachment(0, pixelInformation.GetValueOrDefault(PixelInformation.RGBA_LDR), multisamples:multisamples)); + Framebuffer framebuffer = new(ConnectedWindow); + framebuffer.Append("color", new ColorAttachment(0, pixelInformation.GetValueOrDefault(PixelInformation.RGBA_LDR), multisamples)); if (depth) { - RenderbufferAttachment depthAttach = RenderbufferAttachment.GenerateDepth(); + RenderbufferAttachment depthAttach = RenderbufferAttachment.Depth; depthAttach.Multisample = multisamples; framebuffer.AppendRenderbuffer(depthAttach); } diff --git a/src/renderer/SM.Base/Window/WindowCode.cs b/SMCode/SM.Base/Window/WindowCode.cs similarity index 96% rename from src/renderer/SM.Base/Window/WindowCode.cs rename to SMCode/SM.Base/Window/WindowCode.cs index 8cdd501..6270a52 100644 --- a/src/renderer/SM.Base/Window/WindowCode.cs +++ b/SMCode/SM.Base/Window/WindowCode.cs @@ -60,17 +60,14 @@ namespace SM.Base.Window { window.WindowSize = new Vector2(window.Width, window.Height); window.AspectRatio = (float) window.Width / window.Height; + GL.Viewport(window.ClientRectangle); - if (window.WindowSize.LengthSquared == 0) return; - - GL.Viewport(window.ClientRectangle); - + window.CurrentRenderPipeline?.Resize(); PostProcessEffect.Mvp = Matrix4.CreateScale(window.Width, -window.Height, 1) * Matrix4.LookAt(Vector3.UnitZ, Vector3.Zero, Vector3.UnitY) * Matrix4.CreateOrthographic(window.Width, window.Height, .1f, 100f); - window.CurrentRenderPipeline?.Resize(window); window.AppliedSetup?.Resize(window); } diff --git a/src/renderer/SM.Base/Window/WindowFlags.cs b/SMCode/SM.Base/Window/WindowFlags.cs similarity index 100% rename from src/renderer/SM.Base/Window/WindowFlags.cs rename to SMCode/SM.Base/Window/WindowFlags.cs diff --git a/src/renderer/SM.Base/Window/winIcon.ico b/SMCode/SM.Base/Window/winIcon.ico similarity index 100% rename from src/renderer/SM.Base/Window/winIcon.ico rename to SMCode/SM.Base/Window/winIcon.ico diff --git a/src/renderer/SM.Base/packages.config b/SMCode/SM.Base/packages.config similarity index 77% rename from src/renderer/SM.Base/packages.config rename to SMCode/SM.Base/packages.config index 85e4bbb..e8dfb8b 100644 --- a/src/renderer/SM.Base/packages.config +++ b/SMCode/SM.Base/packages.config @@ -1,6 +1,6 @@  - + \ No newline at end of file diff --git a/src/renderer/SM.OGL/Framebuffer/ColorAttachment.cs b/SMCode/SM.OGL/Framebuffer/ColorAttachment.cs similarity index 60% rename from src/renderer/SM.OGL/Framebuffer/ColorAttachment.cs rename to SMCode/SM.OGL/Framebuffer/ColorAttachment.cs index 0592e2e..cf3678a 100644 --- a/src/renderer/SM.OGL/Framebuffer/ColorAttachment.cs +++ b/SMCode/SM.OGL/Framebuffer/ColorAttachment.cs @@ -1,7 +1,6 @@ #region usings using System; -using OpenTK; using OpenTK.Graphics.OpenGL4; using SM.OGL.Texture; @@ -22,18 +21,6 @@ namespace SM.OGL.Framebuffer /// public int AttachmentID { get; } - /// - /// Contains the framebuffer its connected. - /// Usually the last framebuffer, that called the Compile-method. - /// - public Framebuffer ConnectedFramebuffer { get; private set; } - - /// - /// Can contains the size this attachment want to be. - /// If set, it will ignore the size from the framebuffer. - /// - public Vector2? AttachmentSize = null; - /// /// Returns the of this ColorAttachment. /// @@ -60,8 +47,7 @@ namespace SM.OGL.Framebuffer /// Creates a attachment with a specific id. /// /// - /// - public ColorAttachment(int attachmentId, Vector2? size = null) : this(attachmentId, PixelInformation.RGBA_LDR, size) + public ColorAttachment(int attachmentId) : this(attachmentId, PixelInformation.RGBA_LDR) { } /// @@ -69,19 +55,13 @@ namespace SM.OGL.Framebuffer /// /// /// - /// /// - public ColorAttachment(int attachmentID, PixelInformation pixelInformation, Vector2? size = null, int multisamples = 0) + public ColorAttachment(int attachmentID, PixelInformation pixelInformation, int multisamples = 0) { AttachmentID = attachmentID; PixelInformation = pixelInformation; - AttachmentSize = size; - - if (multisamples > 8) multisamples = 8; _multisamples = multisamples; Target = IsMultisampled ? TextureTarget.Texture2DMultisample : TextureTarget.Texture2D; - - WrapMode = TextureWrapMode.ClampToEdge; } /// /// Generates the attachment. @@ -90,7 +70,6 @@ namespace SM.OGL.Framebuffer public void Generate(Framebuffer f) { _id = GL.GenTexture(); - ConnectedFramebuffer = f; if (IsMultisampled) GenerateMultisampledTexture(f); else GenerateTexture(f); @@ -98,33 +77,29 @@ namespace SM.OGL.Framebuffer private void GenerateTexture(Framebuffer f) { - Vector2 size = AttachmentSize.GetValueOrDefault(f.Size); + GL.BindTexture(TextureTarget.Texture2D, _id); + GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInformation.InternalFormat, + (int)f.Size.X, (int)f.Size.Y, + 0, PixelInformation.Format, PixelInformation.DataType, IntPtr.Zero); - GenerateBaseTexture(size); + GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, + (int)TextureMinFilter.Linear); + GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, + + (int)TextureMinFilter.Linear); + GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, + (int)TextureParameterName.ClampToEdge); + GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, + (int)TextureParameterName.ClampToEdge); + + GL.BindTexture(TextureTarget.Texture2D, 0); } private void GenerateMultisampledTexture(Framebuffer f) { - Vector2 size = AttachmentSize.GetValueOrDefault(f.Size); - - Width = (int)size.X; - Height = (int)size.Y; - - const TextureTarget target = TextureTarget.Texture2DMultisample; - - GL.BindTexture(target, _id); - GL.TexImage2DMultisample((TextureTargetMultisample)target, _multisamples, PixelInformation.InternalFormat, - Width, Height, true); - /* - GL.TexParameter(target, TextureParameterName.TextureMinFilter, (int)Filter); - GL.TexParameter(target, TextureParameterName.TextureMagFilter, (int)Filter); - - GL.TexParameter(target, TextureParameterName.TextureWrapS, - (int)WrapMode); - GL.TexParameter(target, TextureParameterName.TextureWrapT, - (int)WrapMode);*/ - - GL.BindTexture(target, 0); + GL.BindTexture(TextureTarget.Texture2DMultisample, _id); + GL.TexImage2DMultisample(TextureTargetMultisample.Texture2DMultisample, _multisamples, PixelInformation.InternalFormat, (int)f.Size.X, (int)f.Size.Y, true); + GL.BindTexture(TextureTarget.Texture2DMultisample, 0); } } } \ No newline at end of file diff --git a/src/renderer/SM.OGL/Framebuffer/Framebuffer.cs b/SMCode/SM.OGL/Framebuffer/Framebuffer.cs similarity index 66% rename from src/renderer/SM.OGL/Framebuffer/Framebuffer.cs rename to SMCode/SM.OGL/Framebuffer/Framebuffer.cs index 6a817de..628e807 100644 --- a/src/renderer/SM.OGL/Framebuffer/Framebuffer.cs +++ b/SMCode/SM.OGL/Framebuffer/Framebuffer.cs @@ -15,10 +15,6 @@ namespace SM.OGL.Framebuffer /// public class Framebuffer : GLObject { - static Framebuffer CurrentlyActiveFramebuffer; - static Framebuffer CurrentlyActiveDrawFramebuffer; - static Framebuffer CurrentlyActiveReadFramebuffer; - /// protected override bool AutoCompile { get; set; } = true; @@ -50,16 +46,8 @@ namespace SM.OGL.Framebuffer /// public Vector2 Size { get; private set; } - /// - /// Says what value the dafault for the "applyViewport"-value in . - /// public bool DefaultApplyViewport { get; set; } = true; - /// - /// Stores the first color attachment added. - /// - public ColorAttachment FirstColorAttachment { get; private set; } - /// /// Contains all color attachments. /// @@ -68,7 +56,7 @@ namespace SM.OGL.Framebuffer /// /// Contains the current renderbuffer attachments of the framebuffer. /// - public List RenderbufferAttachments { get; } = new List(); + public Dictionary RenderbufferAttachments { get; } = new Dictionary(); /// /// Gets the color attachment with the specified color name. @@ -128,19 +116,15 @@ namespace SM.OGL.Framebuffer foreach (var pair in ColorAttachments) GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, pair.Value.FramebufferAttachment, pair.Value.Target, pair.Value.ID, 0); - FramebufferErrorCode err; - err = GL.CheckFramebufferStatus(FramebufferTarget.Framebuffer); - if (err != FramebufferErrorCode.FramebufferComplete) - throw new Exception("Failed loading framebuffer.\nProblem: " + err); - - foreach (RenderbufferAttachment attachment in RenderbufferAttachments) + foreach (RenderbufferAttachment attachment in RenderbufferAttachments.Keys.ToArray()) { - attachment.Generate(this); - GL.FramebufferRenderbuffer(FramebufferTarget.Framebuffer, attachment.FramebufferAttachment, RenderbufferTarget.Renderbuffer, attachment.ID); + int att = attachment.Generate(this); + GL.FramebufferRenderbuffer(FramebufferTarget.Framebuffer, attachment.FramebufferAttachment, RenderbufferTarget.Renderbuffer, att); + RenderbufferAttachments[attachment] = att; } - err = GL.CheckFramebufferStatus(FramebufferTarget.Framebuffer); + var err = GL.CheckFramebufferStatus(FramebufferTarget.Framebuffer); if (err != FramebufferErrorCode.FramebufferComplete) throw new Exception("Failed loading framebuffer.\nProblem: " + err); @@ -148,25 +132,15 @@ namespace SM.OGL.Framebuffer GL.BindTexture(TextureTarget.Texture2D, 0); } - /// - /// Disposes and clears the attachment - /// - public void Reset() - { - Dispose(); - ColorAttachments.Clear(); - RenderbufferAttachments.Clear(); - } - /// public override void Dispose() { - + foreach (var attachment in ColorAttachments.Values) attachment.Dispose(); - FirstColorAttachment = null; - foreach (RenderbufferAttachment pair in RenderbufferAttachments.ToArray()) + foreach (KeyValuePair pair in RenderbufferAttachments.ToArray()) { - GL.DeleteRenderbuffer(pair.ID); + GL.DeleteRenderbuffer(pair.Value); + RenderbufferAttachments[pair.Key] = -1; } GL.DeleteFramebuffer(this); base.Dispose(); @@ -176,20 +150,12 @@ namespace SM.OGL.Framebuffer /// /// Appends a color attachment. /// - public void Append(string key, int pos) => Append(key, new ColorAttachment(pos, null)); - /// - /// Appends a color attachment. - /// - /// - /// - /// - public void Append(string key, Vector2 size, int pos) => Append(key, new ColorAttachment(pos, size)); + public void Append(string key, int pos) => Append(key, new ColorAttachment(pos)); /// /// Appends a color attachment. /// public void Append(string key, ColorAttachment value) { - if (ColorAttachments.Count == 0) FirstColorAttachment = value; ColorAttachments.Add(key, value); } @@ -199,8 +165,7 @@ namespace SM.OGL.Framebuffer /// public void AppendRenderbuffer(RenderbufferAttachment attachment) { - if (RenderbufferAttachments.Contains(attachment)) return; - RenderbufferAttachments.Add(attachment); + RenderbufferAttachments.Add(attachment, -1); } /// @@ -215,7 +180,6 @@ namespace SM.OGL.Framebuffer /// Activates the framebuffer for the specific target framebuffer and without clearing. /// /// - /// public void Activate(FramebufferTarget target, bool? applyViewport = null) { Activate(target, ClearBufferMask.None, applyViewport); @@ -225,7 +189,6 @@ namespace SM.OGL.Framebuffer /// Activates the framebuffer while clearing the specified buffer. /// /// - /// public void Activate(ClearBufferMask clearMask, bool? applyViewport = null) { Activate(FramebufferTarget.Framebuffer, clearMask, applyViewport); @@ -236,58 +199,19 @@ namespace SM.OGL.Framebuffer /// /// /// - /// public void Activate(FramebufferTarget target, ClearBufferMask clear, bool? applyViewport = null) { - switch (target) - { - case FramebufferTarget.ReadFramebuffer: - CurrentlyActiveReadFramebuffer = this; - break; - case FramebufferTarget.DrawFramebuffer: - CurrentlyActiveDrawFramebuffer = this; - break; - case FramebufferTarget.Framebuffer: - CurrentlyActiveFramebuffer = this; - break; - } - GL.BindFramebuffer(target, this); - if (applyViewport.GetValueOrDefault(DefaultApplyViewport)) - GL.Viewport(0, 0, (int)Size.X, (int)Size.Y); + if (applyViewport.GetValueOrDefault(DefaultApplyViewport)) GL.Viewport(0, 0, (int)Size.X, (int)Size.Y); GL.Clear(clear); } - /// - /// Copies content to the specified Framebuffer. - /// - public void CopyTo(Framebuffer target, ClearBufferMask clear = ClearBufferMask.ColorBufferBit, BlitFramebufferFilter filter = BlitFramebufferFilter.Linear) - { - Activate(FramebufferTarget.ReadFramebuffer, false); - target.Activate(FramebufferTarget.DrawFramebuffer, false); - - GL.BlitFramebuffer(0, 0, (int)Size.X, (int)Size.Y, 0, 0, (int)Size.X, (int)Size.Y, clear, filter); - } - /// /// Returns a handle of the current framebuffer. /// /// /// public static Framebuffer GetCurrentlyActive(FramebufferTarget target = FramebufferTarget.Framebuffer) - { - switch (target) - { - case FramebufferTarget.ReadFramebuffer: - return CurrentlyActiveReadFramebuffer ??= getCurrentlyActive(target); - case FramebufferTarget.DrawFramebuffer: - return CurrentlyActiveDrawFramebuffer ??= getCurrentlyActive(target); - case FramebufferTarget.Framebuffer: - return CurrentlyActiveFramebuffer ??= getCurrentlyActive(target); - } - return null; - } - static Framebuffer getCurrentlyActive(FramebufferTarget target = FramebufferTarget.Framebuffer) { Framebuffer buffer = new Framebuffer() { @@ -308,8 +232,6 @@ namespace SM.OGL.Framebuffer break; } - - return buffer; } } diff --git a/src/renderer/SM.OGL/Framebuffer/IFramebufferWindow.cs b/SMCode/SM.OGL/Framebuffer/IFramebufferWindow.cs similarity index 100% rename from src/renderer/SM.OGL/Framebuffer/IFramebufferWindow.cs rename to SMCode/SM.OGL/Framebuffer/IFramebufferWindow.cs diff --git a/src/renderer/SM.OGL/Framebuffer/RenderbufferAttachment.cs b/SMCode/SM.OGL/Framebuffer/RenderbufferAttachment.cs similarity index 56% rename from src/renderer/SM.OGL/Framebuffer/RenderbufferAttachment.cs rename to SMCode/SM.OGL/Framebuffer/RenderbufferAttachment.cs index de00fb9..3988bb4 100644 --- a/src/renderer/SM.OGL/Framebuffer/RenderbufferAttachment.cs +++ b/SMCode/SM.OGL/Framebuffer/RenderbufferAttachment.cs @@ -5,12 +5,12 @@ namespace SM.OGL.Framebuffer /// /// Describes a renderbuffer attachment. /// - public class RenderbufferAttachment + public struct RenderbufferAttachment { /// /// Preset for the depthbuffer attachment. /// - public static RenderbufferAttachment GenerateDepth() => new RenderbufferAttachment(RenderbufferStorage.Depth24Stencil8, FramebufferAttachment.DepthStencilAttachment); + public static readonly RenderbufferAttachment Depth = new RenderbufferAttachment(RenderbufferStorage.Depth24Stencil8, FramebufferAttachment.DepthStencilAttachment); /// /// Storage describes the internal format for the renderbuffer. @@ -26,11 +26,6 @@ namespace SM.OGL.Framebuffer /// public int Multisample; - /// - /// The id that was given to the renderbuffer. - /// - public int ID; - /// /// Constructor /// @@ -39,8 +34,6 @@ namespace SM.OGL.Framebuffer Storage = storage; FramebufferAttachment = framebufferAttachment; Multisample = multisample; - - ID = -1; } /// @@ -48,49 +41,18 @@ namespace SM.OGL.Framebuffer /// /// The framebuffer /// The ID of the renderbuffer. - public void Generate(Framebuffer f) + public int Generate(Framebuffer f) { - ID = GL.GenRenderbuffer(); + int rb = GL.GenRenderbuffer(); - GL.BindRenderbuffer(RenderbufferTarget.Renderbuffer, ID); + GL.BindRenderbuffer(RenderbufferTarget.Renderbuffer, rb); if (Multisample != 0) GL.RenderbufferStorageMultisample(RenderbufferTarget.Renderbuffer, Multisample, Storage, (int)f.Size.X, (int)f.Size.Y); else GL.RenderbufferStorage(RenderbufferTarget.Renderbuffer, Storage, (int)f.Size.X, (int)f.Size.Y); GL.BindRenderbuffer(RenderbufferTarget.Renderbuffer, 0); - } - /// - /// Disposes the renderbuffer. - /// - public void Dispose() - { - GL.DeleteRenderbuffer(ID); - ID = -1; - } - - /// - public override bool Equals(object obj) - { - if (obj is RenderbufferAttachment ra) - { - if (ra.FramebufferAttachment == FramebufferAttachment) return true; - - return false; - } - - return false; - } - - /// - public override int GetHashCode() - { - int hashCode = -1803239493; - hashCode = hashCode * -1521134295 + Storage.GetHashCode(); - hashCode = hashCode * -1521134295 + FramebufferAttachment.GetHashCode(); - hashCode = hashCode * -1521134295 + Multisample.GetHashCode(); - hashCode = hashCode * -1521134295 + ID.GetHashCode(); - return hashCode; + return rb; } } } \ No newline at end of file diff --git a/src/renderer/SM.OGL/GLCustomActions.cs b/SMCode/SM.OGL/GLCustomActions.cs similarity index 100% rename from src/renderer/SM.OGL/GLCustomActions.cs rename to SMCode/SM.OGL/GLCustomActions.cs diff --git a/src/renderer/SM.OGL/GLDebugging.cs b/SMCode/SM.OGL/GLDebugging.cs similarity index 100% rename from src/renderer/SM.OGL/GLDebugging.cs rename to SMCode/SM.OGL/GLDebugging.cs diff --git a/src/renderer/SM.OGL/GLObject.cs b/SMCode/SM.OGL/GLObject.cs similarity index 98% rename from src/renderer/SM.OGL/GLObject.cs rename to SMCode/SM.OGL/GLObject.cs index a0538e6..89b0fbe 100644 --- a/src/renderer/SM.OGL/GLObject.cs +++ b/SMCode/SM.OGL/GLObject.cs @@ -136,7 +136,7 @@ namespace SM.OGL /// public static void DisposeMarkedObjects() { - foreach (GLObject o in _disposableObjects.ToArray()) + foreach (GLObject o in _disposableObjects) { o.Dispose(); } diff --git a/src/renderer/SM.OGL/GLSettings.cs b/SMCode/SM.OGL/GLSettings.cs similarity index 100% rename from src/renderer/SM.OGL/GLSettings.cs rename to SMCode/SM.OGL/GLSettings.cs diff --git a/src/renderer/SM.OGL/GLSystem.cs b/SMCode/SM.OGL/GLSystem.cs similarity index 100% rename from src/renderer/SM.OGL/GLSystem.cs rename to SMCode/SM.OGL/GLSystem.cs diff --git a/src/renderer/SM.OGL/Mesh/BoundingBox.cs b/SMCode/SM.OGL/Mesh/BoundingBox.cs similarity index 100% rename from src/renderer/SM.OGL/Mesh/BoundingBox.cs rename to SMCode/SM.OGL/Mesh/BoundingBox.cs diff --git a/src/renderer/SM.OGL/Mesh/GenericMesh.cs b/SMCode/SM.OGL/Mesh/GenericMesh.cs similarity index 100% rename from src/renderer/SM.OGL/Mesh/GenericMesh.cs rename to SMCode/SM.OGL/Mesh/GenericMesh.cs diff --git a/src/renderer/SM.OGL/Mesh/ILineMesh.cs b/SMCode/SM.OGL/Mesh/ILineMesh.cs similarity index 100% rename from src/renderer/SM.OGL/Mesh/ILineMesh.cs rename to SMCode/SM.OGL/Mesh/ILineMesh.cs diff --git a/src/renderer/SM.OGL/Mesh/MeshAttribute.cs b/SMCode/SM.OGL/Mesh/MeshAttribute.cs similarity index 100% rename from src/renderer/SM.OGL/Mesh/MeshAttribute.cs rename to SMCode/SM.OGL/Mesh/MeshAttribute.cs diff --git a/src/renderer/SM.OGL/Mesh/MeshAttributeList.cs b/SMCode/SM.OGL/Mesh/MeshAttributeList.cs similarity index 100% rename from src/renderer/SM.OGL/Mesh/MeshAttributeList.cs rename to SMCode/SM.OGL/Mesh/MeshAttributeList.cs diff --git a/src/renderer/SM.OGL/Mesh/VBO.cs b/SMCode/SM.OGL/Mesh/VBO.cs similarity index 100% rename from src/renderer/SM.OGL/Mesh/VBO.cs rename to SMCode/SM.OGL/Mesh/VBO.cs diff --git a/src/optionals/SM.Utils/OpenTK.dll.config b/SMCode/SM.OGL/OpenTK.dll.config similarity index 100% rename from src/optionals/SM.Utils/OpenTK.dll.config rename to SMCode/SM.OGL/OpenTK.dll.config diff --git a/src/renderer/SM.OGL/Properties/AssemblyInfo.cs b/SMCode/SM.OGL/Properties/AssemblyInfo.cs similarity index 100% rename from src/renderer/SM.OGL/Properties/AssemblyInfo.cs rename to SMCode/SM.OGL/Properties/AssemblyInfo.cs diff --git a/src/renderer/SM.OGL/SM.OGL.csproj b/SMCode/SM.OGL/SM.OGL.csproj similarity index 97% rename from src/renderer/SM.OGL/SM.OGL.csproj rename to SMCode/SM.OGL/SM.OGL.csproj index fd8ec5d..74321d3 100644 --- a/src/renderer/SM.OGL/SM.OGL.csproj +++ b/SMCode/SM.OGL/SM.OGL.csproj @@ -12,7 +12,6 @@ v4.5.2 512 true - true @@ -36,7 +35,7 @@ - ..\..\..\packages\OpenTK.3.3.1\lib\net20\OpenTK.dll + ..\..\packages\OpenTK.3.3.1\lib\net20\OpenTK.dll @@ -71,12 +70,12 @@ - - - + + + \ No newline at end of file diff --git a/src/renderer/SM.OGL/Shaders/GenericShader.cs b/SMCode/SM.OGL/Shaders/GenericShader.cs similarity index 90% rename from src/renderer/SM.OGL/Shaders/GenericShader.cs rename to SMCode/SM.OGL/Shaders/GenericShader.cs index c6617a6..27d74e7 100644 --- a/src/renderer/SM.OGL/Shaders/GenericShader.cs +++ b/SMCode/SM.OGL/Shaders/GenericShader.cs @@ -16,12 +16,10 @@ namespace SM.OGL.Shaders /// protected override bool AutoCompile { get; set; } = true; - public bool ErrorInShader { get; private set; } - /// /// Contains the different files for the shader. /// - public ShaderFileCollection ShaderFiles; + protected ShaderFileCollection ShaderFileFiles; /// /// Contains and manage the uniforms from the shader. @@ -69,7 +67,7 @@ namespace SM.OGL.Shaders Console.WriteLine(); - ShaderFiles = new ShaderFileCollection(vertex,fragment, geometry); + ShaderFileFiles = new ShaderFileCollection(vertex,fragment, geometry); } /// @@ -82,7 +80,7 @@ namespace SM.OGL.Shaders /// protected GenericShader(ShaderFileCollection shaderFileFiles) { - ShaderFiles = shaderFileFiles; + ShaderFileFiles = shaderFileFiles; } /// @@ -94,7 +92,7 @@ namespace SM.OGL.Shaders /// public void Update(ShaderFileCollection newShaderFiles) { - ShaderFiles = newShaderFiles; + ShaderFileFiles = newShaderFiles; Recompile(); } @@ -104,17 +102,12 @@ namespace SM.OGL.Shaders public void Load() { _id = GL.CreateProgram(); - Uniforms = new UniformCollection { ParentShader = this }; - ErrorInShader = !ShaderFiles.Append(this); - if (ErrorInShader) - { - GL.DeleteProgram(_id); - return; - } + ShaderFileFiles.Append(this); GL.LinkProgram(_id); - ShaderFiles.Detach(this); + ShaderFileFiles.Detach(this); + Uniforms = new UniformCollection {ParentShader = this}; Uniforms.Import(this); GLDebugging.CheckGLErrors($"A error occured at shader creation for '{GetType()}': %code%"); diff --git a/src/renderer/SM.OGL/Shaders/IUniform.cs b/SMCode/SM.OGL/Shaders/IUniform.cs similarity index 100% rename from src/renderer/SM.OGL/Shaders/IUniform.cs rename to SMCode/SM.OGL/Shaders/IUniform.cs diff --git a/src/renderer/SM.OGL/Shaders/ShaderExtensions.cs b/SMCode/SM.OGL/Shaders/ShaderExtensions.cs similarity index 100% rename from src/renderer/SM.OGL/Shaders/ShaderExtensions.cs rename to SMCode/SM.OGL/Shaders/ShaderExtensions.cs diff --git a/src/renderer/SM.OGL/Shaders/ShaderFile.cs b/SMCode/SM.OGL/Shaders/ShaderFile.cs similarity index 66% rename from src/renderer/SM.OGL/Shaders/ShaderFile.cs rename to SMCode/SM.OGL/Shaders/ShaderFile.cs index 4e395b5..5cb23f8 100644 --- a/src/renderer/SM.OGL/Shaders/ShaderFile.cs +++ b/SMCode/SM.OGL/Shaders/ShaderFile.cs @@ -14,14 +14,12 @@ namespace SM.OGL.Shaders public class ShaderFile : GLObject { private string _data; - + /// /// Contains other shader files to allow access to their functions. /// public List GLSLExtensions = new List(); - public List Defines = new List(); - /// /// Gets/Sets the name for this shader file. /// @@ -65,44 +63,21 @@ namespace SM.OGL.Shaders _data = _data.Replace("//!" + kvp.Key, kvp.Value); } - internal bool Compile(GenericShader shader, ShaderType type) + internal void Compile(GenericShader shader, ShaderType type) { if (_id < 0) { GenerateSource(); _id = GL.CreateShader(type); - if (Defines.Count > 0) - { - string defineString = ""; - foreach(string define in Defines) - { - defineString += "#define " + define + Environment.NewLine; - } - - GL.ShaderSource(_id, 2, new string[] { defineString, _data }, new int[] { defineString.Length, _data.Length }); - } else GL.ShaderSource(_id, _data); + GL.ShaderSource(_id, _data); GL.CompileShader(_id); } - GL.GetShader(_id, ShaderParameter.CompileStatus, out int compileStatus); - if (compileStatus != 1) - { - GL.GetShader(_id, ShaderParameter.InfoLogLength, out int loglength); - - GLCustomActions.AtWarning?.Invoke($"Shader '{ToString()}' doesn't compile correctly.\nReason:" + GL.GetShaderInfoLog(_id)); - - GL.DeleteShader(_id); - return false; - } - GL.AttachShader(shader, _id); + GLDebugging.CheckGLErrors($"Error at loading shader file: '{shader.GetType()}', '{type}', %code%"); - - for (var i = 0; i < GLSLExtensions.Count; i++) { - if (!GLSLExtensions[i].Compile(shader, type)) return false; - } - return true; + for (var i = 0; i < GLSLExtensions.Count; i++) GLSLExtensions[i].Compile(shader, type); } /// diff --git a/src/renderer/SM.OGL/Shaders/ShaderFileCollection.cs b/SMCode/SM.OGL/Shaders/ShaderFileCollection.cs similarity index 89% rename from src/renderer/SM.OGL/Shaders/ShaderFileCollection.cs rename to SMCode/SM.OGL/Shaders/ShaderFileCollection.cs index 33b92ed..0b6f2a7 100644 --- a/src/renderer/SM.OGL/Shaders/ShaderFileCollection.cs +++ b/SMCode/SM.OGL/Shaders/ShaderFileCollection.cs @@ -68,19 +68,17 @@ namespace SM.OGL.Shaders /// Appends the files to the shader. /// /// - internal bool Append(GenericShader shader) + internal void Append(GenericShader shader) { foreach (ShaderFile file in Vertex) - if (!file.Compile(shader, ShaderType.VertexShader)) return false; + file.Compile(shader, ShaderType.VertexShader); if (Geometry != null) foreach (ShaderFile file in Geometry) - if (!file.Compile(shader, ShaderType.GeometryShader)) return false; + file.Compile(shader, ShaderType.GeometryShader); - foreach (ShaderFile file in Fragment) - if (!file.Compile(shader, ShaderType.FragmentShader)) return false; - - return true; + foreach (ShaderFile file in Fragment) + file.Compile(shader, ShaderType.FragmentShader); } /// diff --git a/src/renderer/SM.OGL/Shaders/ShaderPreProcess.cs b/SMCode/SM.OGL/Shaders/ShaderPreProcess.cs similarity index 100% rename from src/renderer/SM.OGL/Shaders/ShaderPreProcess.cs rename to SMCode/SM.OGL/Shaders/ShaderPreProcess.cs diff --git a/SMCode/SM.OGL/Shaders/Uniform.cs b/SMCode/SM.OGL/Shaders/Uniform.cs new file mode 100644 index 0000000..6b498ac --- /dev/null +++ b/SMCode/SM.OGL/Shaders/Uniform.cs @@ -0,0 +1,501 @@ +#region usings + +using OpenTK; +using OpenTK.Graphics; +using OpenTK.Graphics.OpenGL4; +using SM.OGL.Texture; + +#endregion + +namespace SM.OGL.Shaders +{ + /// + /// Manages the uniforms. + /// + public struct Uniform : IUniform + { + /// + /// This contains the location for the uniform. + /// + public int Location { get; internal set; } + + /// + /// This contains the Parent collection of this uniform. + /// + public UniformCollection Parent { get; } + + /// + /// This creates a new uniform manager, that has a null parent. + /// + /// + public Uniform(int location) : this(location, null) + { + } + + /// + /// This creates a new uniform manager, that get the location from the provided shader and with a null parent. + /// + /// + /// + public Uniform(string name, GenericShader shader) : this(GL.GetUniformLocation(shader, name), null) + { + + } + /// + /// This creates a new uniform manager, that get the location from the provided shader and with a parent. + /// + /// + /// + /// + public Uniform(string name, GenericShader shader, UniformCollection parent) : this(GL.GetUniformLocation(shader, name), parent) + { + + } + + /// + /// This create a new uniform manager + /// + /// Location id + /// Parent collection + public Uniform(int location, UniformCollection parent) + { + Location = location; + Parent = parent; + } + + #region Uniform1 + + public void SetUniform1(bool value) + { + GL.Uniform1(Location, value ? 1 : 0); + } + + public void SetUniform1(int value) + { + GL.Uniform1(Location, value); + } + + public void SetUniform1(params int[] values) + { + GL.Uniform1(Location, values.Length, values); + } + + public void SetUniform1(int count, ref int values) + { + GL.Uniform1(Location, count, ref values); + } + + + public void SetUniform1(uint value) + { + GL.Uniform1(Location, value); + } + + public void SetUniform1(params uint[] values) + { + GL.Uniform1(Location, values.Length, values); + } + + public void SetUniform1(int count, ref uint values) + { + GL.Uniform1(Location, count, ref values); + } + + + public void SetUniform1(float value) + { + GL.Uniform1(Location, value); + } + + public void SetUniform1(params float[] values) + { + GL.Uniform1(Location, values.Length, values); + } + + public void SetUniform1(int count, ref float value) + { + GL.Uniform1(Location, count, ref value); + } + + + public void SetUniform1(double value) + { + GL.Uniform1(Location, value); + } + + public void SetUniform1(params double[] values) + { + GL.Uniform1(Location, values.Length, values); + } + + public void SetUniform1(int count, ref double value) + { + GL.Uniform1(Location, count, ref value); + } + + #endregion + + #region Uniform2 + + public void SetUniform2(float x, float y) + { + GL.Uniform2(Location, x, y); + } + + public void SetUniform2(double x, double y) + { + GL.Uniform2(Location, x, y); + } + + public void SetUniform2(uint x, uint y) + { + GL.Uniform2(Location, x, y); + } + + public void SetUniform2(int x, int y) + { + GL.Uniform2(Location, x, y); + } + + public void SetUniform2(params float[] values) + { + GL.Uniform2(Location, values.Length / 2, values); + } + + public void SetUniform2(params double[] values) + { + GL.Uniform2(Location, values.Length / 2, values); + } + + public void SetUniform2(params int[] values) + { + GL.Uniform2(Location, values.Length / 2, values); + } + + public void SetUniform2(params uint[] values) + { + GL.Uniform2(Location, values.Length / 2, values); + } + + public void SetUniform2(int count, ref float values) + { + GL.Uniform2(Location, count, ref values); + } + + public void SetUniform2(int count, ref double values) + { + GL.Uniform2(Location, count, ref values); + } + + public void SetUniform2(int count, ref uint values) + { + GL.Uniform2(Location, count, ref values); + } + + public void SetUniform2(Vector2 vector2) + { + GL.Uniform2(Location, vector2); + } + + public void SetUniform2(ref Vector2 vector2) + { + GL.Uniform2(Location, ref vector2); + } + + #endregion + + #region Uniform3 + + public void SetUniform3(float x, float y, float z) + { + GL.Uniform3(Location, x, y, z); + } + + public void SetUniform3(double x, double y, double z) + { + GL.Uniform3(Location, x, y, z); + } + + public void SetUniform3(uint x, uint y, uint z) + { + GL.Uniform3(Location, x, y, z); + } + + public void SetUniform3(int x, int y, int z) + { + GL.Uniform3(Location, x, y, z); + } + + public void SetUniform3(params float[] values) + { + GL.Uniform3(Location, values.Length / 3, values); + } + + public void SetUniform3(params double[] values) + { + GL.Uniform3(Location, values.Length / 3, values); + } + + public void SetUniform3(params int[] values) + { + GL.Uniform3(Location, values.Length / 3, values); + } + + public void SetUniform3(params uint[] values) + { + GL.Uniform3(Location, values.Length / 3, values); + } + + public void SetUniform3(int count, ref float values) + { + GL.Uniform3(Location, count, ref values); + } + + public void SetUniform3(int count, ref double values) + { + GL.Uniform3(Location, count, ref values); + } + + public void SetUniform3(int count, ref uint values) + { + GL.Uniform3(Location, count, ref values); + } + + public void SetUniform3(Vector3 vector) + { + GL.Uniform3(Location, vector); + } + + public void SetUniform3(ref Vector3 vector) + { + GL.Uniform3(Location, ref vector); + } + + #endregion + + #region Uniform4 + + public void SetUniform4(float x, float y, float z, float w) + { + GL.Uniform4(Location, x, y, z, w); + } + + public void SetUniform4(double x, double y, double z, double w) + { + GL.Uniform4(Location, x, y, z, w); + } + + public void SetUniform4(uint x, uint y, uint z, uint w) + { + GL.Uniform4(Location, x, y, z, w); + } + + public void SetUniform4(int x, int y, int z, int w) + { + GL.Uniform4(Location, x, y, z, w); + } + + public void SetUniform4(params float[] values) + { + GL.Uniform4(Location, values.Length / 4, values); + } + + public void SetUniform4(params double[] values) + { + GL.Uniform4(Location, values.Length / 4, values); + } + + public void SetUniform4(params int[] values) + { + GL.Uniform4(Location, values.Length / 4, values); + } + + public void SetUniform4(params uint[] values) + { + GL.Uniform4(Location, values.Length / 4, values); + } + + public void SetUniform4(int count, ref float values) + { + GL.Uniform4(Location, count, ref values); + } + + public void SetUniform4(int count, ref double values) + { + GL.Uniform4(Location, count, ref values); + } + + public void SetUniform4(int count, ref uint values) + { + GL.Uniform4(Location, count, ref values); + } + + public void SetUniform4(Vector4 vector) + { + GL.Uniform4(Location, vector); + } + + public void SetUniform4(ref Vector4 vector) + { + GL.Uniform4(Location, ref vector); + } + + public void SetUniform4(Color4 color) + { + GL.Uniform4(Location, color); + } + + public void SetUniform4(Quaternion quaternion) + { + GL.Uniform4(Location, quaternion); + } + + #endregion + + #region Matrix2 + + public void SetMatrix2(Matrix2 matrix, bool transpose = false) + { + GL.UniformMatrix2(Location, transpose, ref matrix); + } + + public void SetMatrix2(int count, ref double value, bool transpose = false) + { + GL.UniformMatrix2(Location, count, transpose, ref value); + } + + public void SetMatrix2(int count, ref float value, bool transpose = false) + { + GL.UniformMatrix2(Location, count, transpose, ref value); + } + + public void SetMatrix2(int count, double[] value, bool transpose = false) + { + GL.UniformMatrix2(Location, count, transpose, value); + } + + public void SetMatrix2(int count, float[] value, bool transpose = false) + { + GL.UniformMatrix2(Location, count, transpose, value); + } + + #endregion + + #region Matrix3 + + public void SetMatrix3(Matrix3 matrix, bool transpose = false) + { + GL.UniformMatrix3(Location, transpose, ref matrix); + } + + public void SetMatrix3(int count, ref double value, bool transpose = false) + { + GL.UniformMatrix3(Location, count, transpose, ref value); + } + + public void SetMatrix3(int count, ref float value, bool transpose = false) + { + GL.UniformMatrix3(Location, count, transpose, ref value); + } + + public void SetMatrix3(int count, double[] value, bool transpose = false) + { + GL.UniformMatrix3(Location, count, transpose, value); + } + + public void SetMatrix3(int count, float[] value, bool transpose = false) + { + GL.UniformMatrix3(Location, count, transpose, value); + } + + #endregion + + #region Matrix4 + + public void SetMatrix4(Matrix4 matrix, bool transpose = false) + { + GL.UniformMatrix4(Location, transpose, ref matrix); + } + + public void SetMatrix4(ref Matrix4 matrix, bool transpose = false) + { + GL.UniformMatrix4(Location, transpose, ref matrix); + } + + public void SetMatrix4(int count, ref double value, bool transpose = false) + { + GL.UniformMatrix4(Location, count, transpose, ref value); + } + + public void SetMatrix4(int count, ref float value, bool transpose = false) + { + GL.UniformMatrix4(Location, count, transpose, ref value); + } + + public void SetMatrix4(int count, double[] value, bool transpose = false) + { + GL.UniformMatrix4(Location, count, transpose, value); + } + + public void SetMatrix4(int count, float[] value, bool transpose = false) + { + GL.UniformMatrix4(Location, count, transpose, value); + } + + #endregion + + /// + /// Try to sets the texture at the next possible position and tells the checkUniform, if worked or not. + /// + /// The texture you want to add + /// The check uniform. + public void SetTexture(TextureBase texture, Uniform checkUniform) + { + checkUniform.SetUniform1(texture != null); + if (texture != null) SetTexture(texture); + } + + /// + /// Try to sets the texture at the specified position and tells the checkUniform, if worked or not. + /// + /// The texture you want to add + /// The position + /// The check uniform. + public void SetTexture(TextureBase texture, int pos, Uniform checkUniform) + { + checkUniform.SetUniform1(texture != null); + if (texture != null) SetTexture(texture); + } + + /// + /// Sets the texture to the next possible position. + /// + /// + public void SetTexture(TextureBase texture) + { + if (Parent != null) SetTexture(texture, Parent.NextTexture); + } + + /// + /// Sets the texture to the specified position. + /// + /// + /// + public void SetTexture(TextureBase texture, int texturePos) + { + Parent.NextTexture = texturePos + 1; + GL.ActiveTexture(TextureUnit.Texture0 + texturePos); + GL.BindTexture(texture.Target, texture); + SetUniform1(texturePos); + } + + /// + /// Returns the location from the uniform + /// + /// + public static implicit operator int(Uniform u) + { + return u.Location; + } + } +} \ No newline at end of file diff --git a/src/renderer/SM.OGL/Shaders/UniformArray.cs b/SMCode/SM.OGL/Shaders/UniformArray.cs similarity index 100% rename from src/renderer/SM.OGL/Shaders/UniformArray.cs rename to SMCode/SM.OGL/Shaders/UniformArray.cs diff --git a/src/renderer/SM.OGL/Shaders/UniformCollection.cs b/SMCode/SM.OGL/Shaders/UniformCollection.cs similarity index 100% rename from src/renderer/SM.OGL/Shaders/UniformCollection.cs rename to SMCode/SM.OGL/Shaders/UniformCollection.cs diff --git a/src/renderer/SM.OGL/Texture/PixelInformation.cs b/SMCode/SM.OGL/Texture/PixelInformation.cs similarity index 96% rename from src/renderer/SM.OGL/Texture/PixelInformation.cs rename to SMCode/SM.OGL/Texture/PixelInformation.cs index 109f513..e52e75c 100644 --- a/src/renderer/SM.OGL/Texture/PixelInformation.cs +++ b/SMCode/SM.OGL/Texture/PixelInformation.cs @@ -14,7 +14,7 @@ namespace SM.OGL.Texture /// /// RGB without Alpha channel, High Dynamic Range (0 - n) /// - public static PixelInformation RGB_HDR = new PixelInformation(PixelInternalFormat.R11fG11fB10f, PixelFormat.Rgb, PixelType.Float); + public static PixelInformation RGB_HDR = new PixelInformation(PixelInternalFormat.Rgb16f, PixelFormat.Rgb, PixelType.Float); /// /// RGB with Alpha channel, Low Dynamic Range (0 - 1) /// diff --git a/src/renderer/SM.OGL/Texture/TextureBase.cs b/SMCode/SM.OGL/Texture/TextureBase.cs similarity index 53% rename from src/renderer/SM.OGL/Texture/TextureBase.cs rename to SMCode/SM.OGL/Texture/TextureBase.cs index 524c528..495fe74 100644 --- a/src/renderer/SM.OGL/Texture/TextureBase.cs +++ b/SMCode/SM.OGL/Texture/TextureBase.cs @@ -1,8 +1,6 @@ #region usings -using OpenTK; using OpenTK.Graphics.OpenGL4; -using System; #endregion @@ -12,7 +10,6 @@ namespace SM.OGL.Texture /// Works as a basis for textures. /// public abstract class TextureBase : GLObject - { /// protected override bool AutoCompile { get; set; } = true; @@ -53,46 +50,11 @@ namespace SM.OGL.Texture /// public virtual int Height { get; protected set; } - /// - /// Returns the size of the texture. - /// - public Vector2 Size => new Vector2(Width, Height); - /// - /// Returns the texel size of the texture. - /// Returns: 1 / Size - /// - public Vector2 TexelSize => new Vector2(1f / Width, 1f / Height); - /// public override void Dispose() { GL.DeleteTexture(_id); base.Dispose(); } - - /// - /// Generates a basic texture, that applies all settings from the -class. - /// - /// - protected void GenerateBaseTexture(Vector2 size) - { - Width = (int)size.X; - Height = (int)size.Y; - - GL.BindTexture(TextureTarget.Texture2D, _id); - GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInformation.InternalFormat, - Width, Height, 0, - PixelInformation.Format, PixelInformation.DataType, IntPtr.Zero); - - GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)Filter); - GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)Filter); - - GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, - (int)WrapMode); - GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, - (int)WrapMode); - - GL.BindTexture(TextureTarget.Texture2D, 0); - } } } \ No newline at end of file diff --git a/src/renderer/SM.OGL/Version.cs b/SMCode/SM.OGL/Version.cs similarity index 100% rename from src/renderer/SM.OGL/Version.cs rename to SMCode/SM.OGL/Version.cs diff --git a/src/optionals/SM.Intergrations/packages.config b/SMCode/SM.OGL/packages.config similarity index 61% rename from src/optionals/SM.Intergrations/packages.config rename to SMCode/SM.OGL/packages.config index 12fbc5b..82cdaeb 100644 --- a/src/optionals/SM.Intergrations/packages.config +++ b/SMCode/SM.OGL/packages.config @@ -1,5 +1,4 @@  - \ No newline at end of file diff --git a/src/renderer/SM2D/Controls/Mouse2D.cs b/SMCode/SM2D/Controls/Mouse2D.cs similarity index 100% rename from src/renderer/SM2D/Controls/Mouse2D.cs rename to SMCode/SM2D/Controls/Mouse2D.cs diff --git a/src/renderer/SM2D/Drawing/DrawBackground.cs b/SMCode/SM2D/Drawing/DrawBackground.cs similarity index 98% rename from src/renderer/SM2D/Drawing/DrawBackground.cs rename to SMCode/SM2D/Drawing/DrawBackground.cs index da6c696..3fabd1d 100644 --- a/src/renderer/SM2D/Drawing/DrawBackground.cs +++ b/SMCode/SM2D/Drawing/DrawBackground.cs @@ -85,7 +85,7 @@ namespace SM2D.Drawing { base.DrawContext(ref context); context.ModelMatrix = Matrix4.CreateScale((context.UseCamera as Camera).WorldScale.X, (context.UseCamera as Camera).WorldScale.Y, 0) * Matrix4.CreateTranslation(0,0, -1.1f); - Material.Draw(context); + context.Shader.Draw(context); } } } \ No newline at end of file diff --git a/src/renderer/SM2D/Drawing/DrawObject2D.cs b/SMCode/SM2D/Drawing/DrawObject2D.cs similarity index 97% rename from src/renderer/SM2D/Drawing/DrawObject2D.cs rename to SMCode/SM2D/Drawing/DrawObject2D.cs index ac2a95d..e9176e6 100644 --- a/src/renderer/SM2D/Drawing/DrawObject2D.cs +++ b/SMCode/SM2D/Drawing/DrawObject2D.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using System.Drawing.Printing; using OpenTK; using OpenTK.Graphics; using SM.Base.Drawing; @@ -36,7 +35,7 @@ namespace SM2D.Drawing protected override void DrawContext(ref DrawContext context) { base.DrawContext(ref context); - Material.Draw(context); + context.Shader.Draw(context); } /// diff --git a/src/renderer/SM2D/Drawing/DrawParticles.cs b/SMCode/SM2D/Drawing/DrawParticles.cs similarity index 62% rename from src/renderer/SM2D/Drawing/DrawParticles.cs rename to SMCode/SM2D/Drawing/DrawParticles.cs index e85a302..90f469a 100644 --- a/src/renderer/SM2D/Drawing/DrawParticles.cs +++ b/SMCode/SM2D/Drawing/DrawParticles.cs @@ -12,7 +12,7 @@ namespace SM2D.Drawing public class DrawParticles : ParticleDrawingBasis { /// - public override Func, Vector2> MovementCalculation { get; set; } = ParticleMovement.Default2D; + public override Func MovementCalculation { get; set; } = ParticleMovement.Default2D; /// /// The direction the particles should travel. @@ -30,7 +30,7 @@ namespace SM2D.Drawing } /// - protected override ParticleInstance CreateObject(int index) + protected override ParticleStruct CreateObject(int index) { Vector2 dir; if (Direction.HasValue) @@ -42,26 +42,18 @@ namespace SM2D.Drawing } else dir = new Vector2(Randomize.GetFloat(-1, 1), Randomize.GetFloat(-1, 1)); - var particle = new ParticleInstance() + return new ParticleStruct() { - Matrix = DetachedParticles ? Transform.InWorldSpace : Matrix4.CreateScale(1), - + Matrix = Matrix4.CreateScale(1), Direction = dir, - - Speed = Randomize.GetFloat(MaxSpeed), - StartLifetime = Lifetime - Randomize.GetFloat(LifetimeRandomize) + Speed = Randomize.GetFloat(MaxSpeed) }; - particle.Lifetime = particle.StartLifetime; - - return particle; } /// - protected override Matrix4 CreateMatrix(ParticleInstance Struct, Vector2 direction) + protected override Matrix4 CreateMatrix(ParticleStruct Struct, Vector2 direction) { - Vector2 pos = direction; - - return Struct.Matrix * Matrix4.CreateTranslation(pos.X, pos.Y, 0); + return Struct.Matrix * Matrix4.CreateTranslation(direction.X, direction.Y, 0); } } } \ No newline at end of file diff --git a/src/renderer/SM2D/Drawing/DrawText.cs b/SMCode/SM2D/Drawing/DrawText.cs similarity index 96% rename from src/renderer/SM2D/Drawing/DrawText.cs rename to SMCode/SM2D/Drawing/DrawText.cs index 32dc642..3708e5c 100644 --- a/src/renderer/SM2D/Drawing/DrawText.cs +++ b/SMCode/SM2D/Drawing/DrawText.cs @@ -41,7 +41,7 @@ namespace SM2D.Drawing base.DrawContext(ref context); context.Instances = _instances; - Material.Draw(context); + context.Shader.Draw(context); } } } \ No newline at end of file diff --git a/src/renderer/SM2D/Object/PolyLine.cs b/SMCode/SM2D/Object/PolyLine.cs similarity index 100% rename from src/renderer/SM2D/Object/PolyLine.cs rename to SMCode/SM2D/Object/PolyLine.cs diff --git a/src/renderer/SM2D/Object/Polygon.cs b/SMCode/SM2D/Object/Polygon.cs similarity index 100% rename from src/renderer/SM2D/Object/Polygon.cs rename to SMCode/SM2D/Object/Polygon.cs diff --git a/src/renderer/SM2D/Object/PolygonVertex.cs b/SMCode/SM2D/Object/PolygonVertex.cs similarity index 100% rename from src/renderer/SM2D/Object/PolygonVertex.cs rename to SMCode/SM2D/Object/PolygonVertex.cs diff --git a/src/renderer/SM2D/Pipelines/Basic2DPipeline.cs b/SMCode/SM2D/Pipelines/Basic2DPipeline.cs similarity index 100% rename from src/renderer/SM2D/Pipelines/Basic2DPipeline.cs rename to SMCode/SM2D/Pipelines/Basic2DPipeline.cs diff --git a/src/renderer/SM2D/Properties/AssemblyInfo.cs b/SMCode/SM2D/Properties/AssemblyInfo.cs similarity index 100% rename from src/renderer/SM2D/Properties/AssemblyInfo.cs rename to SMCode/SM2D/Properties/AssemblyInfo.cs diff --git a/src/renderer/SM2D/SM2D.csproj b/SMCode/SM2D/SM2D.csproj similarity index 86% rename from src/renderer/SM2D/SM2D.csproj rename to SMCode/SM2D/SM2D.csproj index 247194f..d58b4f3 100644 --- a/src/renderer/SM2D/SM2D.csproj +++ b/SMCode/SM2D/SM2D.csproj @@ -11,7 +11,6 @@ v4.5.2 512 true - true @@ -31,14 +30,7 @@ prompt 4 - - false - - - ..\..\..\packages\OpenTK.3.3.1\lib\net20\OpenTK.dll - True - @@ -61,6 +53,11 @@ + + + 3.3.1 + + @@ -74,9 +71,5 @@ SM.OGL - - - - \ No newline at end of file diff --git a/src/renderer/SM2D/SM2D.csproj.DotSettings b/SMCode/SM2D/SM2D.csproj.DotSettings similarity index 100% rename from src/renderer/SM2D/SM2D.csproj.DotSettings rename to SMCode/SM2D/SM2D.csproj.DotSettings diff --git a/src/renderer/SM2D/Scene/Camera.cs b/SMCode/SM2D/Scene/Camera.cs similarity index 100% rename from src/renderer/SM2D/Scene/Camera.cs rename to SMCode/SM2D/Scene/Camera.cs diff --git a/src/renderer/SM2D/Scene/ItemCollection.cs b/SMCode/SM2D/Scene/ItemCollection.cs similarity index 100% rename from src/renderer/SM2D/Scene/ItemCollection.cs rename to SMCode/SM2D/Scene/ItemCollection.cs diff --git a/src/renderer/SM2D/Scene/Scene.cs b/SMCode/SM2D/Scene/Scene.cs similarity index 100% rename from src/renderer/SM2D/Scene/Scene.cs rename to SMCode/SM2D/Scene/Scene.cs diff --git a/src/renderer/SM2D/Shader/ShaderCollection.cs b/SMCode/SM2D/Shader/ShaderCollection.cs similarity index 93% rename from src/renderer/SM2D/Shader/ShaderCollection.cs rename to SMCode/SM2D/Shader/ShaderCollection.cs index 2886b20..e7dacf8 100644 --- a/src/renderer/SM2D/Shader/ShaderCollection.cs +++ b/SMCode/SM2D/Shader/ShaderCollection.cs @@ -18,7 +18,7 @@ namespace SM2D.Shader static void SetUniforms(UniformCollection uniforms, DrawContext context) { - uniforms["Tint"].SetColor(context.Material.Tint); + uniforms["Tint"].SetUniform4(context.Material.Tint); uniforms["Texture"].SetTexture(context.Material.Texture, uniforms["UseTexture"]); } } diff --git a/src/renderer/SM2D/Shader/ShaderFiles/basic.glsl b/SMCode/SM2D/Shader/ShaderFiles/basic.glsl similarity index 100% rename from src/renderer/SM2D/Shader/ShaderFiles/basic.glsl rename to SMCode/SM2D/Shader/ShaderFiles/basic.glsl diff --git a/src/renderer/SM2D/Types/Transformation.cs b/SMCode/SM2D/Types/Transformation.cs similarity index 100% rename from src/renderer/SM2D/Types/Transformation.cs rename to SMCode/SM2D/Types/Transformation.cs diff --git a/src/renderer/SM2D/Window/Window2DSetup.cs b/SMCode/SM2D/Window/Window2DSetup.cs similarity index 100% rename from src/renderer/SM2D/Window/Window2DSetup.cs rename to SMCode/SM2D/Window/Window2DSetup.cs diff --git a/src/optionals/SM.Intergrations/Properties/AssemblyInfo.cs b/SMCode/SM3D/Properties/AssemblyInfo.cs similarity index 75% rename from src/optionals/SM.Intergrations/Properties/AssemblyInfo.cs rename to SMCode/SM3D/Properties/AssemblyInfo.cs index eeec0f3..f2e6bad 100644 --- a/src/optionals/SM.Intergrations/Properties/AssemblyInfo.cs +++ b/SMCode/SM3D/Properties/AssemblyInfo.cs @@ -1,16 +1,19 @@ -using System.Reflection; -using System.Runtime.CompilerServices; +#region usings + +using System.Reflection; using System.Runtime.InteropServices; +#endregion + // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. -[assembly: AssemblyTitle("SM.Intergrations")] +[assembly: AssemblyTitle("SM3D")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SM.Intergrations")] -[assembly: AssemblyCopyright("Copyright © 2021")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("SM3D")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2020")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -20,7 +23,7 @@ using System.Runtime.InteropServices; [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("4cb351f4-b3f2-4f77-acc2-02f21dbf5ec2")] +[assembly: Guid("9beca849-e6e9-4e15-83a6-add8c18065cb")] // Version information for an assembly consists of the following four values: // @@ -33,4 +36,4 @@ using System.Runtime.InteropServices; // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] \ No newline at end of file diff --git a/SMCode/SM3D/SM3D.csproj b/SMCode/SM3D/SM3D.csproj new file mode 100644 index 0000000..447701a --- /dev/null +++ b/SMCode/SM3D/SM3D.csproj @@ -0,0 +1,41 @@ + + + + + Debug + AnyCPU + {9BECA849-E6E9-4E15-83A6-ADD8C18065CB} + Library + Properties + SM3D + SM3D + v4.5.2 + 512 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + \ No newline at end of file diff --git a/SMOptionals/SM.Game/Controls/GameController.cs b/SMOptionals/SM.Game/Controls/GameController.cs new file mode 100644 index 0000000..65f41dd --- /dev/null +++ b/SMOptionals/SM.Game/Controls/GameController.cs @@ -0,0 +1,39 @@ +using SharpDX.XInput; + +namespace SM.Game.Controls +{ + public struct GameController + { + public static float GlobalDeadband = 2500; + + private Controller _controller; + + public float Deadband { get; set; } + public bool IsConnected => _controller.IsConnected; + + public UserIndex Index { get; private set; } + + public GameController(int id) : this((UserIndex)id) + {} + + public GameController(UserIndex index = UserIndex.Any) + { + _controller = new Controller(index); + Index = index; + Deadband = GlobalDeadband; + } + + public GameControllerState GetState() + { + if (!IsConnected) + { + return new GameControllerState(true); + } + + Gamepad state = _controller.GetState().Gamepad; + + return new GameControllerState(state, ref this); + } + + } +} \ No newline at end of file diff --git a/src/optionals/SM.Utils/Controls/GameControllerState.cs b/SMOptionals/SM.Game/Controls/GameControllerState.cs similarity index 58% rename from src/optionals/SM.Utils/Controls/GameControllerState.cs rename to SMOptionals/SM.Game/Controls/GameControllerState.cs index 7a20aa4..414a2ae 100644 --- a/src/optionals/SM.Utils/Controls/GameControllerState.cs +++ b/SMOptionals/SM.Game/Controls/GameControllerState.cs @@ -2,7 +2,7 @@ using OpenTK; using SharpDX.XInput; -namespace SM.Utils.Controls +namespace SM.Game.Controls { public struct GameControllerState { @@ -12,7 +12,7 @@ namespace SM.Utils.Controls public GameControllerStateButtons Buttons; public bool FromConnected { get; } - public bool AnyInteraction => Buttons.AnyInteraction || DPad.AnyInteraction || Triggers.AnyInteraction || Thumbs.AnyInteraction; + internal GameControllerState(bool empty) { FromConnected = false; @@ -22,11 +22,22 @@ namespace SM.Utils.Controls DPad = GameControllerStateDPad.Default; Buttons = GameControllerStateButtons.Default; } - internal GameControllerState(Gamepad state, GameController controller) + internal GameControllerState(Gamepad state, ref GameController controller) { FromConnected = true; - Thumbs = new GameControllerStateThumbs(controller, state); + Thumbs = new GameControllerStateThumbs + { + Left = new Vector2( + Math.Abs((float)state.LeftThumbX) < controller.Deadband ? 0 : (float)state.LeftThumbX / short.MaxValue, + Math.Abs((float)state.LeftThumbY) < controller.Deadband ? 0 : (float)state.LeftThumbY / short.MaxValue), + Right = new Vector2( + Math.Abs((float)state.RightThumbX) < controller.Deadband ? 0 : (float)state.RightThumbX / short.MaxValue, + Math.Abs((float)state.RightThumbY) < controller.Deadband ? 0 : (float)state.RightThumbY / short.MaxValue), + + PressedLeft = state.Buttons.HasFlag(GamepadButtonFlags.LeftThumb), + PressedRight = state.Buttons.HasFlag(GamepadButtonFlags.RightThumb) + }; Triggers = new GameControllerStateTriggers() { @@ -35,7 +46,7 @@ namespace SM.Utils.Controls }; DPad = new GameControllerStateDPad(state.Buttons); - Buttons = new GameControllerStateButtons(state.Buttons, controller); + Buttons = new GameControllerStateButtons(state.Buttons); } public override string ToString() diff --git a/src/optionals/SM.Utils/Controls/GameControllerStateButtons.cs b/SMOptionals/SM.Game/Controls/GameControllerStateButtons.cs similarity index 63% rename from src/optionals/SM.Utils/Controls/GameControllerStateButtons.cs rename to SMOptionals/SM.Game/Controls/GameControllerStateButtons.cs index 5bcd5f4..57aca8c 100644 --- a/src/optionals/SM.Utils/Controls/GameControllerStateButtons.cs +++ b/SMOptionals/SM.Game/Controls/GameControllerStateButtons.cs @@ -1,17 +1,12 @@ using SharpDX.XInput; -namespace SM.Utils.Controls +namespace SM.Game.Controls { public struct GameControllerStateButtons { - public static GameControllerStateButtons Default = new GameControllerStateButtons() - { - _buttonFlags = GamepadButtonFlags.None, - _lastButtonFlags = GamepadButtonFlags.None - }; + public static GameControllerStateButtons Default = new GameControllerStateButtons(GamepadButtonFlags.None); private GamepadButtonFlags _buttonFlags; - private GamepadButtonFlags _lastButtonFlags; public bool X; public bool Y; @@ -24,17 +19,11 @@ namespace SM.Utils.Controls public bool LeftThumb; public bool RightThumb; - public bool Start; - public bool Back; + public bool this[GamepadButtonFlags flags] => _buttonFlags.HasFlag(flags); - public bool this[GamepadButtonFlags flags, bool once = false] => _buttonFlags.HasFlag(flags) && !(once && _lastButtonFlags.HasFlag(flags)); - - public bool AnyInteraction { get; } - - internal GameControllerStateButtons(GamepadButtonFlags flags, GameController controller) + internal GameControllerStateButtons(GamepadButtonFlags flags) { _buttonFlags = flags; - _lastButtonFlags = controller._lastPressedButtons; X = flags.HasFlag(GamepadButtonFlags.X); Y = flags.HasFlag(GamepadButtonFlags.Y); @@ -46,11 +35,6 @@ namespace SM.Utils.Controls LeftThumb = flags.HasFlag(GamepadButtonFlags.LeftThumb); RightThumb = flags.HasFlag(GamepadButtonFlags.RightThumb); - - Start = flags.HasFlag(GamepadButtonFlags.Start); - Back = flags.HasFlag(GamepadButtonFlags.Back); - - AnyInteraction = (int) flags >= 16; } public override string ToString() diff --git a/src/optionals/SM.Utils/Controls/GameControllerStateDPad.cs b/SMOptionals/SM.Game/Controls/GameControllerStateDPad.cs similarity index 85% rename from src/optionals/SM.Utils/Controls/GameControllerStateDPad.cs rename to SMOptionals/SM.Game/Controls/GameControllerStateDPad.cs index ff3b30e..5385e60 100644 --- a/src/optionals/SM.Utils/Controls/GameControllerStateDPad.cs +++ b/SMOptionals/SM.Game/Controls/GameControllerStateDPad.cs @@ -1,6 +1,6 @@ using SharpDX.XInput; -namespace SM.Utils.Controls +namespace SM.Game.Controls { public struct GameControllerStateDPad { @@ -11,16 +11,12 @@ namespace SM.Utils.Controls public bool Left; public bool Right; - public bool AnyInteraction { get; } - internal GameControllerStateDPad(GamepadButtonFlags flags) { Up = flags.HasFlag(GamepadButtonFlags.DPadUp); Down = flags.HasFlag(GamepadButtonFlags.DPadDown); Left = flags.HasFlag(GamepadButtonFlags.DPadLeft); Right = flags.HasFlag(GamepadButtonFlags.DPadRight); - - AnyInteraction = (int)flags > 0 && (int) flags < 16; } public override string ToString() diff --git a/SMOptionals/SM.Game/Controls/GameControllerStateThumbs.cs b/SMOptionals/SM.Game/Controls/GameControllerStateThumbs.cs new file mode 100644 index 0000000..1d4eefd --- /dev/null +++ b/SMOptionals/SM.Game/Controls/GameControllerStateThumbs.cs @@ -0,0 +1,21 @@ +using OpenTK; + +namespace SM.Game.Controls +{ + public struct GameControllerStateThumbs + { + public static GameControllerStateThumbs Default = new GameControllerStateThumbs() + {Left = Vector2.Zero, Right = Vector2.Zero}; + + public Vector2 Left; + public Vector2 Right; + + public bool PressedLeft; + public bool PressedRight; + + public override string ToString() + { + return $"Left: ({Left.X}; {Left.Y}){(PressedLeft ? " Pressed" : "")}; Right: ({Right.X}; {Right.Y}){(PressedRight ? " Pressed" : "")}"; + } + } +} \ No newline at end of file diff --git a/src/optionals/SM.Utils/Controls/GameControllerStateTriggers.cs b/SMOptionals/SM.Game/Controls/GameControllerStateTriggers.cs similarity index 78% rename from src/optionals/SM.Utils/Controls/GameControllerStateTriggers.cs rename to SMOptionals/SM.Game/Controls/GameControllerStateTriggers.cs index 3d3f41c..3c99852 100644 --- a/src/optionals/SM.Utils/Controls/GameControllerStateTriggers.cs +++ b/SMOptionals/SM.Game/Controls/GameControllerStateTriggers.cs @@ -1,4 +1,4 @@ -namespace SM.Utils.Controls +namespace SM.Game.Controls { public struct GameControllerStateTriggers { @@ -6,9 +6,6 @@ public float Left; public float Right; - - public bool AnyInteraction => Left != 0f || Right != 0f; - public override string ToString() { return $"Left: {Left}; Right: {Right}"; diff --git a/src/optionals/SM.Utils/Controls/GameKeybind.cs b/SMOptionals/SM.Game/Controls/GameKeybind.cs similarity index 90% rename from src/optionals/SM.Utils/Controls/GameKeybind.cs rename to SMOptionals/SM.Game/Controls/GameKeybind.cs index b8a683d..eb306c8 100644 --- a/src/optionals/SM.Utils/Controls/GameKeybind.cs +++ b/SMOptionals/SM.Game/Controls/GameKeybind.cs @@ -1,6 +1,6 @@ using System; -namespace SM.Utils.Controls +namespace SM.Game.Controls { public class GameKeybind { @@ -18,8 +18,10 @@ namespace SM.Utils.Controls return AI; case GameKeybindActorType.Keyboard: return Keyboard; + break; case GameKeybindActorType.Controller: return Controller; + break; default: throw new ArgumentOutOfRangeException(nameof(type), type, null); } diff --git a/src/optionals/SM.Utils/Controls/GameKeybindActor.cs b/SMOptionals/SM.Game/Controls/GameKeybindActor.cs similarity index 81% rename from src/optionals/SM.Utils/Controls/GameKeybindActor.cs rename to SMOptionals/SM.Game/Controls/GameKeybindActor.cs index 7dfd976..c0527c3 100644 --- a/src/optionals/SM.Utils/Controls/GameKeybindActor.cs +++ b/SMOptionals/SM.Game/Controls/GameKeybindActor.cs @@ -1,6 +1,6 @@ using OpenTK.Input; -namespace SM.Utils.Controls +namespace SM.Game.Controls { public enum GameKeybindActorType { @@ -12,25 +12,16 @@ namespace SM.Utils.Controls public struct GameKeybindActor { private GameKeybindActorType _type; - private GameController _controller; + private GameController? _controller; private GameKeybindHost _keybindHost; public GameKeybindActorType Type => _type; - public GameController Controller => _controller; + public GameController? Controller => _controller; public object[] Parameter; - private GameKeybindActor(GameKeybindActorType type, GameController controller) - { - _type = type; - _controller = controller; - - _keybindHost = null; - - Parameter = new object[0]; - } - private GameKeybindActor(GameKeybindActorType type, ref GameController controller) + private GameKeybindActor(GameKeybindActorType type, GameController? controller) { _type = type; _controller = controller; @@ -67,7 +58,7 @@ namespace SM.Utils.Controls KeyboardState = Keyboard.GetState(), MouseState = Mouse.GetState(), - ControllerState = Controller?.GetState() ?? new GameControllerState(true), + ControllerState = Controller?.GetState(), }; return keybind[Type].Invoke(context); diff --git a/src/optionals/SM.Utils/Controls/GameKeybindContext.cs b/SMOptionals/SM.Game/Controls/GameKeybindContext.cs similarity index 79% rename from src/optionals/SM.Utils/Controls/GameKeybindContext.cs rename to SMOptionals/SM.Game/Controls/GameKeybindContext.cs index c08fe7c..08b6cb4 100644 --- a/src/optionals/SM.Utils/Controls/GameKeybindContext.cs +++ b/SMOptionals/SM.Game/Controls/GameKeybindContext.cs @@ -1,12 +1,12 @@ using OpenTK.Input; -namespace SM.Utils.Controls +namespace SM.Game.Controls { public struct GameKeybindContext { public KeyboardState KeyboardState; public MouseState MouseState; - public GameControllerState ControllerState; + public GameControllerState? ControllerState; public GameKeybindActor Actor; public GameKeybindHost Host; diff --git a/src/optionals/SM.Utils/Controls/GameKeybindHost.cs b/SMOptionals/SM.Game/Controls/GameKeybindHost.cs similarity index 97% rename from src/optionals/SM.Utils/Controls/GameKeybindHost.cs rename to SMOptionals/SM.Game/Controls/GameKeybindHost.cs index 30c9832..c1d57f6 100644 --- a/src/optionals/SM.Utils/Controls/GameKeybindHost.cs +++ b/SMOptionals/SM.Game/Controls/GameKeybindHost.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; -namespace SM.Utils.Controls +namespace SM.Game.Controls { public class GameKeybindHost { diff --git a/src/optionals/SM.Utils/Controls/GameKeybindList.cs b/SMOptionals/SM.Game/Controls/GameKeybindList.cs similarity index 96% rename from src/optionals/SM.Utils/Controls/GameKeybindList.cs rename to SMOptionals/SM.Game/Controls/GameKeybindList.cs index b5db7ed..97662e1 100644 --- a/src/optionals/SM.Utils/Controls/GameKeybindList.cs +++ b/SMOptionals/SM.Game/Controls/GameKeybindList.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; -namespace SM.Utils.Controls +namespace SM.Game.Controls { public class GameKeybindList : List> { diff --git a/src/renderer/SM.Base/OpenTK.dll.config b/SMOptionals/SM.Game/OpenTK.dll.config similarity index 100% rename from src/renderer/SM.Base/OpenTK.dll.config rename to SMOptionals/SM.Game/OpenTK.dll.config diff --git a/src/optionals/SM.Utils/Properties/AssemblyInfo.cs b/SMOptionals/SM.Game/Properties/AssemblyInfo.cs similarity index 100% rename from src/optionals/SM.Utils/Properties/AssemblyInfo.cs rename to SMOptionals/SM.Game/Properties/AssemblyInfo.cs diff --git a/src/optionals/SM.Utils/SMRenderer.Utils.csproj b/SMOptionals/SM.Game/SM.Game.csproj similarity index 83% rename from src/optionals/SM.Utils/SMRenderer.Utils.csproj rename to SMOptionals/SM.Game/SM.Game.csproj index 3e2f80f..cf248b4 100644 --- a/src/optionals/SM.Utils/SMRenderer.Utils.csproj +++ b/SMOptionals/SM.Game/SM.Game.csproj @@ -7,12 +7,11 @@ {079BAB31-3DC4-40DA-90C7-EFAA8517C647} Library Properties - SM.Utils - SM.Utils + SM.Game + SM.Game v4.5.2 512 true - true @@ -33,13 +32,13 @@ - ..\..\..\packages\OpenTK.3.3.1\lib\net20\OpenTK.dll + ..\..\packages\OpenTK.3.3.1\lib\net20\OpenTK.dll - ..\..\..\packages\SharpDX.4.2.0\lib\net45\SharpDX.dll + ..\..\packages\SharpDX.4.2.0\lib\net45\SharpDX.dll - ..\..\..\packages\SharpDX.XInput.4.2.0\lib\net45\SharpDX.XInput.dll + ..\..\packages\SharpDX.XInput.4.2.0\lib\net45\SharpDX.XInput.dll @@ -62,11 +61,5 @@ - - - {8e733844-4204-43e7-b3dc-3913cddabb0d} - SM.Base - - \ No newline at end of file diff --git a/src/optionals/SM.Utils/packages.config b/SMOptionals/SM.Game/packages.config similarity index 100% rename from src/optionals/SM.Utils/packages.config rename to SMOptionals/SM.Game/packages.config diff --git a/SMRendererV3.sln b/SMRendererV3.sln index fecf2a6..93ce3e3 100644 --- a/SMRendererV3.sln +++ b/SMRendererV3.sln @@ -3,23 +3,23 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.30413.136 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SM.OGL", "src\renderer\SM.OGL\SM.OGL.csproj", "{F604D684-BC1D-4819-88B5-8B5D03A17BE0}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SMRenderer", "SMRenderer", "{47EA2879-1D40-4683-BA6C-AB51F286EBDE}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SM.Base", "src\renderer\SM.Base\SM.Base.csproj", "{8E733844-4204-43E7-B3DC-3913CDDABB0D}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SM.OGL", "SMCode\SM.OGL\SM.OGL.csproj", "{F604D684-BC1D-4819-88B5-8B5D03A17BE0}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SM2D", "src\renderer\SM2D\SM2D.csproj", "{A4565538-625A-42C6-A330-DD4F1ABB3986}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SM.Base", "SMCode\SM.Base\SM.Base.csproj", "{8E733844-4204-43E7-B3DC-3913CDDABB0D}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SM_TEST", "tests\SM_TEST\SM_TEST.csproj", "{6D4FB8E6-4D0B-4928-8F9E-EF5C2FBF44E8}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SM3D", "SMCode\SM3D\SM3D.csproj", "{9BECA849-E6E9-4E15-83A6-ADD8C18065CB}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SMRenderer.Utils", "src\optionals\SM.Utils\SMRenderer.Utils.csproj", "{079BAB31-3DC4-40DA-90C7-EFAA8517C647}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SM2D", "SMCode\SM2D\SM2D.csproj", "{A4565538-625A-42C6-A330-DD4F1ABB3986}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SMRenderer.Intergrations", "src\optionals\SM.Intergrations\SMRenderer.Intergrations.csproj", "{4CB351F4-B3F2-4F77-ACC2-02F21DBF5EC2}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SM_TEST", "SM_TEST\SM_TEST.csproj", "{6D4FB8E6-4D0B-4928-8F9E-EF5C2FBF44E8}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Renderer", "Renderer", "{62ED6240-4DEC-4535-95EB-AE3D90A3FDF5}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Optionals", "Optionals", "{AE5B181B-BD8F-4F36-A64E-32C4FF7B6FD6}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Optionals", "Optionals", "{CC0E5493-29E8-4ACB-8462-5724A6F636DE}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SM.Game", "SMOptionals\SM.Game\SM.Game.csproj", "{079BAB31-3DC4-40DA-90C7-EFAA8517C647}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{2D2EDE5F-6610-4DF9-AAFD-664F4023A99D}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SM_WPF_TEST", "SM_WPF_TEST\SM_WPF_TEST.csproj", "{6F5367D3-B7E9-40CE-A692-29F9892B6F2A}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -35,6 +35,10 @@ Global {8E733844-4204-43E7-B3DC-3913CDDABB0D}.Debug|Any CPU.Build.0 = Debug|Any CPU {8E733844-4204-43E7-B3DC-3913CDDABB0D}.Release|Any CPU.ActiveCfg = Release|Any CPU {8E733844-4204-43E7-B3DC-3913CDDABB0D}.Release|Any CPU.Build.0 = Release|Any CPU + {9BECA849-E6E9-4E15-83A6-ADD8C18065CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9BECA849-E6E9-4E15-83A6-ADD8C18065CB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9BECA849-E6E9-4E15-83A6-ADD8C18065CB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9BECA849-E6E9-4E15-83A6-ADD8C18065CB}.Release|Any CPU.Build.0 = Release|Any CPU {A4565538-625A-42C6-A330-DD4F1ABB3986}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A4565538-625A-42C6-A330-DD4F1ABB3986}.Debug|Any CPU.Build.0 = Debug|Any CPU {A4565538-625A-42C6-A330-DD4F1ABB3986}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -47,21 +51,20 @@ Global {079BAB31-3DC4-40DA-90C7-EFAA8517C647}.Debug|Any CPU.Build.0 = Debug|Any CPU {079BAB31-3DC4-40DA-90C7-EFAA8517C647}.Release|Any CPU.ActiveCfg = Release|Any CPU {079BAB31-3DC4-40DA-90C7-EFAA8517C647}.Release|Any CPU.Build.0 = Release|Any CPU - {4CB351F4-B3F2-4F77-ACC2-02F21DBF5EC2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4CB351F4-B3F2-4F77-ACC2-02F21DBF5EC2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4CB351F4-B3F2-4F77-ACC2-02F21DBF5EC2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4CB351F4-B3F2-4F77-ACC2-02F21DBF5EC2}.Release|Any CPU.Build.0 = Release|Any CPU + {6F5367D3-B7E9-40CE-A692-29F9892B6F2A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6F5367D3-B7E9-40CE-A692-29F9892B6F2A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6F5367D3-B7E9-40CE-A692-29F9892B6F2A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6F5367D3-B7E9-40CE-A692-29F9892B6F2A}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution - {F604D684-BC1D-4819-88B5-8B5D03A17BE0} = {62ED6240-4DEC-4535-95EB-AE3D90A3FDF5} - {8E733844-4204-43E7-B3DC-3913CDDABB0D} = {62ED6240-4DEC-4535-95EB-AE3D90A3FDF5} - {A4565538-625A-42C6-A330-DD4F1ABB3986} = {62ED6240-4DEC-4535-95EB-AE3D90A3FDF5} - {6D4FB8E6-4D0B-4928-8F9E-EF5C2FBF44E8} = {2D2EDE5F-6610-4DF9-AAFD-664F4023A99D} - {079BAB31-3DC4-40DA-90C7-EFAA8517C647} = {CC0E5493-29E8-4ACB-8462-5724A6F636DE} - {4CB351F4-B3F2-4F77-ACC2-02F21DBF5EC2} = {CC0E5493-29E8-4ACB-8462-5724A6F636DE} + {F604D684-BC1D-4819-88B5-8B5D03A17BE0} = {47EA2879-1D40-4683-BA6C-AB51F286EBDE} + {8E733844-4204-43E7-B3DC-3913CDDABB0D} = {47EA2879-1D40-4683-BA6C-AB51F286EBDE} + {9BECA849-E6E9-4E15-83A6-ADD8C18065CB} = {47EA2879-1D40-4683-BA6C-AB51F286EBDE} + {A4565538-625A-42C6-A330-DD4F1ABB3986} = {47EA2879-1D40-4683-BA6C-AB51F286EBDE} + {079BAB31-3DC4-40DA-90C7-EFAA8517C647} = {AE5B181B-BD8F-4F36-A64E-32C4FF7B6FD6} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {51C827AB-3306-4EE6-9E60-B7BF84854469} diff --git a/tests/SM_TEST/App.config b/SM_TEST/App.config similarity index 59% rename from tests/SM_TEST/App.config rename to SM_TEST/App.config index 8227adb..88fa402 100644 --- a/tests/SM_TEST/App.config +++ b/SM_TEST/App.config @@ -1,6 +1,6 @@ - + - + - + \ No newline at end of file diff --git a/src/renderer/SM.OGL/OpenTK.dll.config b/SM_TEST/OpenTK.dll.config similarity index 100% rename from src/renderer/SM.OGL/OpenTK.dll.config rename to SM_TEST/OpenTK.dll.config diff --git a/SM_TEST/Program.cs b/SM_TEST/Program.cs new file mode 100644 index 0000000..940dcf7 --- /dev/null +++ b/SM_TEST/Program.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Drawing; +using OpenTK; +using OpenTK.Graphics; +using OpenTK.Graphics.OpenGL; +using SM.Base; +using SM.Base.Animation; +using SM.Base.Controls; +using SM.Base.Drawing; +using SM.Base.Time; +using SM.Base.Window; +using SM2D; +using SM2D.Drawing; +using SM2D.Object; +using SM2D.Scene; +using Font = SM.Base.Drawing.Text.Font; + +namespace SM_TEST +{ + class Program + { + static Scene scene; + private static GLWindow window; + private static PolyLine line; + private static DrawParticles particles; + + private static InterpolationProcess interpolation; + static void Main(string[] args) + { + Font font = new Font(@"C:\Windows\Fonts\Arial.ttf") + { + FontSize = 30, + }; + font.RegenerateTexture(); + + window = new GLWindow(1280, 720, "0ms", WindowFlags.Window, VSyncMode.Off); + window.ApplySetup(new Window2DSetup()); + + window.SetScene(scene = new Scene() + { + ShowAxisHelper = true + }); + scene.Background.Color = Color4.Blue; + scene.Camera = new Camera() + { + + }; + + DrawObject2D test = new DrawObject2D() + { + Texture = new Bitmap("test.png") + }; + test.Material.Blending = true; + test.Transform.Size.Set(100); + test.TextureTransform.SetRectangleRelative(test.Texture, new Vector2(234, 0), new Vector2(220, 201)); + test.Transform.AdjustSizeToTextureTransform(test.TextureTransform); + + scene.Objects.Add(test); + + window.UpdateFrame += WindowOnUpdateFrame; + window.RenderFrame += Window_RenderFrame; + window.Run(); + + Debug.WriteLine("Window Closed"); + } + + private static void Window_RenderFrame(object sender, FrameEventArgs e) + { + window.Title = Math.Floor(e.Time * 1000) + "ms"; + } + + private static void WindowOnUpdateFrame(object sender, FrameEventArgs e) + { + if (Mouse.LeftClick) + interpolation.Stop(); + if (Mouse.RightClick) + interpolation.Stop(false); + } + } +} \ No newline at end of file diff --git a/tests/SM_TEST/Properties/AssemblyInfo.cs b/SM_TEST/Properties/AssemblyInfo.cs similarity index 100% rename from tests/SM_TEST/Properties/AssemblyInfo.cs rename to SM_TEST/Properties/AssemblyInfo.cs diff --git a/src/optionals/SM.Intergrations/SMRenderer.Intergrations.csproj b/SM_TEST/SM_TEST.csproj similarity index 63% rename from src/optionals/SM.Intergrations/SMRenderer.Intergrations.csproj rename to SM_TEST/SM_TEST.csproj index aeea189..5cd19ac 100644 --- a/src/optionals/SM.Intergrations/SMRenderer.Intergrations.csproj +++ b/SM_TEST/SM_TEST.csproj @@ -4,17 +4,17 @@ Debug AnyCPU - {4CB351F4-B3F2-4F77-ACC2-02F21DBF5EC2} - Library - Properties - SM.Intergrations - SM.Intergrations + {6D4FB8E6-4D0B-4928-8F9E-EF5C2FBF44E8} + WinExe + SM_TEST + SM_TEST v4.5.2 512 + true true - + AnyCPU true full false @@ -24,6 +24,7 @@ 4 + AnyCPU pdbonly true bin\Release\ @@ -31,43 +32,43 @@ prompt 4 + + + - ..\..\..\packages\OpenTK.3.3.1\lib\net20\OpenTK.dll - - - ..\..\..\packages\ShaderToolParser.1.0.0-pre3\lib\net450\ShaderToolParser.dll + ..\packages\OpenTK.3.3.1\lib\net20\OpenTK.dll - - - - - - + - - - - - - - - {8e733844-4204-43e7-b3dc-3913cddabb0d} - SM.Base - - - {f604d684-bc1d-4819-88b5-8b5d03a17be0} - SM.OGL - + + + + + + + + {8e733844-4204-43e7-b3dc-3913cddabb0d} + SM.Base + + + {f604d684-bc1d-4819-88b5-8b5d03a17be0} + SM.OGL + + + {a4565538-625a-42c6-a330-dd4f1abb3986} + SM2D + + \ No newline at end of file diff --git a/SM_TEST/TestRenderPipeline.cs b/SM_TEST/TestRenderPipeline.cs new file mode 100644 index 0000000..5c4edfb --- /dev/null +++ b/SM_TEST/TestRenderPipeline.cs @@ -0,0 +1,48 @@ +using OpenTK.Graphics.OpenGL4; +using SM.Base.PostEffects; +using SM.Base.Window; +using SM.OGL.Framebuffer; +using SM.OGL.Texture; + +namespace SM_TEST +{ + public class TestRenderPipeline : RenderPipeline + { + private BloomEffect _bloom; + private Framebuffer _postBuffer; + + public override void Initialization() + { + + MainFramebuffer = CreateWindowFramebuffer(16, PixelInformation.RGBA_HDR); + + _postBuffer = CreateWindowFramebuffer(0, PixelInformation.RGBA_HDR, depth: false); + Framebuffers.Add(_postBuffer); + _bloom = new BloomEffect(_postBuffer, hdr: true, .5f) + { + Threshold = .5f, + }; + + + _bloom.Initilize(this); + base.Initialization(); + } + + protected override void RenderProcess(ref DrawContext context) + { + MainFramebuffer.Activate(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); + context.Scene.DrawBackground(context); + context.Scene.DrawMainObjects(context); + context.Scene.DrawHUD(context); + + PostProcessUtility.ResolveMultisampledBuffers(MainFramebuffer, _postBuffer); + + // _bloom.Draw(context); + Framebuffer.Screen.Activate(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); + + PostProcessUtility.FinalizeHDR(_postBuffer["color"], .5f); + + context.Scene.DrawDebug(context); + } + } +} \ No newline at end of file diff --git a/tests/SM_TEST/packages.config b/SM_TEST/packages.config similarity index 54% rename from tests/SM_TEST/packages.config rename to SM_TEST/packages.config index 7b1ca7f..2a7b555 100644 --- a/tests/SM_TEST/packages.config +++ b/SM_TEST/packages.config @@ -1,9 +1,6 @@  - - - \ No newline at end of file diff --git a/SM_WPF_TEST/App.config b/SM_WPF_TEST/App.config new file mode 100644 index 0000000..88fa402 --- /dev/null +++ b/SM_WPF_TEST/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/SM_WPF_TEST/App.xaml b/SM_WPF_TEST/App.xaml new file mode 100644 index 0000000..c032034 --- /dev/null +++ b/SM_WPF_TEST/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/SM_WPF_TEST/App.xaml.cs b/SM_WPF_TEST/App.xaml.cs new file mode 100644 index 0000000..e481a44 --- /dev/null +++ b/SM_WPF_TEST/App.xaml.cs @@ -0,0 +1,11 @@ +using System.Windows; + +namespace SM_WPF_TEST +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + } +} diff --git a/SM_WPF_TEST/MainWindow.xaml b/SM_WPF_TEST/MainWindow.xaml new file mode 100644 index 0000000..be260a8 --- /dev/null +++ b/SM_WPF_TEST/MainWindow.xaml @@ -0,0 +1,16 @@ + + + + + + + + diff --git a/SM_WPF_TEST/MainWindow.xaml.cs b/SM_WPF_TEST/MainWindow.xaml.cs new file mode 100644 index 0000000..5ee0f90 --- /dev/null +++ b/SM_WPF_TEST/MainWindow.xaml.cs @@ -0,0 +1,32 @@ +using System.Windows; + +namespace SM_WPF_TEST +{ + /// + /// Interaction logic for MainWindow.xaml + /// + public partial class MainWindow : Window + { + public MainWindow() + { + InitializeComponent(); + /* + GLWPFWindow2D gl; + Scene scene; + gl = new GLWPFWindow2D(); + Grid.SetColumn(gl, 1); + grid.Children.Add(gl); + + gl.Start(); + + gl.SetScene(scene = new Scene()); + gl.SetRenderPipeline(Default2DPipeline.Pipeline); + + DrawObject2D cube = new DrawObject2D(); + cube.Color = Color4.Blue; + scene.Objects.Add(cube); + + new Window1().Show();*/ + } + } +} diff --git a/src/renderer/SM2D/OpenTK.dll.config b/SM_WPF_TEST/OpenTK.dll.config similarity index 100% rename from src/renderer/SM2D/OpenTK.dll.config rename to SM_WPF_TEST/OpenTK.dll.config diff --git a/SM_WPF_TEST/Properties/AssemblyInfo.cs b/SM_WPF_TEST/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..499ad94 --- /dev/null +++ b/SM_WPF_TEST/Properties/AssemblyInfo.cs @@ -0,0 +1,53 @@ +using System.Reflection; +using System.Runtime.InteropServices; +using System.Windows; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("SM_WPF_TEST")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SM_WPF_TEST")] +[assembly: AssemblyCopyright("Copyright © 2021")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +//In order to begin building localizable applications, set +//CultureYouAreCodingWith in your .csproj file +//inside a . For example, if you are using US english +//in your source files, set the to en-US. Then uncomment +//the NeutralResourceLanguage attribute below. Update the "en-US" in +//the line below to match the UICulture setting in the project file. + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] + + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/SM_WPF_TEST/Properties/Resources.Designer.cs b/SM_WPF_TEST/Properties/Resources.Designer.cs new file mode 100644 index 0000000..9cf796e --- /dev/null +++ b/SM_WPF_TEST/Properties/Resources.Designer.cs @@ -0,0 +1,70 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + + +namespace SM_WPF_TEST.Properties +{ + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SM_WPF_TEST.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/SM_WPF_TEST/Properties/Resources.resx b/SM_WPF_TEST/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/SM_WPF_TEST/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/SM_WPF_TEST/Properties/Settings.Designer.cs b/SM_WPF_TEST/Properties/Settings.Designer.cs new file mode 100644 index 0000000..a1c90c7 --- /dev/null +++ b/SM_WPF_TEST/Properties/Settings.Designer.cs @@ -0,0 +1,29 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + + +namespace SM_WPF_TEST.Properties +{ + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/SM_WPF_TEST/Properties/Settings.settings b/SM_WPF_TEST/Properties/Settings.settings new file mode 100644 index 0000000..033d7a5 --- /dev/null +++ b/SM_WPF_TEST/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/SM_WPF_TEST/SM_WPF_TEST.csproj b/SM_WPF_TEST/SM_WPF_TEST.csproj new file mode 100644 index 0000000..3d7484c --- /dev/null +++ b/SM_WPF_TEST/SM_WPF_TEST.csproj @@ -0,0 +1,102 @@ + + + + + Debug + AnyCPU + {6F5367D3-B7E9-40CE-A692-29F9892B6F2A} + WinExe + SM_WPF_TEST + SM_WPF_TEST + v4.5.2 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + 4.0 + + + + + + + + MSBuild:Compile + Designer + + + Window1.xaml + + + MSBuild:Compile + Designer + + + App.xaml + Code + + + MainWindow.xaml + Code + + + Designer + MSBuild:Compile + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + + \ No newline at end of file diff --git a/SM_WPF_TEST/Window1.xaml b/SM_WPF_TEST/Window1.xaml new file mode 100644 index 0000000..70408e6 --- /dev/null +++ b/SM_WPF_TEST/Window1.xaml @@ -0,0 +1,12 @@ + + + + + diff --git a/SM_WPF_TEST/Window1.xaml.cs b/SM_WPF_TEST/Window1.xaml.cs new file mode 100644 index 0000000..d5d3271 --- /dev/null +++ b/SM_WPF_TEST/Window1.xaml.cs @@ -0,0 +1,30 @@ +using System.Windows; + +namespace SM_WPF_TEST +{ + /// + /// Interaction logic for Window1.xaml + /// + public partial class Window1 : Window + { + public Window1() + { + InitializeComponent(); + + /*GLWPFWindow2D gl; + Scene scene; + Content = gl = new GLWPFWindow2D(); + gl.Start(); + + gl.SetScene(scene = new Scene()); + gl.SetRenderPipeline(Basic2DPipeline.Pipeline); + + DrawObject2D obj = new DrawObject2D() + { + Color = Color4.Red + }; + obj.ApplyCircle(); + scene.Objects.Add(obj);*/ + } + } +} diff --git a/src/renderer/SM.OGL/packages.config b/SM_WPF_TEST/packages.config similarity index 51% rename from src/renderer/SM.OGL/packages.config rename to SM_WPF_TEST/packages.config index 1f65eab..82cdaeb 100644 --- a/src/renderer/SM.OGL/packages.config +++ b/SM_WPF_TEST/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/src/optionals/SM.Intergrations/ShaderTool/STMaterial.cs b/src/optionals/SM.Intergrations/ShaderTool/STMaterial.cs deleted file mode 100644 index 5f52732..0000000 --- a/src/optionals/SM.Intergrations/ShaderTool/STMaterial.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO.Pipes; -using OpenTK; -using OpenTK.Graphics; -using ShaderToolParser.Nodes; -using ShaderToolParser.Nodes.Textures; -using ShaderToolParser.Variables; -using SM.Base.Drawing; -using SM.Base.Textures; -using SM.Base.Window; - -namespace SM.Intergrations.ShaderTool -{ - public class STMaterial : Material - { - private Vector4 _tintVector = Vector4.One; - - public override Color4 Tint - { - get => Color4.FromXyz(_tintVector); - set => _tintVector = Color4.ToXyz(value); - } - - public STMaterial(STPDrawNode node) - { - if (node.OGLEffect == null) - throw new Exception("[ERROR AT IMPORTING MATERIAL] DrawNode didn't contain a OpenGL-shader."); - - CustomShader = new STMaterialShader(node); - - foreach (KeyValuePair pair in node.Variables) - { - if (pair.Value.Type == STPBasisType.Texture) - ShaderArguments[pair.Key] = new Texture(((STPTextureNode) pair.Value.Texture).Bitmap); - } - } - - public override void Draw(DrawContext context) - { - ShaderArguments["MVP"] = context.Instances[0].ModelMatrix * context.ModelMatrix * context.View * context.World; - ShaderArguments["MasterTextureMatrix"] = context.Instances[0].TextureMatrix * context.TextureMatrix; - ShaderArguments["HasVColor"] = context.Mesh.Attributes.Has("color"); - - ShaderArguments["_MATColor"] = _tintVector; - - base.Draw(context); - } - } -} \ No newline at end of file diff --git a/src/optionals/SM.Intergrations/ShaderTool/STMaterialShader.cs b/src/optionals/SM.Intergrations/ShaderTool/STMaterialShader.cs deleted file mode 100644 index dbc876e..0000000 --- a/src/optionals/SM.Intergrations/ShaderTool/STMaterialShader.cs +++ /dev/null @@ -1,70 +0,0 @@ - -using System; -using System.Collections.Generic; -using OpenTK; -using ShaderToolParser.Nodes; -using ShaderToolParser.Variables; -using SM.Base.Shaders; -using SM.Base.Textures; -using SM.Base.Window; -using SM.OGL.Shaders; -using SM.OGL.Texture; - -namespace SM.Intergrations.ShaderTool -{ - public class STMaterialShader : MaterialShader - { - private event Action _uniforms; - - public STMaterialShader(STPDrawNode drawNode) : base(new ShaderFileCollection()) - { - if (drawNode.OGLEffect == null) - throw new Exception("[ERROR AT IMPORTING SHADER] DrawNode didn't contain a OpenGL-shader."); - - STPCompositeNode composeNode = drawNode.OGLEffect; - - ShaderFiles.Vertex = new[] { new ShaderFile(composeNode.Vertex.ShaderCode) }; - ShaderFiles.Fragment = new [] {new ShaderFile(composeNode.Fragment.ShaderCode)}; - if (composeNode.Geometry != null) - ShaderFiles.Geometry = new[] {new ShaderFile(composeNode.Geometry.ShaderCode)}; - - foreach (KeyValuePair pair in drawNode.Variables) - { - switch (pair.Value.Type) - { - case STPBasisType.Bool: - _uniforms += context => Uniforms[pair.Key].SetBool(context.Material.ShaderArguments.Get(pair.Key, false)); - break; - case STPBasisType.Float: - _uniforms += context => Uniforms[pair.Key].SetFloat(context.Material.ShaderArguments.Get(pair.Key, 0.0f)); - break; - case STPBasisType.Vector2: - _uniforms += context => Uniforms[pair.Key].SetVector2(context.Material.ShaderArguments.Get(pair.Key, Vector2.Zero)); - break; - case STPBasisType.Vector3: - _uniforms += context => Uniforms[pair.Key].SetVector3(context.Material.ShaderArguments.Get(pair.Key, Vector3.Zero)); - break; - case STPBasisType.Vector4: - _uniforms += context => - Uniforms[pair.Key].SetVector4(context.Material.ShaderArguments.Get(pair.Key, Vector4.Zero)); - break; - case STPBasisType.Matrix: - _uniforms += context => Uniforms[pair.Key].SetMatrix4(context.Material.ShaderArguments.Get(pair.Key, Matrix4.Identity)); - break; - case STPBasisType.Texture: - _uniforms += context => Uniforms[pair.Key].SetTexture(context.Material.ShaderArguments.Get(pair.Key, null)); - break; - default: - throw new ArgumentOutOfRangeException(); - } - } - } - - protected override void DrawProcess(DrawContext context) - { - _uniforms.Invoke(context); - - DrawObject(context.ForcedType.GetValueOrDefault(context.Mesh.PrimitiveType), context.Mesh); - } - } -} \ No newline at end of file diff --git a/src/optionals/SM.Intergrations/ShaderTool/STPostProcessEffect.cs b/src/optionals/SM.Intergrations/ShaderTool/STPostProcessEffect.cs deleted file mode 100644 index 6b70f88..0000000 --- a/src/optionals/SM.Intergrations/ShaderTool/STPostProcessEffect.cs +++ /dev/null @@ -1,68 +0,0 @@ -using System; -using System.Collections.Generic; -using OpenTK.Graphics.OpenGL4; -using ShaderToolParser.Nodes; -using ShaderToolParser.Nodes.Textures; -using ShaderToolParser.Variables; -using SM.Base.Drawing; -using SM.Base.PostProcess; -using SM.Base.Textures; -using SM.Base.Window; -using SM.OGL.Framebuffer; -using SM.OGL.Texture; - -namespace SM.Intergrations.ShaderTool -{ - public class STPostProcessEffect : PostProcessEffect - { - private STPostProcessShader _shader; - private Framebuffer tempFramebuffer; - - public ShaderArguments Arguments; - - public STPostProcessEffect(STPDrawNode postEffectNode) - { - Arguments = Arguments ?? new ShaderArguments(); - - if (postEffectNode.OGLEffect == null) - throw new Exception("[ERROR AT IMPORTING EFFECT] DrawNode didn't contain a OpenGL-shader."); - - _shader = new STPostProcessShader(postEffectNode); - - foreach (KeyValuePair pair in postEffectNode.Variables) - { - - if (pair.Value.Type == STPBasisType.Texture) - { - if (pair.Value.Texture == null) continue; - Arguments[pair.Key] = new Texture(((STPTextureNode)pair.Value.Texture).Bitmap); - } - } - } - - protected override void InitProcess() - { - base.InitProcess(); - tempFramebuffer = Pipeline.CreateWindowFramebuffer(0, PixelInformation.RGB_HDR, false); - tempFramebuffer.Compile(); - } - - public override void ScreenSizeChanged(IGenericWindow window) - { - tempFramebuffer.Recompile(); - } - - protected override void Drawing(ColorAttachment source, DrawContext context) - { - Arguments["_Scene"] = (TextureBase)source; - Arguments["_MVP"] = Mvp; - Arguments["_ViewportSize"] = context.Window.WindowSize; - - source.ConnectedFramebuffer.CopyTo(tempFramebuffer); - tempFramebuffer.Activate(); - - _shader.Draw(Arguments); - tempFramebuffer.CopyTo(source.ConnectedFramebuffer); - } - } -} \ No newline at end of file diff --git a/src/optionals/SM.Intergrations/ShaderTool/STPostProcessShader.cs b/src/optionals/SM.Intergrations/ShaderTool/STPostProcessShader.cs deleted file mode 100644 index a8226cc..0000000 --- a/src/optionals/SM.Intergrations/ShaderTool/STPostProcessShader.cs +++ /dev/null @@ -1,74 +0,0 @@ -using System; -using System.Collections.Generic; -using OpenTK; -using OpenTK.Graphics.OpenGL4; -using ShaderToolParser.Nodes; -using ShaderToolParser.Variables; -using SM.Base.Drawing; -using SM.Base.Objects.Static; -using SM.Base.Textures; -using SM.OGL.Shaders; -using SM.OGL.Texture; - -namespace SM.Intergrations.ShaderTool -{ - public class STPostProcessShader : GenericShader - { - private event Action _uniforms; - - public STPostProcessShader(STPDrawNode postProcessNode) : base(new ShaderFileCollection()) - { - if (postProcessNode.OGLEffect == null) - throw new Exception("[ERROR AT IMPORTING SHADER] DrawNode didn't contain a OpenGL-shader."); - - STPCompositeNode composeNode = postProcessNode.OGLEffect; - - ShaderFiles.Vertex = new[] { new ShaderFile(composeNode.Vertex.ShaderCode) }; - ShaderFiles.Fragment = new[] { new ShaderFile(composeNode.Fragment.ShaderCode) }; - if (composeNode.Geometry != null) - ShaderFiles.Geometry = new[] { new ShaderFile(composeNode.Geometry.ShaderCode) }; - - foreach (KeyValuePair pair in postProcessNode.Variables) - { - switch (pair.Value.Type) - { - case STPBasisType.Bool: - _uniforms += context => Uniforms[pair.Key].SetBool(context.Get(pair.Key, false)); - break; - case STPBasisType.Float: - _uniforms += context => Uniforms[pair.Key].SetFloat(context.Get(pair.Key, 0.0f)); - break; - case STPBasisType.Vector2: - _uniforms += context => Uniforms[pair.Key].SetVector2(context.Get(pair.Key, Vector2.Zero)); - break; - case STPBasisType.Vector3: - _uniforms += context => Uniforms[pair.Key].SetVector3(context.Get(pair.Key, Vector3.Zero)); - break; - case STPBasisType.Vector4: - _uniforms += context => - Uniforms[pair.Key].SetVector4(context.Get(pair.Key, Vector4.Zero)); - break; - case STPBasisType.Matrix: - _uniforms += context => Uniforms[pair.Key].SetMatrix4(context.Get(pair.Key, Matrix4.Identity)); - break; - case STPBasisType.Texture: - _uniforms += context => Uniforms[pair.Key].SetTexture(context.Get(pair.Key, null)); - break; - default: - throw new ArgumentOutOfRangeException(); - } - } - } - - public void Draw(ShaderArguments arguments) - { - Activate(); - Plate.Object.Activate(); - - _uniforms.Invoke(arguments); - - GL.DrawArrays(PrimitiveType.Quads, 0, 4); - CleanUp(); - } - } -} \ No newline at end of file diff --git a/src/optionals/SM.Utils/Controls/GameController.cs b/src/optionals/SM.Utils/Controls/GameController.cs deleted file mode 100644 index 43570dc..0000000 --- a/src/optionals/SM.Utils/Controls/GameController.cs +++ /dev/null @@ -1,56 +0,0 @@ -using SharpDX.XInput; -using SM.Base; - -namespace SM.Utils.Controls -{ - public class GameController - { - public static float GlobalDeadband = .1F; - - private Controller _controller; - private ulong _lastFrame; - - internal GamepadButtonFlags _lastPressedButtons; - - public float Deadband { get; set; } - public bool IsConnected => _controller.IsConnected; - - public GameControllerState LastState { get; private set; } - - public UserIndex Index { get; private set; } - - public GameController(int id) : this((UserIndex)id) - {} - - public GameController(UserIndex index = UserIndex.Any) - { - _lastPressedButtons = GamepadButtonFlags.None; - _controller = new Controller(index); - Index = index; - Deadband = GlobalDeadband; - } - - public GameControllerState GetState(bool force = false) - { - if (!force && _lastFrame == SMRenderer.CurrentFrame) - { - return LastState; - } - - GameControllerState st = new GameControllerState(true); - if (IsConnected) - { - Gamepad state = _controller.GetState().Gamepad; - st = new GameControllerState(state, this); - _lastPressedButtons = state.Buttons; - } - - LastState = st; - - _lastFrame = SMRenderer.CurrentFrame; - - return st; - } - - } -} \ No newline at end of file diff --git a/src/optionals/SM.Utils/Controls/GameControllerStateThumbs.cs b/src/optionals/SM.Utils/Controls/GameControllerStateThumbs.cs deleted file mode 100644 index 6741a3c..0000000 --- a/src/optionals/SM.Utils/Controls/GameControllerStateThumbs.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using OpenTK; -using SharpDX.XInput; - -namespace SM.Utils.Controls -{ - public struct GameControllerStateThumbs - { - public static GameControllerStateThumbs Default = new GameControllerStateThumbs() - {Left = Vector2.Zero, Right = Vector2.Zero}; - - public Vector2 Left; - public Vector2 Right; - - public bool PressedLeft; - public bool PressedRight; - - public bool AnyInteraction => Left != Vector2.Zero || Right != Vector2.Zero || PressedLeft || PressedRight; - - public GameControllerStateThumbs(GameController controller, Gamepad state) - { - Vector2 left = new Vector2(state.LeftThumbX, state.LeftThumbY) / short.MaxValue; - Vector2 right = new Vector2(state.RightThumbX, state.RightThumbY) / short.MaxValue; - - Left = new Vector2(Math.Abs(left.X) < controller.Deadband ? 0 : left.X, Math.Abs(left.Y) < controller.Deadband ? 0 : left.Y); - Right = new Vector2(Math.Abs(right.X) < controller.Deadband ? 0 : right.X, Math.Abs(right.Y) < controller.Deadband ? 0 : right.Y); - - PressedLeft = state.Buttons.HasFlag(GamepadButtonFlags.LeftThumb); - PressedRight = state.Buttons.HasFlag(GamepadButtonFlags.RightThumb); - } - - public override string ToString() - { - return $"Left: ({Left.X}; {Left.Y}){(PressedLeft ? " Pressed" : "")}; Right: ({Right.X}; {Right.Y}){(PressedRight ? " Pressed" : "")}"; - } - } -} \ No newline at end of file diff --git a/src/renderer/SM.Base/Drawing/Particles/ParticleDrawingBasis.cs b/src/renderer/SM.Base/Drawing/Particles/ParticleDrawingBasis.cs deleted file mode 100644 index 8461927..0000000 --- a/src/renderer/SM.Base/Drawing/Particles/ParticleDrawingBasis.cs +++ /dev/null @@ -1,212 +0,0 @@ -#region usings - -using System; -using System.Collections.Generic; -using OpenTK; -using SM.Base.Scene; -using SM.Base.Time; -using SM.Base.Window; -using Stopwatch = System.Diagnostics.Stopwatch; - -#endregion - -namespace SM.Base.Drawing.Particles -{ - /// - /// The (drawing) basis for particles - /// - public abstract class ParticleDrawingBasis : DrawingBasis, IScriptable - where TTransform : GenericTransformation, new() - where TDirection : struct - { - private float? _continuesIntervalSeconds = null; - private Interval _continuesInterval; - - /// - /// The stopwatch of the particles. - /// - protected Timer timer; - - /// - /// This contains the different instances for the particles. - /// - protected List> instances; - - /// - /// The amount of particles - /// - public int Amount = 32; - - /// - /// The base lifetime for particles in seconds. - /// - public float Lifetime; - /// - /// Randomizes the lifetime for particles. - /// - public float LifetimeRandomize = 0; - - /// - /// If set to any value (except null), it will create the particles continuously. - /// - public float? ContinuousInterval - { - get => _continuesIntervalSeconds; - set - { - if (value.HasValue) - { - _continuesInterval.Target = value.Value; - } - - _continuesIntervalSeconds = value; - } - } - - /// - /// If true, the particles will spawn in Worldspace and can't be moved by the transformation. - /// - public bool DetachedParticles; - - /// - /// The maximum speed of the particles - /// Default: 25 - /// - public float MaxSpeed = 25; - - /// - /// Sets up the timer. - /// - /// Duration how long the particles should live - protected ParticleDrawingBasis(TimeSpan duration) - { - timer = new Timer(duration); - _continuesInterval = new Interval(0); - _continuesInterval.End += CreateContinuesParticles; - - Lifetime = (float) duration.TotalSeconds; - } - - /// - /// Get/Sets the state of pausing. - /// - public bool Paused - { - get => timer.Paused; - set => timer.Paused = value; - } - - /// - /// Controls the movement of each particles. - /// - public abstract Func, TDirection> MovementCalculation { get; set; } - - /// - public bool UpdateActive { - get => timer.Active || _continuesInterval.Active; - set { return; } - } - - /// - public void Update(UpdateContext context) - { - Stopwatch stp = new Stopwatch(); - stp.Start(); - for (int i = 0; i < instances.Count; i++) - { - instances[i].Lifetime -= context.Deltatime; - if (instances[i].Lifetime <= 0) - { - instances.Remove(instances[i]); - break; - } - - instances[i].ModelMatrix = CreateMatrix(instances[i], MovementCalculation(instances[i])); - } - - Console.WriteLine(); - } - - /// - /// Triggers the particles. - /// - public void Trigger() - { - instances = new List>(); - if (_continuesIntervalSeconds.HasValue) - { - _continuesInterval.Target = _continuesIntervalSeconds.Value; - _continuesInterval.Start(); - - return; - } - - timer.Start(); - - CreateParticles(); - } - - /// - /// Stops the particles. - /// - public void Stop() - { - if (_continuesInterval.Active) - { - _continuesInterval.Stop(); - } - - timer.Stop(); - } - - /// - public override void OnRemoved(object sender) - { - base.OnRemoved(sender); - - Stop(); - } - - /// - protected override void DrawContext(ref DrawContext context) - { - if (!timer.Active && _continuesInterval != null && !_continuesInterval.Active) return; - - base.DrawContext(ref context); - - if (DetachedParticles) context.ModelMatrix = Matrix4.Identity; - - context.Instances = instances.ConvertAll(a => (Instance)a); - - Material.Draw(context); - } - - /// - /// Creates the particles. - /// - protected virtual void CreateParticles() - { - - - for (int i = 0; i < Amount; i++) - { - instances.Add(CreateObject(i)); - } - } - - private void CreateContinuesParticles(Timer arg1, UpdateContext arg2) - { - instances.Add(CreateObject(0)); - } - - /// - /// Creates a particle. - /// - protected abstract ParticleInstance CreateObject(int index); - - /// - /// Generates the desired matrix for drawing. - /// - protected abstract Matrix4 CreateMatrix(ParticleInstance Struct, TDirection relativePosition); - } -} \ No newline at end of file diff --git a/src/renderer/SM.Base/Drawing/Particles/ParticleInstance.cs b/src/renderer/SM.Base/Drawing/Particles/ParticleInstance.cs deleted file mode 100644 index 9b94926..0000000 --- a/src/renderer/SM.Base/Drawing/Particles/ParticleInstance.cs +++ /dev/null @@ -1,40 +0,0 @@ -using OpenTK; - -namespace SM.Base.Drawing.Particles -{ - /// - /// This describes a instance of a particle - /// - public class ParticleInstance : Instance - { - /// - /// The lifetime the particle started with. - /// - public float StartLifetime = 0; - - /// - /// The lifetime this particular particle still has. - /// - public float Lifetime = 0; - - /// - /// A additional matrix to store rotation and scale. - /// - public Matrix4 Matrix; - - /// - /// Speeeeeeeeeed - /// - public float Speed; - } - - /// - public class ParticleInstance : ParticleInstance - where TValue : struct - { - /// - /// A direction, that the particle should travel. - /// - public TValue Direction; - } -} \ No newline at end of file diff --git a/src/renderer/SM.Base/PostEffects/BloomEffect.cs b/src/renderer/SM.Base/PostEffects/BloomEffect.cs deleted file mode 100644 index 0a75569..0000000 --- a/src/renderer/SM.Base/PostEffects/BloomEffect.cs +++ /dev/null @@ -1,270 +0,0 @@ -using OpenTK; -using OpenTK.Graphics; -using OpenTK.Graphics.OpenGL4; -using SM.Base.Drawing; -using SM.Base.PostProcess; -using SM.Base.Types; -using SM.Base.Utility; -using SM.Base.Window; -using SM.OGL.Framebuffer; -using SM.OGL.Shaders; -using SM.OGL.Texture; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SM.Base.PostEffects -{ - enum BloomEffectShaderType - { - Filtering, - Downsampling, - Upsampling, - Combine - } - - /// - /// The recommended bloom effect, that looks way better than the old one. - /// Based on Blender's implermentation, which is based on COD: Infinite Warfare. - /// - public class BloomEffect : PostProcess.PostProcessEffect - { - private static readonly ShaderFile samplingFile = new ShaderFile(AssemblyUtility.ReadAssemblyFile(SMRenderer.PostProcessPath + ".bloom.sampling.frag")); - - private static readonly PostProcessShader _filterShader = new PostProcessShader( - AssemblyUtility.ReadAssemblyFile(SMRenderer.PostProcessPath + ".bloom.filter.frag") - ); - private static readonly PostProcessShader _downsampleShader = new PostProcessShader( - AssemblyUtility.ReadAssemblyFile(SMRenderer.PostProcessPath + ".bloom.downsample.frag") - ); - private static readonly PostProcessShader _upsampleShader = new PostProcessShader( - AssemblyUtility.ReadAssemblyFile(SMRenderer.PostProcessPath + ".bloom.upsample.frag") - ); - private static readonly PostProcessShader _combineShader = new PostProcessShader( - new ShaderFile(AssemblyUtility.ReadAssemblyFile(SMRenderer.PostProcessPath + ".bloom.combine.vert")), - AssemblyUtility.ReadAssemblyFile(SMRenderer.PostProcessPath + ".bloom.combine.frag") - ); - - static BloomEffect() - { - _upsampleShader.ShaderFiles.Fragment[0].GLSLExtensions.Add(samplingFile); - _combineShader.ShaderFiles.Fragment[0].GLSLExtensions.Add(samplingFile); - } - - /* - private static readonly string bloomFile = AssemblyUtility.ReadAssemblyFile(SMRenderer.PostProcessPath + ".bloom.frag"); - private static readonly ShaderFile combineVertex = new ShaderFile(AssemblyUtility.ReadAssemblyFile(SMRenderer.PostProcessPath + ".bloom.combine.vert")); - - static Dictionary _ppShaders = new Dictionary(2); - - static PostProcessShader[] GetShaders(bool high) - { - if (_ppShaders.ContainsKey(high)) return _ppShaders[high]; - - PostProcessShader[] shaders; - _ppShaders.Add(high, shaders = new PostProcessShader[4]); - - for(int i = 0; i < 4; i++) - { - ShaderFile file = new ShaderFile(bloomFile) - { - Defines = - { - "ACTION_"+((BloomEffectShaderType)i).ToString().ToUpper(), - } - }; - if (high) file.Defines.Add("HIGH"); - - PostProcessShader shader; - if (i == 3) shader = new PostProcessShader(vertex: combineVertex, file); - else shader = new PostProcessShader(file); - - shaders[i] = shader; - } - - return shaders; - }*/ - - const int MAXBLOOMSTEPS = 8; - const float INTENSITY = .1f; - - private readonly bool _hdr; - - private List _downsampler; - private List _upsample; - private PostProcessShader[] shaders; - - private int _iterations; - private float _sampleSize; - private Vector4 _thresholdCurve; - private Color4 _bloomColor; - - /// - /// The threshold, where the effect decided what is bright. - /// - public float Threshold = .8f; - /// - /// The radius of the effect. - /// - public float Radius = 6.5f; - /// - /// Makes transition between under/over-threshold gradual. - /// - public float Knee = .5f; - /// - /// The intensity of the effect. - /// - public float Intensity = .5f; - /// - /// The tint of the effect. - /// - public Color4 Color = Color4.White; - - /// - /// An amount map specifices where the bloom effect should be visible. - /// Reads only in the "R"-channel. - /// - public TextureBase AmountMap; - /// - /// Allows you to transform the texture coordnates for - /// - public TextureTransformation AmountMapTransform = new TextureTransformation(); - /// - /// Specifices limits, how the is read. - /// Default: - /// - public MinMax AmountLimits = MinMax.Default; - - /// - /// This creates a more prettier bloom effect. - /// - /// This allows to enable hdr returns. - /// If set true, it will use the high quality settings. - public BloomEffect(bool hdr = false, bool highSetting = true) - { - _hdr = hdr; - //shaders = GetShaders(highSetting); - shaders = new[] { _filterShader, _downsampleShader, _upsampleShader, _combineShader }; - } - /// - protected override void InitProcess() => CreateFramebuffers(); - - private void CreateFramebuffers() - { - if (_downsampler != null) _downsampler.ForEach(a => a.Reset()); - if (_upsample != null) _upsample.ForEach(a => a.Reset()); - - _downsampler = new List(); - _upsample = new List(); - - Vector2 windowSize = Pipeline.ConnectedWindow.WindowSize; - - float minDim = (float)Math.Min(windowSize.X, windowSize.Y); - float maxIter = (Radius - 8.0f) + (float)(Math.Log(minDim) / Math.Log(2)); - int maxIterInt = (int)maxIter; - - _iterations = Math.Max(Math.Min(MAXBLOOMSTEPS, maxIterInt), 1); - - _sampleSize = .5f + maxIter - maxIterInt; - _thresholdCurve = new Vector4( - Threshold - Knee, - Knee * 2, - 0.25f / Math.Max(1e-5f, Knee), - Threshold); - - float intens = (Intensity * INTENSITY); - _bloomColor = new Color4(Color.R * intens, Color.G * intens, Color.B * intens, 1f); - - PixelInformation pixel = new PixelInformation(PixelInternalFormat.R11fG11fB10f, PixelFormat.Rgb, PixelType.Float); - - Vector2 texSize = windowSize; - Framebuffer f = new Framebuffer(texSize); - f.Append("0", new ColorAttachment(0, pixel)); - f.Append("1", new ColorAttachment(1, pixel)); - _downsampler.Add(f); - for (int i = 0; i < _iterations; i++) - { - texSize /= 2; - - f = new Framebuffer(texSize); - f.Append("0", new ColorAttachment(0, pixel)); - _downsampler.Add(f); - - if (i == _iterations - 1) break; - f = new Framebuffer(texSize); - f.Append("0", new ColorAttachment(0, pixel)); - _upsample.Add(f); - } - } - - /// - public override void ScreenSizeChanged(IGenericWindow window) - { - CreateFramebuffers(); - } - - /// - protected override void Drawing(ColorAttachment source, DrawContext context) - { - Framebuffer target = Framebuffer.GetCurrentlyActive(); - - // Filtering - _downsampler[0].Activate(true); - shaders[0].Draw(source, col => - { - col["ThresholdCurve"].SetVector4(_thresholdCurve); - }); - - // Downsampling - ColorAttachment last = _downsampler[0]["0"]; - for(int i = 1; i < _iterations; i++) - { - ColorAttachment downsampleSource = last; - Framebuffer downsampleTarget = _downsampler[i]; - downsampleTarget.Activate(true); - shaders[1].Draw(downsampleSource); - - last = downsampleTarget["0"]; - } - - // Upsampling - for (int i = _iterations - 2; i >= 0; i--) - { - ColorAttachment downsampleSource = _downsampler[i]["0"]; - Framebuffer upsampleTarget = _upsample[i]; - - upsampleTarget.Activate(true); - - shaders[2].Draw(last, (a) => - { - if (last != null) a["baseBuffer"].SetTexture(downsampleSource); - a["sampleSize"].SetFloat(_sampleSize); - }); - - last = upsampleTarget["0"]; - } - - // combine - target.Activate(true); - shaders[3].Draw(last, (a) => - { - a["sampleSize"].SetFloat(_sampleSize); - - a["scene"].SetTexture(_downsampler[0]["1"]); - a["bloomColor"].SetColor(_bloomColor); - - if (AmountMap != null) - { - a["amountTransform"].SetMatrix3(AmountMapTransform.GetMatrix()); - a["amountMap"].SetTexture(AmountMap, a["hasAmountMap"]); - a["amountLimit"].SetVector2((Vector2)AmountLimits); - - } - - a["HDR"].SetBool(_hdr); - }); - } - } -} diff --git a/src/renderer/SM.Base/PostEffects/Shaders/bloom.frag b/src/renderer/SM.Base/PostEffects/Shaders/bloom.frag deleted file mode 100644 index 2401377..0000000 --- a/src/renderer/SM.Base/PostEffects/Shaders/bloom.frag +++ /dev/null @@ -1,188 +0,0 @@ -#version 330 core -/* ACTIONS: -0 = Filtering -1 = Downsamping -2 = Upsampling -3 = Combine -*/ - -in vec2 vTexture; - -uniform vec2 renderedTextureTexelSize; -// Uniforms -uniform vec4 ThresholdCurve; - - -// Downsampling - -uniform float sampleSize; -uniform sampler2D baseBuffer; - -in vec2 amountUV; - -uniform sampler2D scene; -uniform vec4 bloomColor; -uniform bool HDR; - -uniform bool hasAmountMap; -uniform sampler2D amountMap; -uniform vec2 amountLimit; - - -layout(location = 0) out vec4 color; -layout(location = 1) out vec4 sceneOutput; - -vec4 GetRenderColorOffset(vec2); -vec3 reinhardTone(vec3); - -// ---- Utils ---- -vec3 safe_color(vec3 c) { - return clamp(c, vec3(0.0), vec3(1e20)); -} -vec3 median(vec3 a, vec3 b, vec3 c) -{ - return a + b + c - min(min(a, b), c) - max(max(a, b), c); -} -float getBrightness(vec3 col) { - return max(col.r, max(col.g, col.b)); - return (col.r + col.r + col.b + col.g + col.g + col.g) / 6.0; -} - -// ---- Functions ---- -vec3 simpleBoxFilter() { - #if defined (ACTION_DOWNSAMPLING) - vec4 d = renderedTextureTexelSize.xyxy * vec4(-1,-1,1,1); - #else - vec4 d = renderedTextureTexelSize.xyxy * vec4(-1,-1,1,1) * (sampleSize * 0.5); - #endif - - vec3 s; - s = GetRenderColorOffset(d.xy).rgb; - s += GetRenderColorOffset(d.zy).rgb; - s += GetRenderColorOffset(d.xw).rgb; - s += GetRenderColorOffset(d.zw).rgb; - - return s * 0.25; // 1 / 4 = 0.25 -} - -// Downsampling: -vec3 downsample_high() { - vec4 d = renderedTextureTexelSize.xyxy * vec4(-1,-1, +1, +1); - vec3 s1 = GetRenderColorOffset(d.xy).rgb; // - - - // X - - - vec3 s2 = GetRenderColorOffset(d.zy).rgb; // - - - // - X - - vec3 s3 = GetRenderColorOffset(d.xw).rgb; // X - - // - - - - vec3 s4 = GetRenderColorOffset(d.zw).rgb; // X - - // - - - - float s1w = 1.0 / (getBrightness(s1) + 1.0); - float s2w = 1.0 / (getBrightness(s2) + 1.0); - float s3w = 1.0 / (getBrightness(s3) + 1.0); - float s4w = 1.0 / (getBrightness(s4) + 1.0); - float one_div = 1.0 / (s1w + s2w + s3w + s4w); - - return (s1 * s1w + s2 * s2w + s3 * s3w + s4 * s4w) * one_div; -} - -// Upsampling: -vec3 upsample_high() { - vec4 d = renderedTextureTexelSize.xyxy * vec4(1, 1,-1,0) * sampleSize; - - vec3 s; - // Line + 1 - s = GetRenderColorOffset(d.zy).rgb; // x - - - s += GetRenderColorOffset(d.wy).rgb * 2; // - X - - s += GetRenderColorOffset(d.xy).rgb; // - - X - - // Line 0 - s += GetRenderColorOffset(d.zw).rgb * 2; // X - - - s += GetRenderColorOffset(vec2(0)).rgb * 4; // - X - - s += GetRenderColorOffset(d.xw).rgb * 2; // - - X - - // Line - 1 - s += GetRenderColorOffset(d.zz).rgb; // X - - - s += GetRenderColorOffset(d.wz).rgb * 2; // - X - - s += GetRenderColorOffset(d.xz).rgb; // - - X - - return texture2D(baseBuffer, vTexture).rgb + s * 0.0625; // 1 / 16 = 0.0625 -} - -// ---- Actions ---- -vec3 filtering() { - - - vec3 col = safe_color(GetRenderColorOffset(vec2(0)).rgb); - sceneOutput = vec4(col, 1); - return sceneOutput.rgb; - - #ifdef HIGH - vec3 d = renderedTextureTexelSize.xyx * vec3(1,1,0); - vec3 s0 = col + vec3(.1); - vec3 s1 = safe_color(GetRenderColorOffset(-d.xz).rgb) + vec3(.1); - vec3 s2 = safe_color(GetRenderColorOffset(+d.xz).rgb) + vec3(.1); - vec3 s3 = safe_color(GetRenderColorOffset(-d.zy).rgb) + vec3(.1); - vec3 s4 = safe_color(GetRenderColorOffset(+d.zy).rgb) + vec3(.1); - vec3 col = median(median(s0, s1, s2), s3, s4); - #endif - - float br = getBrightness(col); - - float rq = clamp(br - ThresholdCurve.x, 0, ThresholdCurve.y); - rq = ThresholdCurve.z * rq * rq; - - float resultBr = max(rq, br - ThresholdCurve.w) / max(1e-5, br); - return col * resultBr; -} - -vec3 downsample() { - #ifdef HIGH - return downsample_high(); - #else - return simpleBoxFilter(); - #endif -} - -vec3 upsample() { - #ifdef HIGH - return upsample_high(); - #else - return simpleBoxFilter(); - #endif -} - -vec3 combine() { - vec3 scene = safe_color(texture2D(scene, vTexture).rgb); - vec3 blur = upsample() * bloomColor.rgb; - - if (hasAmountMap) { - blur *= clamp(texture2D(amountMap, amountUV).r * (amountLimit.y - amountLimit.x) + amountLimit.x, 0, 1); - } - - if (HDR) { - return scene + blur; - } - - return scene + reinhardTone(blur); -} - -// main: -void main() { - vec3 col; - - #if defined(ACTION_FILTERING) - col = filtering(); - #elif defined(ACTION_DOWNSAMPLING) - col = downsample(); - #elif defined(ACTION_UPSAMPLING) - col = upsample(); - #else - col = combine(); - #endif - - color = vec4(col, 1); -} diff --git a/src/renderer/SM.Base/PostEffects/Shaders/bloom/combine.frag b/src/renderer/SM.Base/PostEffects/Shaders/bloom/combine.frag deleted file mode 100644 index 2c67f8b..0000000 --- a/src/renderer/SM.Base/PostEffects/Shaders/bloom/combine.frag +++ /dev/null @@ -1,41 +0,0 @@ -#version 330 core - -in vec2 vTexture; -in vec2 amountUV; - -uniform sampler2D scene; -uniform vec4 bloomColor; -uniform bool HDR; - -uniform bool hasAmountMap; -uniform sampler2D amountMap; -uniform vec2 amountLimit; - -vec3 safe_color(vec3 c) { - return clamp(c, vec3(0.0), vec3(1e20)); -} - -vec3 upsample_filter_high(); - -layout(location = 0) out vec4 color; - -vec3 reinhardTone(vec3 col) { - return col / (col + vec3(1.0)); -} - -void main() { - - vec3 scene = safe_color(texture2D(scene, vTexture).rgb); - vec3 blur = upsample_filter_high() * bloomColor.rgb; - - if (hasAmountMap) { - blur *= clamp(texture2D(amountMap, amountUV).r * (amountLimit.y - amountLimit.x) + amountLimit.x, 0, 1); - } - - if (HDR) { - color = vec4(scene + blur, 1); - return; - } - - color = vec4(scene + reinhardTone(blur), 1); -} diff --git a/src/renderer/SM.Base/PostEffects/Shaders/bloom/combine.vert b/src/renderer/SM.Base/PostEffects/Shaders/bloom/combine.vert deleted file mode 100644 index 1a92d4c..0000000 --- a/src/renderer/SM.Base/PostEffects/Shaders/bloom/combine.vert +++ /dev/null @@ -1,17 +0,0 @@ -#version 330 - -layout(location = 0) in vec3 aPos; -layout(location = 1) in vec2 aTex; - -uniform mat4 MVP; -uniform mat3 amountTransform; - -out vec2 vTexture; -out vec2 amountUV; - -void main() { - vTexture = aTex; - amountUV = vec2(amountTransform * vec3(aTex, 1)); - - gl_Position = MVP * vec4(aPos, 1); -} \ No newline at end of file diff --git a/src/renderer/SM.Base/PostEffects/Shaders/bloom/downsample.frag b/src/renderer/SM.Base/PostEffects/Shaders/bloom/downsample.frag deleted file mode 100644 index c0c5178..0000000 --- a/src/renderer/SM.Base/PostEffects/Shaders/bloom/downsample.frag +++ /dev/null @@ -1,40 +0,0 @@ -#version 330 core - -uniform vec2 renderedTextureTexelSize; - -vec4 GetRenderColorOffset(vec2); - -float getBrightness(vec3 col) { - return max(col.r, max(col.g, col.b)); - return (col.r + col.r + col.b + col.g + col.g + col.g) / 6.0; -} - -layout(location = 0) out vec4 color; - -vec3 downsample_high() { - vec4 d = renderedTextureTexelSize.xyxy * vec4(-1,-1, +1, +1); - vec3 s1 = GetRenderColorOffset(d.xy).rgb; // - - - // X - - - vec3 s2 = GetRenderColorOffset(d.zy).rgb; // - - - // - X - - vec3 s3 = GetRenderColorOffset(d.xw).rgb; // X - - // - - - - vec3 s4 = GetRenderColorOffset(d.zw).rgb; // X - - // - - - - float s1w = 1.0 / (getBrightness(s1) + 1.0); - float s2w = 1.0 / (getBrightness(s2) + 1.0); - float s3w = 1.0 / (getBrightness(s3) + 1.0); - float s4w = 1.0 / (getBrightness(s4) + 1.0); - float one_div = 1.0 / (s1w + s2w + s3w + s4w); - - return (s1 * s1w + s2 * s2w + s3 * s3w + s4 * s4w) * one_div; -} - -void main() { - - color = vec4(downsample_high(),1); -} diff --git a/src/renderer/SM.Base/PostEffects/Shaders/bloom/filter.frag b/src/renderer/SM.Base/PostEffects/Shaders/bloom/filter.frag deleted file mode 100644 index c14ccf8..0000000 --- a/src/renderer/SM.Base/PostEffects/Shaders/bloom/filter.frag +++ /dev/null @@ -1,48 +0,0 @@ -#version 330 core - -uniform vec4 ThresholdCurve; -uniform vec2 renderedTextureTexelSize; - -vec4 GetRenderColorOffset(vec2); - -layout(location = 0) out vec4 color; -layout(location = 1) out vec4 scene; - -vec3 safe_color(vec3 c) { - return clamp(c, vec3(0.0), vec3(1e20)); -} -vec3 median(vec3 a, vec3 b, vec3 c) -{ - return a + b + c - min(min(a, b), c) - max(max(a, b), c); -} - -float getBrightness(vec3 col) { - - return max(col.r, max(col.g, col.b)); - return (col.r + col.r + col.b + col.g + col.g + col.g) / 6.0; -} - -void main() { - scene = vec4(safe_color(GetRenderColorOffset(vec2(0)).rgb), 1); - - vec3 d = renderedTextureTexelSize.xyx * vec3(1,1,0); - vec3 s0 = scene.rgb + vec3(.1); - vec3 s1 = safe_color(GetRenderColorOffset(-d.xz).rgb) + vec3(.1); - vec3 s2 = safe_color(GetRenderColorOffset(+d.xz).rgb) + vec3(.1); - vec3 s3 = safe_color(GetRenderColorOffset(-d.zy).rgb) + vec3(.1); - vec3 s4 = safe_color(GetRenderColorOffset(+d.zy).rgb) + vec3(.1); - vec3 col = median(median(s0, s1, s2), s3, s4); - float br = getBrightness(col); - - /*vec3 col = safe_color(GetRenderColor().rgb); - float br = getBrightness(col);*/ - - - float rq = clamp(br - ThresholdCurve.x, 0, ThresholdCurve.y); - rq = ThresholdCurve.z * rq * rq; - - float resultBr = max(rq, br - ThresholdCurve.w) / max(1e-5, br); - col *= resultBr; - - color = vec4(col, 1); -} diff --git a/src/renderer/SM.Base/PostEffects/Shaders/bloom/sampling.frag b/src/renderer/SM.Base/PostEffects/Shaders/bloom/sampling.frag deleted file mode 100644 index 9f08e3d..0000000 --- a/src/renderer/SM.Base/PostEffects/Shaders/bloom/sampling.frag +++ /dev/null @@ -1,30 +0,0 @@ -#version 330 core - - -uniform vec2 renderedTextureTexelSize; -uniform float sampleSize; - -vec4 GetRenderColorOffset(vec2); - - -vec3 upsample_filter_high() { - vec4 d = renderedTextureTexelSize.xyxy * vec4(1, 1,-1,0) * sampleSize; - - vec3 s; - // Line + 1 - s = GetRenderColorOffset(d.zy).rgb; // x - - - s += GetRenderColorOffset(d.wy).rgb * 2; // - X - - s += GetRenderColorOffset(d.xy).rgb; // - - X - - // Line 0 - s += GetRenderColorOffset(d.zw).rgb * 2; // X - - - s += GetRenderColorOffset(vec2(0)).rgb * 4; // - X - - s += GetRenderColorOffset(d.xw).rgb * 2; // - - X - - // Line - 1 - s += GetRenderColorOffset(d.zz).rgb; // X - - - s += GetRenderColorOffset(d.wz).rgb * 2; // - X - - s += GetRenderColorOffset(d.xz).rgb; // - - X - - return s * 0.0625; // 1 / 16 = 0.0625 -} \ No newline at end of file diff --git a/src/renderer/SM.Base/PostEffects/Shaders/bloom/upsample.frag b/src/renderer/SM.Base/PostEffects/Shaders/bloom/upsample.frag deleted file mode 100644 index 38c530f..0000000 --- a/src/renderer/SM.Base/PostEffects/Shaders/bloom/upsample.frag +++ /dev/null @@ -1,13 +0,0 @@ -#version 330 core - -in vec2 vTexture; - -uniform sampler2D baseBuffer; - -layout(location = 0) out vec4 color; - -vec3 upsample_filter_high(); - -void main() { - color = vec4(texture2D(baseBuffer, vTexture).rgb + upsample_filter_high(),1); -} diff --git a/src/renderer/SM.Base/PostEffects/Shaders/finalize_hdr.glsl b/src/renderer/SM.Base/PostEffects/Shaders/finalize_hdr.glsl deleted file mode 100644 index eeacf82..0000000 --- a/src/renderer/SM.Base/PostEffects/Shaders/finalize_hdr.glsl +++ /dev/null @@ -1,28 +0,0 @@ -#version 330 - -in vec2 vTexture; - -uniform sampler2D Scene; -uniform float Exposure; -uniform float Gamma; - -layout(location = 0) out vec4 color; - -vec3 ACES(vec3); - -vec3 reinhardTone(vec3); - -vec3 exposure(vec3); - -void main() { - - vec3 scene = texture2D(Scene, vTexture).rgb; - vec3 result = exposure(scene); - #if defined(TYPE_REINHARD) - result = reinhardTone(result); - #elif defined(TYPE_ACES) - result = ACES(result); - #endif - - color = vec4(pow(result, vec3(1 / Gamma)), 1); -} \ No newline at end of file diff --git a/src/renderer/SM.Base/PostEffects/Shaders/hdr_curves.frag b/src/renderer/SM.Base/PostEffects/Shaders/hdr_curves.frag deleted file mode 100644 index 6ec0e52..0000000 --- a/src/renderer/SM.Base/PostEffects/Shaders/hdr_curves.frag +++ /dev/null @@ -1,21 +0,0 @@ -#version 330 core - -uniform float Exposure; - -vec3 ACES(vec3 col) { - const float a = 2.51; - const float b = 0.03; - const float c = 2.43; - const float d = 0.59; - const float e = 0.14; - - return clamp((col * (a * col + b)) / (col * (c * col + d) + e), 0.0,1.0); -} - -vec3 reinhardTone(vec3 col) { - return col / (col + vec3(1.0)); -} - -vec3 exposure(vec3 col) { - return vec3(1) - exp(-col * Exposure); -} \ No newline at end of file diff --git a/src/renderer/SM.Base/PostProcess/PostProcessShader.cs b/src/renderer/SM.Base/PostProcess/PostProcessShader.cs deleted file mode 100644 index b1a4744..0000000 --- a/src/renderer/SM.Base/PostProcess/PostProcessShader.cs +++ /dev/null @@ -1,130 +0,0 @@ -#region usings - -using System; -using System.Collections.Generic; -using OpenTK.Graphics.OpenGL4; -using SM.Base.Objects.Static; -using SM.Base.Utility; -using SM.OGL.Framebuffer; -using SM.OGL.Shaders; - -#endregion - -namespace SM.Base.PostProcess -{ - /// - /// Specific shader for post processing. - /// - public class PostProcessShader : GenericShader - { - private static readonly ShaderFile _fragExtensions = - new ShaderFile(AssemblyUtility.ReadAssemblyFile("SM.Base.PostProcess.DefaultFiles.extensions.frag")); - - private static readonly ShaderFile _normalVertex = - new ShaderFile(AssemblyUtility.ReadAssemblyFile("SM.Base.PostProcess.DefaultFiles.vertexFile.vert")); - - private static readonly string _normalVertexWithExt = - AssemblyUtility.ReadAssemblyFile("SM.Base.PostProcess.DefaultFiles.vertexWithExt.vert"); - - /// - /// Generates an action for the texture handling. - /// - /// - /// - public static Action DefaultTextureAction(ColorAttachment renderedTexture) - { - return (col) => - { - col["renderedTexture"].SetTexture(renderedTexture); - col["renderedTextureTexelSize"].SetVector2(renderedTexture.TexelSize); - }; - } - - /// - /// Creates the shader with the default vertex shader and custom fragment. - /// - public PostProcessShader(string fragment) : this(_normalVertex, new ShaderFile(fragment)) - { - } - /// - /// Creates the shader with the default vertex shader and custom fragment shader. - /// - public PostProcessShader(ShaderFile fragment) : this(_normalVertex, fragment) - { - } - - /// - /// Creates the shader with an vertex extension and custom fragment. - /// - /// - /// - public PostProcessShader(string vertexExt, string fragment) : this(new ShaderFile(_normalVertexWithExt) - { - GLSLExtensions = new List {new ShaderFile(vertexExt)} - }, new ShaderFile(fragment)) - { - } - /// - /// Creates the shader with an vertex shader and custom fragment. - /// - /// - /// - public PostProcessShader(ShaderFile vertex, string fragment) : this(vertex, new ShaderFile(fragment)) - { - } - - /// - /// Creates the shader with an vertex shader and custom fragment. - /// - /// - /// - public PostProcessShader(ShaderFile vertex, ShaderFile fragment) : base( - new ShaderFileCollection(vertex, fragment)) - { - fragment.GLSLExtensions.Add(_fragExtensions); - } - - /// - /// Draws the shader with the color attachment as texture. - /// - /// - public void Draw(ColorAttachment renderedTexture) - { - Draw(DefaultTextureAction(renderedTexture)); - } - - /// - /// Draws the shader with the color attachment as texture and provides access to the uniforms. - /// - /// - /// - public void Draw(ColorAttachment renderedTexture, Action setUniformAction) - { - var texAction = DefaultTextureAction(renderedTexture); - Draw((a) => { - texAction(a); - setUniformAction(a); - }); - } - - /// - /// Draws the shader with special uniforms. - /// - /// - public void Draw(Action setUniformAction) - { - if (ErrorInShader) return; - - Activate(); - Plate.Object.Activate(); - - Uniforms["MVP"].SetMatrix4(PostProcessEffect.Mvp); - - setUniformAction(Uniforms); - - GL.DrawArrays(PrimitiveType.Quads, 0, 4); - - CleanUp(); - } - } -} \ No newline at end of file diff --git a/src/renderer/SM.Base/Types/CVectorBase.cs b/src/renderer/SM.Base/Types/CVectorBase.cs deleted file mode 100644 index 39d5831..0000000 --- a/src/renderer/SM.Base/Types/CVectorBase.cs +++ /dev/null @@ -1,142 +0,0 @@ -using System; -using OpenTK; -using OpenTK.Audio.OpenAL; -using OpenTK.Graphics.OpenGL; -using SM.Base.Animation; - -namespace SM.Base.Types -{ - /// - /// Basis for the CVector classes - /// - public abstract class CVectorBase - { - /// - /// This event triggers when a component changed. - /// - public event Action Changed; - - /// - /// The length/magnitute of the vector. - /// - public float Length => GetLength(); - - /// - /// Gets the square of the vector length (magnitude). - /// - /// - /// This property avoids the costly square root operation required by the Length property. This makes it more suitable - /// for comparisons. - /// - public float LengthSquared => GetLength(true); - - /// - /// Get the length of the vector. - /// - /// If true, it will return the squared product. - /// - public float GetLength(bool squared = false) - { - float length = GetLengthProcess(); - if (squared) return length; - return (float)Math.Sqrt(length); - } - - /// - /// Normalizes the vector. - /// - public void Normalize() - { - float length = GetLength(); - NormalizationProcess(length); - } - - /// - /// Interpolates the motion to the target. - /// - /// How long the interpolation should take. - /// The value it should interpolate. - /// The curve how he interpolates. Preset values can be found under . Default: - /// Auto-starts the interpolation process. - /// A handle to control the interpolation process. - public InterpolationProcess Interpolate(TimeSpan duration, TInterpolateType to, BezierCurve? interpolationCurve = null, bool autoStart = true) - where TInterpolateType : struct - { - return Interpolate(duration, ConvertToVector4(), to, interpolationCurve, autoStart); - } - - /// - /// Interpolates the motion to the target. - /// - /// How long the interpolation should take. - /// The value it should start with. - /// The value it should interpolate. - /// The curve how he interpolates. Preset values can be found under . Default: - /// Auto-starts the interpolation process. - /// A handle to control the interpolation process. - public InterpolationProcess Interpolate(TimeSpan duration, TInterpolateType from, TInterpolateType to, BezierCurve? interpolationCurve = null, bool autoStart = true) - where TInterpolateType : struct - { - Vector4 start = from switch - { - float f => new Vector4(f, 0, 0, 0), - Vector2 v2 => new Vector4(v2.X, v2.Y, 0, 0), - Vector3 v3 => new Vector4(v3.X, v3.Y, v3.Z, 0), - Vector4 v4 => v4, - _ => throw new Exception("[INTERPOLATION] Only float, OpenTK.Vector2, OpenTK.Vector3, OpenTK.Vector4 are allowed as types.") - }; - - return Interpolate(duration, start, to, interpolationCurve, autoStart); - } - - internal InterpolationProcess Interpolate(TimeSpan duration, Vector4 from, TInterpolateType to, BezierCurve? interpolationCurve = null, bool autoStart = true) - where TInterpolateType : struct - { - Vector4 target = to switch - { - float f => new Vector4(f, 0, 0, 0), - Vector2 v2 => new Vector4(v2.X, v2.Y, 0, 0), - Vector3 v3 => new Vector4(v3.X, v3.Y, v3.Z, 0), - Vector4 v4 => v4, - _ => throw new Exception("[INTERPOLATION] Only float, OpenTK.Vector2, OpenTK.Vector3, OpenTK.Vector4 are allowed as types.") - }; - - InterpolationProcess process = new InterpolationProcess(this, duration, from, target, interpolationCurve.GetValueOrDefault(AnimationCurves.Linear)); - if (autoStart) process.Start(); - - return process; - } - - /// - /// Sets the values of the vector, by providing the values over an array. - /// - /// - public abstract void SetRaw(params float[] parameters); - - /// - /// This triggers the event. - /// - protected void TriggerChanged() - { - Changed?.Invoke(); - } - - /// - /// Conversion from to One-dimensional Vector. - /// - /// - protected abstract float GetLengthProcess(); - - /// - /// Normalizes the vector. - /// - /// - protected abstract void NormalizationProcess(float length); - - /// - /// Converts the vector to a - /// - /// - protected abstract Vector4 ConvertToVector4(); - } -} \ No newline at end of file diff --git a/src/renderer/SM.Base/Types/MinMax.cs b/src/renderer/SM.Base/Types/MinMax.cs deleted file mode 100644 index 6b8f2c4..0000000 --- a/src/renderer/SM.Base/Types/MinMax.cs +++ /dev/null @@ -1,53 +0,0 @@ -using OpenTK; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SM.Base.Types -{ - /// - /// Structure to store Min and Max-values. - /// - public struct MinMax - { - /// - /// Default Value: 0..1 - /// - public static readonly MinMax Default = new MinMax(0, 1); - - /// - /// Minimum Value - /// - public float Min; - /// - /// Maximum Value - /// - public float Max; - - /// - /// Creates a MinMax-structure with two values. - /// - public MinMax(float min, float max) - { - Min = min; - Max = max; - } - - /// - /// Get a value that is between and based on t [0..1] - /// - /// - public float GetPoint(float t) - { - return t * (Max - Min) + Min; - } - - /// - /// Converts to Vector2. - /// - /// - public static explicit operator Vector2(MinMax v) => new Vector2(v.Min, v.Max); - } -} diff --git a/src/renderer/SM.Base/Utility/MathUtils.cs b/src/renderer/SM.Base/Utility/MathUtils.cs deleted file mode 100644 index 0e92156..0000000 --- a/src/renderer/SM.Base/Utility/MathUtils.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SM.Base.Utility -{ - class MathUtils - { - public static float Lerp(float start, float end, float t) - { - return start + t * (end - start); - } - } -} diff --git a/src/renderer/SM.OGL/Shaders/Uniform.cs b/src/renderer/SM.OGL/Shaders/Uniform.cs deleted file mode 100644 index 5b5810e..0000000 --- a/src/renderer/SM.OGL/Shaders/Uniform.cs +++ /dev/null @@ -1,585 +0,0 @@ -#region usings - -using OpenTK; -using OpenTK.Graphics; -using OpenTK.Graphics.OpenGL4; -using SM.OGL.Texture; - -#endregion - -namespace SM.OGL.Shaders -{ - /// - /// Manages the uniforms. - /// - public struct Uniform : IUniform - { - /// - /// This contains the location for the uniform. - /// - public int Location { get; internal set; } - - /// - /// This contains the Parent collection of this uniform. - /// - public UniformCollection Parent { get; } - - #region Constructors - /// - /// This creates a new uniform manager, that has a null parent. - /// - /// - public Uniform(int location) : this(location, null) - { - } - - /// - /// This creates a new uniform manager, that get the location from the provided shader and with a null parent. - /// - /// - /// - public Uniform(string name, GenericShader shader) : this(GL.GetUniformLocation(shader, name), null) - { - - } - /// - /// This creates a new uniform manager, that get the location from the provided shader and with a parent. - /// - /// - /// - /// - public Uniform(string name, GenericShader shader, UniformCollection parent) : this(GL.GetUniformLocation(shader, name), parent) - { - - } - - /// - /// This create a new uniform manager - /// - /// Location id - /// Parent collection - public Uniform(int location, UniformCollection parent) - { - Location = location; - Parent = parent; - } - - #endregion - - #region Uniform1 - - /// - /// Set a boolean as value. - /// - /// - public void SetBool(bool value) - { - GL.Uniform1(Location, value ? 1 : 0); - } - - /// - /// Sets a integer. - /// - /// - public void SetInt(int value) - { - GL.Uniform1(Location, value); - } - - /// - /// Sets an array of integers. - /// - /// - public void SetInt(params int[] values) - { - GL.Uniform1(Location, values.Length, values); - } - - /// - /// Set a unsigned integer. - /// - /// - public void SetUInt(uint value) - { - GL.Uniform1(Location, value); - } - - /// - /// Set an array of unsigned integers. - /// - /// - public void SetUInt(params uint[] values) - { - GL.Uniform1(Location, values.Length, values); - } - - /// - /// Sets a float. - /// - /// - public void SetFloat(float value) - { - GL.Uniform1(Location, value); - } - - /// - /// Sets an array of floats. - /// - /// - public void SetFloat(params float[] values) - { - GL.Uniform1(Location, values.Length, values); - } - - #endregion - - #region Uniform2 - - /// - /// Sets a float vector2 by providing the values. - /// - /// - /// - public void SetVector2(float x, float y) - { - GL.Uniform2(Location, x, y); - } - - /// - /// Sets a unsigned integer vector2 by providing the values. - /// - /// - /// - public void SetVector2(uint x, uint y) - { - GL.Uniform2(Location, x, y); - } - - /// - /// Sets a integer vector2 by providing the values. - /// - /// - /// - public void SetVector2(int x, int y) - { - GL.Uniform2(Location, x, y); - } - - /// - /// Sets a float vector2. - /// - /// - public void SetVector2(Vector2 vector2) - { - GL.Uniform2(Location, vector2); - } - - /// - /// Sets a float vector2 by refencing. - /// - /// - public void SetVector2(ref Vector2 vector2) - { - GL.Uniform2(Location, ref vector2); - } - - /// - /// Sets a array of vector2. - /// - /// - public void SetVector2(params Vector2[] values) - { - float[] newValues = new float[values.Length * 2]; - for(int i = 0; i < values.Length; i++) - { - Vector2 val = values[i]; - int newi = i * 2; - newValues[newi] = val.X; - newValues[newi + 1] = val.Y; - } - GL.Uniform2(Location, values.Length, newValues); - } - - /// - /// Sets a float array that get converted to a vector2 array. - /// - /// - public void SetVector2(params float[] values) - { - GL.Uniform2(Location, values.Length / 2, values); - } - - /// - /// Sets a integer array that get converted to a ivector2 array. - /// - /// - public void SetVector2(params int[] values) - { - GL.Uniform2(Location, values.Length / 2, values); - } - - /// - /// Sets a unsigned integer array that get converted to a unsigned integer vector2 array. - /// - /// - public void SetVector2(params uint[] values) - { - GL.Uniform2(Location, values.Length / 2, values); - } - - #endregion - - #region Uniform3 - - /// - /// Sets a float vector3 by providing the values. - /// - /// - /// - /// - public void SetVector3(float x, float y, float z) - { - GL.Uniform3(Location, x, y, z); - } - - /// - /// Sets a unsigned integer vector3 by providing the values. - /// - /// - /// - /// - public void SetVector3(uint x, uint y, uint z) - { - GL.Uniform3(Location, x, y, z); - } - - /// - /// Sets a integer vector3 by providing the values. - /// - /// - /// - /// - public void SetVector3(int x, int y, int z) - { - GL.Uniform3(Location, x, y, z); - } - - /// - /// Sets a vector3. - /// - /// - public void SetVector3(Vector3 vector) - { - GL.Uniform3(Location, vector); - } - /// - /// Sets a vector3 by reference. - /// - /// - public void SetVector3(ref Vector3 vector) - { - GL.Uniform3(Location, ref vector); - } - - /// - /// Sets a array of vector3. - /// - /// - public void SetVector3(params Vector3[] values) - { - float[] newValues = new float[values.Length * 3]; - for (int i = 0; i < values.Length; i++) - { - Vector3 val = values[i]; - int newi = i * 3; - newValues[newi] = val.X; - newValues[newi + 1] = val.Y; - newValues[newi + 2] = val.Z; - } - GL.Uniform3(Location, values.Length, newValues); - } - - /// - /// Sets a array by providing the components. - /// - /// - public void SetVector3(params float[] values) - { - GL.Uniform3(Location, values.Length / 3, values); - } - /// - /// Sets a array by providing the components. - /// - /// - public void SetVector3(params int[] values) - { - GL.Uniform3(Location, values.Length / 3, values); - } - /// - /// Sets a array by providing the components. - /// - /// - public void SetVector3(params uint[] values) - { - GL.Uniform3(Location, values.Length / 3, values); - } - - - #endregion - - #region Uniform4 - - /// - /// Sets a vector4 by providing the values. - /// - /// - /// - /// - /// - public void SetVector4(float x, float y, float z, float w) - { - GL.Uniform4(Location, x, y, z, w); - } - /// - /// Sets a vector4 by providing the values. - /// - /// - /// - /// - /// - public void SetVector4(uint x, uint y, uint z, uint w) - { - GL.Uniform4(Location, x, y, z, w); - } - /// - /// Sets a vector4 by providing the values. - /// - /// - /// - /// - /// - public void SetVector4(int x, int y, int z, int w) - { - GL.Uniform4(Location, x, y, z, w); - } - - /// - /// Sets a vector4. - /// - /// - public void SetVector4(Vector4 vector) - { - GL.Uniform4(Location, vector); - } - - /// - /// Sets a vector4. - /// - /// - public void SetVector4(ref Vector4 vector) - { - GL.Uniform4(Location, ref vector); - } - - /// - /// Sets a array of Vector4. - /// - /// - public void SetVector4(params Vector4[] values) - { - float[] newValues = new float[values.Length * 4]; - for (int i = 0; i < values.Length; i++) - { - Vector4 val = values[i]; - int newi = i * 3; - newValues[newi] = val.X; - newValues[newi + 1] = val.Y; - newValues[newi + 2] = val.Z; - newValues[newi + 3] = val.W; - } - GL.Uniform3(Location, values.Length, newValues); - } - - /// - /// Sets a array by providing the components. - /// - /// - public void SetVector4(params float[] values) - { - GL.Uniform4(Location, values.Length / 4, values); - } - /// - /// Sets a array by providing the components. - /// - /// - public void SetVector4(params int[] values) - { - GL.Uniform4(Location, values.Length / 4, values); - } - /// - /// Sets a array by providing the components. - /// - /// - public void SetVector4(params uint[] values) - { - GL.Uniform4(Location, values.Length / 4, values); - } - - /// - /// Sets a quaternion. - /// - /// - public void SetQuaternion(Quaternion quaternion) - { - GL.Uniform4(Location, quaternion); - } - - #endregion - - #region Matrix2 - - /// - /// Sets a matrix2. - /// - /// - /// If true, the matrix will be transposed. - public void SetMatrix2(Matrix2 matrix, bool transpose = false) - { - GL.UniformMatrix2(Location, transpose, ref matrix); - } - - /// - /// Sets a matrix2 array. - /// - /// - /// - /// If true, the matrix will be transposed. - public void SetMatrix2(int count, float[] value, bool transpose = false) - { - GL.UniformMatrix2(Location, count, transpose, value); - } - - #endregion - - #region Matrix3 - /// - /// Sets a matrix3. - /// - /// - /// If true, the matrix will be transposed. - public void SetMatrix3(Matrix3 matrix, bool transpose = false) - { - GL.UniformMatrix3(Location, transpose, ref matrix); - } - - /// - /// Sets a matrix3 array. - /// - /// - /// - /// If true, the matrix will be transposed. - public void SetMatrix3(int count, float[] value, bool transpose = false) - { - GL.UniformMatrix3(Location, count, transpose, value); - } - - #endregion - - #region Matrix4 - - /// - /// Sets a matrix4. - /// - /// - /// If true, the matrix will be transposed. - public void SetMatrix4(Matrix4 matrix, bool transpose = false) - { - GL.UniformMatrix4(Location, transpose, ref matrix); - } - /// - /// Sets a matrix4 by reference. - /// - /// - /// If true, the matrix will be transposed. - public void SetMatrix4(ref Matrix4 matrix, bool transpose = false) - { - GL.UniformMatrix4(Location, transpose, ref matrix); - } - - /// - /// Sets a matrix4 array. - /// - /// - /// - /// If true, the matrix will be transposed. - public void SetMatrix4(int count, float[] value, bool transpose = false) - { - GL.UniformMatrix4(Location, count, transpose, value); - } - - #endregion - - /// - /// Sets the color. - /// - /// - public void SetColor(Color4 color) - { - GL.Uniform4(Location, color); - } - - /// - /// Try to sets the texture at the next possible position and tells the checkUniform, if worked or not. - /// - /// The texture you want to add - /// The check uniform. - public void SetTexture(TextureBase texture, Uniform checkUniform) - { - checkUniform.SetBool(texture != null); - if (texture != null) SetTexture(texture); - } - - /// - /// Try to sets the texture at the specified position and tells the checkUniform, if worked or not. - /// - /// The texture you want to add - /// The position - /// The check uniform. - public void SetTexture(TextureBase texture, int pos, Uniform checkUniform) - { - checkUniform.SetBool(texture != null); - if (texture != null) SetTexture(texture); - } - - /// - /// Sets the texture to the next possible position. - /// - /// - public void SetTexture(TextureBase texture) - { - if (Parent != null) SetTexture(texture, Parent.NextTexture); - } - - /// - /// Sets the texture to the specified position. - /// - /// - /// - public void SetTexture(TextureBase texture, int texturePos) - { - Parent.NextTexture = texturePos + 1; - GL.ActiveTexture(TextureUnit.Texture0 + texturePos); - GL.BindTexture(texture.Target, texture); - SetInt(texturePos); - } - - /// - /// Returns the location from the uniform - /// - /// - public static implicit operator int(Uniform u) - { - return u.Location; - } - } -} \ No newline at end of file diff --git a/src/renderer/SM2D/packages.config b/src/renderer/SM2D/packages.config deleted file mode 100644 index 1f65eab..0000000 --- a/src/renderer/SM2D/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/tests/SM_TEST/Default Fragment Shader1.frag b/tests/SM_TEST/Default Fragment Shader1.frag deleted file mode 100644 index e97c5eb..0000000 --- a/tests/SM_TEST/Default Fragment Shader1.frag +++ /dev/null @@ -1,10 +0,0 @@ -#version 330 core - -uniform vec4 Color; -uniform float Scale; - -layout(location = 0) out vec4 color; - -void main() { - color = Color * Scale; -} diff --git a/tests/SM_TEST/OpenTK.dll.config b/tests/SM_TEST/OpenTK.dll.config deleted file mode 100644 index 7098d39..0000000 --- a/tests/SM_TEST/OpenTK.dll.config +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/SM_TEST/Program.cs b/tests/SM_TEST/Program.cs deleted file mode 100644 index f36bd80..0000000 --- a/tests/SM_TEST/Program.cs +++ /dev/null @@ -1,116 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Drawing; -using System.Linq; -using System.Runtime.InteropServices.WindowsRuntime; -using OpenTK; -using OpenTK.Graphics; -using OpenTK.Graphics.OpenGL; -using ShaderToolParser; -using SharpDX.XInput; -using SM.Base; -using SM.Base.Animation; -using SM.Base.Controls; -using SM.Base.Drawing; -using SM.Base.Drawing.Text; -using SM.Base.Shaders; -using SM.Base.Time; -using SM.Base.Utility; -using SM.Base.Window; -using SM.Intergrations.ShaderTool; -using SM.Utils.Controls; -using SM2D; -using SM2D.Controls; -using SM2D.Drawing; -using SM2D.Object; -using SM2D.Scene; -using Font = SM.Base.Drawing.Text.Font; - -namespace SM_TEST -{ - class Program - { - static Scene scene; - private static GLWindow window; - private static GameController controller; - - private static GameKeybindActor actor; - - public static STPProject portal; - static void Main(string[] args){ - Font font = new Font(@".\GapSansBold.ttf") - { - FontSize = 51, - }; - - controller = new GameController(0); - GameKeybindHost host = new GameKeybindHost(new GameKeybindList() - { - {"g_test", context => Keyboard.IsAnyKeyPressed, context => context.ControllerState.Buttons[GamepadButtonFlags.A, true]} - }); - actor = GameKeybindActor.CreateControllerActor(controller); - actor.ConnectHost(host); - - - portal = STPProject.CreateFromZIP("portal.zip"); - - window = new GLWindow(1280, 720, "0ms", WindowFlags.Window, VSyncMode.Off); - window.ApplySetup(new Window2DSetup()); - window.SetRenderPipeline(new TestRenderPipeline()); - - window.SetScene(scene = new Scene() - { - ShowAxisHelper = true - }); - scene.Background.Color = Color4.DarkGray; - scene.Camera = new Camera() - { - - }; - - SimpleShader shader = new SimpleShader("basic", AssemblyUtility.ReadAssemblyFile("SM_TEST.Default Fragment Shader1.frag"), (a, b) => { - a["Color"].SetColor(b.Material.Tint); - a["Scale"].SetFloat(b.Material.ShaderArguments.Get("Scale", 1f)); - - }); - DrawObject2D obj = new DrawObject2D() - { - Material = - { - CustomShader = shader, - Tint = new Color4(1f, 0.151217f, 0.050313f, 1), - ShaderArguments = - { - ["Scale"] = 50f - } - } - };/* - DrawObject2D obj2 = new DrawObject2D() - { - Material = - { - Tint = Color4.Aqua, - CustomShader = shader, - ShaderArguments = - { - ["Scale"] = 1000f - } - } - }; - obj2.Transform.Position.Set(300);*/ - - scene.Objects.Add(obj); - - window.RenderFrame += Window_RenderFrame; - window.Run(); - - Debug.WriteLine("Window Closed"); - } - - private static void Window_RenderFrame(object sender, FrameEventArgs e) - { - window.Title = Math.Round(e.Time * 1000,2) + "ms"; - } - } -} \ No newline at end of file diff --git a/tests/SM_TEST/SM_TEST.csproj b/tests/SM_TEST/SM_TEST.csproj deleted file mode 100644 index 3050d81..0000000 --- a/tests/SM_TEST/SM_TEST.csproj +++ /dev/null @@ -1,107 +0,0 @@ - - - - - - - Debug - AnyCPU - {6D4FB8E6-4D0B-4928-8F9E-EF5C2FBF44E8} - WinExe - SM_TEST - SM_TEST - v4.5.2 - 512 - true - true - - - - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - ..\..\packages\OpenTK.3.3.1\lib\net20\OpenTK.dll - - - ..\..\packages\ShaderToolParser.1.0.0-pre3\lib\net450\ShaderToolParser.dll - - - ..\..\packages\SharpDX.4.2.0\lib\net45\SharpDX.dll - - - ..\..\packages\SharpDX.XInput.4.2.0\lib\net45\SharpDX.XInput.dll - - - ..\..\packages\SharpFont.4.0.1\lib\net45\SharpFont.dll - - - - - - - - - - - - - - - - - - - - - - {4cb351f4-b3f2-4f77-acc2-02f21dbf5ec2} - SMRenderer.Intergrations - - - {079BAB31-3DC4-40DA-90C7-EFAA8517C647} - SMRenderer.Utils - - - {8e733844-4204-43e7-b3dc-3913cddabb0d} - SM.Base - - - {f604d684-bc1d-4819-88b5-8b5d03a17be0} - SM.OGL - - - {a4565538-625a-42c6-a330-dd4f1abb3986} - SM2D - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - \ No newline at end of file diff --git a/tests/SM_TEST/TestRenderPipeline.cs b/tests/SM_TEST/TestRenderPipeline.cs deleted file mode 100644 index dcd7b22..0000000 --- a/tests/SM_TEST/TestRenderPipeline.cs +++ /dev/null @@ -1,64 +0,0 @@ -using OpenTK.Graphics.OpenGL4; -using SM.Base.Legacy.PostProcessing; -using SM.Base.PostEffects; -using SM.Base.Textures; -using SM.Base.Window; -using SM.Intergrations.ShaderTool; -using SM.OGL.Framebuffer; -using SM.OGL.Texture; - -namespace SM_TEST -{ - public class TestRenderPipeline : RenderPipeline - { - private BloomEffect _bloom; - - private Framebuffer _postBuffer; - private STPostProcessEffect _vittage; - - protected override void InitializationProcess() - { - MainFramebuffer = CreateWindowFramebuffer(8, PixelInformation.RGBA_HDR, true); - _postBuffer = CreateWindowFramebuffer(0, PixelInformation.RGB_HDR, false); - Framebuffers.Add(_postBuffer); - - _bloom = new BloomEffect(true, true) - { - Radius = 20, - AmountMap = new Texture(new System.Drawing.Bitmap("bloom_amountMap.png")) - }; - PostProcessEffects.Add(_bloom); - - _vittage = new STPostProcessEffect(Program.portal.DrawNodes.Find(a => a.Variables.ContainsKey("_ViewportSize"))) - { - Arguments = - { - {"CheckSize", 10f}, - {"Strength", .25f}, - {"TargetSize", 5f}, - {"Move", 3.33f} - } - }; - PostProcessEffects.Add(_vittage); - } - - protected override void RenderProcess(ref DrawContext context) - { - GL.Enable(EnableCap.DepthTest); - MainFramebuffer.Activate(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); - context.Scene.DrawBackground(context); - context.Scene.DrawMainObjects(context); - context.Scene.DrawHUD(context); - - GL.Disable(EnableCap.DepthTest); - _postBuffer.Activate(ClearBufferMask.ColorBufferBit); - PostProcessUtility.ResolveMultisampledBuffers(MainFramebuffer, _postBuffer); - - _bloom.Draw(_postBuffer["color"], context); - _vittage.Draw(_postBuffer["color"], context); - Framebuffer.Screen.Activate(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); - - PostProcessUtility.FinalizeHDR(_postBuffer["color"], HDRColorCurve.OnlyExposure, .1f); - } - } -} \ No newline at end of file