Not logged in, Join Here! or Log In Below:  
News Articles Search    

 Home / 3D Theory & Graphics / Compressing Shadow Map's Account Manager
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.
Brian Sharpe

April 27, 2005, 12:18 AM

Hi Guys

I work on a renderer that uses depth-array shadow maps
to handle all the shadowing.
These shadow maps are simply an array of doubles. (ie 64bit floats)
( ie, flat shadow map )

Thing is, I want to be able to compress these to
save on memory useage.
( we have a tiled shadowmap scheme that uses a cache to
hold the MostRecentlyUsed shadowmaps. This cache can
only grow to a fixed size in memory before the LeastRecentlyUsed
items start dropping off. )

So my question is, what compression is best for an array of
I was thinking I could save it as an 16bit-RGBA png where
I just take the first 2bytes as the R, 2nd 2bytes as the G
Because PNG is lossless compression, it wouldn't be a problem
getting the exact double back after uncompressing.

Does anybody see a better way of doing this?
Are there any good image-compression algorithms that work on an array
of doubles rather than 8bit or 16bit uints?



April 27, 2005, 03:12 AM

First of all, you should consider whether you really need 64-bit doubles for every shadow map. If you can get away with 32-bit floats for most or even some of them, that's a 50% savings right there.

Second, adjacent values in the depth buffer tend to be similiar in magnitude. You could try a scheme that breaks the buffer up into 4x4 or 8x8 blocks and stores the exponent once and the mantissas individually - falling down to smaller blocks when the depths don't all have the same exponent.

By the same token, depth values tend to vary smoothly except at silhouette edges where they are discontinuous. That makes me think some kind of DCT-based system might be useful - although this is likely to be slower.

This thread contains 2 messages.
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.