Calculate object "depth" (pixel based)

Posted By: Superku

Calculate object "depth" (pixel based) - 09/03/14 03:44

I want to calculate or approximate the depth of at least convex objects (concave is a plus) on a per pixel basis, if possible in a multipass object shader (with some Src/ Dest or COLOR2 magic?). 8bit (0..255) accuracy is enough.
I've tried to do this with a separate depth view that renders the models with clockwise culling - which works with a single object - but this approach obviously fails when you have multiple overlapping objects.
Any ideas? Thanks.
Posted By: Superku

Re: Calculate object "depth" (pixel based) - 11/04/14 15:40

One-time bump.
Posted By: Puppeteer

Re: Calculate object "depth" (pixel based) - 12/05/14 16:10

It depends much on what you are actually trying to do.

If you want the accumulated depth of the overlapping objects you could render only those objects in another rendertarget clock wise with inverse depth.

Another option might be distance function based raymarching in the pixelshader of the objects, but you would have to figure out the distance functions of your objects then.
http://www.iquilezles.org/www/articles/distfunctions/distfunctions.htm

What I like to do when i have very simple shapes is just calculate the depth via ray - plane intersections:
Posted By: Superku

Re: Calculate object "depth" (pixel based) - 12/05/14 16:36

Thank you for your response. Sadly this does not really help me, though. The screenshot is cool and I have used that technique for some experiments in the past and recently, but I need the actual (approximated) diameter/ thickness/ whatever on a per-pixel-basis of a rather arbitrarily shaped object in a view which renders multiple objects (which are all transparent).
What I thought could work was to render the entity first, ignoring the Z-buffer and writing the depth data using clockwise culling somewhere else, then grab that value in a second pass and use it to calculate the real pixel output on the screen. I couldn't get that to work yet, though. Hard to describe for me, sorry.
© 2024 lite-C Forums