mesh.vert.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /**
  2. * Copyright (c) 2018-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
  3. *
  4. * @author Alexander Rose <alexander.rose@weirdbyte.de>
  5. */
  6. export default `
  7. precision highp float;
  8. precision highp int;
  9. #include common
  10. #include read_from_texture
  11. #include common_vert_params
  12. #include color_vert_params
  13. #include common_clip
  14. #ifdef dGeoTexture
  15. uniform vec2 uGeoTexDim;
  16. uniform sampler2D tPositionGroup;
  17. #else
  18. attribute vec3 aPosition;
  19. #endif
  20. attribute mat4 aTransform;
  21. attribute float aInstance;
  22. attribute float aGroup;
  23. #ifdef dGeoTexture
  24. uniform sampler2D tNormal;
  25. #else
  26. attribute vec3 aNormal;
  27. #endif
  28. varying vec3 vNormal;
  29. void main(){
  30. #include assign_group
  31. #include assign_color_varying
  32. #include assign_marker_varying
  33. #include assign_clipping_varying
  34. #include assign_position
  35. #include clip_instance
  36. #ifdef dGeoTexture
  37. vec3 normal = readFromTexture(tNormal, aGroup, 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. `;