Multitexturing Multiply Blending Issue

Hello,



I'm playing with multitexturing and I'm experiencing few problems to get what I want.



So I have 3 layers :


  • The background texture
  • A Shadow texture
  • A Mask texture



    What I want is to apply the mask on the shadow layer (to hide some parts), and then multiply the result with the background.

    The thing is I aslo apply an alpha on this result to have a less dark shadow.



    I've tried to use 2 passes with 2 objects, one with the background, and the other with the shadow & mask, and then I use an alphastate between the 2 objects.

    Unfortunately when I try to apply a multiply between the 2, with this alphastate:

as = DisplaySystem.getDisplaySystem().getRenderer().createAlphaState();
as.setBlendEnabled(true);
as.setSrcFunction(AlphaState.SB_SRC_COLOR);
as.setDstFunction(AlphaState.DB_ZERO);
as.setTestEnabled(true);
as.setTestFunction(AlphaState.TF_GREATER);


The multiply doesn't use the alpha value of my shadow texture, and then the shadow is too dark (but masked).

I'm quite lost with the Opengl Blending Functions, how it works... So mayeb you have a better solution or you know where my problem comes from.

Thanks for your help,
Boris