You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

voxelvert.vert.glsl 1.2KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #version 330
  2. layout(location = 0) in uint position;
  3. //layout(location = 0) in vec3 position;
  4. //layout(location = 1) in vec3 texCoord;
  5. layout(location = 1) in uint face_attrib;
  6. uniform mat4 proj, view, model; //transform matrix
  7. out vec3 texCoordInterp;
  8. out vec3 lightDataInterp;
  9. out vec4 eyeSpacePos;
  10. void main() {
  11. vec3 pos_unpacked;
  12. pos_unpacked.x = float((position >> 8u) & 15u) / 15.0f;
  13. pos_unpacked.y = float((position >> 4u) & 15u) / 15.0f;
  14. pos_unpacked.z = float((position) & 15u) / 15.0f;
  15. vec2 uv_unpacked;
  16. uv_unpacked.x = float((position >> 16u) & 15u) / 15.0f;
  17. uv_unpacked.y = float((position >> 12u) & 15u) / 15.0f;
  18. vec3 offset_unpacked;
  19. offset_unpacked.x = float((face_attrib >> 10u) & 31u);
  20. offset_unpacked.y = float((face_attrib >> 5u) & 31u);
  21. offset_unpacked.z = float((face_attrib) & 31u);
  22. float tex_index = float(face_attrib >> 15u);
  23. vec3 final_position = pos_unpacked + offset_unpacked;
  24. vec4 eyeSpacePosVert = view * model * vec4(final_position, 1.0);
  25. gl_Position = proj * eyeSpacePosVert;
  26. texCoordInterp = vec3(uv_unpacked, tex_index);//texCoord;
  27. lightDataInterp = vec3(1.0f, 1.0f, 1.0f);
  28. eyeSpacePos = eyeSpacePosVert;
  29. }