I am trying to implement a "day-to-night"-filter (as commonly used in cinema) for a 2D game (XNA) by using a full screen HLSL pixel shader. The aim is to transform any bright and colorful image into a dark and bluish night version of that image somewhat like:
Conceptually, my ideas would be to:
- Decrease brightness
- Merge blueish tinted greyscale version of image with original image
- Increase contrast
The current shader I came up with is:
// Look up the color of the original pixel
float3 colorOriginal = tex2D(TextureSampler, texCoord);
// Get corresponding greyscale value (adjusted to human vision)
float greyscale = dot(colorOriginal, float3(0.3, 0.59, 0.11));
// Merge and tint
color.rgb = lerp(colorOriginal, colorOriginal * float3(pow(greyscale,6), pow(greyscale,6), pow(greyscale,3)), timeFactor);
The result is still not completely satisfying. How could I improve this?