~ Transformation can now set to be ignored. (Sending a Identity, when requested) ~ Changed how Meshes store Attributes
50 lines
No EOL
1.5 KiB
C#
50 lines
No EOL
1.5 KiB
C#
#region usings
|
|
|
|
using OpenTK.Graphics.OpenGL4;
|
|
using SM.Base.Contexts;
|
|
using SM.Base.Drawing;
|
|
using SM.Base.Scene;
|
|
using SM.OGL.Shaders;
|
|
using SM.Utility;
|
|
|
|
#endregion
|
|
|
|
namespace SM2D.Shader
|
|
{
|
|
public class Default2DShader : MaterialShader
|
|
{
|
|
public static Default2DShader MaterialShader = new Default2DShader();
|
|
|
|
|
|
private Default2DShader() : base(AssemblyUtility.ReadAssemblyFile("SM2D.Shader.ShaderFiles.default.glsl"))
|
|
{
|
|
Load();
|
|
}
|
|
|
|
protected override void DrawProcess(DrawContext context)
|
|
{
|
|
// Vertex Uniforms
|
|
Uniforms["MVP"].SetMatrix4(context.ModelMaster * context.View * context.World);
|
|
Uniforms["HasVColor"]
|
|
.SetUniform1(context.Mesh.Attributes["color"] != null);
|
|
/*
|
|
Uniforms.GetArray("Instances").Set((i, uniforms) =>
|
|
{
|
|
if (i >= context.Instances.Count) return false;
|
|
|
|
var instance = context.Instances[i];
|
|
uniforms["ModelMatrix"].SetMatrix4(instance.ModelMatrix);
|
|
uniforms["TextureOffset"].SetUniform2(instance.TexturePosition);
|
|
uniforms["TextureScale"].SetUniform2(instance.TextureScale);
|
|
|
|
return true;
|
|
});*/
|
|
|
|
// Fragment Uniforms
|
|
Uniforms["Tint"].SetUniform4(context.Material.Tint);
|
|
Uniforms["Texture"].SetTexture(context.Material.Texture, Uniforms["UseTexture"]);
|
|
|
|
DrawObject(context.Mesh, context.Instances.Count);
|
|
}
|
|
}
|
|
} |