Skip to content

Instantly share code, notes, and snippets.

@pingortle
Last active December 15, 2015 18:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pingortle/5301973 to your computer and use it in GitHub Desktop.
Save pingortle/5301973 to your computer and use it in GitHub Desktop.
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