How to make XNA movable mask on WP7
I have two textures开发者_如何学编程: background and mask. I need to make output that mask defines what is revealed form background. Very important part is that mask needs to be less size then background I will move it in runtime revealing parts of background.
Project is on WP7 so there is limited BlendState
manipulation.
You can use the built in AlphaTestEffect with the Stencil Buffer to achieve the masking you are after.
The steps are:
- Clear the stencil buffer
- Draw your mask to the stencil buffer using AlphaTestEffect so only non-transparent pixels are drawn.
- Draw your image using stencil buffer masking.
The Crappy Coding article Texture Modification using Render Targets, with some Stencil Buffer Action shows how to do this and has working sample code.
精彩评论