OK, this is not as easy as you think. I would use an effect and two renderTargets for this ... I make sure that I use one rendering step to try to do this, and that will not work. Photoshop has layers, and each layer has an alpha channel. By the way, it would be nice to know which application you are making.
So, first in D3D I would create 2 RGBA_32bit renderTargets of the same size as your window, and clear them to white. Make the array the same (new RenderTarget [2];) for sharing.
Now set the blending state to (AlphaFunc = Add, src = SrcAlpha, Dst = InvSrcAlpha). For the first circle, you draw it in renderTarget [0], using renderTarget [1] as the input source for the texture / sampler. You will have a circle with an effect that will take the color of the circles and multiply it by the color of the sample using renderTarget [1]. After you draw circle one, you change renderTarget [0] with renderTarget [1] by simple indexing, so now renderTarget [1] is the one you draw and renderTarget [0] is the one you choose. Then you repeat the drawing process for circle 2, etc.
After you draw a circle, you copy the last drawn rendering into the backBuffer and represent the scene.
Here is a logical example of how you do this. If you need a coding link http://www.codesampler.com/ , this is a good place.
void TestLayering() { bool rtIndex = false; RenderTarget* renderTarget = new RenderTarget[2]; Effect effect = new Effect("multiplyEffect.fx"); effect.Enable(); BlendingFunc = Add; BlendingSource = SrcAlpha; BlendingDest = InvSrcAlpha; for(int i = 0; i != circleCount; ++i) { renderTarget[rtIndex].EnableAsRenderTarget(); renderTarget[!rtIndex].EnableAsSampler(); circle[i].Draw(); rtIndex = !rtIndex; }
source share