Game Development Community

Grabbing a render target's image data

by Manoel Neto · in Torque Game Engine Advanced · 07/06/2006 (3:55 pm) · 1 replies

I've implemented cubemap "probes" in TSE, which we're gonna use for ambient lighting. It works fine so far: the probes will render dynamic cubemaps around their position once, and my objects can pick the cubemaps from the nearest probes.

Now I need to blur the hell out of those cubemaps, so they can be used as ambient lighting, but I've hit a big wall. Seems blurring a cubemap in realtime isn't as straightforward as I thought it was, and I'm looking for other ways.

I thought about generating mipmaps for the cubemaps after they're done rendering, and use texCUBEbias() to make my shader use smaller mipmap levels, but it looks horrid, since the cubemap edges become visible on small mipmaps, and to make it worse the GPU won't bilinear filter between different cubemap faces.

I've searched the net, and found ATI's CubeMapGen. It's a tool which can generate properly blurred mipmaps for cubemaps. There's a GUI, a command-line interface, and ATI was even nice enough to provide a library (which seems the ideal solution, since I can blur the mipmaps inside Torque itself).

But how do I get to the cubemap's bitmaps? I need to feed them into CubeMapGen, tell it to process them, then refresh the cubemap, but I'm having problems since the dynamic cubemap's surfaces are render targets.

Can anyone with D3D knowledge help?

#1
07/07/2006 (10:52 am)
Alright, got that sorted out. After a few hours alt-tabbing back and forth between the MSDN website and the cubemap code, I managed to grasp all the D3D9 mumbo jumbo required to get onto a render target's mipmap surfaces.

ATI's CubeMapGen work perfectly! After adding a maxMipLevel field to custom materials, I could make them use blurred cubemaps:

img257.imageshack.us/img257/6692/fuzzycubemap8ul.th.jpgFuzzy reflection

Now onto finding a way to save the cubemaps to disc, so I can use texture compression on them...