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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// FRAGMENT

#version 450

layout(location=0) out vec4 colorOut;
//layout(location=1) in float texIdxOut;
//layout(location=3) in vec2 uv;

//uniform  sampler2DArray texSampler;
//uniform Block
//{

// vec4 colorIn;
//};

void main()
{
    //vec4 color = texture(texSampler,vec3(uv.xy,texIdxOut));
    //colorOut = vec4(color.rgba);
    colorOut = vec4(0,1,0,1);
}


// VERTEX

#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;

uniform Block
{
// camera
vec2 camera;
// resolution (for scaling from pixels to NDC)
vec2 pixelsToNdc;
};
#endif

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
	gl_Position = vec4(pos,1,1);
}