35 lines
837 B
GLSL
35 lines
837 B
GLSL
#include "entity.glsl"
|
|
|
|
// Outputs to fragment shader
|
|
out vec2 v_TextureCoord;
|
|
flat out int v_Entity;
|
|
|
|
void main() {
|
|
int entityIndex = gl_InstanceID;
|
|
int indiceIndex = gl_VertexID % 6;
|
|
|
|
Entity entity = entities[entityIndex];
|
|
|
|
vec4 quadPos = entityGetCoordinates(entity);
|
|
vec4 quadUVs = entityGetUVs(entity);
|
|
|
|
vec2 vertex;
|
|
vec2 uv;
|
|
if(indiceIndex == 0 || indiceIndex == 4) {
|
|
vertex = quadPos.xy;
|
|
uv = quadUVs.xy;
|
|
} else if(indiceIndex == 1) {
|
|
vertex = quadPos.zy;
|
|
uv = quadUVs.zy;
|
|
} else if(indiceIndex == 2 || indiceIndex == 5) {
|
|
vertex = quadPos.zw;
|
|
uv = quadUVs.zw;
|
|
} else if(indiceIndex == 3) {
|
|
vertex = quadPos.xw;
|
|
uv = quadUVs.xw;
|
|
}
|
|
|
|
gl_Position = transforms.projection * transforms.view * vec4(vertex, 0.0, 1.0);
|
|
v_TextureCoord = uv;
|
|
v_Entity = entityIndex;
|
|
} |