1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#version 450

// vertices
layout(location=0)in vec2 pos;
// offset (position basically)
//layout(location=1)in vec2 offset;

#if 0
// uv
layout(location=2)in vec2 uvIn;
layout(location=5)out vec2 uv;
// texIdx
layout(location=3)in float texIdx;
layout(location=6)out float texIdxOut;
// size
layout(location=4)in vec2 size;
#endif
layout (set=0, binding = 0) uniform Block
{
// camera
vec2 camera;
// resolution (for scaling from pixels to NDC)
//vec2 pixelsToNdc;
};


vec2 positions[3] = vec2[](
vec2(0.0,-0.5),
vec2(0.5,0.5),
vec2(-0.5,0.5)
);

void main()
{
#if 0
    texIdxOut = texIdx;
    // set UV
    uv = uvIn;
    // set size of the object (square only)
	vec2 newPos = (pos.xy*(vec2(64,64)*0.5));
    //make 0,0 be the Top Left of the object drawn
	newPos.xy -= vec2(-64,64)*0.5;
    // offset position
     newPos += vec2(offset.x,offset.y);
    // offset camera
	 newPos += camera;
    // scale to the resolution (so positions can be in pixels)
	newPos *= pixelsToNdc;
    // make (0,0) Top Left
	newPos -= vec2(1,-1);
    gl_Position = vec4(newPos,1.0,1.0);
	#endif
    vec2 test = pos + camera;
	gl_Position = vec4(test,1,1);
}