OGL module?

Here's where to discuss using Stéphane Leys' very well done alternative runtime editor. If you're a control freak at runtime you have to check this out!

OGL module?

Postby Ken Norris » Tue Mar 17, 2009 9:31 pm

Howdy again,

I can't seem to find the OGL module. Is there a tutorial on using OGL graphic shapes?

Ken N.
All the best,
Ken N.
http://fhtinyradio.com/
kenn@fhtinyradio.com
User avatar
Ken Norris
 
Posts: 284
Joined: Mon Nov 03, 2008 7:27 pm

Re: OGL module?

Postby S. Leys » Tue Mar 17, 2009 11:39 pm

Ken Norris wrote:I can't seem to find the OGL module. Is there a tutorial on using OGL graphic shapes?


There is no OGL module. There is a tutorial named "OGL tutorial 4.sc45" in the MPI samples folder.
Xogl is still a work in progress. At the time being I'm working on transparent CSG. After months of hard work I've finally found the way to do depth peeling with the stencil (this technique allows order independent transparency). But this is not yet in the tutorial.

S.
User avatar
S. Leys
 
Posts: 628
Joined: Sun Jul 06, 2008 11:03 am

Re: OGL module?

Postby 1nperson0z » Wed Mar 18, 2009 4:21 pm

At the time being I'm working on transparent CSG. After months of hard work I've finally found the way to do depth peeling with the stencil (this technique allows order independent transparency).


For which Stéphane deserves some kind of award if successful. It's a seriously difficult problem.

Sorry Stéphane, I feel I'm responsible for setting you off on the CSG path and then leaving you to it...

Regards
Ian B
MacBook Pro 2.4Ghz i7 8Gb 10.11.3
1nperson0z
 
Posts: 78
Joined: Wed Jul 09, 2008 3:31 pm
Location: Blue Mountains Australia

Re: OGL module?

Postby S. Leys » Thu Mar 19, 2009 2:30 am

inpersonoz wrote:For which Stéphane deserves some kind of award if successful. It's a seriously difficult problem.

Sorry Stéphane, I feel I'm responsible for setting you off on the CSG path and then leaving you to it...


Don't be sorry, even if it's probably the most difficult problem I ever had to solve, it's also the most interesting (I suspect that the two are linked ;-).

Here is a simple, classic, example.
Three cylinders subtracted from the intersection of a cube and a sphere.
The opaque view
CSG sample 1.jpeg
CSG sample 1.jpeg (15.78 KiB) Viewed 1179 times


Same thing with all primitives transparent
CSG sample 2.jpeg
CSG sample 2.jpeg (13.59 KiB) Viewed 1181 times

This is still limited to 1-convex primitives and one stencil (even if I save and restore it lots of time) i.e. 7 primitives. But I don't despair of having several stencils and thus an unlimited number of primitives (and unlimited calculation time ;-)

I'm glad to have done this parser allowing to mix OGL commands and SuperTalk.
For instance, I can do things like this :
Code: Select all
on setStenFromDepth  PrimList, replval, dpthf
   global icull,iaccum
   enable cull;   enable depthtest;   StencilFunc al,replval;   stencilop keep, keep, repl;      depthmask false
   depthfunc dpthf;   cullface item icull of line 1 of PrimList
   repeat for each line tPrim of PrimList   
      stencilmask 2^ item iaccum of tPrim;      CSGprim item 1 of tPrim
   end repeat
   Stencilop keep,keep,0;   depthfunc =;   stencilmask 255;   cullface back;   CSGprim znear
end setStenFromDepth

enable cull, cullface, Stencilop ... etc are not ST handlers but OGL commands to be passed to Xogl. The parser interprets this script and builds the ST script which will build the list of commands with their arguments and pass this to Xogl which will interpret it and finally execute the commands.

Of course, there are tree layers of interpretation and this is rather slow but it's tremendously faster than having to recompile for any test, it makes prototyping quite fast and easy.
At the time being, I'm working on the normalization of the CSG tree. I already had the opportunity of working with arithmetic trees when doing my XXL spreadsheet but boolean trees are quite different, especially because they can't be solved easily by just unstacking, it's much more difficult to subtract a sphere from a cube than doing 5-3. For instance, (a+b)-c = (a-c)+(b-c), for some reasons, it's much faster to do (a-c)+(b-c) than (a+b)-c, so the tree needs to be arranged.

I can't resist to post another, more elaborated sample.
blue cube + red sphere - large blue cylinder * purple sphere - small bue cylinder - green cylinder
In this view there are 4 levels of transparency i.e. some parts are visible through 3 layers of other parts. This is where depth peeling is essential.

CSG sample 3.jpeg
CSG sample 3.jpeg (11.7 KiB) Viewed 1179 times


BTW, it's nice to be able to post pictures. These forums have some drawbacks but they also have advantages, after all ;-)

S.
User avatar
S. Leys
 
Posts: 628
Joined: Sun Jul 06, 2008 11:03 am


Return to Using MPI

Who is online

Users browsing this forum: No registered users and 1 guest