05.01.2021
+ Bloom effect + PixelInformation + Many Summaries + Add-methods for CVectors + Exposure-Field in GenericCamera for HDR. ~ ColorAttachments now can have PixelInformation ~ Transformed MeshAttributes to a own class ~ Fixed the non-applying of transformations at texts ~ Added more information to the context ~ Improved Pipeline-Process. ~ Changed how Uniform takes arrays - Light system
This commit is contained in:
parent
9b917ac181
commit
4c18127c88
52 changed files with 697 additions and 373 deletions
|
|
@ -14,6 +14,7 @@ namespace SM.OGL.Shaders
|
|||
/// </summary>
|
||||
public abstract class GenericShader : GLObject
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override bool AutoCompile { get; } = true;
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -26,6 +27,10 @@ namespace SM.OGL.Shaders
|
|||
/// </summary>
|
||||
protected UniformCollection Uniforms;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="combinedData"></param>
|
||||
protected GenericShader(string combinedData)
|
||||
{
|
||||
int firstPos = combinedData.IndexOf("//# region ", StringComparison.Ordinal);
|
||||
|
|
@ -106,7 +111,6 @@ namespace SM.OGL.Shaders
|
|||
/// </summary>
|
||||
/// <param name="mesh">The mesh.</param>
|
||||
/// <param name="amount">The amounts for instancing.</param>
|
||||
/// <param name="bindVAO">Binds the vertex array for the mesh.</param>
|
||||
protected void DrawObject(GenericMesh mesh, int amount = 1)
|
||||
{
|
||||
if (mesh.Indices != null)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,13 @@
|
|||
namespace SM.OGL.Shaders
|
||||
{
|
||||
/// <summary>
|
||||
/// Uniform interface
|
||||
/// </summary>
|
||||
public interface IUniform
|
||||
{
|
||||
/// <summary>
|
||||
/// Location of the uniforms
|
||||
/// </summary>
|
||||
int Location { get; }
|
||||
}
|
||||
}
|
||||
|
|
@ -8,16 +8,33 @@ using System.Reflection;
|
|||
|
||||
namespace SM.OGL.Shaders
|
||||
{
|
||||
/// <summary>
|
||||
/// Holder for shader extensions
|
||||
/// </summary>
|
||||
public class ShaderExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Holds the extensions.
|
||||
/// </summary>
|
||||
public static Dictionary<string, ShaderFile> Extensions { get; private set; } =
|
||||
new Dictionary<string, ShaderFile>();
|
||||
|
||||
/// <summary>
|
||||
/// Adds extensions from the calling assembly
|
||||
/// </summary>
|
||||
/// <param name="prefix">Prefix for the added extensions.</param>
|
||||
/// <param name="path">Path, where the extensions are located.</param>
|
||||
public static void AddAssemblyExtensions(string prefix, string path)
|
||||
{
|
||||
AddAssemblyExtensions(prefix, Assembly.GetCallingAssembly(), path);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds extensions from the specific assembly
|
||||
/// </summary>
|
||||
/// <param name="prefix">Prefix for the added extensions.</param>
|
||||
/// <param name="assembly">The specific assembly</param>
|
||||
/// <param name="path">Path, where the extensions are located.</param>
|
||||
public static void AddAssemblyExtensions(string prefix, Assembly assembly, string path)
|
||||
{
|
||||
var paths = assembly.GetManifestResourceNames();
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ namespace SM.OGL.Shaders
|
|||
/// </summary>
|
||||
/// <param name="vertex">The vertex source file.</param>
|
||||
/// <param name="fragment">The fragment source file.</param>
|
||||
/// <param name="geometry">The geometry source file.</param>
|
||||
public ShaderFileCollection(string vertex, string fragment, string geometry = "") : this(new ShaderFile(vertex),
|
||||
new ShaderFile(fragment), geometry != "" ? new ShaderFile(geometry) : null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -7,8 +7,14 @@ using System.Collections.Generic;
|
|||
|
||||
namespace SM.OGL.Shaders
|
||||
{
|
||||
/// <summary>
|
||||
/// Holds Actions for the preprocessor.
|
||||
/// </summary>
|
||||
public class ShaderPreProcess
|
||||
{
|
||||
/// <summary>
|
||||
/// Holds actions for the preprocessor.
|
||||
/// </summary>
|
||||
public static Dictionary<string, Action<ShaderFile, string>> Actions =
|
||||
new Dictionary<string, Action<ShaderFile, string>>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -24,14 +24,29 @@ namespace SM.OGL.Shaders
|
|||
/// </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)
|
||||
{
|
||||
|
||||
|
|
@ -60,9 +75,9 @@ namespace SM.OGL.Shaders
|
|||
GL.Uniform1(Location, value);
|
||||
}
|
||||
|
||||
public void SetUniform1(int count, params int[] values)
|
||||
public void SetUniform1(params int[] values)
|
||||
{
|
||||
GL.Uniform1(Location, count, values);
|
||||
GL.Uniform1(Location, values.Length, values);
|
||||
}
|
||||
|
||||
public void SetUniform1(int count, ref int values)
|
||||
|
|
@ -76,9 +91,9 @@ namespace SM.OGL.Shaders
|
|||
GL.Uniform1(Location, value);
|
||||
}
|
||||
|
||||
public void SetUniform1(int count, params uint[] values)
|
||||
public void SetUniform1(params uint[] values)
|
||||
{
|
||||
GL.Uniform1(Location, count, values);
|
||||
GL.Uniform1(Location, values.Length, values);
|
||||
}
|
||||
|
||||
public void SetUniform1(int count, ref uint values)
|
||||
|
|
@ -92,9 +107,9 @@ namespace SM.OGL.Shaders
|
|||
GL.Uniform1(Location, value);
|
||||
}
|
||||
|
||||
public void SetUniform1(int count, params float[] values)
|
||||
public void SetUniform1(params float[] values)
|
||||
{
|
||||
GL.Uniform1(Location, count, values);
|
||||
GL.Uniform1(Location, values.Length, values);
|
||||
}
|
||||
|
||||
public void SetUniform1(int count, ref float value)
|
||||
|
|
@ -108,9 +123,9 @@ namespace SM.OGL.Shaders
|
|||
GL.Uniform1(Location, value);
|
||||
}
|
||||
|
||||
public void SetUniform1(int count, params double[] values)
|
||||
public void SetUniform1(params double[] values)
|
||||
{
|
||||
GL.Uniform1(Location, count, values);
|
||||
GL.Uniform1(Location, values.Length, values);
|
||||
}
|
||||
|
||||
public void SetUniform1(int count, ref double value)
|
||||
|
|
@ -142,24 +157,24 @@ namespace SM.OGL.Shaders
|
|||
GL.Uniform2(Location, x, y);
|
||||
}
|
||||
|
||||
public void SetUniform2(int count, params float[] values)
|
||||
public void SetUniform2(params float[] values)
|
||||
{
|
||||
GL.Uniform2(Location, count, values);
|
||||
GL.Uniform2(Location, values.Length / 2, values);
|
||||
}
|
||||
|
||||
public void SetUniform2(int count, params double[] values)
|
||||
public void SetUniform2(params double[] values)
|
||||
{
|
||||
GL.Uniform2(Location, count, values);
|
||||
GL.Uniform2(Location, values.Length / 2, values);
|
||||
}
|
||||
|
||||
public void SetUniform2(int count, params int[] values)
|
||||
public void SetUniform2(params int[] values)
|
||||
{
|
||||
GL.Uniform2(Location, count, values);
|
||||
GL.Uniform2(Location, values.Length / 2, values);
|
||||
}
|
||||
|
||||
public void SetUniform2(int count, params uint[] values)
|
||||
public void SetUniform2(params uint[] values)
|
||||
{
|
||||
GL.Uniform2(Location, count, values);
|
||||
GL.Uniform2(Location, values.Length / 2, values);
|
||||
}
|
||||
|
||||
public void SetUniform2(int count, ref float values)
|
||||
|
|
@ -211,24 +226,24 @@ namespace SM.OGL.Shaders
|
|||
GL.Uniform3(Location, x, y, z);
|
||||
}
|
||||
|
||||
public void SetUniform3(int count, params float[] values)
|
||||
public void SetUniform3(params float[] values)
|
||||
{
|
||||
GL.Uniform3(Location, count, values);
|
||||
GL.Uniform3(Location, values.Length / 3, values);
|
||||
}
|
||||
|
||||
public void SetUniform3(int count, params double[] values)
|
||||
public void SetUniform3(params double[] values)
|
||||
{
|
||||
GL.Uniform3(Location, count, values);
|
||||
GL.Uniform3(Location, values.Length / 3, values);
|
||||
}
|
||||
|
||||
public void SetUniform3(int count, params int[] values)
|
||||
public void SetUniform3(params int[] values)
|
||||
{
|
||||
GL.Uniform3(Location, count, values);
|
||||
GL.Uniform3(Location, values.Length / 3, values);
|
||||
}
|
||||
|
||||
public void SetUniform3(int count, params uint[] values)
|
||||
public void SetUniform3(params uint[] values)
|
||||
{
|
||||
GL.Uniform3(Location, count, values);
|
||||
GL.Uniform3(Location, values.Length / 3, values);
|
||||
}
|
||||
|
||||
public void SetUniform3(int count, ref float values)
|
||||
|
|
@ -280,24 +295,24 @@ namespace SM.OGL.Shaders
|
|||
GL.Uniform4(Location, x, y, z, w);
|
||||
}
|
||||
|
||||
public void SetUniform4(int count, params float[] values)
|
||||
public void SetUniform4(params float[] values)
|
||||
{
|
||||
GL.Uniform4(Location, count, values);
|
||||
GL.Uniform4(Location, values.Length / 4, values);
|
||||
}
|
||||
|
||||
public void SetUniform4(int count, params double[] values)
|
||||
public void SetUniform4(params double[] values)
|
||||
{
|
||||
GL.Uniform4(Location, count, values);
|
||||
GL.Uniform4(Location, values.Length / 4, values);
|
||||
}
|
||||
|
||||
public void SetUniform4(int count, params int[] values)
|
||||
public void SetUniform4(params int[] values)
|
||||
{
|
||||
GL.Uniform4(Location, count, values);
|
||||
GL.Uniform4(Location, values.Length / 4, values);
|
||||
}
|
||||
|
||||
public void SetUniform4(int count, params uint[] values)
|
||||
public void SetUniform4(params uint[] values)
|
||||
{
|
||||
GL.Uniform4(Location, count, values);
|
||||
GL.Uniform4(Location, values.Length / 4, values);
|
||||
}
|
||||
|
||||
public void SetUniform4(int count, ref float values)
|
||||
|
|
|
|||
|
|
@ -74,6 +74,16 @@ namespace SM.OGL.Shaders
|
|||
if (key.Contains("["))
|
||||
{
|
||||
var keySplits = key.Split('[', ']');
|
||||
if (keySplits[2] == "")
|
||||
{
|
||||
if (keySplits[1] == "0")
|
||||
{
|
||||
Add(keySplits[0], loc);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (keySplits[0] != lastArrayKey)
|
||||
{
|
||||
if (arrayFilled) Add(lastArrayKey, array);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue