Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
"blending of these two renders" What does that mean? What kind of "blending" are you looking for? – Nicol Bolas Jun 22 '12 at 23:25
Could you provide a picture of what you're trying to achieve? – Laurent Couvidou Jun 25 '12 at 15:31
@NicolBolas I mean, the shadow over the circle, like this but "masking" the shadow over the circle – elect Jun 26 '12 at 9:04
@lorancou – elect Jun 26 '12 at 9:05
@elect I don't get it, is that what you want, or what you've achieved so far? – Laurent Couvidou Jun 26 '12 at 10:32
up vote 2 down vote accepted

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.