mesh.vert.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 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. #ifdef dGeoTexture
  16. uniform vec2 uGeoTexDim;
  17. uniform sampler2D tPosition;
  18. uniform sampler2D tGroup;
  19. uniform sampler2D tNormal;
  20. #else
  21. attribute vec3 aPosition;
  22. attribute float aGroup;
  23. attribute vec3 aNormal;
  24. #endif
  25. attribute mat4 aTransform;
  26. attribute float aInstance;
  27. varying vec3 vNormal;
  28. void main(){
  29. #include assign_group
  30. #include assign_color_varying
  31. #include assign_marker_varying
  32. #include assign_clipping_varying
  33. #include assign_position
  34. #include clip_instance
  35. #ifdef dGeoTexture
  36. vec3 normal = readFromTexture(tNormal, VertexID, uGeoTexDim).xyz;
  37. #else
  38. vec3 normal = aNormal;
  39. #endif
  40. mat3 normalMatrix = transpose3(inverse3(mat3(modelView)));
  41. vec3 transformedNormal = normalize(normalMatrix * normalize(normal));
  42. #if defined(dFlipSided) && !defined(dDoubleSided) // TODO checking dDoubleSided should not be required, ASR
  43. transformedNormal = -transformedNormal;
  44. #endif
  45. vNormal = transformedNormal;
  46. }
  47. `;