Jump to content
  • Advertisement
Sign in to follow this  
Raxvan

texture blending

This topic is 4834 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
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.

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.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.

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!