Multitexturing (Image Included)

BlitzMax Forums/BlitzMax Programming/Multitexturing (Image Included)

FBEpyon(Posted 2005) [#1]
I posted this a longtime ago, but now Im doing it in Minib3d, but I'm not getting any replies back from that forum so if anyone here could help please..

Sorry image not here anymore :(

http://www.blitzmax.com/Community/posts.php?topic=76409 original post...


FBEpyon(Posted 2008) [#2]
Sorry for the double post...

I'm just trying to get some help so if anyone could help please I have been trying to get this figured out for weeks??

I'm trying to get make the texture change with the slops (like rocks on the slops and grass on the flatter areas of the terrain, but someone just please help???

:(


tonyg(Posted 2008) [#3]
I have no idea about minib3d but here is a post with some good multitexturing links and this contains some BlitzMax code to do it.
They're DX examples and, I think, miniB3D is OGL.


FBEpyon(Posted 2008) [#4]
I'm not looking for links, I'm looking for more like a explained way of doing it.. can someone post some more readable code..


plash(Posted 2008) [#5]
DX nor the OGL version will be very readable.

If you missed it.
Function Splat(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



tonyg(Posted 2008) [#6]
...and, in D3D7Max2d and GLMax2d, these are the same statements used when the command setblend lightblend/alphablend/shadeblend/maskblend is used.


FBEpyon(Posted 2008) [#7]
Okay I don't really understand what you ment by the "these are the same statements used when the command setblend lightblend/alphablend/shadeblend/maskblend is used. " which statements are the same..?


tonyg(Posted 2008) [#8]
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 :

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.