• Advertisement
Sign in to follow this  

Subtractive Blending - How? (CG)

This topic is 3655 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

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
Advertisement
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
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
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
oh lord!

The Compiler wants "Subtract" instead of "Sub" :-o

I'm gonna try if that works, now...

Share this post


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

  • Advertisement