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)



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.

  • \$\begingroup\$ 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? \$\endgroup\$ – GPUquant May 21 '13 at 9:27
  • \$\begingroup\$ @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. \$\endgroup\$ – Nathan Reed May 21 '13 at 17:17
  • \$\begingroup\$ @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. \$\endgroup\$ – Nathan Reed May 23 '13 at 23:10
  • \$\begingroup\$ 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. \$\endgroup\$ – GPUquant Jul 4 '13 at 14:04
  • \$\begingroup\$ @GPUquant No, independent discards aren't possible. You would have to do two separate passes, one for each render target, in that case. \$\endgroup\$ – Nathan Reed Jul 20 '13 at 5:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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