Archived

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

monkeyography

player customized texture color

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

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

g_pD3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_BLENDTEXTUREALPHA );

Share this post


Link to post
Share on other sites