<p>The GS is responsible for assigning a particular primitive to a particular layer. The GS is also responsible for writing values for <code>gl_ClipDistance</code> for a particular primitive. So the GS is perfectly capable of doing both of those things: assigning a primitive to a layer and doing the clip-plane computations for that layer.</p>
<p>And if you need to &quot;deactivate&quot; a clip plane for a particular primitive assigned to a particular layer, just assign the <code>gl_ClipDistance[i]</code> for that to 1.0 for all of its vertices.</p>

CC BY-SA 4.0
2021-02-04T09:02:22.220Z
only to be sure... do you meen gl_ClipDistance[] instead of gl_ClipPlane[]?  Does the distance value be interpolated for the triangle during the rasterization step?
Thomas
CC BY-SA 4.0
2021-02-04T14:45:32.430Z
@Thomas: I fixed the variable. And all primitive vertex outputs are interpolated (unless you declare them to not be interpolated with the `flat` qualifier).
Nicol Bolas
CC BY-SA 4.0
2021-02-04T15:53:52.270Z
Thanks a lot! Then I'll try to implement it that way =)
Thomas
CC BY-SA 4.0
2021-02-03T21:49:28.497Z
2021-02-04T14:27:07.443Z
2021-02-04T14:27:07.443Z
Nicol Bolas
<p>I want to render a scene from multiple positions and orientations. I think the geometry shader is a good choice to not use the Vertex and tessellation shaders for each camera position again. So I want to do layered rendering. I already did that once, but this time I simultaneously want to use additional clip planes. Each camera position has its own clip planes, which should not be visible from other cameras.
My question: is it possible to define clipPlanes (glClipPlane) for a specific layer? Or is it better to do that during the fragment shader step, by doing dot-product, check the sign and discard if necessary?
Does I have other options (except: rendering the scene in a loop for each position / orientation)?</p>
<p>Thanks a lot!</p>

<opengl><clipping>
OpenGL layered rendering with multiple additional clip planes per view
Thomas
# OpenGL layered rendering with multiple additional clip planes per view

(Asked by: username_0 on 2021-02-03)

I want to render a scene from multiple positions and orientations. I think the geometry shader is a good choice to not use the Vertex and tessellation shaders for each camera position again. So I want to do layered rendering. I already did that once, but this time I simultaneously want to use additional clip planes. Each camera position has its own clip planes, which should not be visible from other cameras.
My question: is it possible to define clipPlanes (glClipPlane) for a specific layer? Or is it better to do that during the fragment shader step, by doing dot-product, check the sign and discard if necessary?
Does I have other options (except: rendering the scene in a loop for each position / orientation)?

Thanks a lot!

**Tags:** opengl, clipping


---

## 1 answers

### Answer by username_1 on 2021-02-03. Score: 3 | Accepted answer

The GS is responsible for assigning a particular primitive to a particular layer. The GS is also responsible for writing values for `gl_ClipDistance` for a particular primitive. So the GS is perfectly capable of doing both of those things: assigning a primitive to a layer and doing the clip-plane computations for that layer.

And if you need to "deactivate" a clip plane for a particular primitive assigned to a particular layer, just assign the `gl_ClipDistance[i]` for that to 1.0 for all of its vertices.

> **Comments:**
> **username_0**: only to be sure... do you meen gl_ClipDistance[] instead of gl_ClipPlane[]?  Does the distance value be interpolated for the triangle during the rasterization step?  
> **username_1**: @username_0: I fixed the variable. And all primitive vertex outputs are interpolated (unless you declare them to not be interpolated with the `flat` qualifier).  
> **username_0**: Thanks a lot! Then I'll try to implement it that way =)  

---

