When the player loses all of their lives, I want the entire game screen to go grayscale, but not stop updating immediately. I'd also prefer it fade to grayscale instead of suddenly lose all color. Everything I've found so far is either about taking a screenshot and making it grayscale, or making a specific texture grayscale. Is there a way to change the entire playing field and all objects within to grayscale without iterating through everything?
|
The easiest way to do this is to create a shader for it (See code below). Draw everything to a render target, then use the shader to draw that to your back buffer In your game code record when the player dies, then in subsequent renders interpolate a shader parameter between 1 (full colour) and 0 (full grey-scale) according to
The reason for the 0.3, 0.59 and 0.11 is because the human eye doesn't treat colours equally, those values give a better greyscale image. |
|||||||||||||||
|
|
EDIT After thinking about it, if you are not putting a tint on anything, but using the graphics original colors you could just have (like I state down below) all your colors of drawn objects set to a declared Color variable set to white. (Color NoTint = Color.White;) and then Lerp that if player lives is equal to zero. Every object drawn with the NoTint Color will slowly change (according to your interpolation rate mentioned below) to whatever you are Lerping it to. However if you do have different tints on different objects, the below foreach loop might work. End Edit In my limited knowledge I would try this: Declare the colors you use when drawing specific objects, ex. Color catColor = Color.Brown, then add all of your games colors to a list.
You can even do this for items you draw with no tint and Lerp the Color.White to a Color.Gray. (name that something like Color NoTint = Color.White, and put that on all your drawn objects) There is probably a better way, regardless I hope this helps! |
|||||||
|
