1
$\begingroup$

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!

$\endgroup$
3
$\begingroup$

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.

$\endgroup$
3
  • $\begingroup$ 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? $\endgroup$ – Thomas Feb 4 at 9:02
  • $\begingroup$ @Thomas: I fixed the variable. And all primitive vertex outputs are interpolated (unless you declare them to not be interpolated with the flat qualifier). $\endgroup$ – Nicol Bolas Feb 4 at 14:45
  • $\begingroup$ Thanks a lot! Then I'll try to implement it that way =) $\endgroup$ – Thomas Feb 4 at 15:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.