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'm implementing direct volume rendering engine with volume bricking, but I'm stuck with this problem:

For each volume brick I render to color render target [CRT] (for visualization) and to data render target [DRT] (used for isosurface object picking). DRT is of the DXGI_FORMAT_R16G16_SINT format. All works fine and smooth except wrong handling of blending DRTs of multiple volume bricks together. Closer brick always occludes further brick DRT.

Here are the pictures to illustrate my point (if the object has proper DRT data it's outlined - as you can se in the highlighted area, there are objects/parts with no data) wrong case with volume bricking enabled no volume bricking, everything is OK

Could somebody please give me a tip, how to handle this? Of course I could always render every brick to separate DRT and write own shader to merge them properly, but isn't there a way of only properly setting blending modes?

(now I'm rendering with blending disabled for DRTs)

Thanks

share|improve this question

1 Answer 1

Direct3D 11 does not support blending for DXGI_FORMAT_R16G16_SINT or any of the other _UINT or _SINT formats. Blending is only available for the _UNORM, _SNORM, and _FLOAT formats. See the full list on MSDN.

I don't know exactly how you're using this data buffer, but it might be simplest to switch to R16G16_FLOAT - it should require no modifications to your shaders or other code, assuming you don't actually need the full range and precision of 16-bit integer values.

If you do need that much precision, you could try R16G16_UNORM or _SNORM, which use 16-bit integers internally but scaled to/from the [0, 1] or [-1, 1] range, respectively, on read/write. Alternatively you could switch to R32G32_FLOAT, which would give you all the range and precision you could want (and more) but would take up twice the memory, and likely also be slower.

share|improve this answer
    
okay, you're right that the format could be changed to some more suitable, but the main question remains. How to setup blending like this: there is value A in destination render target [RT] and value B computed by pixel shader. The result should be A if (B==0) or B in all other cases. Any ideas how to do this bi-polar blending? –  GPUquant May 21 '13 at 9:27
    
@Gpuquant, unfortunately I don't think any of the D3D11 blend modes will do what you describe. Blending isn't programmable, so you're restricted to the operations that can be described by D3D11_BLEND_DESC. –  Nathan Reed May 21 '13 at 17:17
    
@GPUquant It just occurred to me that you might be able to do what you're looking for with discard. If the desired result is that the value in the render target is unchanged whenever the pixel shader outputs zero, you could just have your pixel shader execute a discard in that case, and leave blending turned off. –  Nathan Reed May 23 '13 at 23:10
    
that would be solution only if one render target was bound. The problem is, that I need to do discard independently on multiple render targets - which is not possible I think. –  GPUquant Jul 4 '13 at 14:04
    
@GPUquant No, independent discards aren't possible. You would have to do two separate passes, one for each render target, in that case. –  Nathan Reed Jul 20 '13 at 5:24

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.