   if (sign(determinant(float2x2(v2,v1))) == sign(determinant(float2x2(v2,v3)))) {
                float2 tmp = P[2];
                if (sign(determinant(float2x2(v1,v2))) != sign(determinant(float2x2(v1,v3)))) {
                    P[2] = P[1];  // swap(P2, P1)
                    P[1] = tmp;
                } else {
                    P[2] = P[3];  // swap(P2, P3)
                    P[3] = tmp;
                }
            }

            // Find the "turn direction" of each corner and net turn direction.
            float4 dir;
            float netdir = 0.0;
            for (int i = 0; i < 4; ++i) {
                float2 prev = P[i] - P[(i + 3) & 3], next = P[(i + 1) & 3] - P[i];
                dir[i] = sign(determinant(float2x2(prev, next)));
                netdir += dir[i];
            }

            // sk_VertexID comes in fan order. Convert to strip order.
            int vertexidx = sk_VertexID;
            vertexidx ^= vertexidx >> 1;

            // Remove the non-convex vertex, if any.
            if (dir[vertexidx] != sign(netdir)) {
                vertexidx = (vertexidx + 1) & 3;
            }

            localcoord = P[vertexidx];