Texture Splatting using a DLL?

Blitz3D Forums/Blitz3D Programming/Texture Splatting using a DLL?

Kryzon(Posted 2009) [#1]
Has anybody succeded in doing texture splatting using a DLL, like Tom Speed's?

It gives out SetTextureStageState function but doesn't provide a SetTexture function so that we can specify what texture do we use. I have no C++ knowledge so I wouldn't even dare to make a DLL to cover that up.

PS: The texture splatting method I'm refering to is the one that binds the diffuse map with an external alpha map that you would supply, instead of using the one directly from the diffuse map.


Kryzon(Posted 2009) [#2]
Basically, it would be these same steps:

// Alphamap: take the alpha from the alphamap, we don't care about the color
g_Direct3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
g_Direct3DDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);

// Texture: take the color from the texture, take the alpha from the previous stage
g_Direct3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
g_Direct3DDevice->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE);
g_Direct3DDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
g_Direct3DDevice->SetTextureStageState(1, D3DTSS_ALPHAARG1, D3DTA_CURRENT);

g_Direct3DDevice->SetTexture(0, g_Alphamap);
g_Direct3DDevice->SetTexture(1, g_Texture);

g_Direct3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, g_Vertices, sizeof(QuadVertex));

Is there any way to do this with Tom's DLL? (except the rendering part, which would be the RenderWorld)


MikhailV(Posted 2009) [#3]
See FastExt library and FastExt_Example_TextureBlends.bb example.


Ross C(Posted 2009) [#4]
Texture splatting?


Beaker(Posted 2009) [#5]
http://en.wikipedia.org/wiki/Texture_splatting :)


MikhailV(Posted 2009) [#6]
You can use texture splatting with FastExt without problems. What for again to invent a "bicycle"? :)


Ross C(Posted 2009) [#7]
Ah right, gotcha. Excuse the laziness :P


Kryzon(Posted 2009) [#8]
I'm considering this like a personal challenge (that's why I don't just buy a lib to take care of it). Plus, I end up learning something too.

I managed to get pixel fog running through the simple RenderState changing, so this is doable too (especially Range Fog which is very useful).

The only problem is how to apply the texture stages to the individual textures, like MikhailV did it.

Sehaijyn managed to get it too: http://blitzbasic.com/Community/posts.php?topic=52663


Kryzon(Posted 2009) [#9]
.


Guy Fawkes(Posted 2009) [#10]
nope.

sorry


Kryzon(Posted 2009) [#11]
Nevermind! After some diagnostics, I think I got it....kinda....


MikhailV(Posted 2009) [#12]
Good lad :D


Kryzon(Posted 2009) [#13]
Yeah, I'm still having some trouble with doing it manually but...man...
I was taking a look at those libraries at http://www.fastlibs.com and I gotta say they look amazing!

Using FastExt, with just two calls to their proprietary TextureBlend function, they set up texture splatting with no trouble:

- Just so you know, the grass texture is using an alpha channel from a totally different texture, one loaded simply to provide the external alpha channel.

These libs are fantastic, especially FastExt! they give a whole new level of control over Blitz3D.


MikhailV(Posted 2009) [#14]
Thanks :) This comfortable and quickly!