Game Development Community

a "culling" type of shader??

by deepscratch · in Torque 3D Professional · 01/31/2011 (1:34 am) · 8 replies

hi all,
this is difficult to explain, the effect I need, but here goes:

scenario...
imagine a group of billboards that all use the same texture,
now imagine them overlapping each other,
imagine the textures have alpha,
as the layers of overlap get greater, the color of the most overlapped areas will be darker than the rest.

that is what I would like to avoid,
so I thought that a shader that could only take the top most billboards into acount for rendering, and ignore anything that is under the overlaps,
giving a final appearance of a "singularity", for want of a better word.

ok, pictures that describe the scenario;

first up, what the effect would be without need shader:
img717.imageshack.us/img717/2299/unculled.jpg


the red lines here show the overlapped areas, the blue is what should be rendered only.
img844.imageshack.us/img844/4540/culledside.jpg


and this is the final, shaded effect I am trying to get.
img214.imageshack.us/img214/3088/culled.jpg

notice how the final image is a uniform shade as opposed to the darkening areas of the unshaded effect?
so,
if anyone has any ideas, suggestions or alternative methods to achieve this uniform effect,
please lets hear about it.

thanks

#1
01/31/2011 (5:00 am)
Hey deepscratch,the process you're looking for is called "marching".
Nvidia use a SPH marching in their demonstrations.
#2
02/03/2011 (6:54 pm)
You could render the billboards into its own render bin, have a shader process the output and color every pixel that has a non-zero alpha to any color you want. And then draw that with the rest of the objects - although this only works if you don't really care about occluding other objects.

My Sihouette selection postfx resource based on Matt Jolly's shader code works pretty much the same way, except there's an additional step that checks whether a pixel is on the border of a shape - since it draws a silhouette.

It wouldn't be too hard to do this in a postfx if that'd work for you.
#3
02/04/2011 (12:26 am)
hi Konrad,
yes, I was thinking the same, that shader would work very well,
I noticed though, that its not 1.1beta3 compatable....

what are the chances of getting it to work???

EDIT:
just tried it, there need to be changes done to the resource to compile in 1.1b3 unfortunately.
#4
02/04/2011 (2:44 am)
I'm going to check on it perhaps over this weekend and see what needs to be changed.
#5
02/04/2011 (4:36 am)
awesome,
thanks Konrad,
that would be great.
#6
06/24/2014 (3:06 am)
shameless bumping a very old thread because I am still in need of a shader to do this
#7
06/25/2014 (2:12 am)
Have you tried using the stencil buffer?
#8
06/25/2014 (5:56 am)
stencil buffer??
shaders are my weak point