Changing Blend State?

Apr 21, 2014 at 8:19 PM
I'm currently using the VolumeRendering_Desktop sample and I am unsure how you intended for blend states to be changed, I must have missed it in the documentation.

I successfully added my blend state using the following code (SetAlphaBlending is my own method, which I added)
BlendStateConfigDX11 blendConfig;
    blendConfig.SetAlphaBlending();
    int iBlendState = m_pRenderer11->CreateBlendState( &blendConfig );
    if ( iBlendState == -1 ) {
        Log::Get().Write( L"Failed to create alpha blend state" );
        assert(false);
    }
The blend state is added to the stack of blend states. However there are two more blend states before it, from when the renderer initialises.

The blend state works (I cleared the other blend states to test it) but I figured I should ask how this was intended to work.

I was unable to find anything in the documentation (could be that I am just terrible at searching).

Thanks.
Coordinator
Apr 22, 2014 at 1:36 PM
Normally you would create a blend state, and then set it within the an Entity's material for a given view type. For example, here is a code snippet to set the blend state for a VolumeActor:
m_pActor1->GetBody()->GetMaterial()->Params[VT_PERSPECTIVE].pEffect->m_iBlendState = blendState;
It is a little chatty, but this allows you to provide a different pipeline configuration for each type of view in a scene. Sorry that there isn't more documentation available - most of the explanations are in the source code, so you will have to dig around to find out the details. Or of course, you can just ask questions in the discussion forums :)
Apr 22, 2014 at 3:58 PM
Not a problem. If I have trouble finding stuff in the source code I'll probably post a question. I did a quick search but my work around was fine for the time being.

My thanks.