ClippingPlane software vs JOGL backend

Have jReality programming problems or questions? Post them here.
Post Reply
STRESS
Posts: 141
Joined: Mon 19. Jan 2009, 12:10

ClippingPlane software vs JOGL backend

Post by STRESS » Mon 1. Jun 2009, 10:43

Are clippingPlane supported in the software backend? I am using a series of local clip planes as a manual screen scissor clipping. It all seems to work fine using the JOGL backend but it doesn't work at all when running the software backend, basically it renders nothing.

User avatar
gunn
Posts: 323
Joined: Thu 14. Dec 2006, 09:56
Location: TU Berlin
Contact:

Re: ClippingPlane software vs JOGL backend

Post by gunn » Thu 4. Jun 2009, 12:17

Quick suggestion: try flipping the clipping planes first (multiply by diagonal matrix (1,1,-1)), maybe the software viewer has the opposite idea of which side of the clipping plane should be clipped away. And if that's the case, we'll get the two backends harmonized (same thing had happened with front and back facing sides of the geometry, which has now been fixed).
jReality core developer

User avatar
gunn
Posts: 323
Joined: Thu 14. Dec 2006, 09:56
Location: TU Berlin
Contact:

Re: ClippingPlane software vs JOGL backend

Post by gunn » Mon 8. Jun 2009, 10:47

I had a bit more time so I looked in the tutorials and found de.jreality.tutorial.geom.ClippingPlaneExample. This example works correctly for both the JOGL and the software backends on my machine. I recommend running it on your machine, verifying that it works correctly for both backends, and then ... compare your code to see if you are doing anything unusual. If nothing reveals itself, post the code if you can reduce it to a readable sample.
jReality core developer

STRESS
Posts: 141
Joined: Mon 19. Jan 2009, 12:10

Re: ClippingPlane software vs JOGL backend

Post by STRESS » Tue 16. Jun 2009, 19:23

Sorry for not replying earlier on this but I've been occupied doing other things lately. Yes the example works the same in JOGL and software. But just make a tiny modification and the behaviour changes completely. For example add following line after ClippingPlane cp = new ClippingPlane() :

Code: Select all

cp.setLocal(true);
Now according to documentation and it should only act on scene nodes that are children of the clip node. It does that in hardware (where there is no clipping at all anymore since the node has no children). But it still behaves globaly in the software backend.

This makes it impossible in the software backend to have a cascade of clip planes. (like left and right)

User avatar
gunn
Posts: 323
Joined: Thu 14. Dec 2006, 09:56
Location: TU Berlin
Contact:

Re: ClippingPlane software vs JOGL backend

Post by gunn » Tue 16. Jun 2009, 20:16

That is a big help in clarifying where the problem lies. Originally all clipping planes were global; I added support for local clipping planes in the JOGL backend, and I suppose that the same feature has not yet been implemented in the software backend.

Local clipping planes turn out to be quite awkward to implement, since they can't be grouped as children of the same node, but have to be arranged ''vertically'' so to speak. Additionally the transformations are complicated that the motion of the clipping plane itself often has to be undone for its children so that only the clipping plane moves. See http://www3.math.tu-berlin.de/jreality/ ... _slice_box for an example which uses local clipping planes.
jReality core developer

STRESS
Posts: 141
Joined: Mon 19. Jan 2009, 12:10

Re: ClippingPlane software vs JOGL backend

Post by STRESS » Wed 17. Jun 2009, 10:34

Thanks for clarifying the problem gunn
Local clipping planes turn out to be quite awkward to implement, since they can't be grouped as children of the same node, but have to be arranged ''vertically'' so to speak. Additionally the transformations are complicated that the motion of the clipping plane itself often has to be undone for its children so that only the clipping plane moves.
Yep I noticed that it makes your head spin a bit when implementing to keep track and it required to add many intermediate nodes, but in the end it works. Even though it is a bit awkward way of doing it at least in the OpenGL way. I personaly would find it better if you could specifying more than one plane at once. Like in the old OpenGL 1.3 fixed function pipeline OpenGL where there are six arbitrary clip planes you can set. Nowadays it is probably emulated via injecting vertex shader code.
See http://www3.math.tu-berlin.de/jreality/ ... _slice_box for an example which uses local clipping planes.
Oh I didn't know that exists but I assume it doesn't work under the software backend either?

User avatar
gunn
Posts: 323
Joined: Thu 14. Dec 2006, 09:56
Location: TU Berlin
Contact:

Re: ClippingPlane software vs JOGL backend

Post by gunn » Wed 17. Jun 2009, 13:36

In rereading this thread, I noticed that perhaps you don't need to use local clipping planes, but were of the opinion that a set of clipping planes (more than one) requires the use of local clipping planes. That's not the case. You can declare your global clipping planes anywhere in the scene graph; they are collected (properly transformed of course depending on where they are in the scene graph) and used to clip the whole scene. Using six to clip to a box works fine, but you can't then draw anything outside the box. It should work also then in the software backend, at least until the local clipping planes are implemented there.
jReality core developer

STRESS
Posts: 141
Joined: Mon 19. Jan 2009, 12:10

Re: ClippingPlane software vs JOGL backend

Post by STRESS » Wed 17. Jun 2009, 14:52

Thanks for the suggestion gunn.

However, I probably didn't fully explain what I am trying to achieve. Actually I don't want to clip everything in my scene just certain objects that's why I need the local feature.

User avatar
gunn
Posts: 323
Joined: Thu 14. Dec 2006, 09:56
Location: TU Berlin
Contact:

Re: ClippingPlane software vs JOGL backend

Post by gunn » Sat 20. Jun 2009, 14:36

I've gone ahead and added support for local clipping planes in the software backend. At least the tutorial example de.jreality.tutorial.geom.SliceBoxExample now works in both viewers. Update from the svn repository to get these changes.
jReality core developer

STRESS
Posts: 141
Joined: Mon 19. Jan 2009, 12:10

Re: ClippingPlane software vs JOGL backend

Post by STRESS » Wed 24. Jun 2009, 10:04

Works perfectly now! Excellent work gunn!

STRESS
Posts: 141
Joined: Mon 19. Jan 2009, 12:10

Re: ClippingPlane software vs JOGL backend

Post by STRESS » Wed 24. Jun 2009, 18:19

Well I am afraid I have to backpaddle a bit there :cry:

1. It seems lines do not get correctly clipped in the software backend. The line clipping removes the line completely if one of the endpoints of the line lies on the opposite side of the clip plane.

2. It seems it still occational affects nodes that are outside it the local clip plane in the software backend. I haven't quite figured out in which relation they have to be to the node that includes the local clip plane.

User avatar
gunn
Posts: 323
Joined: Thu 14. Dec 2006, 09:56
Location: TU Berlin
Contact:

Re: ClippingPlane software vs JOGL backend

Post by gunn » Wed 24. Jun 2009, 19:05

I think at this point we have to wait for the author of the software backend to join the discussion, since the points which you are now bringing up involve code which I wouldn't want to try to edit. The fact that it was relatively simple to get local clip planes more-or-less working gives me hope that fixing the problems you've noticed, won't be too difficult.
jReality core developer

STRESS
Posts: 141
Joined: Mon 19. Jan 2009, 12:10

Re: ClippingPlane software vs JOGL backend

Post by STRESS » Thu 25. Jun 2009, 10:16

gunn wrote:I think at this point we have to wait for the author of the software backend to join the discussion, since the points which you are now bringing up involve code which I wouldn't want to try to edit. The fact that it was relatively simple to get local clip planes more-or-less working gives me hope that fixing the problems you've noticed, won't be too difficult.
Fair enough. It is that not super urgent anyway, it is just something that would be nice if it gets fixed.

Btw I found out what node relations seem to be ill behaving in the software backend. Imagine following graph structure:

Code: Select all

  root Node
     |
     |---> Child Node 1
     |
     |---> Child Node 2 *
     |         |
     |         |----> Child Node 1 of Child Node 2
     |
     ----> Child Node 3

* means node contains a local clip plane
So in the software backend the local clip plane of Child Node 2 seems to affect it's own children but also Child Node3. However Child Node 1 is unaeffect.

User avatar
gunn
Posts: 323
Joined: Thu 14. Dec 2006, 09:56
Location: TU Berlin
Contact:

Re: ClippingPlane software vs JOGL backend

Post by gunn » Thu 25. Jun 2009, 19:02

Well, I looked again at what I had done and discovered (I think) a mistake which would cause exactly the problem you're seeing with the scene graph structure in your post. So, update svn and see if I've managed to remove the bug.
jReality core developer

STRESS
Posts: 141
Joined: Mon 19. Jan 2009, 12:10

Re: ClippingPlane software vs JOGL backend

Post by STRESS » Mon 29. Jun 2009, 14:57

Thanks gunn I will give it a try even though I rearranged my nodes so it doesn't get to the problem anymore but I can juggle them back 8)

Post Reply