Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
sprite:setBlendMode(Sprite.MULTIPLY) — Gideros Forum

sprite:setBlendMode(Sprite.MULTIPLY)

SnowThiefSnowThief Member
edited May 2013 in General questions
Is this possible? Because I can't figure out how to do it.

I have two textures and a shape:

Ground texture (as in the surface of the Earth with roads, fields, houses, etc. seen from above)
Cloud cover texture (also seen from above)
Rectangular shape with alpha 0 (black, but could be any color as alpha 0 makes it completely transparent)

To explain it as simply as I can:

At first all the user sees is the cloud layer texture
The user clicks somewhere
Where the user clicked, I draw the rectangular shape on top of the cloud texture with sprite:setBlendMode(Sprite.MULTIPLY). Now, [255, 255, 255, 255] (white cloud with 255 alpha) * [0, 0, 0, 0] (black rectangle with 0 alpha) = [0, 0, 0, 0] (And since our result alpha = 0, we now have a hole in the cloud.)
I then draw the cloud with the hole on top of the ground texture and the ground is now visible through the cloud where the user clicked! Yay!

Except... it doesn't work. Like, at all. Is there a concept I'm not getting here? I simply don't see what's wrong with my method:

Cloud that has a part of it multiplied with alpha 0 = Cloud with hole
Draw cloud with hole on top of ground

Should I be able to get this to work? I will post code if necessary, but no need if you tell me that it's for some reason impossible.

If it's not possible, what would be another way to achieve letting the user punch holes in the clouds, so the ground is visible through those holes?

Edit: I found someone else pretty much asking the same question: http://www.giderosmobile.com/forum/discussion/comment/7078

ondesic: "Is it possible to draw one image onto another? Let's say I have two images. One image that is entirely black. The other image is a background picture.The black image is loaded onto of the background picture to hide it. Then I want to show the image underneath by punching holes in the black image. Would gideros allow me to do this by drawing transparent images onto the black image?"

atilim: "@ondesic most probably I would put a screen size quad on top of your scene with multiplicative blending (Sprite:setBlendMode(Sprite.MULTIPLY))"

So it should definitely be possible, right?
Sign In or Register to comment.