Advertisement Jump to content
Sign in to follow this  

texture blending

This topic is 4903 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post

Link to post
Share on other sites
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.

Share this post

Link to post
Share on other sites
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 colors
Device.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.SetStreamSource(0, vertexBuffer2, 0);

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.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!