Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


player customized texture color

This topic is 5655 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

I want to add color to the textures on some of my meshes to denote which player owns which object. For example, a red player would hunt down powerups that are noticeably red while a blue player would hunt down noticeably blue powerups. I want the result to look nice, something like ''replace X color on the texture with player color'' or ''tint light areas of the texture with player color''. I''m playing around with ideas and tried changing the mesh''s vertex colors. This tints everything on the texture that''s not pure black; it''s acceptable but pretty ugly. I was poking around in the docs and discovered vertex shaders. Continuing my research I couldn''t help but notice that programming pixel shaders looked fairly assemblyish and terrifying. Anyone know a nice easy way to do something like this? If vertex shaders really are the way to go where can I find some good tutorials? Thanks a bunch

Share this post

Link to post
Share on other sites

Figured it out and vertex shaders were *not* the answer. If you would like to replace the alpha value of a texture with the diffuse color of the material you''re laying it over then:


// Render material diffuse color in place of texture alpha

// (only visible if alphablending is off)


// make sure we can see texture''s alpha

g_pD3DDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, false );

// Set argument 1 to the texture color.

g_pD3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);

// Set argument 2 to the iterated diffuse color.

g_pD3DDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);

// Color operation is to blend arg2 with arg1''s alpha values


Share this post

Link to post
Share on other sites

  • 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!