Here is the code I am using to create the new texture where terrain is the object containing and responsible for rendering the terrain, and crater is the object containing and responsible for rendering the crater.
// Render to texture the crater
this.crater.Position = position;
RenderTarget2D renderTarget = new RenderTarget2D(device, this.terrain.Texture.Width, this.terrain.Texture.Height);
device.SetRenderTarget(renderTarget);
device.Clear(Color.Transparent);
// first pass set the collision point
SpriteBatch spriteBatch = new SpriteBatch(device);
//spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Opaque, SamplerState.LinearClamp, DepthStencilState.Default,
// RasterizerState.CullNone);
spriteBatch.Begin();
this.terrain.render(spriteBatch);
this.crater.render(spriteBatch);
spriteBatch.End();
// second pass make the collision point transparent
?
this.terrain.Texture = (Texture2D)renderTarget;
device.SetRenderTarget(null);
this.textureColourData = TextureUtils.getColourData2D(this.terrain.Texture);
}
Here is the resulting image after the terrain has been hit twice.
Uploaded with ImageShack.us
If anyone could point me in the direction of the second pass for changing these pixels to transparent that would be great. Please note I also tried just manually going through the textures Color data but this is noticeably slow.
Any help would be great.
Thanks.