Sign in to follow this  
yk_cadcg

dx sdk tutorial "State Management" confusing

Recommended Posts

yk_cadcg    100
hi below 2 commented para brings the same render results. It's confusing, since the results should never be the same. Thanks for suggestions.
	ID3D10BlendState* pStateBlend = NULL;
	D3D10_BLEND_DESC descBlend;
	ZeroMemory(&descBlend, sizeof(D3D10_BLEND_DESC));
	descBlend.BlendEnable[0] = TRUE;
	descBlend.SrcBlend = D3D10_BLEND_ONE; //D3D10_BLEND_SRC_COLOR ; the same
	descBlend.DestBlend = D3D10_BLEND_ONE; //D3D10_BLEND_DEST_COLOR ; the same
	descBlend.BlendOp = D3D10_BLEND_OP_MAX;
	descBlend.SrcBlendAlpha = D3D10_BLEND_SRC_ALPHA ;
	descBlend.DestBlendAlpha = D3D10_BLEND_DEST_ALPHA;
	descBlend.BlendOpAlpha = D3D10_BLEND_OP_MIN;
	descBlend.RenderTargetWriteMask[0] = D3D10_COLOR_WRITE_ENABLE_ALL;
	V(g_pd3dDevice->CreateBlendState(&descBlend, &pStateBlend));
	float blendFactor[4] = {0, 0, 0, 0};
	UINT sampleMask = 0xffffffff;
	g_pd3dDevice->OMSetBlendState(pStateBlend, blendFactor, sampleMask);
about CreateBlendState()'s D3D10_BLEND_DESC descBlend: confusing. for anyone of descBlend's SrcBlend,DestBlend,SrcBlendAlpha,or DestBlendAlpha, take SrcBlend for example, the equation is said by SDK to be SrcColor*SrcBlend(BlendOp)DestColor*DestBlend where SrcBlend or DestBlend can be srcColor's or destColor's component, or 0, 1 const, or BlendFactor const(which is set outside in another function OMSetBlendState()). if i use the 2 commented paras, then results should not be max(ps output color, rendertarget's existing color), but rather be max(ps*ps, rt*rt). But i find actual result is still max(ps, rt), which is weird. btw, this tutorial sets State in shader, not in API; but the sdk never gives Shader State spec. [Edited by - yk_cadcg on October 10, 2007 10:03:23 AM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this