Last active
December 15, 2015 18:09
-
-
Save pingortle/5301973 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Surface s = _scene.Find<Surface>(); | |
Texture2D t = MaterialPaintGroup.GetMaskTextures((MaterialGroup)s.Material).OfType<Texture2D>().First(); | |
RenderTarget2D target = new RenderTarget2D(GraphicsDevice, t.Width, t.Height); | |
GraphicsDevice.SetRenderTarget(target); | |
SpriteBatch sb = new SpriteBatch(GraphicsDevice); | |
sb.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, null, null); | |
GraphicsDevice.Clear(Color.Transparent); | |
sb.Draw(t, new Vector2(0f, 0f), null, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 1f); | |
sb.Draw(_dynamicMaskTexture, Vector2.Zero, null, Color.White, 0f, new Vector2(_dynamicMaskTexture.Width / 2f, _dynamicMaskTexture.Height / 2f), 1f, SpriteEffects.None, 1f); | |
sb.End(); | |
GraphicsDevice.SetRenderTarget(null); | |
MaterialPaintGroup.SetMaskTextures((MaterialGroup)s.Material, new List<Texture2D>() { target }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment