Advertisement
Tkap1

Untitled

Oct 8th, 2022
992
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.23 KB | None | 0 0
  1. #version 420 core
  2. layout (location = 0) in vec3 vertices;
  3. layout (location = 1) in vec4 uv;
  4. layout (location = 2) in vec2 vertex_offset;
  5. layout (location = 3) in vec4 color;
  6. layout (location = 4) in mat4 model;
  7.  
  8. out vec3 v_vertices;
  9. out vec2 v_uv;
  10. out vec3 v_world_pos;
  11. // out vec3 v_normal;
  12. out vec4 v_color;
  13. out vec2 v_local_uv;
  14.  
  15. uniform mat4 projection;
  16.  
  17. void main()
  18. {
  19.  
  20.     vec3 temp_vertices = vec3(vertices.xy + vertex_offset, vertices.z);
  21.  
  22.     vec4 temp = projection * model * vec4(temp_vertices, 1);
  23.     // vec4 temp = projection * model * vec4(temp_vertices, 1);
  24.     gl_Position = temp;
  25.  
  26.  
  27.     v_vertices = temp_vertices;
  28.     v_world_pos = (model * vec4(temp_vertices, 1)).xyz;
  29.     // v_normal = normal;
  30.     v_color = color;
  31.  
  32.     vec2 uv_min = uv.xy;
  33.     vec2 uv_max = uv.zw;
  34.  
  35.     vec2 uvs[6];
  36.     uvs[0] = uv_min;
  37.     uvs[1] = vec2(uv_max.x, uv_min.y);
  38.     uvs[2] = vec2(uv_max.x, uv_max.y);
  39.     uvs[3] = uv_min;
  40.     uvs[4] = vec2(uv_max.x, uv_max.y);
  41.     uvs[5] = vec2(uv_min.x, uv_max.y);
  42.  
  43.     v_uv = uvs[gl_VertexID % 6];
  44.  
  45.     vec2 local_uvs[6];
  46.     local_uvs[0] = vec2(0, 0);
  47.     local_uvs[1] = vec2(1, 0);
  48.     local_uvs[2] = vec2(1, 1);
  49.     local_uvs[3] = vec2(0, 0);
  50.     local_uvs[4] = vec2(1, 1);
  51.     local_uvs[5] = vec2(0, 1);
  52.     v_local_uv = local_uvs[gl_VertexID % 6];
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement