@arctic-fox, is that definately the code you got those results with?
I have been looking at multitexturing for a little while and have managed to 'merge' the blend and texture1. This gives me results as per your code (but *not* in the image) where there is no gradual move from one texture to the other.
When I try to alpha the images together it blends nicely
but darkens the picture.
Here is the code which shows the problem I have :
Strict
SetGraphicsDriver D3D7Max2DDriver()
Graphics 800,600
Global gDriver:TD3D7Max2DDriver = TD3D7Max2DDriver(_max2dDriver)
Local imgGrass:TImage = LoadImage("grass.png")
Local imgDirt:TImage = LoadImage("floor.png")
Local imgMask:TImage = LoadImage("blending.png")
While Not KeyHit(KEY_ESCAPE)
Cls
SetBlend alphaBLEND
SetAlpha 1.0
DrawImage imgGrass,0,0
DrawText "imgGrass",0,0
DrawImage imgDirt,256,0
DrawText "imgDirt",256,0
DrawImage imgMask,512,0
DrawText "imgMask",512,0
DrawImage imgGrass,0,256
DrawImage imgDirt,256,256
If MouseDown(1) Then
SetAlpha 0.6
' SetBlend alphablend
Splat1(imgDirt, imgMask)
DrawImage imgDirt, 0 ,256
gDriver.device.SetTexture 1 , Null
DrawText "imgDirt splat1",0,256
Splat1(imgGrass, imgMask)
DrawImage imgGrass, 256 ,256
gDriver.device.SetTexture 1 , Null
DrawText "imgGrass splat1",256,256
' Else
EndIf
If MouseDown(2) Then
' SetAlpha 0.6
Splat2(imgDirt, imgMask)
DrawImage imgDirt, 0 ,256
gDriver.device.SetTexture 1 , Null
DrawText "imgDirt splat2",0,256
Splat2(imgGrass, imgMask)
DrawImage imgGrass, 256 ,256
gDriver.device.SetTexture 1 , Null
DrawText "imgGrass splat2",256,256
EndIf
Flip
Wend
End
Function Splat1(r_image1:TImage , r_image2:TImage)
Local frame1:TD3D7ImageFrame=TD3D7ImageFrame(r_image1.frame(0))
Local frame2:TD3D7ImageFrame=TD3D7ImageFrame(r_image2.frame(0))
D3D7GraphicsDriver().Direct3DDevice7().SetTexture 0,frame1.surface
gDriver.device.SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
gDriver.device.SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
gDriver.device.SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
D3D7GraphicsDriver().Direct3DDevice7().SetTexture 1,frame2.surface
gDriver.device.SetTextureStageState( 1, D3DTSS_COLORARG1, D3DTA_TEXTURE );
gDriver.device.SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_MODULATE );
gDriver.device.SetTextureStageState( 1, D3DTSS_COLORARG2, D3DTA_CURRENT );
gDriver.device.SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
End Function
Function Splat2(r_image1:TImage , r_image2:TImage)
Local frame1:TD3D7ImageFrame=TD3D7ImageFrame(r_image1.frame(0))
Local frame2:TD3D7ImageFrame=TD3D7ImageFrame(r_image2.frame(0))
gDriver.device.SetTexture 0,frame1.surface
gDriver.device.SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
gDriver.device.SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
gDriver.device.SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
gDriver.device.SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );
gDriver.device.SetTexture 1 , frame2.surface
gDriver.device.SetTextureStageState( 1, D3DTSS_COLORARG1, D3DTA_TEXTURE);
gDriver.device.SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_SELECTARG2);
gDriver.device.SetTextureStageState( 1, D3DTSS_COLORARG2, D3DTA_CURRENT);
gDriver.device.SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );
gDriver.device.SetTextureStageState( 1 , D3DTSS_ALPHAARG1 , D3DTA_TEXTURE ) ;
End Function
I keep coming back to multitexturing and, some day, was hoping for a DX/OGL module where an array of images and texturestates was passed to the function and the results returned.