Compare commits
11 commits
be07a1bfb6
...
687125cc3e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
687125cc3e | ||
|
|
8a84182563 | ||
|
|
443877019b | ||
|
|
17cbebcf6a | ||
|
|
2c0517ca48 | ||
|
|
9b52d401e7 | ||
|
|
dffa581596 | ||
|
|
89de4258e1 | ||
|
|
db7f01dca1 | ||
|
|
651628401d | ||
|
|
2be5c879be |
205 changed files with 3325 additions and 2139 deletions
8
README.md
Normal file
8
README.md
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
# 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.
|
||||||
|
|
@ -1,24 +0,0 @@
|
||||||
#region usings
|
|
||||||
|
|
||||||
using SM.Base.Time;
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
namespace SM.Base.Drawing.Particles
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// A context, with that the particle system sends the information for the movement function.
|
|
||||||
/// </summary>
|
|
||||||
public struct ParticleContext
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// The Timer of the particles
|
|
||||||
/// </summary>
|
|
||||||
public Timer Timer;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The current speed of the particles.
|
|
||||||
/// </summary>
|
|
||||||
public float Speed;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,139 +0,0 @@
|
||||||
#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
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// The (drawing) basis for particles
|
|
||||||
/// </summary>
|
|
||||||
public abstract class ParticleDrawingBasis<TTransform, TDirection> : DrawingBasis<TTransform>, IScriptable
|
|
||||||
where TTransform : GenericTransformation, new()
|
|
||||||
where TDirection : struct
|
|
||||||
{
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The amount of particles
|
|
||||||
/// </summary>
|
|
||||||
public int Amount = 32;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This contains the different instances for the particles.
|
|
||||||
/// </summary>
|
|
||||||
protected List<Instance> instances;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The maximum speed of the particles
|
|
||||||
/// </summary>
|
|
||||||
public float MaxSpeed = 50;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This contains all important information for each particle.
|
|
||||||
/// </summary>
|
|
||||||
protected ParticleStruct<TDirection>[] particleStructs;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The stopwatch of the particles.
|
|
||||||
/// </summary>
|
|
||||||
protected Timer timer;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Sets up the timer.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="duration">Duration how long the particles should live</param>
|
|
||||||
protected ParticleDrawingBasis(TimeSpan duration)
|
|
||||||
{
|
|
||||||
timer = new Timer(duration);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Get/Sets the state of pausing.
|
|
||||||
/// </summary>
|
|
||||||
public bool Paused
|
|
||||||
{
|
|
||||||
get => timer.Paused;
|
|
||||||
set => timer.Paused = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Controls the movement of each particles.
|
|
||||||
/// </summary>
|
|
||||||
public abstract Func<TDirection, ParticleContext, TDirection> MovementCalculation { get; set; }
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public bool UpdateActive {
|
|
||||||
get => timer.Active;
|
|
||||||
set { return; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Triggers the particles.
|
|
||||||
/// </summary>
|
|
||||||
public void Trigger()
|
|
||||||
{
|
|
||||||
timer.Start();
|
|
||||||
|
|
||||||
CreateParticles();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void DrawContext(ref DrawContext context)
|
|
||||||
{
|
|
||||||
if (!timer.Active) return;
|
|
||||||
|
|
||||||
base.DrawContext(ref context);
|
|
||||||
|
|
||||||
context.Instances = instances;
|
|
||||||
|
|
||||||
context.Shader.Draw(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Creates the particles.
|
|
||||||
/// </summary>
|
|
||||||
protected virtual void CreateParticles()
|
|
||||||
{
|
|
||||||
particleStructs = new ParticleStruct<TDirection>[Amount];
|
|
||||||
instances = new List<Instance>();
|
|
||||||
for (int i = 0; i < Amount; i++)
|
|
||||||
{
|
|
||||||
particleStructs[i] = CreateObject(i);
|
|
||||||
|
|
||||||
instances.Add(new Instance());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Creates a particle.
|
|
||||||
/// </summary>
|
|
||||||
protected abstract ParticleStruct<TDirection> CreateObject(int index);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Generates the desired matrix for drawing.
|
|
||||||
/// </summary>
|
|
||||||
protected abstract Matrix4 CreateMatrix(ParticleStruct<TDirection> Struct, TDirection relativePosition);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,30 +0,0 @@
|
||||||
#region usings
|
|
||||||
|
|
||||||
using OpenTK;
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
namespace SM.Base.Drawing.Particles
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// A particle...
|
|
||||||
/// </summary>
|
|
||||||
public struct ParticleStruct<TDirection>
|
|
||||||
where TDirection : struct
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// A direction, that the particle should travel.
|
|
||||||
/// </summary>
|
|
||||||
public TDirection Direction;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// A matrix to store rotation and scale.
|
|
||||||
/// </summary>
|
|
||||||
public Matrix4 Matrix;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Speeeeeeeeeed
|
|
||||||
/// </summary>
|
|
||||||
public float Speed;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,144 +0,0 @@
|
||||||
#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
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Represents a font.
|
|
||||||
/// </summary>
|
|
||||||
public class Font : Texture
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// The char set for the font.
|
|
||||||
/// <para>Default: <see cref="FontCharStorage.SimpleUTF8" /></para>
|
|
||||||
/// </summary>
|
|
||||||
public ICollection<char> CharSet = FontCharStorage.SimpleUTF8;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The font family, that is used to find the right font.
|
|
||||||
/// </summary>
|
|
||||||
public FontFamily FontFamily;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The font size.
|
|
||||||
/// <para>Default: 12</para>
|
|
||||||
/// </summary>
|
|
||||||
public float FontSize = 12;
|
|
||||||
|
|
||||||
public float SpaceWidth { get; private set; }
|
|
||||||
|
|
||||||
public float Spacing = 1;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The font style.
|
|
||||||
/// <para>Default: <see cref="System.Drawing.FontStyle.Regular" /></para>
|
|
||||||
/// </summary>
|
|
||||||
public FontStyle FontStyle = FontStyle.Regular;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This contains all information for the different font character.
|
|
||||||
/// </summary>
|
|
||||||
public Dictionary<char, CharParameter> Positions = new Dictionary<char, CharParameter>();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Generates a font from a font family from the specified path.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="path">The specified path</param>
|
|
||||||
public Font(string path)
|
|
||||||
{
|
|
||||||
var pfc = new PrivateFontCollection();
|
|
||||||
pfc.AddFontFile(path);
|
|
||||||
FontFamily = pfc.Families[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Generates a font from a specified font family.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="font">Font-Family</param>
|
|
||||||
public Font(FontFamily font)
|
|
||||||
{
|
|
||||||
FontFamily = font;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public override TextureWrapMode WrapMode { get; set; } = TextureWrapMode.ClampToEdge;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Regenerates the texture.
|
|
||||||
/// </summary>
|
|
||||||
public void RegenerateTexture()
|
|
||||||
{
|
|
||||||
Width = 0;
|
|
||||||
Height = 0;
|
|
||||||
Positions = new Dictionary<char, CharParameter>();
|
|
||||||
|
|
||||||
|
|
||||||
var map = new Bitmap(1000, 20);
|
|
||||||
var charParams = new Dictionary<char, float[]>();
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public override void Compile()
|
|
||||||
{
|
|
||||||
RegenerateTexture();
|
|
||||||
base.Compile();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
#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);
|
|
||||||
}
|
|
||||||
|
|
@ -1,72 +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.Shaders;
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
namespace SM.Base.PostProcess
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Specific shader for post processing.
|
|
||||||
/// </summary>
|
|
||||||
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");
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Creates the shader with the default vertex shader and custom fragment.
|
|
||||||
/// </summary>
|
|
||||||
public PostProcessShader(string fragment) : this(_normalVertex,
|
|
||||||
new ShaderFile(fragment))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Creates the shader with an vertex extension and custom fragment.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="vertexExt"></param>
|
|
||||||
/// <param name="fragment"></param>
|
|
||||||
public PostProcessShader(string vertexExt, string fragment) : this(new ShaderFile(_normalVertexWithExt)
|
|
||||||
{
|
|
||||||
GLSLExtensions = new List<ShaderFile> {new ShaderFile(vertexExt)}
|
|
||||||
}, new ShaderFile(fragment))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
private PostProcessShader(ShaderFile vertex, ShaderFile fragment) : base(
|
|
||||||
new ShaderFileCollection(vertex, fragment))
|
|
||||||
{
|
|
||||||
fragment.GLSLExtensions.Add(_fragExtensions);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Draws the shader with special uniforms.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="setUniformAction"></param>
|
|
||||||
public void Draw(Action<UniformCollection> setUniformAction)
|
|
||||||
{
|
|
||||||
Activate();
|
|
||||||
Plate.Object.Activate();
|
|
||||||
|
|
||||||
Uniforms["MVP"].SetMatrix4(PostProcessEffect.Mvp);
|
|
||||||
|
|
||||||
setUniformAction(Uniforms);
|
|
||||||
|
|
||||||
GL.DrawArrays(PrimitiveType.Quads, 0, 4);
|
|
||||||
|
|
||||||
CleanUp();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,83 +0,0 @@
|
||||||
using System;
|
|
||||||
using OpenTK;
|
|
||||||
|
|
||||||
namespace SM.Base.Types
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Basis for the CVector classes
|
|
||||||
/// </summary>
|
|
||||||
public abstract class CVectorBase
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// This event triggers when a component changed.
|
|
||||||
/// </summary>
|
|
||||||
public event Action Changed;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The length/magnitute of the vector.
|
|
||||||
/// </summary>
|
|
||||||
public float Length => GetLength();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the square of the vector length (magnitude).
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>
|
|
||||||
/// This property avoids the costly square root operation required by the Length property. This makes it more suitable
|
|
||||||
/// for comparisons.
|
|
||||||
/// </remarks>
|
|
||||||
public float LengthSquared => GetLength(true);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Get the length of the vector.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="squared">If true, it will return the squared product.</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public float GetLength(bool squared = false)
|
|
||||||
{
|
|
||||||
float length = GetLengthProcess();
|
|
||||||
if (squared) return length;
|
|
||||||
return (float)Math.Sqrt(length);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Normalizes the vector.
|
|
||||||
/// </summary>
|
|
||||||
public void Normalize()
|
|
||||||
{
|
|
||||||
float length = GetLength();
|
|
||||||
NormalizationProcess(length);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Sets the values of the vector, by providing the values over an array.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="parameters"></param>
|
|
||||||
public abstract void SetRaw(params float[] parameters);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This triggers the <see cref="Changed"/> event.
|
|
||||||
/// </summary>
|
|
||||||
protected void TriggerChanged()
|
|
||||||
{
|
|
||||||
Changed?.Invoke();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Conversion from <see cref="float" /> to One-dimensional Vector.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
protected abstract float GetLengthProcess();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Normalizes the vector.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="length"></param>
|
|
||||||
protected abstract void NormalizationProcess(float length);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Converts the vector to a <see cref="Vector4"/>
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
protected abstract Vector4 ConvertToVector4();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,501 +0,0 @@
|
||||||
#region usings
|
|
||||||
|
|
||||||
using OpenTK;
|
|
||||||
using OpenTK.Graphics;
|
|
||||||
using OpenTK.Graphics.OpenGL4;
|
|
||||||
using SM.OGL.Texture;
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
namespace SM.OGL.Shaders
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Manages the uniforms.
|
|
||||||
/// </summary>
|
|
||||||
public struct Uniform : IUniform
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// This contains the location for the uniform.
|
|
||||||
/// </summary>
|
|
||||||
public int Location { get; internal set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This contains the Parent collection of this uniform.
|
|
||||||
/// </summary>
|
|
||||||
public UniformCollection Parent { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This creates a new uniform manager, that has a null parent.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="location"></param>
|
|
||||||
public Uniform(int location) : this(location, null)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This creates a new uniform manager, that get the location from the provided shader and with a null parent.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="name"></param>
|
|
||||||
/// <param name="shader"></param>
|
|
||||||
public Uniform(string name, GenericShader shader) : this(GL.GetUniformLocation(shader, name), null)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// This creates a new uniform manager, that get the location from the provided shader and with a parent.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="name"></param>
|
|
||||||
/// <param name="shader"></param>
|
|
||||||
/// <param name="parent"></param>
|
|
||||||
public Uniform(string name, GenericShader shader, UniformCollection parent) : this(GL.GetUniformLocation(shader, name), parent)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This create a new uniform manager
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="location">Location id</param>
|
|
||||||
/// <param name="parent">Parent collection</param>
|
|
||||||
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
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Try to sets the texture at the next possible position and tells the checkUniform, if worked or not.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="texture">The texture you want to add</param>
|
|
||||||
/// <param name="checkUniform">The check uniform.</param>
|
|
||||||
public void SetTexture(TextureBase texture, Uniform checkUniform)
|
|
||||||
{
|
|
||||||
checkUniform.SetUniform1(texture != null);
|
|
||||||
if (texture != null) SetTexture(texture);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Try to sets the texture at the specified position and tells the checkUniform, if worked or not.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="texture">The texture you want to add</param>
|
|
||||||
/// <param name="pos">The position</param>
|
|
||||||
/// <param name="checkUniform">The check uniform.</param>
|
|
||||||
public void SetTexture(TextureBase texture, int pos, Uniform checkUniform)
|
|
||||||
{
|
|
||||||
checkUniform.SetUniform1(texture != null);
|
|
||||||
if (texture != null) SetTexture(texture);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Sets the texture to the next possible position.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="texture"></param>
|
|
||||||
public void SetTexture(TextureBase texture)
|
|
||||||
{
|
|
||||||
if (Parent != null) SetTexture(texture, Parent.NextTexture);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Sets the texture to the specified position.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="texture"></param>
|
|
||||||
/// <param name="texturePos"></param>
|
|
||||||
public void SetTexture(TextureBase texture, int texturePos)
|
|
||||||
{
|
|
||||||
Parent.NextTexture = texturePos + 1;
|
|
||||||
GL.ActiveTexture(TextureUnit.Texture0 + texturePos);
|
|
||||||
GL.BindTexture(texture.Target, texture);
|
|
||||||
SetUniform1(texturePos);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns the location from the uniform
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="u"></param>
|
|
||||||
public static implicit operator int(Uniform u)
|
|
||||||
{
|
|
||||||
return u.Location;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,41 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
|
||||||
<PropertyGroup>
|
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
|
||||||
<ProjectGuid>{9BECA849-E6E9-4E15-83A6-ADD8C18065CB}</ProjectGuid>
|
|
||||||
<OutputType>Library</OutputType>
|
|
||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
|
||||||
<RootNamespace>SM3D</RootNamespace>
|
|
||||||
<AssemblyName>SM3D</AssemblyName>
|
|
||||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
|
||||||
<FileAlignment>512</FileAlignment>
|
|
||||||
<Deterministic>true</Deterministic>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
|
||||||
<DebugSymbols>true</DebugSymbols>
|
|
||||||
<DebugType>full</DebugType>
|
|
||||||
<Optimize>false</Optimize>
|
|
||||||
<OutputPath>bin\Debug\</OutputPath>
|
|
||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
|
||||||
<ErrorReport>prompt</ErrorReport>
|
|
||||||
<WarningLevel>4</WarningLevel>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
|
||||||
<DebugType>pdbonly</DebugType>
|
|
||||||
<Optimize>true</Optimize>
|
|
||||||
<OutputPath>bin\Release\</OutputPath>
|
|
||||||
<DefineConstants>TRACE</DefineConstants>
|
|
||||||
<ErrorReport>prompt</ErrorReport>
|
|
||||||
<WarningLevel>4</WarningLevel>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Reference Include="System" />
|
|
||||||
<Reference Include="System.Core" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
|
||||||
</Project>
|
|
||||||
|
|
@ -1,39 +0,0 @@
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
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" : "")}";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -3,23 +3,23 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio Version 16
|
# Visual Studio Version 16
|
||||||
VisualStudioVersion = 16.0.30413.136
|
VisualStudioVersion = 16.0.30413.136
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SMRenderer", "SMRenderer", "{47EA2879-1D40-4683-BA6C-AB51F286EBDE}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SM.OGL", "src\renderer\SM.OGL\SM.OGL.csproj", "{F604D684-BC1D-4819-88B5-8B5D03A17BE0}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SM.OGL", "SMCode\SM.OGL\SM.OGL.csproj", "{F604D684-BC1D-4819-88B5-8B5D03A17BE0}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SM.Base", "src\renderer\SM.Base\SM.Base.csproj", "{8E733844-4204-43E7-B3DC-3913CDDABB0D}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SM.Base", "SMCode\SM.Base\SM.Base.csproj", "{8E733844-4204-43E7-B3DC-3913CDDABB0D}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SM2D", "src\renderer\SM2D\SM2D.csproj", "{A4565538-625A-42C6-A330-DD4F1ABB3986}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SM3D", "SMCode\SM3D\SM3D.csproj", "{9BECA849-E6E9-4E15-83A6-ADD8C18065CB}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SM_TEST", "tests\SM_TEST\SM_TEST.csproj", "{6D4FB8E6-4D0B-4928-8F9E-EF5C2FBF44E8}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SM2D", "SMCode\SM2D\SM2D.csproj", "{A4565538-625A-42C6-A330-DD4F1ABB3986}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SMRenderer.Utils", "src\optionals\SM.Utils\SMRenderer.Utils.csproj", "{079BAB31-3DC4-40DA-90C7-EFAA8517C647}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SM_TEST", "SM_TEST\SM_TEST.csproj", "{6D4FB8E6-4D0B-4928-8F9E-EF5C2FBF44E8}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SMRenderer.Intergrations", "src\optionals\SM.Intergrations\SMRenderer.Intergrations.csproj", "{4CB351F4-B3F2-4F77-ACC2-02F21DBF5EC2}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Optionals", "Optionals", "{AE5B181B-BD8F-4F36-A64E-32C4FF7B6FD6}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Renderer", "Renderer", "{62ED6240-4DEC-4535-95EB-AE3D90A3FDF5}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SM.Game", "SMOptionals\SM.Game\SM.Game.csproj", "{079BAB31-3DC4-40DA-90C7-EFAA8517C647}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Optionals", "Optionals", "{CC0E5493-29E8-4ACB-8462-5724A6F636DE}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SM_WPF_TEST", "SM_WPF_TEST\SM_WPF_TEST.csproj", "{6F5367D3-B7E9-40CE-A692-29F9892B6F2A}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{2D2EDE5F-6610-4DF9-AAFD-664F4023A99D}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
|
@ -35,10 +35,6 @@ Global
|
||||||
{8E733844-4204-43E7-B3DC-3913CDDABB0D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{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.ActiveCfg = Release|Any CPU
|
||||||
{8E733844-4204-43E7-B3DC-3913CDDABB0D}.Release|Any CPU.Build.0 = 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.ActiveCfg = Debug|Any CPU
|
||||||
{A4565538-625A-42C6-A330-DD4F1ABB3986}.Debug|Any CPU.Build.0 = 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
|
{A4565538-625A-42C6-A330-DD4F1ABB3986}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
|
@ -51,20 +47,21 @@ Global
|
||||||
{079BAB31-3DC4-40DA-90C7-EFAA8517C647}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{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.ActiveCfg = Release|Any CPU
|
||||||
{079BAB31-3DC4-40DA-90C7-EFAA8517C647}.Release|Any CPU.Build.0 = Release|Any CPU
|
{079BAB31-3DC4-40DA-90C7-EFAA8517C647}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{6F5367D3-B7E9-40CE-A692-29F9892B6F2A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{4CB351F4-B3F2-4F77-ACC2-02F21DBF5EC2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{6F5367D3-B7E9-40CE-A692-29F9892B6F2A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{4CB351F4-B3F2-4F77-ACC2-02F21DBF5EC2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{6F5367D3-B7E9-40CE-A692-29F9892B6F2A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{4CB351F4-B3F2-4F77-ACC2-02F21DBF5EC2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{6F5367D3-B7E9-40CE-A692-29F9892B6F2A}.Release|Any CPU.Build.0 = Release|Any CPU
|
{4CB351F4-B3F2-4F77-ACC2-02F21DBF5EC2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(NestedProjects) = preSolution
|
GlobalSection(NestedProjects) = preSolution
|
||||||
{F604D684-BC1D-4819-88B5-8B5D03A17BE0} = {47EA2879-1D40-4683-BA6C-AB51F286EBDE}
|
{F604D684-BC1D-4819-88B5-8B5D03A17BE0} = {62ED6240-4DEC-4535-95EB-AE3D90A3FDF5}
|
||||||
{8E733844-4204-43E7-B3DC-3913CDDABB0D} = {47EA2879-1D40-4683-BA6C-AB51F286EBDE}
|
{8E733844-4204-43E7-B3DC-3913CDDABB0D} = {62ED6240-4DEC-4535-95EB-AE3D90A3FDF5}
|
||||||
{9BECA849-E6E9-4E15-83A6-ADD8C18065CB} = {47EA2879-1D40-4683-BA6C-AB51F286EBDE}
|
{A4565538-625A-42C6-A330-DD4F1ABB3986} = {62ED6240-4DEC-4535-95EB-AE3D90A3FDF5}
|
||||||
{A4565538-625A-42C6-A330-DD4F1ABB3986} = {47EA2879-1D40-4683-BA6C-AB51F286EBDE}
|
{6D4FB8E6-4D0B-4928-8F9E-EF5C2FBF44E8} = {2D2EDE5F-6610-4DF9-AAFD-664F4023A99D}
|
||||||
{079BAB31-3DC4-40DA-90C7-EFAA8517C647} = {AE5B181B-BD8F-4F36-A64E-32C4FF7B6FD6}
|
{079BAB31-3DC4-40DA-90C7-EFAA8517C647} = {CC0E5493-29E8-4ACB-8462-5724A6F636DE}
|
||||||
|
{4CB351F4-B3F2-4F77-ACC2-02F21DBF5EC2} = {CC0E5493-29E8-4ACB-8462-5724A6F636DE}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {51C827AB-3306-4EE6-9E60-B7BF84854469}
|
SolutionGuid = {51C827AB-3306-4EE6-9E60-B7BF84854469}
|
||||||
|
|
|
||||||
|
|
@ -1,82 +0,0 @@
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,48 +0,0 @@
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8" ?>
|
|
||||||
<configuration>
|
|
||||||
<startup>
|
|
||||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
|
|
||||||
</startup>
|
|
||||||
</configuration>
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
<Application x:Class="SM_WPF_TEST.App"
|
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
||||||
xmlns:local="clr-namespace:SM_WPF_TEST"
|
|
||||||
StartupUri="MainWindow.xaml">
|
|
||||||
<Application.Resources>
|
|
||||||
|
|
||||||
</Application.Resources>
|
|
||||||
</Application>
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
using System.Windows;
|
|
||||||
|
|
||||||
namespace SM_WPF_TEST
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Interaction logic for App.xaml
|
|
||||||
/// </summary>
|
|
||||||
public partial class App : Application
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
<Window x:Class="SM_WPF_TEST.MainWindow"
|
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
||||||
xmlns:local="clr-namespace:SM_WPF_TEST"
|
|
||||||
mc:Ignorable="d"
|
|
||||||
Title="MainWindow" Height="450" Width="800">
|
|
||||||
<Grid Name="grid">
|
|
||||||
<Grid.ColumnDefinitions>
|
|
||||||
<ColumnDefinition Width="Auto"/>
|
|
||||||
<ColumnDefinition/>
|
|
||||||
</Grid.ColumnDefinitions>
|
|
||||||
<Label Content="WPF WITH SM-RENDERER" />
|
|
||||||
</Grid>
|
|
||||||
</Window>
|
|
||||||
|
|
@ -1,32 +0,0 @@
|
||||||
using System.Windows;
|
|
||||||
|
|
||||||
namespace SM_WPF_TEST
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Interaction logic for MainWindow.xaml
|
|
||||||
/// </summary>
|
|
||||||
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();*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,53 +0,0 @@
|
||||||
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
|
|
||||||
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
|
|
||||||
//inside a <PropertyGroup>. For example, if you are using US english
|
|
||||||
//in your source files, set the <UICulture> 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")]
|
|
||||||
70
SM_WPF_TEST/Properties/Resources.Designer.cs
generated
70
SM_WPF_TEST/Properties/Resources.Designer.cs
generated
|
|
@ -1,70 +0,0 @@
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// <auto-generated>
|
|
||||||
// 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.
|
|
||||||
// </auto-generated>
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
namespace SM_WPF_TEST.Properties
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
|
||||||
/// </summary>
|
|
||||||
// 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()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns the cached ResourceManager instance used by this class.
|
|
||||||
/// </summary>
|
|
||||||
[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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Overrides the current thread's CurrentUICulture property for all
|
|
||||||
/// resource lookups using this strongly typed resource class.
|
|
||||||
/// </summary>
|
|
||||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
|
||||||
internal static global::System.Globalization.CultureInfo Culture
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return resourceCulture;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
resourceCulture = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,117 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
||||||
29
SM_WPF_TEST/Properties/Settings.Designer.cs
generated
29
SM_WPF_TEST/Properties/Settings.Designer.cs
generated
|
|
@ -1,29 +0,0 @@
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// <auto-generated>
|
|
||||||
// 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.
|
|
||||||
// </auto-generated>
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
<?xml version='1.0' encoding='utf-8'?>
|
|
||||||
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
|
|
||||||
<Profiles>
|
|
||||||
<Profile Name="(Default)" />
|
|
||||||
</Profiles>
|
|
||||||
<Settings />
|
|
||||||
</SettingsFile>
|
|
||||||
|
|
@ -1,102 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
|
||||||
<PropertyGroup>
|
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
|
||||||
<ProjectGuid>{6F5367D3-B7E9-40CE-A692-29F9892B6F2A}</ProjectGuid>
|
|
||||||
<OutputType>WinExe</OutputType>
|
|
||||||
<RootNamespace>SM_WPF_TEST</RootNamespace>
|
|
||||||
<AssemblyName>SM_WPF_TEST</AssemblyName>
|
|
||||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
|
||||||
<FileAlignment>512</FileAlignment>
|
|
||||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
|
||||||
<WarningLevel>4</WarningLevel>
|
|
||||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
|
||||||
<Deterministic>true</Deterministic>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
|
||||||
<DebugSymbols>true</DebugSymbols>
|
|
||||||
<DebugType>full</DebugType>
|
|
||||||
<Optimize>false</Optimize>
|
|
||||||
<OutputPath>bin\Debug\</OutputPath>
|
|
||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
|
||||||
<ErrorReport>prompt</ErrorReport>
|
|
||||||
<WarningLevel>4</WarningLevel>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
|
||||||
<DebugType>pdbonly</DebugType>
|
|
||||||
<Optimize>true</Optimize>
|
|
||||||
<OutputPath>bin\Release\</OutputPath>
|
|
||||||
<DefineConstants>TRACE</DefineConstants>
|
|
||||||
<ErrorReport>prompt</ErrorReport>
|
|
||||||
<WarningLevel>4</WarningLevel>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Reference Include="System" />
|
|
||||||
<Reference Include="System.Xml" />
|
|
||||||
<Reference Include="System.Core" />
|
|
||||||
<Reference Include="System.Xaml">
|
|
||||||
<RequiredTargetFramework>4.0</RequiredTargetFramework>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="WindowsBase" />
|
|
||||||
<Reference Include="PresentationCore" />
|
|
||||||
<Reference Include="PresentationFramework" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ApplicationDefinition Include="App.xaml">
|
|
||||||
<Generator>MSBuild:Compile</Generator>
|
|
||||||
<SubType>Designer</SubType>
|
|
||||||
</ApplicationDefinition>
|
|
||||||
<Compile Include="Window1.xaml.cs">
|
|
||||||
<DependentUpon>Window1.xaml</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
<Page Include="MainWindow.xaml">
|
|
||||||
<Generator>MSBuild:Compile</Generator>
|
|
||||||
<SubType>Designer</SubType>
|
|
||||||
</Page>
|
|
||||||
<Compile Include="App.xaml.cs">
|
|
||||||
<DependentUpon>App.xaml</DependentUpon>
|
|
||||||
<SubType>Code</SubType>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="MainWindow.xaml.cs">
|
|
||||||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
|
||||||
<SubType>Code</SubType>
|
|
||||||
</Compile>
|
|
||||||
<Page Include="Window1.xaml">
|
|
||||||
<SubType>Designer</SubType>
|
|
||||||
<Generator>MSBuild:Compile</Generator>
|
|
||||||
</Page>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Include="Properties\AssemblyInfo.cs">
|
|
||||||
<SubType>Code</SubType>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="Properties\Resources.Designer.cs">
|
|
||||||
<AutoGen>True</AutoGen>
|
|
||||||
<DesignTime>True</DesignTime>
|
|
||||||
<DependentUpon>Resources.resx</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="Properties\Settings.Designer.cs">
|
|
||||||
<AutoGen>True</AutoGen>
|
|
||||||
<DependentUpon>Settings.settings</DependentUpon>
|
|
||||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
|
||||||
</Compile>
|
|
||||||
<EmbeddedResource Include="Properties\Resources.resx">
|
|
||||||
<Generator>ResXFileCodeGenerator</Generator>
|
|
||||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
|
||||||
</EmbeddedResource>
|
|
||||||
<None Include="OpenTK.dll.config" />
|
|
||||||
<None Include="packages.config" />
|
|
||||||
<None Include="Properties\Settings.settings">
|
|
||||||
<Generator>SettingsSingleFileGenerator</Generator>
|
|
||||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
|
||||||
</None>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<None Include="App.config" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
|
||||||
</Project>
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
<Window x:Class="SM_WPF_TEST.Window1"
|
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
||||||
xmlns:local="clr-namespace:SM_WPF_TEST"
|
|
||||||
mc:Ignorable="d"
|
|
||||||
Title="Window1" Height="450" Width="800">
|
|
||||||
<Grid>
|
|
||||||
|
|
||||||
</Grid>
|
|
||||||
</Window>
|
|
||||||
|
|
@ -1,30 +0,0 @@
|
||||||
using System.Windows;
|
|
||||||
|
|
||||||
namespace SM_WPF_TEST
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Interaction logic for Window1.xaml
|
|
||||||
/// </summary>
|
|
||||||
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);*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,19 +1,16 @@
|
||||||
#region usings
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
using System.Reflection;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
// General Information about an assembly is controlled through the following
|
// General Information about an assembly is controlled through the following
|
||||||
// set of attributes. Change these attribute values to modify the information
|
// set of attributes. Change these attribute values to modify the information
|
||||||
// associated with an assembly.
|
// associated with an assembly.
|
||||||
[assembly: AssemblyTitle("SM3D")]
|
[assembly: AssemblyTitle("SM.Intergrations")]
|
||||||
[assembly: AssemblyDescription("")]
|
[assembly: AssemblyDescription("")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCompany("Microsoft")]
|
[assembly: AssemblyCompany("")]
|
||||||
[assembly: AssemblyProduct("SM3D")]
|
[assembly: AssemblyProduct("SM.Intergrations")]
|
||||||
[assembly: AssemblyCopyright("Copyright © Microsoft 2020")]
|
[assembly: AssemblyCopyright("Copyright © 2021")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
|
@ -23,7 +20,7 @@ using System.Runtime.InteropServices;
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
[assembly: Guid("9beca849-e6e9-4e15-83a6-add8c18065cb")]
|
[assembly: Guid("4cb351f4-b3f2-4f77-acc2-02f21dbf5ec2")]
|
||||||
|
|
||||||
// Version information for an assembly consists of the following four values:
|
// Version information for an assembly consists of the following four values:
|
||||||
//
|
//
|
||||||
|
|
@ -4,17 +4,17 @@
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
<ProjectGuid>{6D4FB8E6-4D0B-4928-8F9E-EF5C2FBF44E8}</ProjectGuid>
|
<ProjectGuid>{4CB351F4-B3F2-4F77-ACC2-02F21DBF5EC2}</ProjectGuid>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>Library</OutputType>
|
||||||
<RootNamespace>SM_TEST</RootNamespace>
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
<AssemblyName>SM_TEST</AssemblyName>
|
<RootNamespace>SM.Intergrations</RootNamespace>
|
||||||
|
<AssemblyName>SM.Intergrations</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
|
||||||
<Deterministic>true</Deterministic>
|
<Deterministic>true</Deterministic>
|
||||||
|
<TargetFrameworkProfile />
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
<DebugType>full</DebugType>
|
<DebugType>full</DebugType>
|
||||||
<Optimize>false</Optimize>
|
<Optimize>false</Optimize>
|
||||||
|
|
@ -24,7 +24,6 @@
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
|
||||||
<DebugType>pdbonly</DebugType>
|
<DebugType>pdbonly</DebugType>
|
||||||
<Optimize>true</Optimize>
|
<Optimize>true</Optimize>
|
||||||
<OutputPath>bin\Release\</OutputPath>
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
|
@ -32,43 +31,43 @@
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup>
|
|
||||||
<StartupObject />
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="OpenTK, Version=3.3.1.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
|
<Reference Include="OpenTK, Version=3.3.1.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\OpenTK.3.3.1\lib\net20\OpenTK.dll</HintPath>
|
<HintPath>..\..\..\packages\OpenTK.3.3.1\lib\net20\OpenTK.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="ShaderToolParser, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\..\packages\ShaderToolParser.1.0.0-pre3\lib\net450\ShaderToolParser.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
<Reference Include="System.Drawing" />
|
<Reference Include="System.Drawing" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Net.Http" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Program.cs" />
|
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="TestRenderPipeline.cs" />
|
<Compile Include="ShaderTool\STMaterial.cs" />
|
||||||
|
<Compile Include="ShaderTool\STMaterialShader.cs" />
|
||||||
|
<Compile Include="ShaderTool\STPostProcessEffect.cs" />
|
||||||
|
<Compile Include="ShaderTool\STPostProcessShader.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="App.config" />
|
<ProjectReference Include="..\..\renderer\SM.Base\SM.Base.csproj">
|
||||||
<None Include="OpenTK.dll.config" />
|
|
||||||
<None Include="packages.config" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<WCFMetadata Include="Connected Services\" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\SMCode\SM.Base\SM.Base.csproj">
|
|
||||||
<Project>{8e733844-4204-43e7-b3dc-3913cddabb0d}</Project>
|
<Project>{8e733844-4204-43e7-b3dc-3913cddabb0d}</Project>
|
||||||
<Name>SM.Base</Name>
|
<Name>SM.Base</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\SMCode\SM.OGL\SM.OGL.csproj">
|
<ProjectReference Include="..\..\renderer\SM.OGL\SM.OGL.csproj">
|
||||||
<Project>{f604d684-bc1d-4819-88b5-8b5d03a17be0}</Project>
|
<Project>{f604d684-bc1d-4819-88b5-8b5d03a17be0}</Project>
|
||||||
<Name>SM.OGL</Name>
|
<Name>SM.OGL</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\SMCode\SM2D\SM2D.csproj">
|
</ItemGroup>
|
||||||
<Project>{a4565538-625a-42c6-a330-dd4f1abb3986}</Project>
|
<ItemGroup>
|
||||||
<Name>SM2D</Name>
|
<None Include="OpenTK.dll.config" />
|
||||||
</ProjectReference>
|
<None Include="packages.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
</Project>
|
</Project>
|
||||||
50
src/optionals/SM.Intergrations/ShaderTool/STMaterial.cs
Normal file
50
src/optionals/SM.Intergrations/ShaderTool/STMaterial.cs
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
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<string, STPVariable> 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,70 @@
|
||||||
|
|
||||||
|
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<DrawContext> _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<string, STPVariable> 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<TextureBase>(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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,68 @@
|
||||||
|
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<string, STPVariable> 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,74 @@
|
||||||
|
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<ShaderArguments> _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<string, STPVariable> 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<TextureBase>(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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<packages>
|
||||||
<package id="OpenTK" version="3.3.1" targetFramework="net452" />
|
<package id="OpenTK" version="3.3.1" targetFramework="net452" />
|
||||||
|
<package id="ShaderToolParser" version="1.0.0-pre3" targetFramework="net452" />
|
||||||
</packages>
|
</packages>
|
||||||
56
src/optionals/SM.Utils/Controls/GameController.cs
Normal file
56
src/optionals/SM.Utils/Controls/GameController.cs
Normal file
|
|
@ -0,0 +1,56 @@
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using SharpDX.XInput;
|
using SharpDX.XInput;
|
||||||
|
|
||||||
namespace SM.Game.Controls
|
namespace SM.Utils.Controls
|
||||||
{
|
{
|
||||||
public struct GameControllerState
|
public struct GameControllerState
|
||||||
{
|
{
|
||||||
|
|
@ -12,7 +12,7 @@ namespace SM.Game.Controls
|
||||||
public GameControllerStateButtons Buttons;
|
public GameControllerStateButtons Buttons;
|
||||||
|
|
||||||
public bool FromConnected { get; }
|
public bool FromConnected { get; }
|
||||||
|
public bool AnyInteraction => Buttons.AnyInteraction || DPad.AnyInteraction || Triggers.AnyInteraction || Thumbs.AnyInteraction;
|
||||||
internal GameControllerState(bool empty)
|
internal GameControllerState(bool empty)
|
||||||
{
|
{
|
||||||
FromConnected = false;
|
FromConnected = false;
|
||||||
|
|
@ -22,22 +22,11 @@ namespace SM.Game.Controls
|
||||||
DPad = GameControllerStateDPad.Default;
|
DPad = GameControllerStateDPad.Default;
|
||||||
Buttons = GameControllerStateButtons.Default;
|
Buttons = GameControllerStateButtons.Default;
|
||||||
}
|
}
|
||||||
internal GameControllerState(Gamepad state, ref GameController controller)
|
internal GameControllerState(Gamepad state, GameController controller)
|
||||||
{
|
{
|
||||||
FromConnected = true;
|
FromConnected = true;
|
||||||
|
|
||||||
Thumbs = new GameControllerStateThumbs
|
Thumbs = new GameControllerStateThumbs(controller, state);
|
||||||
{
|
|
||||||
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()
|
Triggers = new GameControllerStateTriggers()
|
||||||
{
|
{
|
||||||
|
|
@ -46,7 +35,7 @@ namespace SM.Game.Controls
|
||||||
};
|
};
|
||||||
|
|
||||||
DPad = new GameControllerStateDPad(state.Buttons);
|
DPad = new GameControllerStateDPad(state.Buttons);
|
||||||
Buttons = new GameControllerStateButtons(state.Buttons);
|
Buttons = new GameControllerStateButtons(state.Buttons, controller);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
|
|
@ -1,12 +1,17 @@
|
||||||
using SharpDX.XInput;
|
using SharpDX.XInput;
|
||||||
|
|
||||||
namespace SM.Game.Controls
|
namespace SM.Utils.Controls
|
||||||
{
|
{
|
||||||
public struct GameControllerStateButtons
|
public struct GameControllerStateButtons
|
||||||
{
|
{
|
||||||
public static GameControllerStateButtons Default = new GameControllerStateButtons(GamepadButtonFlags.None);
|
public static GameControllerStateButtons Default = new GameControllerStateButtons()
|
||||||
|
{
|
||||||
|
_buttonFlags = GamepadButtonFlags.None,
|
||||||
|
_lastButtonFlags = GamepadButtonFlags.None
|
||||||
|
};
|
||||||
|
|
||||||
private GamepadButtonFlags _buttonFlags;
|
private GamepadButtonFlags _buttonFlags;
|
||||||
|
private GamepadButtonFlags _lastButtonFlags;
|
||||||
|
|
||||||
public bool X;
|
public bool X;
|
||||||
public bool Y;
|
public bool Y;
|
||||||
|
|
@ -19,11 +24,17 @@ namespace SM.Game.Controls
|
||||||
public bool LeftThumb;
|
public bool LeftThumb;
|
||||||
public bool RightThumb;
|
public bool RightThumb;
|
||||||
|
|
||||||
public bool this[GamepadButtonFlags flags] => _buttonFlags.HasFlag(flags);
|
public bool Start;
|
||||||
|
public bool Back;
|
||||||
|
|
||||||
internal GameControllerStateButtons(GamepadButtonFlags 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)
|
||||||
{
|
{
|
||||||
_buttonFlags = flags;
|
_buttonFlags = flags;
|
||||||
|
_lastButtonFlags = controller._lastPressedButtons;
|
||||||
|
|
||||||
X = flags.HasFlag(GamepadButtonFlags.X);
|
X = flags.HasFlag(GamepadButtonFlags.X);
|
||||||
Y = flags.HasFlag(GamepadButtonFlags.Y);
|
Y = flags.HasFlag(GamepadButtonFlags.Y);
|
||||||
|
|
@ -35,6 +46,11 @@ namespace SM.Game.Controls
|
||||||
|
|
||||||
LeftThumb = flags.HasFlag(GamepadButtonFlags.LeftThumb);
|
LeftThumb = flags.HasFlag(GamepadButtonFlags.LeftThumb);
|
||||||
RightThumb = flags.HasFlag(GamepadButtonFlags.RightThumb);
|
RightThumb = flags.HasFlag(GamepadButtonFlags.RightThumb);
|
||||||
|
|
||||||
|
Start = flags.HasFlag(GamepadButtonFlags.Start);
|
||||||
|
Back = flags.HasFlag(GamepadButtonFlags.Back);
|
||||||
|
|
||||||
|
AnyInteraction = (int) flags >= 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
using SharpDX.XInput;
|
using SharpDX.XInput;
|
||||||
|
|
||||||
namespace SM.Game.Controls
|
namespace SM.Utils.Controls
|
||||||
{
|
{
|
||||||
public struct GameControllerStateDPad
|
public struct GameControllerStateDPad
|
||||||
{
|
{
|
||||||
|
|
@ -11,12 +11,16 @@ namespace SM.Game.Controls
|
||||||
public bool Left;
|
public bool Left;
|
||||||
public bool Right;
|
public bool Right;
|
||||||
|
|
||||||
|
public bool AnyInteraction { get; }
|
||||||
|
|
||||||
internal GameControllerStateDPad(GamepadButtonFlags flags)
|
internal GameControllerStateDPad(GamepadButtonFlags flags)
|
||||||
{
|
{
|
||||||
Up = flags.HasFlag(GamepadButtonFlags.DPadUp);
|
Up = flags.HasFlag(GamepadButtonFlags.DPadUp);
|
||||||
Down = flags.HasFlag(GamepadButtonFlags.DPadDown);
|
Down = flags.HasFlag(GamepadButtonFlags.DPadDown);
|
||||||
Left = flags.HasFlag(GamepadButtonFlags.DPadLeft);
|
Left = flags.HasFlag(GamepadButtonFlags.DPadLeft);
|
||||||
Right = flags.HasFlag(GamepadButtonFlags.DPadRight);
|
Right = flags.HasFlag(GamepadButtonFlags.DPadRight);
|
||||||
|
|
||||||
|
AnyInteraction = (int)flags > 0 && (int) flags < 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
37
src/optionals/SM.Utils/Controls/GameControllerStateThumbs.cs
Normal file
37
src/optionals/SM.Utils/Controls/GameControllerStateThumbs.cs
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
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" : "")}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
namespace SM.Game.Controls
|
namespace SM.Utils.Controls
|
||||||
{
|
{
|
||||||
public struct GameControllerStateTriggers
|
public struct GameControllerStateTriggers
|
||||||
{
|
{
|
||||||
|
|
@ -6,6 +6,9 @@
|
||||||
|
|
||||||
public float Left;
|
public float Left;
|
||||||
public float Right;
|
public float Right;
|
||||||
|
|
||||||
|
public bool AnyInteraction => Left != 0f || Right != 0f;
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return $"Left: {Left}; Right: {Right}";
|
return $"Left: {Left}; Right: {Right}";
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace SM.Game.Controls
|
namespace SM.Utils.Controls
|
||||||
{
|
{
|
||||||
public class GameKeybind
|
public class GameKeybind
|
||||||
{
|
{
|
||||||
|
|
@ -18,10 +18,8 @@ namespace SM.Game.Controls
|
||||||
return AI;
|
return AI;
|
||||||
case GameKeybindActorType.Keyboard:
|
case GameKeybindActorType.Keyboard:
|
||||||
return Keyboard;
|
return Keyboard;
|
||||||
break;
|
|
||||||
case GameKeybindActorType.Controller:
|
case GameKeybindActorType.Controller:
|
||||||
return Controller;
|
return Controller;
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
throw new ArgumentOutOfRangeException(nameof(type), type, null);
|
throw new ArgumentOutOfRangeException(nameof(type), type, null);
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
using OpenTK.Input;
|
using OpenTK.Input;
|
||||||
|
|
||||||
namespace SM.Game.Controls
|
namespace SM.Utils.Controls
|
||||||
{
|
{
|
||||||
public enum GameKeybindActorType
|
public enum GameKeybindActorType
|
||||||
{
|
{
|
||||||
|
|
@ -12,16 +12,25 @@ namespace SM.Game.Controls
|
||||||
public struct GameKeybindActor
|
public struct GameKeybindActor
|
||||||
{
|
{
|
||||||
private GameKeybindActorType _type;
|
private GameKeybindActorType _type;
|
||||||
private GameController? _controller;
|
private GameController _controller;
|
||||||
|
|
||||||
private GameKeybindHost _keybindHost;
|
private GameKeybindHost _keybindHost;
|
||||||
|
|
||||||
public GameKeybindActorType Type => _type;
|
public GameKeybindActorType Type => _type;
|
||||||
public GameController? Controller => _controller;
|
public GameController Controller => _controller;
|
||||||
|
|
||||||
public object[] Parameter;
|
public object[] Parameter;
|
||||||
|
|
||||||
private GameKeybindActor(GameKeybindActorType type, GameController? controller)
|
private GameKeybindActor(GameKeybindActorType type, GameController controller)
|
||||||
|
{
|
||||||
|
_type = type;
|
||||||
|
_controller = controller;
|
||||||
|
|
||||||
|
_keybindHost = null;
|
||||||
|
|
||||||
|
Parameter = new object[0];
|
||||||
|
}
|
||||||
|
private GameKeybindActor(GameKeybindActorType type, ref GameController controller)
|
||||||
{
|
{
|
||||||
_type = type;
|
_type = type;
|
||||||
_controller = controller;
|
_controller = controller;
|
||||||
|
|
@ -58,7 +67,7 @@ namespace SM.Game.Controls
|
||||||
|
|
||||||
KeyboardState = Keyboard.GetState(),
|
KeyboardState = Keyboard.GetState(),
|
||||||
MouseState = Mouse.GetState(),
|
MouseState = Mouse.GetState(),
|
||||||
ControllerState = Controller?.GetState(),
|
ControllerState = Controller?.GetState() ?? new GameControllerState(true),
|
||||||
};
|
};
|
||||||
|
|
||||||
return keybind[Type].Invoke(context);
|
return keybind[Type].Invoke(context);
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
using OpenTK.Input;
|
using OpenTK.Input;
|
||||||
|
|
||||||
namespace SM.Game.Controls
|
namespace SM.Utils.Controls
|
||||||
{
|
{
|
||||||
public struct GameKeybindContext
|
public struct GameKeybindContext
|
||||||
{
|
{
|
||||||
public KeyboardState KeyboardState;
|
public KeyboardState KeyboardState;
|
||||||
public MouseState MouseState;
|
public MouseState MouseState;
|
||||||
public GameControllerState? ControllerState;
|
public GameControllerState ControllerState;
|
||||||
|
|
||||||
public GameKeybindActor Actor;
|
public GameKeybindActor Actor;
|
||||||
public GameKeybindHost Host;
|
public GameKeybindHost Host;
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace SM.Game.Controls
|
namespace SM.Utils.Controls
|
||||||
{
|
{
|
||||||
public class GameKeybindHost
|
public class GameKeybindHost
|
||||||
{
|
{
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace SM.Game.Controls
|
namespace SM.Utils.Controls
|
||||||
{
|
{
|
||||||
public class GameKeybindList : List<KeyValuePair<string, GameKeybind>>
|
public class GameKeybindList : List<KeyValuePair<string, GameKeybind>>
|
||||||
{
|
{
|
||||||
|
|
@ -7,11 +7,12 @@
|
||||||
<ProjectGuid>{079BAB31-3DC4-40DA-90C7-EFAA8517C647}</ProjectGuid>
|
<ProjectGuid>{079BAB31-3DC4-40DA-90C7-EFAA8517C647}</ProjectGuid>
|
||||||
<OutputType>Library</OutputType>
|
<OutputType>Library</OutputType>
|
||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
<RootNamespace>SM.Game</RootNamespace>
|
<RootNamespace>SM.Utils</RootNamespace>
|
||||||
<AssemblyName>SM.Game</AssemblyName>
|
<AssemblyName>SM.Utils</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
<Deterministic>true</Deterministic>
|
<Deterministic>true</Deterministic>
|
||||||
|
<TargetFrameworkProfile />
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
|
@ -32,13 +33,13 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="OpenTK, Version=3.3.1.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
|
<Reference Include="OpenTK, Version=3.3.1.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
|
||||||
<HintPath>..\..\packages\OpenTK.3.3.1\lib\net20\OpenTK.dll</HintPath>
|
<HintPath>..\..\..\packages\OpenTK.3.3.1\lib\net20\OpenTK.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="SharpDX, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
|
<Reference Include="SharpDX, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
|
||||||
<HintPath>..\..\packages\SharpDX.4.2.0\lib\net45\SharpDX.dll</HintPath>
|
<HintPath>..\..\..\packages\SharpDX.4.2.0\lib\net45\SharpDX.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="SharpDX.XInput, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
|
<Reference Include="SharpDX.XInput, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
|
||||||
<HintPath>..\..\packages\SharpDX.XInput.4.2.0\lib\net45\SharpDX.XInput.dll</HintPath>
|
<HintPath>..\..\..\packages\SharpDX.XInput.4.2.0\lib\net45\SharpDX.XInput.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
|
|
@ -61,5 +62,11 @@
|
||||||
<None Include="OpenTK.dll.config" />
|
<None Include="OpenTK.dll.config" />
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\renderer\SM.Base\SM.Base.csproj">
|
||||||
|
<Project>{8e733844-4204-43e7-b3dc-3913cddabb0d}</Project>
|
||||||
|
<Name>SM.Base</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
</Project>
|
</Project>
|
||||||
|
|
@ -18,10 +18,20 @@ namespace SM.Base.Controls
|
||||||
private static MouseState? _mouseState;
|
private static MouseState? _mouseState;
|
||||||
private static List<MouseButton> _lastButtonsPressed = new List<MouseButton>();
|
private static List<MouseButton> _lastButtonsPressed = new List<MouseButton>();
|
||||||
|
|
||||||
|
private static Vector2 _inScreen;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The current position of the mouse in the screen.
|
/// Gets or sets the current position of the mouse in the screen.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static Vector2 InScreen { get; private set; }
|
public static Vector2 InScreen
|
||||||
|
{
|
||||||
|
get => _inScreen;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_inScreen = value;
|
||||||
|
UpdateNormalized(SMRenderer.CurrentWindow);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The current position of the mouse in the screen from 0..1.
|
/// The current position of the mouse in the screen from 0..1.
|
||||||
|
|
@ -40,6 +50,16 @@ namespace SM.Base.Controls
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static bool RightClick => IsDown(MouseButton.Right, true);
|
public static bool RightClick => IsDown(MouseButton.Right, true);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// If true, it disables the tracking of the mouse, allowing you to change the <see cref="InScreen"/> value, without the system replacing it again.
|
||||||
|
/// </summary>
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The event to update the values.
|
/// The event to update the values.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -47,8 +67,10 @@ namespace SM.Base.Controls
|
||||||
/// <param name="window">The window where the mouse is checked</param>
|
/// <param name="window">The window where the mouse is checked</param>
|
||||||
internal static void MouseMoveEvent(MouseMoveEventArgs mmea, IGenericWindow window)
|
internal static void MouseMoveEvent(MouseMoveEventArgs mmea, IGenericWindow window)
|
||||||
{
|
{
|
||||||
|
if (StopTracking) return;
|
||||||
|
|
||||||
InScreen = new Vector2(mmea.X, mmea.Y);
|
InScreen = new Vector2(mmea.X, mmea.Y);
|
||||||
InScreenNormalized = new Vector2(mmea.X / (float) window.Width, mmea.Y / (float) window.Height);
|
UpdateNormalized(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void SetState()
|
internal static void SetState()
|
||||||
|
|
@ -39,9 +39,16 @@ namespace SM.Base.Drawing
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the current model matrix.
|
/// Returns the current model matrix.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="force">If set to true, it will always (re-)calculate the model matrix.</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public Matrix4 GetMatrix()
|
public Matrix4 GetMatrix(bool force = false)
|
||||||
{
|
{
|
||||||
|
if (force)
|
||||||
|
{
|
||||||
|
_lastFrame = SMRenderer.CurrentFrame;
|
||||||
|
return _modelMatrix = RequestMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
if (Ignore) return Matrix4.Identity;
|
if (Ignore) return Matrix4.Identity;
|
||||||
|
|
||||||
if (_lastFrame != SMRenderer.CurrentFrame)
|
if (_lastFrame != SMRenderer.CurrentFrame)
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
using SM.Base.Shaders;
|
using SM.Base.Shaders;
|
||||||
|
using SM.Base.Window;
|
||||||
using SM.OGL.Texture;
|
using SM.OGL.Texture;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
@ -16,26 +17,35 @@ namespace SM.Base.Drawing
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A setting to enable Blending.
|
/// A setting to enable Blending.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool Blending = false;
|
public virtual bool Blending { get; set; } = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A custom shader, that is used to draw this material.
|
/// A custom shader, that is used to draw this material.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public MaterialShader CustomShader;
|
public virtual MaterialShader CustomShader { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The base texture. (aka. Diffuse Texture)
|
/// The base texture. (aka. Diffuse Texture)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public TextureBase Texture;
|
public virtual TextureBase Texture { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The tint or color.
|
/// The tint or color.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Color4 Tint = Color4.White;
|
public virtual Color4 Tint { get; set; } = Color4.White;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This allows custom shaders to use own shader arguments.
|
/// This allows custom shaders to use own shader arguments.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ShaderArguments ShaderArguments { get; internal set; } = new ShaderArguments();
|
public ShaderArguments ShaderArguments { get; internal set; } = new ShaderArguments();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Draws the material with the provided context.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="context"></param>
|
||||||
|
public virtual void Draw(DrawContext context)
|
||||||
|
{
|
||||||
|
context.Shader.Draw(context);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
212
src/renderer/SM.Base/Drawing/Particles/ParticleDrawingBasis.cs
Normal file
212
src/renderer/SM.Base/Drawing/Particles/ParticleDrawingBasis.cs
Normal file
|
|
@ -0,0 +1,212 @@
|
||||||
|
#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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The (drawing) basis for particles
|
||||||
|
/// </summary>
|
||||||
|
public abstract class ParticleDrawingBasis<TTransform, TDirection> : DrawingBasis<TTransform>, IScriptable
|
||||||
|
where TTransform : GenericTransformation, new()
|
||||||
|
where TDirection : struct
|
||||||
|
{
|
||||||
|
private float? _continuesIntervalSeconds = null;
|
||||||
|
private Interval _continuesInterval;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The stopwatch of the particles.
|
||||||
|
/// </summary>
|
||||||
|
protected Timer timer;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This contains the different instances for the particles.
|
||||||
|
/// </summary>
|
||||||
|
protected List<ParticleInstance<TDirection>> instances;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The amount of particles
|
||||||
|
/// </summary>
|
||||||
|
public int Amount = 32;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The base lifetime for particles in seconds.
|
||||||
|
/// </summary>
|
||||||
|
public float Lifetime;
|
||||||
|
/// <summary>
|
||||||
|
/// Randomizes the lifetime for particles.
|
||||||
|
/// </summary>
|
||||||
|
public float LifetimeRandomize = 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// If set to any value (except null), it will create the particles continuously.
|
||||||
|
/// </summary>
|
||||||
|
public float? ContinuousInterval
|
||||||
|
{
|
||||||
|
get => _continuesIntervalSeconds;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value.HasValue)
|
||||||
|
{
|
||||||
|
_continuesInterval.Target = value.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
_continuesIntervalSeconds = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// If true, the particles will spawn in Worldspace and can't be moved by the transformation.
|
||||||
|
/// </summary>
|
||||||
|
public bool DetachedParticles;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The maximum speed of the particles
|
||||||
|
/// <para>Default: 25</para>
|
||||||
|
/// </summary>
|
||||||
|
public float MaxSpeed = 25;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sets up the timer.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="duration">Duration how long the particles should live</param>
|
||||||
|
protected ParticleDrawingBasis(TimeSpan duration)
|
||||||
|
{
|
||||||
|
timer = new Timer(duration);
|
||||||
|
_continuesInterval = new Interval(0);
|
||||||
|
_continuesInterval.End += CreateContinuesParticles;
|
||||||
|
|
||||||
|
Lifetime = (float) duration.TotalSeconds;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get/Sets the state of pausing.
|
||||||
|
/// </summary>
|
||||||
|
public bool Paused
|
||||||
|
{
|
||||||
|
get => timer.Paused;
|
||||||
|
set => timer.Paused = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Controls the movement of each particles.
|
||||||
|
/// </summary>
|
||||||
|
public abstract Func<ParticleInstance<TDirection>, TDirection> MovementCalculation { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public bool UpdateActive {
|
||||||
|
get => timer.Active || _continuesInterval.Active;
|
||||||
|
set { return; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Triggers the particles.
|
||||||
|
/// </summary>
|
||||||
|
public void Trigger()
|
||||||
|
{
|
||||||
|
instances = new List<ParticleInstance<TDirection>>();
|
||||||
|
if (_continuesIntervalSeconds.HasValue)
|
||||||
|
{
|
||||||
|
_continuesInterval.Target = _continuesIntervalSeconds.Value;
|
||||||
|
_continuesInterval.Start();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
timer.Start();
|
||||||
|
|
||||||
|
CreateParticles();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Stops the particles.
|
||||||
|
/// </summary>
|
||||||
|
public void Stop()
|
||||||
|
{
|
||||||
|
if (_continuesInterval.Active)
|
||||||
|
{
|
||||||
|
_continuesInterval.Stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
timer.Stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override void OnRemoved(object sender)
|
||||||
|
{
|
||||||
|
base.OnRemoved(sender);
|
||||||
|
|
||||||
|
Stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates the particles.
|
||||||
|
/// </summary>
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a particle.
|
||||||
|
/// </summary>
|
||||||
|
protected abstract ParticleInstance<TDirection> CreateObject(int index);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Generates the desired matrix for drawing.
|
||||||
|
/// </summary>
|
||||||
|
protected abstract Matrix4 CreateMatrix(ParticleInstance<TDirection> Struct, TDirection relativePosition);
|
||||||
|
}
|
||||||
|
}
|
||||||
40
src/renderer/SM.Base/Drawing/Particles/ParticleInstance.cs
Normal file
40
src/renderer/SM.Base/Drawing/Particles/ParticleInstance.cs
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
using OpenTK;
|
||||||
|
|
||||||
|
namespace SM.Base.Drawing.Particles
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This describes a instance of a particle
|
||||||
|
/// </summary>
|
||||||
|
public class ParticleInstance : Instance
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The lifetime the particle started with.
|
||||||
|
/// </summary>
|
||||||
|
public float StartLifetime = 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The lifetime this particular particle still has.
|
||||||
|
/// </summary>
|
||||||
|
public float Lifetime = 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A additional matrix to store rotation and scale.
|
||||||
|
/// </summary>
|
||||||
|
public Matrix4 Matrix;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Speeeeeeeeeed
|
||||||
|
/// </summary>
|
||||||
|
public float Speed;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public class ParticleInstance<TValue> : ParticleInstance
|
||||||
|
where TValue : struct
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A direction, that the particle should travel.
|
||||||
|
/// </summary>
|
||||||
|
public TValue Direction;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -14,17 +14,17 @@ namespace SM.Base.Drawing.Particles
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Default movement for 2D.
|
/// Default movement for 2D.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static Vector2 Default2D(Vector2 direction, ParticleContext context)
|
public static Vector2 Default2D(ParticleInstance<Vector2> particle)
|
||||||
{
|
{
|
||||||
return direction * (context.Timer.Elapsed * context.Speed);
|
return particle.Direction * ((particle.StartLifetime - particle.Lifetime) * particle.Speed);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Default movement for 3D.
|
/// Default movement for 3D.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static Vector3 Default3D(Vector3 direction, ParticleContext context)
|
public static Vector3 Default3D(ParticleInstance<Vector3> particle)
|
||||||
{
|
{
|
||||||
return direction * (context.Timer.Elapsed * context.Speed);
|
return particle.Direction * ((particle.StartLifetime - particle.Lifetime) * particle.Speed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -40,6 +40,12 @@ namespace SM.Base.Drawing.Text
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float FontSize { get; set; } = 12;
|
public float FontSize { get; set; } = 12;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Allows to adjust the baseline to fix clipping issues.
|
||||||
|
/// <para>Due to some issues with the calculations, this is a temporary fix.</para>
|
||||||
|
/// </summary>
|
||||||
|
public float BaselineAdjust { get; set; } = 1f;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The character positions.
|
/// The character positions.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -64,6 +70,8 @@ namespace SM.Base.Drawing.Text
|
||||||
public void RegenerateTexture()
|
public void RegenerateTexture()
|
||||||
{
|
{
|
||||||
Width = Height = 0;
|
Width = Height = 0;
|
||||||
|
|
||||||
|
//Height = Math.Abs(_fontFace.BBox.Bottom) + _fontFace.BBox.Top;
|
||||||
Positions = new Dictionary<char, CharParameter>();
|
Positions = new Dictionary<char, CharParameter>();
|
||||||
|
|
||||||
_fontFace.SetCharSize(0, FontSize, 0, 96);
|
_fontFace.SetCharSize(0, FontSize, 0, 96);
|
||||||
|
|
@ -83,7 +91,7 @@ namespace SM.Base.Drawing.Text
|
||||||
|
|
||||||
float bBoxHeight = (Math.Abs(_fontFace.BBox.Bottom) + _fontFace.BBox.Top);
|
float bBoxHeight = (Math.Abs(_fontFace.BBox.Bottom) + _fontFace.BBox.Top);
|
||||||
float bBoxTopScale = _fontFace.BBox.Top / bBoxHeight;
|
float bBoxTopScale = _fontFace.BBox.Top / bBoxHeight;
|
||||||
float baseline = Height * bBoxTopScale + 1;
|
float baseline = (Height * bBoxTopScale) + BaselineAdjust;
|
||||||
|
|
||||||
Map = new Bitmap(Width, Height);
|
Map = new Bitmap(Width, Height);
|
||||||
using (Graphics g = Graphics.FromImage(Map))
|
using (Graphics g = Graphics.FromImage(Map))
|
||||||
|
|
@ -95,8 +103,7 @@ namespace SM.Base.Drawing.Text
|
||||||
{
|
{
|
||||||
_fontFace.LoadChar(keyvalue.Key, LoadFlags.Render, LoadTarget.Normal);
|
_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);
|
g.DrawImageUnscaled(_fontFace.Glyph.Bitmap.ToGdipBitmap(Color.White), (int)keyvalue.Value[1], y);
|
||||||
|
|
||||||
Vector2 offset = new Vector2(keyvalue.Value[1] / Width, 0);
|
Vector2 offset = new Vector2(keyvalue.Value[1] / Width, 0);
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
#region usings
|
#region usings
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
using SM.Base.Objects.Static;
|
using SM.Base.Objects.Static;
|
||||||
|
|
@ -130,9 +132,13 @@ namespace SM.Base.Drawing.Text
|
||||||
{
|
{
|
||||||
if (!Font.WasCompiled) Font.RegenerateTexture();
|
if (!Font.WasCompiled) Font.RegenerateTexture();
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(_text)) return;
|
||||||
|
|
||||||
_text = _text.Replace("\r\n", "\n").Replace("\t", " ");
|
_text = _text.Replace("\r\n", "\n").Replace("\t", " ");
|
||||||
|
|
||||||
_instances = new Instance[_text.Length];
|
_instances = new Instance[_text.Length];
|
||||||
|
List<Tuple<Vector2, Instance[]>> lines = new List<Tuple<Vector2, Instance[]>>();
|
||||||
|
List<Instance> currentLineInstances = new List<Instance>();
|
||||||
|
|
||||||
float x = 0;
|
float x = 0;
|
||||||
float y = 0;
|
float y = 0;
|
||||||
|
|
@ -146,8 +152,13 @@ namespace SM.Base.Drawing.Text
|
||||||
|
|
||||||
if (_text[i] == '\n')
|
if (_text[i] == '\n')
|
||||||
{
|
{
|
||||||
|
if (currentLineInstances.Count > 0)
|
||||||
|
{
|
||||||
|
lines.Add(new Tuple<Vector2, Instance[]>(new Vector2(x, y), currentLineInstances.ToArray()));
|
||||||
|
currentLineInstances.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
y += Font.Height;
|
y += Font.Height;
|
||||||
Width = Math.Max(Width, x);
|
|
||||||
x = 0;
|
x = 0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -170,32 +181,41 @@ namespace SM.Base.Drawing.Text
|
||||||
|
|
||||||
var matrix = Matrix4.CreateScale(parameter.Width, Font.Height, 1) *
|
var matrix = Matrix4.CreateScale(parameter.Width, Font.Height, 1) *
|
||||||
Matrix4.CreateTranslation(x + parameter.Width / 2, -y, 0);
|
Matrix4.CreateTranslation(x + parameter.Width / 2, -y, 0);
|
||||||
_instances[i] = new Instance
|
currentLineInstances.Add(_instances[i] = new Instance
|
||||||
{
|
{
|
||||||
ModelMatrix = matrix,
|
ModelMatrix = matrix,
|
||||||
TextureMatrix = parameter.TextureMatrix
|
TextureMatrix = parameter.TextureMatrix
|
||||||
};
|
});
|
||||||
|
|
||||||
x += parameter.Advance;
|
x += parameter.Advance;
|
||||||
}
|
}
|
||||||
|
if (currentLineInstances.Count > 0)
|
||||||
|
lines.Add(new Tuple<Vector2, Instance[]>(new Vector2(x, y), currentLineInstances.ToArray()));
|
||||||
|
|
||||||
Height = y + Font.Height;
|
Height = y + Font.Height;
|
||||||
Width = x;
|
Width = lines.Max(a => a.Item1.X);
|
||||||
|
|
||||||
if (Origin != TextOrigin.Left)
|
if (Origin != TextOrigin.Left)
|
||||||
{
|
{
|
||||||
foreach (Instance i in _instances)
|
foreach (Tuple<Vector2, Instance[]> line in lines)
|
||||||
{
|
{
|
||||||
if (i == null) continue;
|
|
||||||
switch (Origin)
|
foreach (Instance i in line.Item2)
|
||||||
{
|
{
|
||||||
case TextOrigin.Center:
|
if (i == null) continue;
|
||||||
i.ModelMatrix *= Matrix4.CreateTranslation(-Width / 2, 0, 0);
|
switch (Origin)
|
||||||
break;
|
{
|
||||||
case TextOrigin.Right:
|
case TextOrigin.Center:
|
||||||
i.ModelMatrix *= Matrix4.CreateTranslation(-Width, 0, 0);
|
i.ModelMatrix *= Matrix4.CreateTranslation(-line.Item1.X / 2, 0, 0);
|
||||||
break;
|
break;
|
||||||
|
case TextOrigin.Right:
|
||||||
|
i.ModelMatrix *= Matrix4.CreateTranslation(-line.Item1.X, 0, 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
#region usings
|
#region usings
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Drawing;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using OpenTK.Graphics.OpenGL4;
|
using OpenTK.Graphics.OpenGL4;
|
||||||
using SM.Base.Drawing;
|
using SM.Base.Drawing;
|
||||||
|
|
@ -7,28 +9,31 @@ using SM.Base.PostProcess;
|
||||||
using SM.Base.Utility;
|
using SM.Base.Utility;
|
||||||
using SM.Base.Window;
|
using SM.Base.Window;
|
||||||
using SM.OGL.Framebuffer;
|
using SM.OGL.Framebuffer;
|
||||||
|
using SM.OGL.Shaders;
|
||||||
using SM.OGL.Texture;
|
using SM.OGL.Texture;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace SM.Base.PostEffects
|
namespace SM.Base.Legacy.PostProcessing
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A bloom post process effect.
|
/// A bloom post process effect.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class BloomEffect : PostProcessEffect
|
[Obsolete("This bloom effect isn't good. Please use SM.Base.PostEffects.BloomEffect, if you want a good bloom effect.")]
|
||||||
|
public class BloomEffectOld : PostProcessEffect
|
||||||
{
|
{
|
||||||
private static BezierCurve _defaultCurve = new BezierCurve(Vector2.UnitY, Vector2.Zero, new Vector2(0.4f, 0), new Vector2(.5f,0));
|
private static BezierCurve _defaultCurve = new BezierCurve(Vector2.UnitY, Vector2.Zero, new Vector2(0.4f, 0), new Vector2(.5f,0));
|
||||||
private static readonly PostProcessShader _mergeShader = new PostProcessShader(
|
private static readonly PostProcessShader _mergeShader = new PostProcessShader(
|
||||||
AssemblyUtility.ReadAssemblyFile(SMRenderer.PostProcessPath + ".bloom_merge_vert.glsl"),
|
new ShaderFile(AssemblyUtility.ReadAssemblyFile("SM.Base.Legacy.PostProcessing.bloom_merge.vert")),
|
||||||
AssemblyUtility.ReadAssemblyFile(SMRenderer.PostProcessPath + ".bloom_merge.glsl"));
|
AssemblyUtility.ReadAssemblyFile("SM.Base.Legacy.PostProcessing.bloom_merge.glsl"));
|
||||||
|
|
||||||
private static readonly PostProcessShader _shader =
|
private static readonly PostProcessShader _shader =
|
||||||
new PostProcessShader(AssemblyUtility.ReadAssemblyFile(SMRenderer.PostProcessPath + ".bloom_blur.glsl"));
|
new PostProcessShader(AssemblyUtility.ReadAssemblyFile("SM.Base.Legacy.PostProcessing.bloom_blur.glsl"));
|
||||||
private const float _defaultTextureScale = .75f;
|
private const float _defaultTextureScale = .75f;
|
||||||
|
|
||||||
private Framebuffer _source;
|
private Framebuffer _source;
|
||||||
|
|
||||||
|
private Framebuffer _tempColorBuffer;
|
||||||
private Framebuffer _bloomBuffer1;
|
private Framebuffer _bloomBuffer1;
|
||||||
private Framebuffer _bloomBuffer2;
|
private Framebuffer _bloomBuffer2;
|
||||||
|
|
||||||
|
|
@ -83,12 +88,6 @@ namespace SM.Base.PostEffects
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float Radius = 1;
|
public float Radius = 1;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This can disable the bloom calculation.
|
|
||||||
/// <para>Default: true</para>
|
|
||||||
/// </summary>
|
|
||||||
public bool Enable = true;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This defines the weight curve.
|
/// This defines the weight curve.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -101,6 +100,7 @@ namespace SM.Base.PostEffects
|
||||||
UpdateWeights();
|
UpdateWeights();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This defines how many picks the effect should pick from the weight curve.
|
/// This defines how many picks the effect should pick from the weight curve.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -112,7 +112,7 @@ namespace SM.Base.PostEffects
|
||||||
/// <param name="source">This can specify a own source framebuffer. If not set, it will take the Pipeline MainFramebuffer.</param>
|
/// <param name="source">This can specify a own source framebuffer. If not set, it will take the Pipeline MainFramebuffer.</param>
|
||||||
/// <param name="hdr">This allows to enable hdr returns.</param>
|
/// <param name="hdr">This allows to enable hdr returns.</param>
|
||||||
/// <param name="textureScale">This allows for a increase in performance, by lowering the calculating texture scale.</param>
|
/// <param name="textureScale">This allows for a increase in performance, by lowering the calculating texture scale.</param>
|
||||||
public BloomEffect(Framebuffer source = null, bool hdr = false, float? textureScale = null)
|
public BloomEffectOld(Framebuffer source = null, bool hdr = false, float? textureScale = null)
|
||||||
{
|
{
|
||||||
_source = source;
|
_source = source;
|
||||||
_hdr = hdr;
|
_hdr = hdr;
|
||||||
|
|
@ -137,6 +137,10 @@ namespace SM.Base.PostEffects
|
||||||
|
|
||||||
_source.ColorAttachments["color"].PixelInformation = PixelInformation.RGBA_HDR;
|
_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)
|
_bloomBuffer1 = new Framebuffer(Pipeline.ConnectedWindow, _textureScale)
|
||||||
{
|
{
|
||||||
Name = "BloomX"
|
Name = "BloomX"
|
||||||
|
|
@ -150,61 +154,62 @@ namespace SM.Base.PostEffects
|
||||||
_bloomBuffer2.Append("yBuffer", _yBuffer = new ColorAttachment(0, PixelInformation.RGBA_HDR));
|
_bloomBuffer2.Append("yBuffer", _yBuffer = new ColorAttachment(0, PixelInformation.RGBA_HDR));
|
||||||
_bloomBuffer2.Compile();
|
_bloomBuffer2.Compile();
|
||||||
|
|
||||||
|
Pipeline.Framebuffers.Add(_tempColorBuffer);
|
||||||
Pipeline.Framebuffers.Add(_bloomBuffer1);
|
Pipeline.Framebuffers.Add(_bloomBuffer1);
|
||||||
Pipeline.Framebuffers.Add(_bloomBuffer2);
|
Pipeline.Framebuffers.Add(_bloomBuffer2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override void Draw(DrawContext context)
|
protected override void Drawing(ColorAttachment source, DrawContext context)
|
||||||
{
|
{
|
||||||
if (Enable)
|
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++)
|
||||||
{
|
{
|
||||||
GL.Viewport(0, 0, (int) (Pipeline.ConnectedWindow.Width * _textureScale),
|
(hoz ? _bloomBuffer1 : _bloomBuffer2).Activate(false);
|
||||||
(int) (Pipeline.ConnectedWindow.Height * _textureScale));
|
|
||||||
|
|
||||||
Framebuffer target = Framebuffer.GetCurrentlyActive();
|
_shader.Draw(collection =>
|
||||||
bool first = true, hoz = true;
|
|
||||||
int iter = Iterations * 2;
|
|
||||||
for (int i = 0; i < iter; i++)
|
|
||||||
{
|
{
|
||||||
(hoz ? _bloomBuffer1 : _bloomBuffer2).Activate(false);
|
collection["renderedTexture"].SetTexture(first ? source : (hoz ? _yBuffer : _xBuffer));
|
||||||
|
|
||||||
_shader.Draw(collection =>
|
collection["First"].SetBool(first);
|
||||||
{
|
collection["Threshold"].SetFloat(Threshold);
|
||||||
collection["renderedTexture"].SetTexture(first ? _source.ColorAttachments["color"] : (hoz ? _yBuffer : _xBuffer));
|
|
||||||
|
|
||||||
collection["First"].SetUniform1(first);
|
collection["Horizontal"].SetBool(hoz);
|
||||||
collection["Threshold"].SetUniform1(Threshold);
|
|
||||||
|
|
||||||
collection["Horizontal"].SetUniform1(hoz);
|
collection["Weights"].SetFloat(_weights);
|
||||||
|
collection["WeightCount"].SetFloat(WeightCurvePickAmount);
|
||||||
|
collection["Power"].SetFloat(Power);
|
||||||
|
|
||||||
collection["Weights"].SetUniform1(_weights);
|
collection["Radius"].SetFloat(_textureScale * Radius);
|
||||||
collection["WeightCount"].SetUniform1(WeightCurvePickAmount);
|
});
|
||||||
collection["Power"].SetUniform1(Power);
|
|
||||||
|
|
||||||
collection["Radius"].SetUniform1(_textureScale * Radius);
|
hoz = !hoz;
|
||||||
});
|
if (first) first = false;
|
||||||
|
|
||||||
hoz = !hoz;
|
|
||||||
if (first) first = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
GL.Viewport(Pipeline.ConnectedWindow.ClientRectangle);
|
|
||||||
target.Activate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GL.Viewport(Pipeline.ConnectedWindow.ClientRectangle);
|
||||||
|
target.Activate();
|
||||||
|
|
||||||
_mergeShader.Draw(collection =>
|
_mergeShader.Draw(collection =>
|
||||||
{
|
{
|
||||||
collection["Scene"].SetTexture(_source.ColorAttachments["color"]);
|
collection["Scene"].SetTexture(_tempColorBuffer["color"]);
|
||||||
collection["Bloom"].SetTexture(_yBuffer);
|
collection["Bloom"].SetTexture(_yBuffer);
|
||||||
|
|
||||||
collection["MinAmount"].SetUniform1(MinAmount);
|
collection["MinAmount"].SetFloat(MinAmount);
|
||||||
collection["MaxAmount"].SetUniform1(MaxAmount);
|
collection["MaxAmount"].SetFloat(MaxAmount);
|
||||||
collection["AmountMap"].SetTexture(AmountMap, collection["HasAmountMap"]);
|
collection["AmountMap"].SetTexture(AmountMap, collection["HasAmountMap"]);
|
||||||
collection["TextureTransform"].SetMatrix3(AmountTransform.GetMatrix());
|
collection["TextureTransform"].SetMatrix3(AmountTransform.GetMatrix());
|
||||||
|
|
||||||
collection["Exposure"].SetUniform1(context.UseCamera.Exposure);
|
collection["Exposure"].SetFloat(context.UseCamera.Exposure);
|
||||||
collection["HDR"].SetUniform1(_hdr);
|
collection["HDR"].SetBool(_hdr);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
#version 330
|
#version 330
|
||||||
#define PI 3.14159265359
|
|
||||||
|
|
||||||
uniform sampler2D renderedTexture;
|
uniform sampler2D renderedTexture;
|
||||||
uniform float RenderScale;
|
uniform float RenderScale;
|
||||||
|
|
@ -16,6 +15,7 @@ uniform float Power;
|
||||||
uniform float Radius;
|
uniform float Radius;
|
||||||
|
|
||||||
layout(location = 0) out vec4 color;
|
layout(location = 0) out vec4 color;
|
||||||
|
layout(location = 1) out vec4 scene;
|
||||||
|
|
||||||
vec4 GetRenderColorOffset(vec2 offset);
|
vec4 GetRenderColorOffset(vec2 offset);
|
||||||
|
|
||||||
|
|
@ -31,6 +31,8 @@ float GetWeight(int dif) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
if (First) scene = GetRenderColorOffset(vec2(0));
|
||||||
|
|
||||||
vec3 thres = vec3(First ? Threshold : 0);
|
vec3 thres = vec3(First ? Threshold : 0);
|
||||||
|
|
||||||
vec2 tex_offset = 1.0 / textureSize(renderedTexture, 0) * vec2(Horizontal ? 1 : 0, Horizontal ? 0 : 1);
|
vec2 tex_offset = 1.0 / textureSize(renderedTexture, 0) * vec2(Horizontal ? 1 : 0, Horizontal ? 0 : 1);
|
||||||
|
|
@ -18,7 +18,7 @@ layout(location = 0) out vec4 color;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
vec3 result = texture(Bloom, vTexture).rgb;
|
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) {
|
if (!HDR) {
|
||||||
result = vec3(1.0) - exp(-result * Exposure);
|
result = vec3(1.0) - exp(-result * Exposure);
|
||||||
}
|
}
|
||||||
|
|
@ -1,11 +1,18 @@
|
||||||
#version 330
|
#version 330
|
||||||
|
|
||||||
|
layout(location = 0) in vec3 aPos;
|
||||||
layout(location = 1) in vec2 aTex;
|
layout(location = 1) in vec2 aTex;
|
||||||
|
|
||||||
|
uniform mat4 MVP;
|
||||||
uniform mat3 TextureTransform;
|
uniform mat3 TextureTransform;
|
||||||
|
|
||||||
|
out vec2 vTexture;
|
||||||
out vec2 TransformedTexture;
|
out vec2 TransformedTexture;
|
||||||
|
|
||||||
void vertex() {
|
|
||||||
|
void main() {
|
||||||
|
vTexture = aTex;
|
||||||
TransformedTexture = vec2(TextureTransform * vec3(aTex, 1));
|
TransformedTexture = vec2(TextureTransform * vec3(aTex, 1));
|
||||||
|
|
||||||
|
gl_Position = MVP * vec4(aPos, 1);
|
||||||
}
|
}
|
||||||
|
|
@ -5,6 +5,7 @@ using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.IO.Compression;
|
using System.IO.Compression;
|
||||||
|
using System.Reflection;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using OpenTK.Graphics.OpenGL4;
|
using OpenTK.Graphics.OpenGL4;
|
||||||
using SM.OGL;
|
using SM.OGL;
|
||||||
|
|
@ -82,14 +83,14 @@ namespace SM.Base
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Presets for the log targets.
|
/// Presets for the log targets.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static Dictionary<LogTarget, string> Preset = new()
|
public static Dictionary<LogTarget, string> Preset = new Dictionary<LogTarget, string>()
|
||||||
{
|
{
|
||||||
{LogTarget.Console, "[%type%] %msg%"},
|
{LogTarget.Console, "[%type%] %msg%"},
|
||||||
{LogTarget.Debugger, "[%type%] %msg%"},
|
{LogTarget.Debugger, "[%type%] %msg%"},
|
||||||
{LogTarget.File, "<%date%, %time%> [%type%] %msg%"}
|
{LogTarget.File, "<%date%, %time%> [%type%] %msg%"}
|
||||||
};
|
};
|
||||||
|
|
||||||
private static readonly Dictionary<LogType, ConsoleColor> Colors = new()
|
private static readonly Dictionary<LogType, ConsoleColor> Colors = new Dictionary<LogType, ConsoleColor>()
|
||||||
{
|
{
|
||||||
{LogType.Info, ConsoleColor.Green},
|
{LogType.Info, ConsoleColor.Green},
|
||||||
{LogType.Warning, ConsoleColor.Yellow},
|
{LogType.Warning, ConsoleColor.Yellow},
|
||||||
|
|
@ -145,7 +146,10 @@ namespace SM.Base
|
||||||
{
|
{
|
||||||
if (_init) return;
|
if (_init) return;
|
||||||
|
|
||||||
AppDomain.CurrentDomain.UnhandledException += ExceptionHandler;
|
if (!Debugger.IsAttached)
|
||||||
|
{
|
||||||
|
AppDomain.CurrentDomain.UnhandledException += ExceptionHandler;
|
||||||
|
}
|
||||||
AppDomain.CurrentDomain.DomainUnload += (sender, args) =>
|
AppDomain.CurrentDomain.DomainUnload += (sender, args) =>
|
||||||
{
|
{
|
||||||
_logStream.WriteLine("Unload application");
|
_logStream.WriteLine("Unload application");
|
||||||
|
|
@ -172,9 +176,12 @@ namespace SM.Base
|
||||||
Write(e.IsTerminating ? "Terminating Error" : LogType.Error.ToString(),
|
Write(e.IsTerminating ? "Terminating Error" : LogType.Error.ToString(),
|
||||||
e.IsTerminating ? ConsoleColor.DarkRed : ConsoleColor.Red, e.ExceptionObject);
|
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)
|
if (e.IsTerminating)
|
||||||
{
|
{
|
||||||
MessageBox.Show($"Critical error occured.\n\n{e.ExceptionObject}",
|
MessageBox.Show($"Critical error occured at {name}.\n\n{e.ExceptionObject}",
|
||||||
$"Terminating Error: {e.ExceptionObject.GetType().Name}");
|
$"Terminating Error: {e.ExceptionObject.GetType().Name}");
|
||||||
_logStream?.Close();
|
_logStream?.Close();
|
||||||
}
|
}
|
||||||
270
src/renderer/SM.Base/PostEffects/BloomEffect.cs
Normal file
270
src/renderer/SM.Base/PostEffects/BloomEffect.cs
Normal file
|
|
@ -0,0 +1,270 @@
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The recommended bloom effect, that looks way better than the old one.
|
||||||
|
/// <para>Based on Blender's implermentation, which is based on COD: Infinite Warfare.</para>
|
||||||
|
/// </summary>
|
||||||
|
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<bool, PostProcessShader[]> _ppShaders = new Dictionary<bool, PostProcessShader[]>(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<Framebuffer> _downsampler;
|
||||||
|
private List<Framebuffer> _upsample;
|
||||||
|
private PostProcessShader[] shaders;
|
||||||
|
|
||||||
|
private int _iterations;
|
||||||
|
private float _sampleSize;
|
||||||
|
private Vector4 _thresholdCurve;
|
||||||
|
private Color4 _bloomColor;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The threshold, where the effect decided what is bright.
|
||||||
|
/// </summary>
|
||||||
|
public float Threshold = .8f;
|
||||||
|
/// <summary>
|
||||||
|
/// The radius of the effect.
|
||||||
|
/// </summary>
|
||||||
|
public float Radius = 6.5f;
|
||||||
|
/// <summary>
|
||||||
|
/// Makes transition between under/over-threshold gradual.
|
||||||
|
/// </summary>
|
||||||
|
public float Knee = .5f;
|
||||||
|
/// <summary>
|
||||||
|
/// The intensity of the effect.
|
||||||
|
/// </summary>
|
||||||
|
public float Intensity = .5f;
|
||||||
|
/// <summary>
|
||||||
|
/// The tint of the effect.
|
||||||
|
/// </summary>
|
||||||
|
public Color4 Color = Color4.White;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// An amount map specifices where the bloom effect should be visible.
|
||||||
|
/// <para>Reads only in the "R"-channel.</para>
|
||||||
|
/// </summary>
|
||||||
|
public TextureBase AmountMap;
|
||||||
|
/// <summary>
|
||||||
|
/// Allows you to transform the texture coordnates for <see cref="AmountMap"/>
|
||||||
|
/// </summary>
|
||||||
|
public TextureTransformation AmountMapTransform = new TextureTransformation();
|
||||||
|
/// <summary>
|
||||||
|
/// Specifices limits, how the <see cref="AmountMap"/> is read.
|
||||||
|
/// <para>Default: <see cref="MinMax.Default"/></para>
|
||||||
|
/// </summary>
|
||||||
|
public MinMax AmountLimits = MinMax.Default;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This creates a more prettier bloom effect.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="hdr">This allows to enable hdr returns.</param>
|
||||||
|
/// <param name="highSetting">If set true, it will use the high quality settings.</param>
|
||||||
|
public BloomEffect(bool hdr = false, bool highSetting = true)
|
||||||
|
{
|
||||||
|
_hdr = hdr;
|
||||||
|
//shaders = GetShaders(highSetting);
|
||||||
|
shaders = new[] { _filterShader, _downsampleShader, _upsampleShader, _combineShader };
|
||||||
|
}
|
||||||
|
/// <inheritdoc/>
|
||||||
|
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<Framebuffer>();
|
||||||
|
_upsample = new List<Framebuffer>();
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public override void ScreenSizeChanged(IGenericWindow window)
|
||||||
|
{
|
||||||
|
CreateFramebuffers();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -4,18 +4,34 @@ using OpenTK.Graphics.OpenGL4;
|
||||||
using SM.Base.PostProcess;
|
using SM.Base.PostProcess;
|
||||||
using SM.Base.Utility;
|
using SM.Base.Utility;
|
||||||
using SM.OGL.Framebuffer;
|
using SM.OGL.Framebuffer;
|
||||||
|
using SM.OGL.Shaders;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace SM.Base.PostEffects
|
namespace SM.Base.PostEffects
|
||||||
{
|
{
|
||||||
|
public enum HDRColorCurve
|
||||||
|
{
|
||||||
|
OnlyExposure,
|
||||||
|
Reinhard,
|
||||||
|
ACES
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This class has some utility for render pipelines
|
/// This class has some utility for render pipelines
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class PostProcessUtility
|
public static class PostProcessUtility
|
||||||
{
|
{
|
||||||
private static readonly PostProcessShader _hdrExposureShader =
|
public static readonly ShaderFile HDRCurves = new ShaderFile(AssemblyUtility.ReadAssemblyFile(SMRenderer.PostProcessPath + ".hdr_curves.frag"));
|
||||||
new PostProcessShader(AssemblyUtility.ReadAssemblyFile(SMRenderer.PostProcessPath + ".finalize_hdr.glsl"));
|
private static readonly string _finalizeHdrCode = AssemblyUtility.ReadAssemblyFile(SMRenderer.PostProcessPath + ".finalize_hdr.glsl");
|
||||||
|
|
||||||
|
private static readonly Dictionary<HDRColorCurve, PostProcessShader> _hdrExposureShader = new Dictionary<HDRColorCurve, PostProcessShader>()
|
||||||
|
{
|
||||||
|
{ 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 _gammaShader =
|
private static readonly PostProcessShader _gammaShader =
|
||||||
new PostProcessShader(
|
new PostProcessShader(
|
||||||
|
|
@ -38,7 +54,7 @@ namespace SM.Base.PostEffects
|
||||||
target.Activate(FramebufferTarget.DrawFramebuffer);
|
target.Activate(FramebufferTarget.DrawFramebuffer);
|
||||||
GL.BlitFramebuffer(0, 0, (int) multisampledBuffers.Size.X, (int) multisampledBuffers.Size.Y, 0, 0,
|
GL.BlitFramebuffer(0, 0, (int) multisampledBuffers.Size.X, (int) multisampledBuffers.Size.Y, 0, 0,
|
||||||
(int) target.Size.X, (int) target.Size.Y, ClearBufferMask.ColorBufferBit,
|
(int) target.Size.X, (int) target.Size.Y, ClearBufferMask.ColorBufferBit,
|
||||||
BlitFramebufferFilter.Nearest);
|
BlitFramebufferFilter.Linear);
|
||||||
|
|
||||||
target.Activate();
|
target.Activate();
|
||||||
}
|
}
|
||||||
|
|
@ -48,12 +64,12 @@ namespace SM.Base.PostEffects
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="attachment"></param>
|
/// <param name="attachment"></param>
|
||||||
/// <param name="exposure"></param>
|
/// <param name="exposure"></param>
|
||||||
public static void FinalizeHDR(ColorAttachment attachment, float exposure)
|
public static void FinalizeHDR(ColorAttachment attachment, HDRColorCurve colorCurve = HDRColorCurve.ACES, float exposure = 1)
|
||||||
{
|
{
|
||||||
_hdrExposureShader.Draw(u =>
|
_hdrExposureShader[colorCurve].Draw(u =>
|
||||||
{
|
{
|
||||||
u["Gamma"].SetUniform1(Gamma);
|
u["Gamma"].SetFloat(Gamma);
|
||||||
u["Exposure"].SetUniform1(exposure);
|
u["Exposure"].SetFloat(exposure);
|
||||||
u["Scene"].SetTexture(attachment);
|
u["Scene"].SetTexture(attachment);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -66,7 +82,7 @@ namespace SM.Base.PostEffects
|
||||||
{
|
{
|
||||||
_gammaShader.Draw(u =>
|
_gammaShader.Draw(u =>
|
||||||
{
|
{
|
||||||
u["Gamma"].SetUniform1(Gamma);
|
u["Gamma"].SetFloat(Gamma);
|
||||||
u["Scene"].SetTexture(attachment);
|
u["Scene"].SetTexture(attachment);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
188
src/renderer/SM.Base/PostEffects/Shaders/bloom.frag
Normal file
188
src/renderer/SM.Base/PostEffects/Shaders/bloom.frag
Normal file
|
|
@ -0,0 +1,188 @@
|
||||||
|
#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);
|
||||||
|
}
|
||||||
41
src/renderer/SM.Base/PostEffects/Shaders/bloom/combine.frag
Normal file
41
src/renderer/SM.Base/PostEffects/Shaders/bloom/combine.frag
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
#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);
|
||||||
|
}
|
||||||
17
src/renderer/SM.Base/PostEffects/Shaders/bloom/combine.vert
Normal file
17
src/renderer/SM.Base/PostEffects/Shaders/bloom/combine.vert
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
#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);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
#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);
|
||||||
|
}
|
||||||
48
src/renderer/SM.Base/PostEffects/Shaders/bloom/filter.frag
Normal file
48
src/renderer/SM.Base/PostEffects/Shaders/bloom/filter.frag
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
#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);
|
||||||
|
}
|
||||||
30
src/renderer/SM.Base/PostEffects/Shaders/bloom/sampling.frag
Normal file
30
src/renderer/SM.Base/PostEffects/Shaders/bloom/sampling.frag
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
#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
|
||||||
|
}
|
||||||
13
src/renderer/SM.Base/PostEffects/Shaders/bloom/upsample.frag
Normal file
13
src/renderer/SM.Base/PostEffects/Shaders/bloom/upsample.frag
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
#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);
|
||||||
|
}
|
||||||
28
src/renderer/SM.Base/PostEffects/Shaders/finalize_hdr.glsl
Normal file
28
src/renderer/SM.Base/PostEffects/Shaders/finalize_hdr.glsl
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
#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);
|
||||||
|
}
|
||||||
21
src/renderer/SM.Base/PostEffects/Shaders/hdr_curves.frag
Normal file
21
src/renderer/SM.Base/PostEffects/Shaders/hdr_curves.frag
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
#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);
|
||||||
|
}
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using SM.Base.Scene;
|
using SM.Base.Scene;
|
||||||
using SM.Base.Window;
|
using SM.Base.Window;
|
||||||
|
using SM.OGL.Framebuffer;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
@ -23,6 +24,12 @@ namespace SM.Base.PostProcess
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected RenderPipeline Pipeline;
|
protected RenderPipeline Pipeline;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Enables the effect.
|
||||||
|
/// <para>Default: true</para>
|
||||||
|
/// </summary>
|
||||||
|
public bool Enable = true;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initialize the effect.
|
/// Initialize the effect.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -40,11 +47,20 @@ namespace SM.Base.PostProcess
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This executes
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="source"></param>
|
||||||
|
/// <param name="context"></param>
|
||||||
|
public void Draw(ColorAttachment source, DrawContext context)
|
||||||
|
{
|
||||||
|
if (Enable) Drawing(source, context);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Method to draw the actual effect.
|
/// Method to draw the actual effect.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract void Draw(DrawContext context);
|
protected abstract void Drawing(ColorAttachment source, DrawContext context);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Event, when the scene changed.
|
/// Event, when the scene changed.
|
||||||
|
|
@ -52,5 +68,14 @@ namespace SM.Base.PostProcess
|
||||||
public virtual void SceneChanged(GenericScene scene)
|
public virtual void SceneChanged(GenericScene scene)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Event, when the screen size changed.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="window">Window that changed</param>
|
||||||
|
public virtual void ScreenSizeChanged(IGenericWindow window)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
130
src/renderer/SM.Base/PostProcess/PostProcessShader.cs
Normal file
130
src/renderer/SM.Base/PostProcess/PostProcessShader.cs
Normal file
|
|
@ -0,0 +1,130 @@
|
||||||
|
#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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Specific shader for post processing.
|
||||||
|
/// </summary>
|
||||||
|
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");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Generates an action for the texture handling.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="renderedTexture"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static Action<UniformCollection> DefaultTextureAction(ColorAttachment renderedTexture)
|
||||||
|
{
|
||||||
|
return (col) =>
|
||||||
|
{
|
||||||
|
col["renderedTexture"].SetTexture(renderedTexture);
|
||||||
|
col["renderedTextureTexelSize"].SetVector2(renderedTexture.TexelSize);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates the shader with the default vertex shader and custom fragment.
|
||||||
|
/// </summary>
|
||||||
|
public PostProcessShader(string fragment) : this(_normalVertex, new ShaderFile(fragment))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Creates the shader with the default vertex shader and custom fragment shader.
|
||||||
|
/// </summary>
|
||||||
|
public PostProcessShader(ShaderFile fragment) : this(_normalVertex, fragment)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates the shader with an vertex extension and custom fragment.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="vertexExt"></param>
|
||||||
|
/// <param name="fragment"></param>
|
||||||
|
public PostProcessShader(string vertexExt, string fragment) : this(new ShaderFile(_normalVertexWithExt)
|
||||||
|
{
|
||||||
|
GLSLExtensions = new List<ShaderFile> {new ShaderFile(vertexExt)}
|
||||||
|
}, new ShaderFile(fragment))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Creates the shader with an vertex shader and custom fragment.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="vertex"></param>
|
||||||
|
/// <param name="fragment"></param>
|
||||||
|
public PostProcessShader(ShaderFile vertex, string fragment) : this(vertex, new ShaderFile(fragment))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates the shader with an vertex shader and custom fragment.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="vertex"></param>
|
||||||
|
/// <param name="fragment"></param>
|
||||||
|
public PostProcessShader(ShaderFile vertex, ShaderFile fragment) : base(
|
||||||
|
new ShaderFileCollection(vertex, fragment))
|
||||||
|
{
|
||||||
|
fragment.GLSLExtensions.Add(_fragExtensions);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Draws the shader with the color attachment as texture.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="renderedTexture"></param>
|
||||||
|
public void Draw(ColorAttachment renderedTexture)
|
||||||
|
{
|
||||||
|
Draw(DefaultTextureAction(renderedTexture));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Draws the shader with the color attachment as texture and provides access to the uniforms.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="renderedTexture"></param>
|
||||||
|
/// <param name="setUniformAction"></param>
|
||||||
|
public void Draw(ColorAttachment renderedTexture, Action<UniformCollection> setUniformAction)
|
||||||
|
{
|
||||||
|
var texAction = DefaultTextureAction(renderedTexture);
|
||||||
|
Draw((a) => {
|
||||||
|
texAction(a);
|
||||||
|
setUniformAction(a);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Draws the shader with special uniforms.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="setUniformAction"></param>
|
||||||
|
public void Draw(Action<UniformCollection> setUniformAction)
|
||||||
|
{
|
||||||
|
if (ErrorInShader) return;
|
||||||
|
|
||||||
|
Activate();
|
||||||
|
Plate.Object.Activate();
|
||||||
|
|
||||||
|
Uniforms["MVP"].SetMatrix4(PostProcessEffect.Mvp);
|
||||||
|
|
||||||
|
setUniformAction(Uniforms);
|
||||||
|
|
||||||
|
GL.DrawArrays(PrimitiveType.Quads, 0, 4);
|
||||||
|
|
||||||
|
CleanUp();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="..\..\..\packages\SharpFont.4.0.1\build\SharpFont.props" Condition="Exists('..\..\..\packages\SharpFont.4.0.1\build\SharpFont.props')" />
|
||||||
|
<Import Project="..\..\..\packages\SharpFont.Dependencies.2.6\build\SharpFont.Dependencies.props" Condition="Exists('..\..\..\packages\SharpFont.Dependencies.2.6\build\SharpFont.Dependencies.props')" />
|
||||||
<Import Project="..\..\..\IAmTwo - Kopie\packages\SharpFont.4.0.1\build\SharpFont.props" Condition="Exists('..\..\..\IAmTwo - Kopie\packages\SharpFont.4.0.1\build\SharpFont.props')" />
|
<Import Project="..\..\..\IAmTwo - Kopie\packages\SharpFont.4.0.1\build\SharpFont.props" Condition="Exists('..\..\..\IAmTwo - Kopie\packages\SharpFont.4.0.1\build\SharpFont.props')" />
|
||||||
<Import Project="..\..\..\IAmTwo - Kopie\packages\SharpFont.Dependencies.2.6\build\SharpFont.Dependencies.props" Condition="Exists('..\..\..\IAmTwo - Kopie\packages\SharpFont.Dependencies.2.6\build\SharpFont.Dependencies.props')" />
|
<Import Project="..\..\..\IAmTwo - Kopie\packages\SharpFont.Dependencies.2.6\build\SharpFont.Dependencies.props" Condition="Exists('..\..\..\IAmTwo - Kopie\packages\SharpFont.Dependencies.2.6\build\SharpFont.Dependencies.props')" />
|
||||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
|
@ -16,6 +18,7 @@
|
||||||
<Deterministic>true</Deterministic>
|
<Deterministic>true</Deterministic>
|
||||||
<NuGetPackageImportStamp>
|
<NuGetPackageImportStamp>
|
||||||
</NuGetPackageImportStamp>
|
</NuGetPackageImportStamp>
|
||||||
|
<TargetFrameworkProfile />
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
|
@ -37,23 +40,6 @@
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
<LangVersion>latest</LangVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
|
||||||
<Reference Include="OpenTK, Version=3.3.1.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
|
|
||||||
<HintPath>..\..\packages\OpenTK.3.3.1\lib\net20\OpenTK.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="PresentationCore" />
|
|
||||||
<Reference Include="SharpFont, Version=4.0.1.200, Culture=neutral, PublicKeyToken=48add4c483071cdf, processorArchitecture=MSIL">
|
|
||||||
<HintPath>..\..\..\IAmTwo - Kopie\packages\SharpFont.4.0.1\lib\net45\SharpFont.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="System" />
|
|
||||||
<Reference Include="System.Core" />
|
|
||||||
<Reference Include="System.Drawing" />
|
|
||||||
<Reference Include="System.IO.Compression" />
|
|
||||||
<Reference Include="System.IO.Compression.FileSystem" />
|
|
||||||
<Reference Include="System.Windows.Forms" />
|
|
||||||
<Reference Include="System.Xaml" />
|
|
||||||
<Reference Include="WindowsBase" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Animation\AnimationCurves.cs" />
|
<Compile Include="Animation\AnimationCurves.cs" />
|
||||||
<Compile Include="Animation\InterpolationProcess.cs" />
|
<Compile Include="Animation\InterpolationProcess.cs" />
|
||||||
|
|
@ -62,21 +48,23 @@
|
||||||
<Compile Include="Drawing\DrawingBasis.cs" />
|
<Compile Include="Drawing\DrawingBasis.cs" />
|
||||||
<Compile Include="Drawing\GenericTransformation.cs" />
|
<Compile Include="Drawing\GenericTransformation.cs" />
|
||||||
<Compile Include="Drawing\Instance.cs" />
|
<Compile Include="Drawing\Instance.cs" />
|
||||||
|
<Compile Include="Drawing\Particles\ParticleInstance.cs" />
|
||||||
<Compile Include="Drawing\ShaderArguments.cs" />
|
<Compile Include="Drawing\ShaderArguments.cs" />
|
||||||
<Compile Include="Drawing\TextureTransformation.cs" />
|
<Compile Include="Drawing\TextureTransformation.cs" />
|
||||||
<Compile Include="Drawing\Text\Font.cs" />
|
<Compile Include="Drawing\Text\Font.cs" />
|
||||||
|
<Compile Include="PostEffects\BloomEffect.cs" />
|
||||||
<Compile Include="PostEffects\PostProcessUtility.cs" />
|
<Compile Include="PostEffects\PostProcessUtility.cs" />
|
||||||
<Compile Include="Scene\ICollectionItem.cs" />
|
<Compile Include="Scene\ICollectionItem.cs" />
|
||||||
<Compile Include="Scene\IFixedScriptable.cs" />
|
<Compile Include="Scene\IFixedScriptable.cs" />
|
||||||
<Compile Include="Shaders\MaterialShader.cs" />
|
<Compile Include="Shaders\MaterialShader.cs" />
|
||||||
<Compile Include="Drawing\Particles\ParticleContext.cs" />
|
|
||||||
<Compile Include="Drawing\Particles\ParticleMovement.cs" />
|
<Compile Include="Drawing\Particles\ParticleMovement.cs" />
|
||||||
<Compile Include="Drawing\Particles\ParticleStruct.cs" />
|
|
||||||
<Compile Include="Drawing\Particles\ParticleDrawingBasis.cs" />
|
<Compile Include="Drawing\Particles\ParticleDrawingBasis.cs" />
|
||||||
<Compile Include="Shaders\SimpleShader.cs" />
|
<Compile Include="Shaders\SimpleShader.cs" />
|
||||||
<Compile Include="Types\CVector4.cs" />
|
<Compile Include="Types\CVector4.cs" />
|
||||||
<Compile Include="Types\CVectorBase.cs" />
|
<Compile Include="Types\CVectorBase.cs" />
|
||||||
|
<Compile Include="Types\MinMax.cs" />
|
||||||
<Compile Include="Utility\IInitializable.cs" />
|
<Compile Include="Utility\IInitializable.cs" />
|
||||||
|
<Compile Include="Utility\MathUtils.cs" />
|
||||||
<Compile Include="Utility\Ray.cs" />
|
<Compile Include="Utility\Ray.cs" />
|
||||||
<Compile Include="Utility\Util.cs" />
|
<Compile Include="Utility\Util.cs" />
|
||||||
<Compile Include="Window\Contexts\DrawContext.cs" />
|
<Compile Include="Window\Contexts\DrawContext.cs" />
|
||||||
|
|
@ -87,7 +75,7 @@
|
||||||
<Compile Include="Objects\InstancedMesh.cs" />
|
<Compile Include="Objects\InstancedMesh.cs" />
|
||||||
<Compile Include="Objects\Mesh.cs" />
|
<Compile Include="Objects\Mesh.cs" />
|
||||||
<Compile Include="Objects\Static\AxisHelper.cs" />
|
<Compile Include="Objects\Static\AxisHelper.cs" />
|
||||||
<Compile Include="PostEffects\BloomEffect.cs" />
|
<Compile Include="Legacy\PostProcessing\BloomEffectOld.cs" />
|
||||||
<Compile Include="PostProcess\PostProcessEffect.cs" />
|
<Compile Include="PostProcess\PostProcessEffect.cs" />
|
||||||
<Compile Include="PostProcess\PostProcessShader.cs" />
|
<Compile Include="PostProcess\PostProcessShader.cs" />
|
||||||
<Compile Include="Scene\IScriptable.cs" />
|
<Compile Include="Scene\IScriptable.cs" />
|
||||||
|
|
@ -127,25 +115,16 @@
|
||||||
<EmbeddedResource Include="PostProcess\DefaultFiles\vertexFile.vert" />
|
<EmbeddedResource Include="PostProcess\DefaultFiles\vertexFile.vert" />
|
||||||
<EmbeddedResource Include="PostProcess\DefaultFiles\extensions.frag" />
|
<EmbeddedResource Include="PostProcess\DefaultFiles\extensions.frag" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\SM.OGL\SM.OGL.csproj">
|
|
||||||
<Project>{f604d684-bc1d-4819-88b5-8b5d03a17be0}</Project>
|
|
||||||
<Name>SM.OGL</Name>
|
|
||||||
</ProjectReference>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Include="PostProcess\DefaultFiles\vertexWithExt.vert" />
|
<EmbeddedResource Include="PostProcess\DefaultFiles\vertexWithExt.vert" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Include="PostEffects\Shaders\bloom_blur.glsl" />
|
<EmbeddedResource Include="Legacy\PostProcessing\bloom_blur.glsl" />
|
||||||
<EmbeddedResource Include="PostEffects\Shaders\bloom_merge.glsl" />
|
<EmbeddedResource Include="Legacy\PostProcessing\bloom_merge.glsl" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="OpenTK.dll.config" />
|
|
||||||
<None Include="packages.config" />
|
|
||||||
<EmbeddedResource Include="Shaders\SimpleShaderPresets\basic_vertex.glsl" />
|
<EmbeddedResource Include="Shaders\SimpleShaderPresets\basic_vertex.glsl" />
|
||||||
<EmbeddedResource Include="Shaders\SimpleShaderPresets\instanced_vertex.glsl" />
|
<EmbeddedResource Include="Shaders\SimpleShaderPresets\instanced_vertex.glsl" />
|
||||||
<EmbeddedResource Include="PostEffects\Shaders\bloom_merge_vert.glsl" />
|
|
||||||
<EmbeddedResource Include="PostEffects\Shaders\finalize_hdr.glsl" />
|
<EmbeddedResource Include="PostEffects\Shaders\finalize_hdr.glsl" />
|
||||||
<EmbeddedResource Include="PostEffects\Shaders\finalize_gamma.glsl" />
|
<EmbeddedResource Include="PostEffects\Shaders\finalize_gamma.glsl" />
|
||||||
<EmbeddedResource Include="Shaders\Extensions\fragment\textureGamma.glsl" />
|
<EmbeddedResource Include="Shaders\Extensions\fragment\textureGamma.glsl" />
|
||||||
|
|
@ -154,12 +133,50 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Include="Window\winIcon.ico" />
|
<EmbeddedResource Include="Window\winIcon.ico" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\SM.OGL\SM.OGL.csproj">
|
||||||
|
<Project>{f604d684-bc1d-4819-88b5-8b5d03a17be0}</Project>
|
||||||
|
<Name>SM.OGL</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="OpenTK, Version=3.3.1.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\..\packages\OpenTK.3.3.1\lib\net20\OpenTK.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="SharpFont, Version=4.0.1.200, Culture=neutral, PublicKeyToken=48add4c483071cdf, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\..\packages\SharpFont.4.0.1\lib\net45\SharpFont.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.ComponentModel.Composition" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="System.Drawing" />
|
||||||
|
<Reference Include="System.IO.Compression" />
|
||||||
|
<Reference Include="System.IO.Compression.FileSystem" />
|
||||||
|
<Reference Include="System.Net.Http" />
|
||||||
|
<Reference Include="System.Windows" />
|
||||||
|
<Reference Include="System.Windows.Forms" />
|
||||||
|
<Reference Include="System.XML" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<EmbeddedResource Include="Legacy\PostProcessing\bloom_merge.vert" />
|
||||||
|
<None Include="OpenTK.dll.config" />
|
||||||
|
<None Include="packages.config" />
|
||||||
|
<EmbeddedResource Include="PostEffects\Shaders\bloom\filter.frag" />
|
||||||
|
<EmbeddedResource Include="PostEffects\Shaders\bloom\downsample.frag" />
|
||||||
|
<EmbeddedResource Include="PostEffects\Shaders\bloom\upsample.frag" />
|
||||||
|
<EmbeddedResource Include="PostEffects\Shaders\bloom\combine.frag" />
|
||||||
|
<EmbeddedResource Include="PostEffects\Shaders\bloom\sampling.frag" />
|
||||||
|
<EmbeddedResource Include="PostEffects\Shaders\bloom\combine.vert" />
|
||||||
|
<EmbeddedResource Include="PostEffects\Shaders\bloom.frag" />
|
||||||
|
<EmbeddedResource Include="PostEffects\Shaders\hdr_curves.frag" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ErrorText>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}.</ErrorText>
|
<ErrorText>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}.</ErrorText>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Error Condition="!Exists('..\..\..\IAmTwo - Kopie\packages\SharpFont.Dependencies.2.6\build\SharpFont.Dependencies.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\IAmTwo - Kopie\packages\SharpFont.Dependencies.2.6\build\SharpFont.Dependencies.props'))" />
|
|
||||||
<Error Condition="!Exists('..\..\..\IAmTwo - Kopie\packages\SharpFont.4.0.1\build\SharpFont.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\IAmTwo - Kopie\packages\SharpFont.4.0.1\build\SharpFont.props'))" />
|
|
||||||
</Target>
|
</Target>
|
||||||
</Project>
|
</Project>
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue