Tuesday 22 July 2014

Dual-source blending in DirectX 11

It's not described in the documentation, but dual-source blending in DirectX 11 D3D11_BLEND_SRC1_COLOR is achieved using SV_TARGET1. You would have a BlendState like this (all in fx format):
BlendState CompositeBlend
{
    BlendEnable[0]  =TRUE;
    SrcBlend        =ONE;
    DestBlend       =SRC1_COLOR;
    BlendOp         =ADD;
};
And an output structure that looks like it's writing to two rendertargets. But you only have one rendertarget!
struct TwoColourOutput
{
    float4 add      :SV_TARGET0;
    float4 multiply :SV_TARGET1;
};
And then the pixel shader does:
TwoColourOutput PSMain(v2f IN) : SV_TARGET
{
    TwoColourOutput result =...
    return result;
}
The result - the value in the rendertarget is multiplied by result.multiply, and then result.add is added to it. Viola!

Saturday 19 July 2014

How to remove the annoying "External Dependencies" pretend-folder from Visual Studio

http://stackoverflow.com/questions/2466286/vs2010-how-to-remove-hide-the-external-dependencies-folder-in-solution-explor
On the right side panel expand the Text Editor section, then expand C/C++ and then click on Advanced. Set the Disable External Dependencies Folder to True and restart Visual Studio.