Jump to content
  • Advertisement
Sign in to follow this  
thedodgeruk

EXAMPLES OF BLEND STATES ?

This topic is 2568 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i have several blend states depending on what i need , but these are pretty generail

below is an example off one , is there a web site that lists all the major ones so i not have to write them out , and maybee a few odd but good ones


D3D10_BLEND_DESC BlendState;
BlendState.AlphaToCoverageEnable = FALSE;
BlendState.BlendEnable[0] = TRUE;
BlendState.SrcBlend = D3D10_BLEND_SRC_ALPHA;
BlendState.DestBlend = D3D10_BLEND_ONE;
BlendState.BlendOp = D3D10_BLEND_OP_ADD;
BlendState.SrcBlendAlpha = D3D10_BLEND_ZERO;
BlendState.DestBlendAlpha = D3D10_BLEND_ZERO;
BlendState.BlendOpAlpha = D3D10_BLEND_OP_ADD;
BlendState.RenderTargetWriteMask[0] = D3D10_COLOR_WRITE_ENABLE_ALL;

Share this post


Link to post
Share on other sites
Advertisement
The blend mode structure can be represented as a small equation:[font="Courier New"]ShaderOut * SrcFactor [operation] RenderTarget * DstFactor[/font]

Your example configures this equation with the values:
[font="Courier New"]RenderTarget.rgb = ShaderOut.rgb * ShaderOut.a + RenderTarget.rgb * 1[/font]
[font="Courier New"]RenderTarget.a = ShaderOut.a * 0 + RenderTarget.a * 0[/font]

Which is equivalent to the HLSL code (assuming you could read from the render-target in HLSL):
[font="Courier New"]renderTarget.rgb += shaderOut.rgb * shaderOut.a;[/font]
[font="Courier New"]renderTarget.a = 0;
[/font]
Once you're comfortable converting between this fixed structure/equation and the code that it represents, then you can easily turn small snippets of HLSL code into blend-modes instead.

I don't know if the mode you've given as an example has a common name (maybe "alpha additive"?), but the most common ones are:

Multiplicative: [font="Lucida Console"]ShaderOut * RenderTarget[/font] (srcFactor = dst, dstFactor = 0, operation = add)
Additive: [font="Lucida Console"]ShaderOut + RenderTarget[/font] (srcFactor = 1, dstFactor = 1, operation = add)
Subtractive: [font="Lucida Console"]ShaderOut - RenderTarget[/font] (srcFactor = 1, dstFactor = 1, operation = sub)
Alpha: [font="Lucida Console"]ShaderOut*ShaderOut.a + RenderTarget * 1-ShaderOut.a [/font](srcFactor = srcAlpha, dstFactor = InvSrcAlpha, operation = add)
Premultiplied Alpha: [font="Lucida Console"]ShaderOut + RenderTarget * 1-ShaderOut.a [/font](srcFactor = 1, dstFactor = InvSrcAlpha, operation = add)
Darker: [font="Lucida Console"]min(ShaderOut, RenderTarget)[/font][font="Arial"] (srcFactor = 1, dstFactor = 1, operation = min)[/font]
Lighter: [font="Lucida Console"]max(ShaderOut, RenderTarget)[/font][font="Arial"] (srcFactor = 1, dstFactor = 1, operation = max)[/font]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!