Holidays 12.10. -> 25.10.2020
~ Moved code around in files. SM.Base: + PostProcessing-system + OnInitialization() for Scenes. + Shader-Extensions + Added option to not react while unfocused to the window. + Added Screenshots to the window. + Connected the log system to the SM.OGL-action system. ~ Replaced IShader with abstract MaterialShader. ~ When a log compression folder doesn't exist, it will create one. SM.OGL: + Added support for UniformArrays + Added ShaderPreProcessing + Added Shader Extensions. + Added Debug actions. + SM.OGL settings ~ Framebuffer Size is automaticly changed, when the window and scale is set. SM2D: + Added easy shader drawing.
This commit is contained in:
parent
2c00dbd31a
commit
03b3942732
102 changed files with 2683 additions and 1398 deletions
9
SMCode/SM.Base/PostProcess/DefaultFiles/extensions.frag
Normal file
9
SMCode/SM.Base/PostProcess/DefaultFiles/extensions.frag
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#version 330
|
||||
|
||||
in vec2 vTexture;
|
||||
|
||||
uniform sampler2D renderedTexture;
|
||||
|
||||
vec4 GetRenderColor() {
|
||||
return texture(renderedTexture, vTexture);
|
||||
}
|
||||
14
SMCode/SM.Base/PostProcess/DefaultFiles/vertexFile.vert
Normal file
14
SMCode/SM.Base/PostProcess/DefaultFiles/vertexFile.vert
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#version 330
|
||||
|
||||
layout(location = 0) in vec3 aPos;
|
||||
layout(location = 1) in vec2 aTex;
|
||||
|
||||
uniform mat4 MVP;
|
||||
|
||||
out vec2 vTexture;
|
||||
|
||||
void main() {
|
||||
vTexture = aTex;
|
||||
|
||||
gl_Position = MVP * vec4(aPos, 1);
|
||||
}
|
||||
18
SMCode/SM.Base/PostProcess/DefaultFiles/vertexWithExt.vert
Normal file
18
SMCode/SM.Base/PostProcess/DefaultFiles/vertexWithExt.vert
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#version 330
|
||||
|
||||
layout(location = 0) in vec3 aPos;
|
||||
layout(location = 1) in vec2 aTex;
|
||||
|
||||
uniform mat4 MVP;
|
||||
|
||||
out vec2 vTexture;
|
||||
|
||||
void vertex();
|
||||
|
||||
void main() {
|
||||
vTexture = aTex;
|
||||
|
||||
gl_Position = MVP * vec4(aPos, 1);
|
||||
|
||||
vertex();
|
||||
}
|
||||
30
SMCode/SM.Base/PostProcess/PostProcessEffect.cs
Normal file
30
SMCode/SM.Base/PostProcess/PostProcessEffect.cs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics.OpenGL4;
|
||||
using SM.Base.Objects.Static;
|
||||
using SM.OGL.Framebuffer;
|
||||
using SM.OGL.Shaders;
|
||||
|
||||
namespace SM.Base.PostProcess
|
||||
{
|
||||
public abstract class PostProcessEffect
|
||||
{
|
||||
internal static Matrix4 Mvp;
|
||||
|
||||
public virtual ICollection<Framebuffer> RequiredFramebuffers { get; }
|
||||
|
||||
public virtual void Init() {}
|
||||
|
||||
public virtual void Init(Framebuffer main)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
public virtual void Draw(Framebuffer main)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
64
SMCode/SM.Base/PostProcess/PostProcessShader.cs
Normal file
64
SMCode/SM.Base/PostProcess/PostProcessShader.cs
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using OpenTK.Graphics.OpenGL4;
|
||||
using SM.Base.Objects.Static;
|
||||
using SM.OGL.Framebuffer;
|
||||
using SM.OGL.Shaders;
|
||||
using SM.Utility;
|
||||
|
||||
namespace SM.Base.PostProcess
|
||||
{
|
||||
public class PostProcessShader : GenericShader
|
||||
{
|
||||
private static ShaderFile _fragExtensions = new ShaderFile(AssemblyUtility.ReadAssemblyFile("SM.Base.PostProcess.DefaultFiles.extensions.frag"));
|
||||
private static ShaderFile _normalVertex = new ShaderFile(AssemblyUtility.ReadAssemblyFile("SM.Base.PostProcess.DefaultFiles.vertexFile.vert"));
|
||||
private static string _normalVertexWithExt =
|
||||
AssemblyUtility.ReadAssemblyFile("SM.Base.PostProcess.DefaultFiles.vertexWithExt.vert");
|
||||
|
||||
public PostProcessShader(string fragment) : this(_normalVertex,
|
||||
new ShaderFile(fragment)) { }
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public void Draw(ColorAttachment color)
|
||||
{
|
||||
GL.UseProgram(this);
|
||||
GL.BindVertexArray(Plate.Object);
|
||||
|
||||
Uniforms["MVP"].SetMatrix4(PostProcessEffect.Mvp);
|
||||
Uniforms["renderedTexture"].SetTexture(color, 0);
|
||||
|
||||
GL.DrawArrays(PrimitiveType.Quads, 0, 4);
|
||||
|
||||
GL.BindTexture(TextureTarget.Texture2D, 0);
|
||||
GL.BindVertexArray(0);
|
||||
GL.UseProgram(0);
|
||||
}
|
||||
|
||||
public void Draw(ColorAttachment color, Action<UniformCollection> setUniformAction)
|
||||
{
|
||||
GL.UseProgram(this);
|
||||
GL.BindVertexArray(Plate.Object);
|
||||
|
||||
Uniforms["MVP"].SetMatrix4(PostProcessEffect.Mvp);
|
||||
Uniforms["renderedTexture"].SetTexture(color, 0);
|
||||
|
||||
setUniformAction(Uniforms);
|
||||
|
||||
GL.DrawArrays(PrimitiveType.Quads, 0, 4);
|
||||
|
||||
GL.BindTexture(TextureTarget.Texture2D, 0);
|
||||
GL.BindVertexArray(0);
|
||||
GL.UseProgram(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue