1

I've been looking at this Volumetric Line shader setup that Philip Rideout created: http://prideout.net/blog/?p=61

Unfortunately, his implementation does not work for OpenGL ES 2. Before I start investigating in depth on how I could do something similar but with an OpenGL ES 2 setup, I would like to discuss how this could be achieved and certainly, if anyone already has this working, maybe they can share some thoughts.

It seems that what would be needed for this to work on OGL ES 2 is creating a set of vertexes that form a triangle strip with the prismoids created from the line information.

1 Answer 1

1

I've done raytraced cylinder impostors like he describes in OpenGL ES 2.0. It's a little trickier than with desktop OpenGL, but it is possible.

To do so, I fed in four vertices for each cylinder (at the starting point of the center line for the cylinder), as well as the direction vector from start to end for the cylinder. In the vertex shader, I displaced the four vertices in screen space to cover the area that would hold the raytraced cylinder. In the fragment shader, I draw out the raytraced representation of that cylinder.

This schematic demonstrates the general process:

Cylinder raytraced impostors

What makes this a little more difficult on OpenGL ES 2.0 is that we don't have the ability to write to gl_FragDepth in order to handle the overlap of two solid cylinders. I ended up doing a pre-pass where I rendered the depth of each fragment of the cylinder to an offscreen texture, then used that depth texture in the raytracing stage to discard non-visible fragments.

A slightly more detailed writeup of this process can be found here, and the source code for my application using this can be downloaded from here. I warn you that the depth and raytracing math isn't perfect for my cylinders in that application, and I'm still working on fixing that.

2
  • Interesting Brad. So the overlap solution you mention, does that produce the chamfer where two cylinders join?
    – Claudia
    Jan 5, 2012 at 19:14
  • @Claudia - Yes, although in my case the overlap was more commonly between a sphere and a cylinder or a sphere and another sphere. The depth value written out as a color for the first pass is the closest depth of any object to the camera at that fragment, so the proper intersection is drawn in the later raytracing stage. You can see the sphere-cylinder intersections in the screenshot here: sunsetlakesoftware.com/image/caffeine-ipad?size=_original
    – Brad Larson
    Jan 5, 2012 at 19:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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