Jump to content
  • Advertisement
Sign in to follow this  
david w

Texture Overlay

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

Im using DirectX 9. I can blur and blend images no problem. What I really need help with is overlaying 2 textures. I think overlay is similar to blending. What I am doing to blend at this moment is take 2 textures lock them and just blend the rgb's to make a blended texture. I think the process must be very similar for overlay, but at this point I dont know how the code would be written to overlay one texture on the other. Does anyone here have any idea how this might be done, with the lock method and traversing the texture by the pitch? Thank you.

Share this post


Link to post
Share on other sites
Advertisement
Well, after a bit more research, I have found out what I want to do. I want to do additive blending, like you would do for say a particle effect, or lens flares. I want to do it without using directx or opengl renderstates. I want to be able to just do it by adding the bitmaps together, by locking them and then doing the additive blending on each pixel.

Does anyone have any idea how to do this?

Share this post


Link to post
Share on other sites
You already said how you want to do it:

"by locking them and then doing the additive blending on each pixel"

so, whats the problem?

Share this post


Link to post
Share on other sites
Ok my exact problem is that I dont really know how to do additive blending. I thought I did but its not working the way I expect. What I am doing right now is.

int alpha = blend;
int inverse_alpha = 255 - alpha;
DWORD Dest_r = red;
DWORD Dest_g = green;
DWORD Dest_b = blue;

DWORD source1_r = red1;
DWORD source1_g = green1;
DWORD source1_b = blue1;

DWORD source2_r = red2;
DWORD source2_g = green2;
DWORD source2_b = blue2;


Dest_r = ((source1_r * alpha) + (source2_r * inverse_alpha))/255;
Dest_g = ((source1_g * alpha) + (source2_g * inverse_alpha))/255;
Dest_b = ((source1_b * alpha) + (source2_b * inverse_alpha))/255;

This is blending two images, but not in the way I expect. I thought that I would get an overlay/additive effect. Like how when you put a bunch of sprites on top of each other, they combine to form a "brighter" image.

Share this post


Link to post
Share on other sites
But he has alpha there. And it is necessary for correct results if alpha channel is used. Some sprites blended without the alpha channel might even show odd things.

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!