View Full Version : Projected shadows/ Blending
I'm projecting shadows for my object correctly and i'm blending it so its translucent but my problem is i'm getting triangles piling up ontop of other tris and making nasty artifacts... i'm turning on backface culling for the shadow and i've tried enabling/disabling DEPTH_TEST , but its still messy... anything i can do to fix this?
08-05-2001, 01:17 PM
There could be a couple different things going on here. For one, unless you have taken measures to prevent it, I suspect you are seeing z-fighting. Secondly, I suspect you are seeing over-blending artifacts when one projected triangle overlays another.
I'll spare you from adding a lot of code and simply tell you that doing shadows the way you seem to be doing them, is a pain. To make them look right you would have to do a lot of code rearranging or at best make some compromises. One simple compromise to prevent most of the z-fighting is to use a very small perpendicular offset to slightly push the shadow off the coincident surface. That won't stop the blending artifacts though. To do that would either require building a complex polygon which would be the union of all the projected shadow polygons, and then just draw the single complex polygon, or you use a stencil buffer to prevent shadows from over-blending.
I suspect your best bet however is to simply toss out what you are using now, and implement stencil buffered shadow volumes or shadow maps.
thanks for the suggestions, i researched both but while i was testing i found a solution...
i create the stencil buffer in the shape of my object, but i draw with alpha_testing on against a texture i know has 100% opague pixels... so it draws nothing into the buffer which is what i want.... next i draw a quad(or 2 tris) into the stencil that fills it completely with blending so its translucent
the result has no artifacts since its just a big blended quad... but is there a better way to draw primitives but with no pixels drawn to the buffer instead of my alpha_test ?
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.