We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
Transparent Globe (Read 1415 times)
Transparent Globe
Feb 4th, 2008, 10:11pm
 
Hi all, I've taken Mike Chang's OpenGL Textured Sphere example and hacked it up a bit.  One particular bit of shininess that I'd like to implement would be a transparent globe.  Not entirely transparent, just enough to make it look interesting.

Now, I've tried many different ways.  The most simple way was to create a PNG with alpha mask.  In this example, I use a very harsh alpha mask, despite what I said above.

Here are the results as I rotate the globe along the Y-axis.  As a place marker, Hawaii is the Purple/pink colored dot.

You'll see in the first image, you should be able to see Africa on the reverse side of the globe.  But nothing appears:

http://img292.imageshack.us/img292/1466/globe1ik2.gif

As the globe is rotated, bits of the continent become visible, but are displayed in a weird, interlaced pattern.

http://img166.imageshack.us/img166/4882/globe2hd6.gif

http://img125.imageshack.us/img125/3526/globe3ld5.gif

http://img116.imageshack.us/img116/3597/globe4rr0.gif

Finally, when the globe's low polar coordinate passes the X-axis, everything behaves fine.  But only when the globe is rotated in such a way.

http://img102.imageshack.us/img102/9103/globe5sk4.gif

Any thoughts?
Re: Transparent Globe
Reply #1 - Feb 4th, 2008, 10:21pm
 
If anyone else would like to try this out, here's the PNG that I'm using.  Just plug it into Chang's example (included with Processing), and set background(255).

http://img218.imageshack.us/img218/7784/world32ktl6.png
Re: Transparent Globe
Reply #2 - Feb 5th, 2008, 9:08pm
 
Hey there

You can use these two commands to control culling and normals:

Code:

gl.glFrontFace(GL.GL_CCW);
gl.glEnable(GL.GL_CULL_FACE);
Re: Transparent Globe
Reply #3 - Feb 6th, 2008, 5:52am
 
Interesting, thank you mflux.  The glFrontFace command allows me to specifically set which side of the polygons are front and back.  The front ones appear to have priority.  When I set the 'front' to GL_CCW, the polygons that originally had priority completely disappear.  What I'm left with is a completely transparent sphere, with the inside polygons always visible.

So this solves one problem, rendering the inside polygons without interlacing or tearing.  But I'd like to render the outside polygons too.

I might try adding two sphere, one inside with GL_CCW enabled, the outside with it off.  This might work out just fine.

Thanks for the help!
Re: Transparent Globe
Reply #4 - Feb 6th, 2008, 5:57am
 
Oh yes, that worked quite nicely.  A bit of a hack but it shouldn't take much more time to render, theoretically its the same amount of polygons.

Thank you so much for your help, this looks beautiful.
Re: Transparent Globe
Reply #5 - Feb 7th, 2008, 9:01am
 
Glad it worked.

FYI GL_CCW means to draw the polygon counter-clockwise. From a graphics perspective, this makes the normals one direction. GL_CW is clockwise, so it flips the normals.

http://www.webreference.com/3d/glossary/normal.html
Page Index Toggle Pages: 1