mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
48 lines
955 B
GLSL
48 lines
955 B
GLSL
// Vertex position.
|
|
/*layout (location = 0)*/ attribute vec2 aPos;
|
|
// Texture coordinates.
|
|
/*layout (location = 1)*/ attribute vec2 tCoord;
|
|
// Colour modulation.
|
|
/*layout (location = 2)*/ attribute vec4 modulate;
|
|
|
|
varying vec2 UV;
|
|
|
|
// Maybe we should merge these CPU side.
|
|
// idk yet.
|
|
uniform mat3 modelMatrix;
|
|
|
|
// Allows us to do texture atlassing with texture coordinates 0->1
|
|
// Input texture coordinates get mapped to this range.
|
|
uniform vec4 modifyUV;
|
|
|
|
vec2 pixel_snap(vec2 vertex)
|
|
{
|
|
vertex += 1.0;
|
|
vertex /= SCREEN_PIXEL_SIZE*2.0;
|
|
vertex = floor(vertex + 0.5);
|
|
vertex *= SCREEN_PIXEL_SIZE*2.0;
|
|
vertex -= 1.0;
|
|
|
|
return vertex;
|
|
}
|
|
|
|
vec2 apply_mvp(vec2 vertex)
|
|
{
|
|
vec3 transformed = projectionMatrix * viewMatrix * modelMatrix * vec3(vertex, 1.0);
|
|
|
|
return transformed.xy;
|
|
}
|
|
|
|
// [SHADER_HEADER_CODE]
|
|
|
|
void main()
|
|
{
|
|
vec2 VERTEX = aPos;
|
|
|
|
UV = tCoord;
|
|
|
|
// [SHADER_CODE]
|
|
|
|
gl_Position = vec4(VERTEX, 0.0, 1.0);
|
|
}
|