In D3D7Max2D module the setblend method uses the SetTextureStageState commands to change the way textures are drawn. For setblend the commands are used on a single texture : Single texturing. For multitexturing the same commands are used but it takes the result of one texture blend and then applies it to the next texture blend.
In short, for multitexturing, you
a) Take an image
b) Apply a blend type using the colour and alpha arguments you require.
c) Use the result as input to the next stage
d) Apply a blend type using the colour and alpha
arguments you require.
e) Result is a 'blended' texture resulting from multiple textures.
I have commented the following code :
Function Splat(r_image1:TImage , r_image2:TImage)
' Declare frame1 and frame2 to hold the frame for the images to be used in the multitexture.
Local frame1:TD3D7ImageFrame=TD3D7ImageFrame(r_image1.frame(0))
Local frame2:TD3D7ImageFrame=TD3D7ImageFrame(r_image2.frame(0))
' We start with the first stage (STAGE 0) of our multitexture operation.
' Set the texture to be applied to the surface of frame1
gDriver.device.SetTexture 0,frame1.surface
' Input ARG1 for the colour is the texture used in the settexture command,
gDriver.device.SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
' For the colour operation use ARG1 (e.g. our texture)
gDriver.device.SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
' Input ARG1 for the alpha is the texture
gDriver.device.SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
' For the alpha operation use ARG1 (e.g. our texture)
gDriver.device.SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );
' So far we have done nothing except input our texture without changing it.
' BUT we have now have it available to be used in our second stage of the multitexture
' STAGE 1
' Set the texture to be applied tp the surface of frame2
gDriver.device.SetTexture 1 , frame2.surface
' The *new* texture set in the command above is now set to ARG1 for the colour operation.
gDriver.device.SetTextureStageState( 1, D3DTSS_COLORARG1, D3DTA_TEXTURE);
' However, we are taking the colour from ARG2
gDriver.device.SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_SELECTARG2);
' ARG2 is set to 'Current' which is the texture resulting from the previous stage.
gDriver.device.SetTextureStageState( 1, D3DTSS_COLORARG2, D3DTA_CURRENT);
' The alpha is taken from ARG1
gDriver.device.SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );
' Alpha ARG1 is taken from our texture
gDriver.device.SetTextureStageState( 1 , D3DTSS_ALPHAARG1 , D3DTA_TEXTURE ) ;
'The result is a single texture blended from 2 images input and saved in the second image.
End Function
Hope it helps but I can't explain it any better than the links I gave.
I found 'Special Effects Game programming with DirectX' and 'Beginning openGL' useful for this sort of thing,.
The MFCTEX, D3DMultex and OGLMulTex are useful to see the results of blend operations and provide the code that just needs a little changing for Bmax use.