Blending clouds and sun

I have a bitmap containing clouds (blue background with white clouds) and a sun (black background with white sun). How can I blend these to give the effect of the clouds going over the sun but the sun coming out when it goes over the clouds’ blue background?

okay, if u just have a sky plane… it’s pretty easy

draw two quads on the “ceiling”:

farther one will have the sun texture mapped onto it blackpixels => alpha=0 there else alpha=1

closer quad: map the cloud texture to it, alpha=(red+green intensity)/2.0
//this’ll make the blue pixels have alpha=0, and white pixels alpha=1 etc

and u should be done

won’t be the best looking, but u should be done

if u want to learn about good cloud stuff http://www.gamedev.net/community/forums/topic.asp?topic_id=86024

btw, i don’t check this forum often… so if u have a question or something e-mail me.

Thanks a bunch, I will give this a try.