Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- attribute vec3 left; //vertex to the left of this vertex
- attribute vec3 right; //vertex to the right of this vertex
- attribute vec3 left; //vertex to the left of this vertex
- attribute vec3 right; //vertex to the right of this vertex
- uniform float aspect;
- varying vec3 vNormal;
- varying vec2 vUv;
- void main() {
- vNormal = normal;
- vUv = uv;
- mat4 xform= projectionMatrix * modelViewMatrix;
- vec4 A = xform * vec4( position, 1.0 );
- vec4 B = xform * vec4( left, 1.0 );
- vec4 C = xform * vec4( right, 1.0 );
- vec3 CB = C.xyz - B.xyz;
- vec2 BA = B.xy - A.xy;
- vec2 CA = C.xy - A.xy;
- float lengthBA = length(BA);
- float lengthCA = length(CA);
- float ratio = lengthBA / ( lengthBA + lengthCA );
- vec3 D = B.xyz + ratio * CB.xyz;
- vec3 AD = D - A.xyz;
- vec3 bisect = normalize(AD);
- float theta = acos( dot(BA, CA) / (lengthBA * lengthCA) ) / 2.0;
- float AE = 1.0/(sin(theta)*aspect);
- newPos.z += AE/length(AD) * (D.z - A.z);
- newPos.x += bisect.x*AE;
- newPos.y += bisect.y*AE;
- gl_Position = newPos;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement