mesh.vert.ts 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /**
  2. * Copyright (c) 2018-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
  3. *
  4. * @author Alexander Rose <alexander.rose@weirdbyte.de>
  5. */
  6. export const mesh_vert = `
  7. precision highp float;
  8. precision highp int;
  9. precision highp sampler2D;
  10. #include common
  11. #include read_from_texture
  12. #include common_vert_params
  13. #include color_vert_params
  14. #include common_clip
  15. #include texture3d_from_2d_linear
  16. #ifdef dGeoTexture
  17. uniform vec2 uGeoTexDim;
  18. uniform sampler2D tPosition;
  19. uniform sampler2D tGroup;
  20. uniform sampler2D tNormal;
  21. #else
  22. attribute vec3 aPosition;
  23. attribute float aGroup;
  24. attribute vec3 aNormal;
  25. #endif
  26. attribute mat4 aTransform;
  27. attribute float aInstance;
  28. varying vec3 vNormal;
  29. void main(){
  30. #include assign_group
  31. #include assign_marker_varying
  32. #include assign_clipping_varying
  33. #include assign_position
  34. #include assign_color_varying
  35. #include clip_instance
  36. #ifdef dGeoTexture
  37. vec3 normal = readFromTexture(tNormal, VertexID, uGeoTexDim).xyz;
  38. #else
  39. vec3 normal = aNormal;
  40. #endif
  41. mat3 normalMatrix = transpose3(inverse3(mat3(modelView)));
  42. vec3 transformedNormal = normalize(normalMatrix * normalize(normal));
  43. #if defined(dFlipSided) && !defined(dDoubleSided) // TODO checking dDoubleSided should not be required, ASR
  44. transformedNormal = -transformedNormal;
  45. #endif
  46. vNormal = transformedNormal;
  47. }
  48. `;