Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #version 460 core
- layout (points) in;
- layout (triangle_strip, max_vertices = 4) out;
- in vec3 outColor[];
- in vec2 outCenter[];
- in float outAngle[];
- out vec3 finalColor;
- uniform mat4 mvp;
- float scale = 10.0f;
- vec2 SetOffset(int vertice){
- vec2 offset;
- switch(vertice){
- default: break;
- case 0: break;
- case 1: offset.x = scale; break;
- case 2: offset.y = scale; break;
- case 3: offset.x = scale; offset.y = scale; break;
- }
- return offset;
- }
- void createVertex(int vertice){
- float inX = gl_in[0].gl_Position.x;
- float inY = gl_in[0].gl_Position.y;
- vec2 result = SetOffset(vertice);
- float bRotX = inX * scale + result.x;
- float bRotY = inY * scale + result.y;
- vec2 center = outCenter[0];
- float cx = center.x;
- float cy = center.y;
- float inRad = radians(outAngle[0]);
- float cr = cos(inRad);
- float sr = sin(inRad);
- float endX = cr * bRotX - sr * bRotY;
- float endY = sr * bRotX + cr * bRotY;
- gl_Position = mvp * vec4(endX, endY, 1.0, 1.0);
- // ^--- Line that results a chaos if I add the centering to the variables. (vec2 center)
- // gl_Position = mvp * vec4(endX + center.x, endY + center.y, 1.0, 1.0);
- finalColor = outColor[0];
- EmitVertex();
- }
- void main(void){
- createVertex(0);
- createVertex(1);
- createVertex(2);
- createVertex(3);
- EndPrimitive();
- }
Advertisement
Add Comment
Please, Sign In to add comment