PDA

View Full Version : Multisampling failing in shadow volume



kitfox
01-05-2010, 07:30 PM
I'm having some trouble getting multisampling to work properly in a 3D shadow volume I'm implementing.

This is a hobby project based on the renderer described in GPU Gems (chapter 39). It takes a 3D texture and renders it into a series of slices. To achieve a shadow effect, these slices are parallel planes which are normal to the half vector between the viewer and the light and clipped to the bounding cube. They are drawn with translucency so the image is built up one layer at a time.

Unfortunately, my result is suffering from a bad case of jaggies where the planes clip to the edges of the cube. Part of this is unavoidable, since each slice casts a shadow onto the layer below it, and since the planes are not perpendicular the viewer, you will see a bit of the cast shadow.

I thought I could disguise this by adding multisampling. While multisampling itself seems to work (the wireframe I draw around the shadow volume is anitaliased correctly), the slices themselves have jagged edges.

I am creating my buffers with sample buffers enabled and a sample size of 8. I am calling glEnable(GL_MULTISAMPLE) before doing my drawing. You can see the way it is implemented here:

http://kenai.com/projects/volumeviewer/s...anel.java?rev=4 (http://kenai.com/projects/volumeviewer/sources/source-code-repository/content/proj/VolumeViewer/src/com/kitfox/volume/viewer/ViewerPanel.java?rev=4)

You can run the current implementation here (Select Demo/Opaque to see a clear example of the jagged lines):

http://volumeviewer.kenai.com/

If you wish, you can even download the project by going to:

http://kenai.com/projects/volumeviewer/sources

zeoverlord
01-06-2010, 04:05 AM
Simply put, multi sampling works on polygon edges and rarely on textures that uses alpha testing

ZbuffeR
01-06-2010, 04:12 AM
For alpha to be multisampled, search for alpha to coverage.