I want to utilize shaders to not only discard fragments if they are on one side of a predefined plane but also render a contour along the intersection.

My fragment shader currently does something along the lines of:

float dot = dot(world_coordinate, normalize(clipping_normal.xyz)) - clipping_normal.w;
if (dot > 0.0f) 

this works but without the desired contour. I tried comparing the dot product against values close to 0.0 but this results in a contour with varying width depending on view etc...

This is what I am trying to achieve. Notice that the white contour/edge of where the plane intersects the sphere is of consistent width:


  • 1
    $\begingroup$ Please don't cross post to different stack exchange sites. $\endgroup$ – user1118321 Mar 1 '19 at 3:58
  • $\begingroup$ As user1118321 said, don't do that. It results in information and answers being split up between different places, making it harder for people to find information, and wasting the effort of answerers. You can already see this because your question on Game Development has been clarified but this one has not. Since your question there now has more information, I'm going to close this copy. $\endgroup$ – Dan Hulme Mar 2 '19 at 9:57
  • $\begingroup$ While this question is on-topic, I'm closing because it's a cross-post of a question on another site, which has received more edits and clarification on the other site. $\endgroup$ – Dan Hulme Mar 2 '19 at 9:57