<p>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.</p>
<p>My fragment shader currently does something along the lines of:</p>
<pre><code>float dot = dot(world_coordinate, normalize(clipping_normal.xyz)) - clipping_normal.w;
if (dot &gt; 0.0f) 
    discard;
</code></pre>
<p>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...</p>
<p>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:</p>
<p><a href="https://i.sstatic.net/omrFH.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/omrFH.png" alt="cross-section" /></a></p>

CC BY-SA 4.0
2019-03-01T03:58:37.083Z
Please don't [cross post to different stack exchange sites](https://gamedev.stackexchange.com/questions/168510/show-the-edges-between-the-clipping-plane-and-clipped-objects).
user1118321
CC BY-SA 4.0
2019-03-02T09:57:09.857Z
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 [gamedev.se] has been clarified but this one has not. Since your question there now has more information, I'm going to close this copy.
Dan Hulme
CC BY-SA 4.0
2019-03-02T09:57:56.920Z
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.
Dan Hulme
<opengl><shader><glsl><fragment-shader>
Show the edges between the clipping plane and clipped objects
graphics_guy
# Show the edges between the clipping plane and clipped objects

(Asked by: username_0 on 2019-02-28)

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) 
    discard;

```

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:

[![cross-section](https://i.sstatic.net/omrFH.png)](https://i.sstatic.net/omrFH.png)

**Tags:** opengl, shader, glsl, fragment-shader

> **Comments:**
> **username_1**: Please don't [cross post to different stack exchange sites](https://gamedev.stackexchange.com/questions/168510/show-the-edges-between-the-clipping-plane-and-clipped-objects).  
> **username_2**: As username_1 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 [gamedev.se] has been clarified but this one has not. Since your question there now has more information, I'm going to close this copy.  
> **username_2**: 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.  

---

## 0 answers

