vertex.vs 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. #version 430
  2. layout (binding = 0) uniform sampler3D samp;
  3. out vec3 varTexture;
  4. out int varIndex;
  5. const float step = 1.0 / 63.0;
  6. void main(void) {
  7. int id = gl_VertexID;
  8. int x = id & 0x3F;
  9. int y = (id >> 6) & 0x3F;
  10. int z = (id >> 12) & 0x3F;
  11. vec3 xyz = vec3(x, y, z);
  12. gl_Position = vec4(xyz, 1.0);
  13. varTexture = xyz * step;
  14. const float limit = 0.5f;
  15. int b1 = int(texture(samp, varTexture).r < limit);
  16. int b2 = int(texture(samp, varTexture + vec3(step, 0.0, 0.0)).r < limit);
  17. int b3 = int(texture(samp, varTexture + vec3(step, 0.0, step)).r < limit);
  18. int b4 = int(texture(samp, varTexture + vec3(0.0, 0.0, step)).r < limit);
  19. int b5 = int(texture(samp, varTexture + vec3(0.0, step, 0.0)).r < limit);
  20. int b6 = int(texture(samp, varTexture + vec3(step, step, 0.0)).r < limit);
  21. int b7 = int(texture(samp, varTexture + vec3(step, step, step)).r < limit);
  22. int b8 = int(texture(samp, varTexture + vec3(0.0, step, step)).r < limit);
  23. varIndex = (b1 << 7) | (b2 << 6) | (b3 << 5) | (b4 << 4) |
  24. (b5 << 3) | (b6 << 2) | (b7 << 1) | b8;
  25. }