texture blending

Started by
1 comment, last by Armadon 18 years, 8 months ago
hi now i am working on a project and i am trying to blend 2 textures form separate vertex buffers.So far i have no idea how to do it. Is possible to blend 2 textures from 2 vertex buffers when the the vertex buffers touch?? tnx
Advertisement
it's possible.vertex buffers and texture buffers are independent from each other.

g_pd3dDevice->SetTexture( 0, Texture0 ); //vertex buffer 0's texture
g_pd3dDevice->SetTexture( 1, Texture1 ); //vertex buffer 1's texture
g_pd3dDevice->SetStreamSource( 0, VertexBuffer0, sizeof(YOUR_VERTEX) );

//blend bla bla

//render bla bla

to get a better answer i think u may write which mesh system u use and how u render it.i think your problem is u dont know how u can access texture and vertex buffers.
Hi there Raxvan,
How are you doing?

[The Problem]
You want to texture blend 2 textures.

[The Solution]
The texture that you assign, is actually telling the device to render with the texture. It has no affiliation with the vertex buffer whatsoever.

So what you can do is the following
1) Set the texture state
//set the operation for the colorsDevice.TextureState[0].ColorOperation = TextureOperation.Modulate;Device.TextureState[0].ColorArgument1 = TextureArgument.TextureColor;Device.TextureState[0].ColorArgument2 = TextureArgument.Diffuse;//set the operation for the alpha values.Device.TextureState[0].AlphaOperation = TextureOperation.Modulate;Device.TextureState[0].AlphaArgument1 = TextureArgument.TextureColor;Device.TextureState[0].AlphaArgument2 = TextureArgument.Diffuse;//set the textures in different stages.Device.SetTexture(0, texture1);Device.SetTexture(1, texture2);//render your primitives here.Device.SetStreamSource(0, vertexBuffer1, 0);Device.DrawPrimitives(...);Device.SetStreamSource(0, vertexBuffer2, 0);Device.DrawPrimitives(...);


You lay a base texture and then in the second texture you make transparent at certain places so that the base texture blends through.

Texture alpha blending.

I hope this helps a bit bud. Take care.

This topic is closed to new replies.

Advertisement