Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. attribute vec3 left; //vertex to the left of this vertex
  2. attribute vec3 right; //vertex to the right of this vertex
  3.  
  4. attribute vec3 left; //vertex to the left of this vertex
  5. attribute vec3 right; //vertex to the right of this vertex
  6. uniform float aspect;
  7. varying vec3 vNormal;
  8. varying vec2 vUv;
  9.  
  10. void main() {
  11. vNormal = normal;
  12. vUv = uv;
  13.  
  14. mat4 xform= projectionMatrix * modelViewMatrix;
  15. vec4 A = xform * vec4( position, 1.0 );
  16. vec4 B = xform * vec4( left, 1.0 );
  17. vec4 C = xform * vec4( right, 1.0 );
  18.  
  19. vec3 CB = C.xyz - B.xyz;
  20. vec2 BA = B.xy - A.xy;
  21. vec2 CA = C.xy - A.xy;
  22. float lengthBA = length(BA);
  23. float lengthCA = length(CA);
  24. float ratio = lengthBA / ( lengthBA + lengthCA );
  25. vec3 D = B.xyz + ratio * CB.xyz;
  26. vec3 AD = D - A.xyz;
  27. vec3 bisect = normalize(AD);
  28.  
  29. float theta = acos( dot(BA, CA) / (lengthBA * lengthCA) ) / 2.0;
  30. float AE = 1.0/(sin(theta)*aspect);
  31. newPos.z += AE/length(AD) * (D.z - A.z);
  32. newPos.x += bisect.x*AE;
  33. newPos.y += bisect.y*AE;
  34.  
  35. gl_Position = newPos;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement