Something I'm wondering about, that's probably not possible unfortunately, but thought I'd ask - I'm setting up a deferred lighting shader that takes in 2 textures and outputs to 2 render targets. Their channels are:
Input Tex 1: Color Texture
Channel 1: R
Channel 2: G
Channel 3: B
Channel 4: A
Input Tex 2: Normal + Specular Texture
Channel 1: X
Channel 2: Y
Channel 3: Z
Channel 4: Specular Amount
Output Target 1: Color Target
Channel 1: R
Channel 2: G
Channel 3: B
Channel 4: A
Output Target 2: Normal+Specular Target
Channel 1: X
Channel 2: Y
Channel 3: Z
Channel 4: Specular Amount
Pretty simple. Except - when outputting to the Normal+Specular target, I want to mask the pixels that are written using the Color texture's alpha channel to control the amount of blending. But - I'm outputting a vector4 as my second color from the shader, whose channels are all used up.
So is there any way of having Direct3D use an alpha value temporarily as a blend parameter, use it to "mask" my 4 norm+spec channels, then discard it after use? Or to have render target 2 use render target 1's alpha as its blend parameter?
I know I can represent a normal vector using only 2 components - e.g. store X & Y then recalculate Z on the fly - but the process would be simpler & probably perform better if I could get away with leaving them unchanged - so hoping to find a solution that way.
Thanks!
So, to follow up on this one - I ended up just encoding the XYZ normals into two components using a Spheremap transform technique (#3 mentioned on the page http://aras-p.info/texts/CompactNormalStorage.html#method03spherical ).
So I'm writing the same alpha value to both targets to control blending - couldn't find any other way.