PolylineShadowVolumeMorphFS.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. //This file is automatically rebuilt by the Cesium build process.
  2. export default "in vec3 v_forwardDirectionEC;\n\
  3. in vec3 v_texcoordNormalizationAndHalfWidth;\n\
  4. in float v_batchId;\n\
  5. \n\
  6. #ifdef PER_INSTANCE_COLOR\n\
  7. in vec4 v_color;\n\
  8. #else\n\
  9. in vec2 v_alignedPlaneDistances;\n\
  10. in float v_texcoordT;\n\
  11. #endif\n\
  12. \n\
  13. float rayPlaneDistanceUnsafe(vec3 origin, vec3 direction, vec3 planeNormal, float planeDistance) {\n\
  14. // We don't expect the ray to ever be parallel to the plane\n\
  15. return (-planeDistance - dot(planeNormal, origin)) / dot(planeNormal, direction);\n\
  16. }\n\
  17. \n\
  18. void main(void)\n\
  19. {\n\
  20. vec4 eyeCoordinate = gl_FragCoord;\n\
  21. eyeCoordinate /= eyeCoordinate.w;\n\
  22. \n\
  23. #ifdef PER_INSTANCE_COLOR\n\
  24. out_FragColor = czm_gammaCorrect(v_color);\n\
  25. #else // PER_INSTANCE_COLOR\n\
  26. // Use distances for planes aligned with segment to prevent skew in dashing\n\
  27. float distanceFromStart = rayPlaneDistanceUnsafe(eyeCoordinate.xyz, -v_forwardDirectionEC, v_forwardDirectionEC.xyz, v_alignedPlaneDistances.x);\n\
  28. float distanceFromEnd = rayPlaneDistanceUnsafe(eyeCoordinate.xyz, v_forwardDirectionEC, -v_forwardDirectionEC.xyz, v_alignedPlaneDistances.y);\n\
  29. \n\
  30. // Clamp - distance to aligned planes may be negative due to mitering\n\
  31. distanceFromStart = max(0.0, distanceFromStart);\n\
  32. distanceFromEnd = max(0.0, distanceFromEnd);\n\
  33. \n\
  34. float s = distanceFromStart / (distanceFromStart + distanceFromEnd);\n\
  35. s = (s * v_texcoordNormalizationAndHalfWidth.x) + v_texcoordNormalizationAndHalfWidth.y;\n\
  36. \n\
  37. czm_materialInput materialInput;\n\
  38. \n\
  39. materialInput.s = s;\n\
  40. materialInput.st = vec2(s, v_texcoordT);\n\
  41. materialInput.str = vec3(s, v_texcoordT, 0.0);\n\
  42. \n\
  43. czm_material material = czm_getMaterial(materialInput);\n\
  44. out_FragColor = vec4(material.diffuse + material.emission, material.alpha);\n\
  45. #endif // PER_INSTANCE_COLOR\n\
  46. }\n\
  47. ";