Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I want to create a render target that is 32-bit, with 16 bits each for alpha and luminance. The closest surface formats I can find in the DirectX SDK are:

D3DFMT_A8L8    // 16-bit, 8 bits each for alpha and luminance.
D3DFMT_G16R16F // 32-bit float, 16 bits for red and 16 bits for green.

But I don't think either of these will work, since D3DFMT_A8L8 doesn't have the precision and D3DFMT_G16R16F doesn't have an alpha channel (I need a separate blend state for alpha).

How can I create a render target that allows a separate blend state for luminance and alpha, with 16-bit precision on each channel, that doesn't exceed 32-bits per pixel?

share|improve this question
1  
I think your only choice is to use multiple render targets for this approach. –  r2d2rigo Jun 21 '11 at 18:35
    
That's a good suggestion, worth looking into. What about encoding a float into 2 channels? Like, putting luminance in RG and alpha in BA in a R8G8B8A8 render target. Are there good examples of this anywhere? –  J Junker Jun 21 '11 at 22:52
    
@Junker If that were possible (and Id swear at the end of the day it should be but my knowledge of DirectX is dated) why wouldnt you use the G16R16F format? –  James Jun 21 '11 at 23:31
    
I'm also looking at getting this working on another target platform, and it turns out it doesn't support G16R16F, so I'm hoping to find a way to encode 2 8bit channels into a 16 bit channel and still support the blend modes for downsampled translucency –  J Junker Jun 22 '11 at 16:53
    
HLSL shaders are ignorant of the implementation of the datatype they are stored in, so you couldn't really bit twiddle it into two floats. And trying to jam it in there otherwise will be error prone and won't likely match up to the same 16 bits that you'd expect. You could use MRT's and two R32F textures however. –  Arelius Jun 23 '11 at 0:19

1 Answer 1

There are no formats with a 16-bit alpha channel except for D3DFMT_A16B16G16R16F.

Even if you could deal with encoding the luminance elsewhere, you'd also have to do similar tricks with alpha for your separate blend requirements, but the blend stage wouldn't understand those tricks and would produce unintelligible data.

I would suggest resorting, as suggested in the comments, to multiple render targets and a 'recombine' step.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.