shader/sprite_vtx.glsl

Thu, 21 Mar 2024 23:00:39 +0100

author
Mike Becker <universe@uap-core.de>
date
Thu, 21 Mar 2024 23:00:39 +0100
changeset 42
cc912686f663
parent 41
df81d493716e
permissions
-rw-r--r--

increase maximum possible number of 2D layers

15
362b7659dc76 add shader loading and unloading
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1 #version 400 core
362b7659dc76 add shader loading and unloading
Mike Becker <universe@uap-core.de>
parents:
diff changeset
2
16
c5dde81b6fb2 add text rendering and demo FPS counter
Mike Becker <universe@uap-core.de>
parents: 15
diff changeset
3 layout(location = 0) in vec2 position;
15
362b7659dc76 add shader loading and unloading
Mike Becker <universe@uap-core.de>
parents:
diff changeset
4 out vec2 texcoord;
362b7659dc76 add shader loading and unloading
Mike Becker <universe@uap-core.de>
parents:
diff changeset
5
362b7659dc76 add shader loading and unloading
Mike Becker <universe@uap-core.de>
parents:
diff changeset
6 uniform mat4 projection;
362b7659dc76 add shader loading and unloading
Mike Becker <universe@uap-core.de>
parents:
diff changeset
7 uniform mat4 model;
41
df81d493716e add correct interleaving of opaque and transparent sprites
Mike Becker <universe@uap-core.de>
parents: 40
diff changeset
8 uniform float depth;
15
362b7659dc76 add shader loading and unloading
Mike Becker <universe@uap-core.de>
parents:
diff changeset
9
362b7659dc76 add shader loading and unloading
Mike Becker <universe@uap-core.de>
parents:
diff changeset
10 void main(void) {
41
df81d493716e add correct interleaving of opaque and transparent sprites
Mike Becker <universe@uap-core.de>
parents: 40
diff changeset
11 vec4 pos = projection*model*vec4(position.x, position.y, 0, 1.0);
df81d493716e add correct interleaving of opaque and transparent sprites
Mike Becker <universe@uap-core.de>
parents: 40
diff changeset
12 // apply depth
42
cc912686f663 increase maximum possible number of 2D layers
Mike Becker <universe@uap-core.de>
parents: 41
diff changeset
13 pos.z = depth / -1024.0;
41
df81d493716e add correct interleaving of opaque and transparent sprites
Mike Becker <universe@uap-core.de>
parents: 40
diff changeset
14 gl_Position = pos;
16
c5dde81b6fb2 add text rendering and demo FPS counter
Mike Becker <universe@uap-core.de>
parents: 15
diff changeset
15 texcoord = vec2(model[0].x, model[1].y)*position;
15
362b7659dc76 add shader loading and unloading
Mike Becker <universe@uap-core.de>
parents:
diff changeset
16 }

mercurial