September 11, 2017 · analysis

Don't be afraid of the dark II

Two and a half years ago, the darkness mode was improved to support multiple players as the original only works with one player.

This effect has worked well since then but recently it was reported that some Ubuntu machines produce corrupted RenderTarget textures.

Up until today, it worked by:

Now, this is all done in the Pixel Shader without the need for the RenderTarget!

Usage is simple, just pass a couple of parameters to the shader and draw.

pixelShader.CurrentTechnique = pixelShader.Techniques["DARK"];
spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, null, pixelShader);
spriteBatch.Draw(darkness, new Vector2(PuzzleBounds.X, PuzzleBounds.Y), PuzzleBounds, Color.White);

This approach makes the code cleaner (by simply not have an additional RT) and fixes the effect on Ubuntu machines.

Night time!
Darkness mode!



Also a Lode Runner fan. A fan that gets to write the most important parts!