28.10.2020

SM.Core:
+ Particle System
+ scriptable system for scripts

~ Moved Texts- and Particles-namespace to SM.Base.Drawing
~ Changed how you tell the stopwatch to pause. (From method to property)
~ Fixed Randomize.GetFloat(min, max)
~ Now automaticly adds the DrawingBase.Transformation to DrawContext.ModelMatrix. No need to change DrawContext.Instances[0], anymore.

SM.OGL:
+ "one-file-shader"-support

SM2D:
+ DrawParticles (Control for Texture and Color not there yet)

~ Changed coordnate system to upper-right as (1,1)
~ Changed default shader to "one-file-shader"
This commit is contained in:
Michel Fedde 2020-10-28 18:19:15 +01:00
parent 03b3942732
commit beb9c19081
45 changed files with 580 additions and 190 deletions

View file

@ -2,6 +2,7 @@
using OpenTK.Graphics.OpenGL4;
using SM.Base.Contexts;
using SM.Base.Drawing;
using SM.Base.Scene;
using SM.OGL.Shaders;
using SM.Utility;
@ -13,12 +14,9 @@ namespace SM2D.Shader
public class Default2DShader : MaterialShader
{
public static Default2DShader MaterialShader = new Default2DShader();
//protected override bool AutoCompile { get; } = true;
private Default2DShader() : base(new ShaderFileCollection(
AssemblyUtility.ReadAssemblyFile("SM2D.Shader.ShaderFiles.default.vert"),
AssemblyUtility.ReadAssemblyFile("SM2D.Shader.ShaderFiles.default.frag")))
private Default2DShader() : base(AssemblyUtility.ReadAssemblyFile("SM2D.Shader.ShaderFiles.default.glsl"))
{
Load();
}
@ -32,7 +30,7 @@ namespace SM2D.Shader
Uniforms.GetArray("Instances").Set((i, uniforms) =>
{
if (i >= context.Instances.Length) return false;
if (i >= context.Instances.Count) return false;
var instance = context.Instances[i];
uniforms["ModelMatrix"].SetMatrix4(instance.ModelMatrix);
@ -46,7 +44,7 @@ namespace SM2D.Shader
Uniforms["Tint"].SetUniform4(context.Material.Tint);
Uniforms["Texture"].SetTexture(context.Material.Texture, Uniforms["UseTexture"]);
DrawObject(context.Mesh, context.Instances.Length);
DrawObject(context.Mesh, context.Instances.Count);
}
}
}

View file

@ -1,15 +0,0 @@
#version 330
in vec2 vTexture;
in vec4 vColor;
uniform vec4 Tint;
uniform bool UseTexture;
uniform sampler2D Texture;
layout(location = 0) out vec4 color;
void main() {
color = vColor * Tint;
if (UseTexture) color *= texture(Texture, vTexture);
}

View file

@ -0,0 +1,29 @@
#version 330
//# region vertex
//# import SM_base_vertex_basic
void ApplyTexModifier();
void CheckVertexColor();
void ApplyModelTransformation();
void vmain() {
ApplyTexModifier();
CheckVertexColor();
ApplyModelTransformation();
}
//# region fragment
in vec2 vTexture;
in vec4 vColor;
uniform vec4 Tint;
uniform bool UseTexture;
uniform sampler2D Texture;
layout(location = 0) out vec4 color;
void fmain() {
color = vColor * Tint;
if (UseTexture) color *= texture(Texture, vTexture);
}

View file

@ -1,12 +0,0 @@
#version 330
//# import SM_base_vertex_basic
void ApplyTexModifier();
void CheckVertexColor();
void ApplyModelTransformation();
void main() {
ApplyTexModifier();
CheckVertexColor();
ApplyModelTransformation();
}