Guest User

Untitled

a guest
Oct 8th, 2025
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.31 KB | Source Code | 0 0
  1. #version 460 core
  2.  
  3. layout (points) in;
  4. layout (triangle_strip, max_vertices = 4) out;
  5.  
  6. in vec3 outColor[];
  7. in vec2 outCenter[];
  8. in float outAngle[];
  9.  
  10. out vec3 finalColor;
  11.  
  12. uniform mat4 mvp;
  13.  
  14. float scale = 10.0f;
  15.  
  16. vec2 SetOffset(int vertice){
  17.     vec2 offset;
  18.     switch(vertice){
  19.         default: break;
  20.         case 0: break;
  21.         case 1: offset.x = scale; break;
  22.         case 2: offset.y = scale; break;
  23.         case 3: offset.x = scale; offset.y = scale; break;
  24.     }
  25.     return offset;
  26. }
  27.  
  28. void createVertex(int vertice){
  29.     float inX = gl_in[0].gl_Position.x;
  30.     float inY = gl_in[0].gl_Position.y;
  31.  
  32.     vec2 result = SetOffset(vertice);
  33.  
  34.     float bRotX = inX * scale + result.x;
  35.     float bRotY = inY * scale + result.y;
  36.  
  37.     vec2 center = outCenter[0];
  38.     float cx = center.x;
  39.     float cy = center.y;
  40.     float inRad = radians(outAngle[0]);
  41.     float cr = cos(inRad);
  42.     float sr = sin(inRad);
  43.     float endX = cr * bRotX - sr * bRotY;
  44.     float endY = sr * bRotX + cr * bRotY;
  45.    
  46.     gl_Position = mvp * vec4(endX, endY, 1.0, 1.0);
  47.     // ^--- Line that results a chaos if I add the centering to the variables. (vec2 center)
  48.     // gl_Position = mvp * vec4(endX + center.x, endY + center.y, 1.0, 1.0);
  49.  
  50.     finalColor = outColor[0];
  51.     EmitVertex();
  52. }
  53.  
  54.  
  55. void main(void){
  56.     createVertex(0);
  57.     createVertex(1);
  58.     createVertex(2);
  59.     createVertex(3);
  60.     EndPrimitive();
  61. }
Advertisement
Add Comment
Please, Sign In to add comment