direct-volume.vert.ts 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /**
  2. * Copyright (c) 2017-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
  3. *
  4. * @author Alexander Rose <alexander.rose@weirdbyte.de>
  5. * @author Michael Krone <michael.krone@uni-tuebingen.de>
  6. */
  7. export const directVolume_vert = `
  8. precision highp float;
  9. attribute vec3 aPosition;
  10. attribute mat4 aTransform;
  11. attribute float aInstance;
  12. uniform mat4 uModelView;
  13. uniform mat4 uProjection;
  14. uniform vec4 uInvariantBoundingSphere;
  15. varying vec3 vOrigPos;
  16. varying float vInstance;
  17. varying vec4 vBoundingSphere;
  18. varying mat4 vTransform;
  19. uniform vec3 uBboxSize;
  20. uniform vec3 uBboxMin;
  21. uniform vec3 uBboxMax;
  22. uniform vec3 uGridDim;
  23. uniform mat4 uTransform;
  24. uniform mat4 uUnitToCartn;
  25. void main() {
  26. vec4 unitCoord = vec4(aPosition + vec3(0.5), 1.0);
  27. vec4 mvPosition = uModelView * aTransform * uUnitToCartn * unitCoord;
  28. vOrigPos = (aTransform * uUnitToCartn * unitCoord).xyz;
  29. vInstance = aInstance;
  30. vBoundingSphere = vec4(
  31. (aTransform * vec4(uInvariantBoundingSphere.xyz, 1.0)).xyz,
  32. uInvariantBoundingSphere.w
  33. );
  34. vTransform = aTransform;
  35. gl_Position = uProjection * mvPosition;
  36. // move z position to near clip plane (but not too close to get precision issues)
  37. gl_Position.z = gl_Position.w - 0.01;
  38. }
  39. `;