18.09.2020
+ Textures ~ Changed 2D coordnate system to lower right as XY+
This commit is contained in:
parent
589d131246
commit
a603ecc417
26 changed files with 267 additions and 16 deletions
|
|
@ -1,8 +1,12 @@
|
|||
#version 330
|
||||
|
||||
in vec2 vTexture;
|
||||
|
||||
uniform vec4 Tint;
|
||||
uniform sampler2D Texture;
|
||||
|
||||
layout(location = 0) out vec4 color;
|
||||
|
||||
void main() {
|
||||
color = vec4(1,1,1,1) + Tint;
|
||||
color = Tint * texture(Texture, vTexture);
|
||||
}
|
||||
|
|
@ -1,9 +1,14 @@
|
|||
#version 330
|
||||
layout(location = 0) in vec3 aPos;
|
||||
layout(location = 1) in vec2 aTex;
|
||||
|
||||
uniform mat4 MVP;
|
||||
uniform mat4 ModelMatrix;
|
||||
|
||||
out vec2 vTexture;
|
||||
|
||||
void main() {
|
||||
vTexture = aTex;
|
||||
|
||||
gl_Position = MVP * ModelMatrix * vec4(aPos, 1);
|
||||
}
|
||||
|
|
@ -1,20 +1,21 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics.OpenGL4;
|
||||
using SM.Base.Contexts;
|
||||
using SM.Base.Scene;
|
||||
using SM.Base.StaticObjects;
|
||||
using SM.OGL.Shaders;
|
||||
|
||||
namespace SM.Base.Shader
|
||||
{
|
||||
public class InstanceShader : GenericShader
|
||||
public class InstanceShader : GenericShader, IShader
|
||||
{
|
||||
protected override bool AutoCompile { get; } = true;
|
||||
|
||||
public Action<UniformCollection, DrawContext> SetUniform;
|
||||
|
||||
public InstanceShader(string vertex, string fragment, Action<UniformCollection, DrawContext> setUniform) : base(
|
||||
new ShaderFileCollection(vertex, fragment))
|
||||
public InstanceShader(string vertex, string fragment, Action<UniformCollection, DrawContext> setUniform) : base(new ShaderFileCollection(vertex, fragment))
|
||||
{
|
||||
SetUniform = setUniform;
|
||||
}
|
||||
|
|
@ -28,5 +29,10 @@ namespace SM.Base.Shader
|
|||
|
||||
GL.UseProgram(0);
|
||||
}
|
||||
|
||||
public void DrawInstanced(DrawContext context, ICollection<Matrix4> instanceCollection)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -12,7 +12,8 @@ namespace SM.Base.Shader
|
|||
{
|
||||
u["MVP"].SetMatrix4(context.View * context.World);
|
||||
u["ModelMatrix"].SetMatrix4(context.ModelMatrix);
|
||||
u["Tint"].SetUniform4(1,1,1,1);
|
||||
u["Tint"].SetUniform4(context.Material.Tint);
|
||||
u["Texture"].SetTexture(context.Material.Texture, 0);
|
||||
}));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue