 
       vec4 newPos = inPos + lambda * edge;
       cutPositions[cutPositionCount++] = newPos;
-      emit(newPos, vec4(1, 1, 0, 1));
+      vec4 c = (colorMat * newPos) * 0.5f + vec4(0.5, 0.5f, 0.5f, 0);
+      c.a = 0.5f;
+      emit(newPos, c);  // vec4(1, 1, 0, 1));
     }
   }
 

  EndPrimitive();
}

void processSide(mat4 matrix, vec4 center, vec4 side, vec4 varying1, vec4 varying2)
{
  vec4 triangle[3] = vec4[3](
    matrix * (center + side - varying1 - varying2),
    matrix * (center + side - varying1 + varying2),
    matrix * (center + side + varying1 - varying2));
  processTriangle(triangle);

  triangle = vec4[3](
    matrix * (center + side + varying1 - varying2),
    matrix * (center + side - varying1 + varying2),
    matrix * (center + side + varying1 + varying2));
  processTriangle(triangle);
}

void main()

  }
}

void processTriangle(mat4 matrix, vec4 triangle[3])
{
  const float cutOffZ = 0.4;
  triangleCount = 0;
  isFirst = true;

  mat4 colorMat = inverse(matrix);

  for (int i = 0; i < 3; ++i)
  {
    vec4 inPos = triangle[i];
    if (inPos.z >= cutOffZ)
    {
      vec4 c = (colorMat * inPos) * 0.5f + vec4(0.5, 0.5f, 0.5f, 0);
      c.a = 0.5f;
      emit(inPos, c);  // vColor[0]);
    }
    vec4 nextPos = triangle[(i + 1) % 3];
    if ((nextPos.z < cutOffZ && inPos.z >= cutOffZ) ||
