27.09.2020
~ Moved Default-Shader to 2D to provied 2D-specific feature ~ Fixed UVs in Polygon
This commit is contained in:
parent
617a7ef044
commit
2aa12f8d25
19 changed files with 166 additions and 83 deletions
15
SMCode/SM2D/Shader/ShaderFiles/default.frag
Normal file
15
SMCode/SM2D/Shader/ShaderFiles/default.frag
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
#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);
|
||||
}
|
||||
23
SMCode/SM2D/Shader/ShaderFiles/default.vert
Normal file
23
SMCode/SM2D/Shader/ShaderFiles/default.vert
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
#version 330
|
||||
#define maxInstances 32
|
||||
layout(location = 0) in vec3 aPos;
|
||||
layout(location = 1) in vec2 aTex;
|
||||
layout(location = 3) in vec4 aColor;
|
||||
|
||||
uniform mat4 MVP;
|
||||
uniform bool HasVColor;
|
||||
uniform mat4 ModelMatrix[maxInstances];
|
||||
uniform vec2 TextureOffset[maxInstances];
|
||||
uniform vec2 TextureScale[maxInstances];
|
||||
|
||||
out vec2 vTexture;
|
||||
out vec4 vColor;
|
||||
|
||||
void main() {
|
||||
vTexture = aTex * TextureScale[gl_InstanceID] + TextureOffset[gl_InstanceID];
|
||||
|
||||
if (HasVColor) vColor = aColor;
|
||||
else vColor = vec4(1);
|
||||
|
||||
gl_Position = MVP * ModelMatrix[gl_InstanceID] * vec4(aPos, 1);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue