• Advertisement
Sign in to follow this  

Texture / Memory reservation for Shadows and Lightmaps

This topic is 462 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Numbers, numbers. Remembering "old days", I allocate my texture-buffers somewhat parsimonious, like grandpa saving bread-crumbs in case the Germans would invade again. But do I need to? Of course there is always a limit, but I have no clue where that limit -globally- is. What I do know is that my shadowMaps and lightMaps suck, quality/resolution wise.

Can you give an example of "your numbers" (how much, how big)? Here are my two major cases: ShadowMaps & LightMaps. Currently I have 68 MB reserved for them together. A single 2048 x 2048 R16F shadowMap (an Atlas texture, divided in smaller slots), and 4x a 2048 x 2048 RGBA8 lightMap. Again divided in smaller tiles for various resolutions.

 

LightMaps in particular are interesting, because the size can vary from football fields to a stupid polygon that should be happy with a few pixels. And also vertical (wall) resolutions are common. But how to deal with all those different resolutions, if you want to "pack" things together (atlas, TextureArray, ...)? At least, I suppose you shouldn't be giving each light or surface its own separated texture? Nice thing about my current approach is that I can activate a single or few textures at forehand, and render the whole thing.



Problem with my current Atlas approach, is A: I think it's just too little. Resolutions need to be pretty small to pack everything together, and 68 MB isn't that much for Video Memory nowadays (but... how much is reserved typically???).

And B: the reservation is fixed currently. Obviously large tiles, such as a 1024x1024 lightMap or shadowMap, already eat up a quarter of my entire atlas. So I only reserve 1 or 2 of those. Now, 80% of the time, they aren't used (waste!). And when I do need them, I might want a third big-texture as well maybe, which isn't available. Bummer.

Now I'm thinking about 2D TextureArrays and a more dynamic reservation (reserve whatever is needed at the time, divide in smaller chunks if not needed). Yet, I wonder how others do it. When looking at LightMapping in Unreal4 for example, it doesn't seem to care what numbers you fill in. Then again, I bet something should manage things smartly in the background, otherwise you'll be out of memory in notime, 2048 maps eating up to 32 MB each, if using a RGBA16F format.

Share this post


Link to post
Share on other sites
Advertisement

You dont need to retain everything in the GPU at the same time. You can accumulate shadowing results with a fixed set of shadowmaps. ie, rendering by batches of X amount of lights until you draw all of them. So, it depends on your budget, or how you define it to be. If you want to work with 512Mb of VRAM, you'll have to budget for meshes, render targets, textures, etc accordingly.

Share this post


Link to post
Share on other sites

Well, that happens, sort of. The world is split in chunks, and streamed on the fly. Invisible or unloaded parts won't require slots, and lightmaps are "baked" into a free atlas slot when needed. In fact there is only a single big shadowMap, where multiple smaller ones are baked somewhere inside, making things easy to batch.

 

It's more that I don't have a real feeling what the typical numbers are, these days. I believe the average "modern" platform has about 1024 MB VRAM to spend. So how much of that is approximately spend on shadowMaps or lightMaps? I know there is not an exact answer on that, as it also has to do with importance, size of your world, et cetera. But are we talking about megabytes, tens of, hundreds of...? 

 

I could create a 256 MB LightMap stack (say 16x 2048x2048 RGBA8 - a 2D textureArray). But when dealing with such big numbers, I'm always afraid of choking the GPU, even though I'm not sure if size (amount of slices) really matters here... Which makes me doubt if others are doing it like that at all.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement