Trouble mixing modern and legacy OpenGL

Hi,

TL;DR : I can’t apply glClipPlane to a VBO which rendering is handled by shaders.

I develop Jzy3D, a library for 3D charts in Java. I use legacy OpenGL (1 & 2) as often as I can as I find it easy to understand and portable on old or low cost computers.

I recently started adding shader based rendering mainly to add the dual depth peeling as demonstrated by Louis Bavoil.

I can make it work properly except that clipping planes are not applied properly (see below). I wonder if there are recommandations to better mix legacy and modern OpenGL? E.g. should I implement clipping inside the vertex shader of the depth peeling algorithm?

The case I try to render is a VBO made of polygons which looks as follow when unclipped

Standard rendering (no depth peeling) with clipping properly applied
The geometry is clipped properly, but some polygons are not rendered as I don’t have depth peeling enabled and as they are farer than other.

Weighted Average Peeling with clipping glitch
Polygons are all properly rendered without having to care about their rendering order, but clipping is not applied properly.

Here is the depth peeling implementation I am using

The scene graph has a draw method that simply invokes clipping planes.

Yes, that is expected. You are using shaders and that means the vertex processing is now up to your shader instead of the legacy fixed function pipeline. See the bottom of this wiki page for the gl_ClipDistance[] variables that allow you to inform the GPU how far each vertex is away from a clip plane.

1 Like

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.