• ### What is your GameDev Story?

Public Group

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

## Recommended Posts

How can I blend two D3DCOLOR's together to get a new one in between? eg something like this to get the colour thats nearer to the 2nd colour: D3DCOLOR darkgrey = d3d_blend(0xFFFFFFFF, 0xFF000000, 80) I thought about braking it back down into it's 4 components (a, r, g, b) so I can get a point between each pair of values then put it back together but that doesn't seem very effient for something I'll need muliple times every frame...

##### Share on other sites
Quote:
 Original post by Sync ViewsI thought about braking it back down into it's 4 components (a, r, g, b) so I can get a point between each pair of values then put it back together but that doesn't seem very effient for something I'll need muliple times every frame...

If there was/is such a function in D3D(X) then it'll be implemented in software so it won't do it any differently to this. You could easily write your own function which won't be losing efficiency, better yet do it in a shader.

##### Share on other sites
wouldn't taking the average of each value be the same? maybe I'm just imagining things, but taking the average seems to blend it?

edit: to add 'weight', can simply manipulate the average..

i.e., if you want it to be 2 parts black and 1 part white, you can just make a function a la:

D3DCOLOR blend( D3DCOLOR color1, int weight1, D3DCOLOR color2, int weight2 );

and have the rough manipulation be something were you add color1's value multiplied by weight 1 with color2's value multiplied by weight2 and divide by weight1 + weight2.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 19
• 15
• 10
• 9
• 11
• ### Forum Statistics

• Total Topics
634097
• Total Posts
3015510
×