Sign in to follow this  
david w

Texture Overlay

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this