I am trying to implement controllable bloom. By controllable I mean bloom that can be requested even for non-bright pixels by adding the bloom value into a model's texture channel. To do this I need to somehow pass this value (the strength of the bloom for the current pixel) into the bloom post-processor. The most obvious choice would be storing it in the alpha channel, but I use alphablending for every model I draw so for me this is not an option. A quick and dirty solution is to use MRT, render to two textures and then recombine them into one which is a huge waste of memory and speed. Another solution could be to render the scene twice: once for the color and alpha components and second for the bloom components - that is the by-the-book method I find on every internet page. Even when rendering into a smaller RT this is still an overkill.
Another thing I thought about was using YCbCr encoding and then simply increasing Y to order bloom, but I always get a green-ish image after decoding (even if I encode-decode in the very same shader, line after line). Here is the encode-decode operations I did:
inline float3 RGBtoYCbCr(float3 color)
{
float3 YCbCr;
YCbCr.r = color.r*0.299f + color.g*0.587f + color.b*0.114f;
YCbCr.g = 0.5f + (-color.r*0.168f - color.g*0.331f + color.b*0.5f);
YCbCr.b = 0.5f + (color.r*0.5f - color.g*418 - color.b*0.081f);
return YCbCr;
}
inline float3 YCbCrtoRGB(float3 color)
{
float3 RGB;
RGB.r = color.r+1.402*(color.b-0.5f);
RGB.g = color.r-0.344*(color.g-0.5f)-0.714*(color.b-0.5f);
RGB.b = color.r+1.772*(color.g-0.5f);
return RGB;
}
float4 MainShader(...)
{
...
output.COLOR.rgb = saturate(output.COLOR.rgb);
output.COLOR.rgb = RGBtoYCbCr(output.COLOR.rgb);
output.COLOR.rgb = YCbCrtoRGB(output.COLOR.rgb);
}
So I wanted to ask if anyone knows a way to do it in one pass without MRT and (if possible) by still rendering an HDR image?