Sign in to follow this  
nicmenz

Subtractive Blending - How? (CG)

Recommended Posts

nicmenz    169
Hi, what I want to do is to compute an object's thickness using the method proposed in "The naked truth behind Nvidia's Demos". For this purpose I first have to render all front facing polygons additively, then all back-facing polygons subtractively. I use this code for additive blending, is this correct and what is the code for subtractive blending?
ZEnable = true;
ZWriteEnable = true;
ZFunc = LessEqual;
AlphaBlendEnable = true;
AlphaFunc = GREATEREQUAL;
//BlendOp = Sub; // What is this? There is no "Add" by the way
SrcBlend = SrcAlpha;
DestBlend = InvSrcAlpha;
CullMode = CW;

please help ;) Greetings, Nick

Share this post


Link to post
Share on other sites
Ysaneya    1383
The code for subtractive blending is the line you've commented out. Any recent (understand: less than 6 years old) video card has hardware functionality to change the blending operation. By default, it is additive, but there's subtractive blending too. For example in OpenGL, you can check the GL_EXT_blend_subtract or GL_EXT_blend_equation_separate extensions.

Y.

Share this post


Link to post
Share on other sites
nicmenz    169
hi,

thanks for your reply but I made a mistake in my posting: For the parameter "BlendOp=" there's obviously only the value "Add", when I change it to "Sub" the compiler gives an error.


ZEnable = false;
ZWriteEnable = false;
ZFunc = GreaterEqual;
AlphaBlendEnable = true;
AlphaFunc = GREATEREQUAL ;
//BlendOp = Add; // PROBLEM: Compiler says SUB doesn't exist
SrcBlend = SrcAlpha;
DestBlend = InvSrcAlpha;
CullMode = CCW;



Is there a possibility to make subtractive blending using the "ScrBlend" and "DestBlend" Values??

Share this post


Link to post
Share on other sites
Gooberius    226
No, you can't use Src/Dest blend values because the blend operations works like this:

pixel = SrcFactor * SrcValue op DestFactor * DestValue

You need to change "op" (which can be add, sub, min, max, maybe some others I forgot), changing the src/dest values will only change the multiplicative bits of that equation.

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