Multitexturing Multiply Blending Issue


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();

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,