Jump to content
  • Advertisement
Sign in to follow this  
Sync Views

fadeing between colours

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

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 this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Sync Views
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...

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 this post


Link to post
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.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!