Multipass, muliply, add, subtract, and blend ratio.

I am working on an openGl plugin for Maya that performs multipass rendering. I have most of it working eccept for a couple of items. I have a psuedo add function by using glBlendFunc(GL_ONE, GL_ONE); I am having difficulty figuring out how to do it in Multiply and subtract modes also.

My limitation is that I have to use only OpenGL 1.2 and don’t have access to GL_ARB_multitexture or any of the cool extenstions.


Morris Olmsted

Multiplicative blending is one of these two. They are the same.


For subtractive blending, use the same blending function as for additive blending, but change the blending equation.

glBlendFunc(GL_ONE, GL_ONE);


[This message has been edited by Bob (edited 03-08-2002).]

Thank you very much for your help.


If I am also trying to perform a sliding ratio for my last pass of my render, where do I adjust the alpha? I mean I don’t see a place where I could substitute a value of my own or use a variable as a multiplicand. I also am needing to perform a devide function too, but as a seperate stepp.


Morris Olmsted

I didn’t mention it. I gave two different blending equations for subtractive blending. The first one is for (source - destination), and the other one for (destin<tion - source), I think. Anyways, have a look in the OpenGL specification for more details.

Crossfading between two passes can be done with glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA). Then use glColor4*(r, g, b, a) (or any other way to set the alpha channel of your objects) to control the blending factor. It’s the alpha channel that decides the amount to blend from the source and the destination. 90% alpha means 90% from the source, and 10% from the destination, added together.