What I am looking for is the following: I have a circle on a square image, alpha is 0 at the corners

enter image description here

and also a square shadow, alpha is 0 everywhere else

enter image description here

I would like to have as final result a blending of these two renders, plus the shadow not being rendered outside the circle

How could I achieve that?

  • 1
    \$\begingroup\$ "blending of these two renders" What does that mean? What kind of "blending" are you looking for? \$\endgroup\$ Jun 22, 2012 at 23:25
  • \$\begingroup\$ Could you provide a picture of what you're trying to achieve? \$\endgroup\$ Jun 25, 2012 at 15:31
  • \$\begingroup\$ @NicolBolas I mean, the shadow over the circle, like this dl.dropbox.com/u/1401029/Result.png but "masking" the shadow over the circle \$\endgroup\$
    – elect
    Jun 26, 2012 at 9:04
  • \$\begingroup\$ @lorancou dl.dropbox.com/u/1401029/Result.png \$\endgroup\$
    – elect
    Jun 26, 2012 at 9:05
  • \$\begingroup\$ @elect I don't get it, is that what you want, or what you've achieved so far? \$\endgroup\$ Jun 26, 2012 at 10:32

1 Answer 1


What you probably want is a stencil buffer. Render your circle with stencil write, and then change opengl state so that only the bits that have the stencil bits on should be updated, and then render your shadow thingy.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .