Loads and loads of small improvements I added while developing on my game
This commit is contained in:
parent
41421b1df9
commit
a7c71e7ea1
107 changed files with 2278 additions and 1023 deletions
|
|
@ -4,15 +4,11 @@ layout(location = 0) in vec3 aPos;
|
|||
layout(location = 1) in vec2 aTex;
|
||||
|
||||
uniform mat4 MVP;
|
||||
uniform mat4 ModelMatrix;
|
||||
|
||||
out vec2 vTexture;
|
||||
out vec2 FragPos;
|
||||
|
||||
void main() {
|
||||
vTexture = aTex;
|
||||
|
||||
FragPos = vec2(ModelMatrix * vec4(aPos, 1));
|
||||
|
||||
gl_Position = MVP * vec4(aPos, 1);
|
||||
}
|
||||
|
|
@ -4,17 +4,13 @@ layout(location = 0) in vec3 aPos;
|
|||
layout(location = 1) in vec2 aTex;
|
||||
|
||||
uniform mat4 MVP;
|
||||
uniform mat4 ModelMatrix;
|
||||
|
||||
out vec2 vTexture;
|
||||
out vec2 FragPos;
|
||||
|
||||
void vertex();
|
||||
|
||||
void main() {
|
||||
vTexture = aTex;
|
||||
|
||||
FragPos = vec2(ModelMatrix * vec4(aPos, 1));
|
||||
|
||||
gl_Position = MVP * vec4(aPos, 1);
|
||||
|
||||
|
|
|
|||
|
|
@ -3,9 +3,10 @@ using System.Collections.Generic;
|
|||
using System.Diagnostics;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics.OpenGL4;
|
||||
using SM.Base.Contexts;
|
||||
using SM.Base;
|
||||
using SM.Base.Objects.Static;
|
||||
using SM.Base.Scene;
|
||||
using SM.Base.Windows;
|
||||
using SM.OGL.Framebuffer;
|
||||
using SM.OGL.Shaders;
|
||||
|
||||
|
|
@ -16,8 +17,7 @@ namespace SM.Base.PostProcess
|
|||
/// </summary>
|
||||
public abstract class PostProcessEffect
|
||||
{
|
||||
internal static Matrix4 Mvp;
|
||||
internal static Matrix4 Model;
|
||||
public static Matrix4 Mvp = Matrix4.Identity;
|
||||
|
||||
protected RenderPipeline Pipeline;
|
||||
|
||||
|
|
|
|||
|
|
@ -42,45 +42,23 @@ namespace SM.Base.PostProcess
|
|||
fragment.GLSLExtensions.Add(_fragExtensions);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws the shader without special uniforms.
|
||||
/// </summary>
|
||||
/// <param name="color"></param>
|
||||
public void Draw(ColorAttachment color)
|
||||
{
|
||||
GL.UseProgram(this);
|
||||
GL.BindVertexArray(Plate.Object);
|
||||
|
||||
Uniforms["MVP"].SetMatrix4(PostProcessEffect.Mvp);
|
||||
Uniforms["ModelMatrix"].SetMatrix4(PostProcessEffect.Model);
|
||||
Uniforms["renderedTexture"].SetTexture(color);
|
||||
|
||||
GL.DrawArrays(PrimitiveType.Quads, 0, 4);
|
||||
|
||||
CleanUp();
|
||||
GL.UseProgram(0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws the shader with special uniforms.
|
||||
/// </summary>
|
||||
/// <param name="color"></param>
|
||||
/// <param name="setUniformAction"></param>
|
||||
public void Draw(ColorAttachment color, Action<UniformCollection> setUniformAction)
|
||||
public void Draw(Action<UniformCollection> setUniformAction)
|
||||
{
|
||||
GL.UseProgram(this);
|
||||
GL.BindVertexArray(Plate.Object);
|
||||
Activate();
|
||||
Plate.Object.Activate();
|
||||
|
||||
Uniforms["MVP"].SetMatrix4(PostProcessEffect.Mvp);
|
||||
Uniforms["ModelMatrix"].SetMatrix4(PostProcessEffect.Model);
|
||||
Uniforms["renderedTexture"].SetTexture(color);
|
||||
|
||||
setUniformAction(Uniforms);
|
||||
|
||||
GL.DrawArrays(PrimitiveType.Quads, 0, 4);
|
||||
|
||||
CleanUp();
|
||||
GL.UseProgram(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue