I've taken the formula for decomposing rgb to luma and come back(it gives different result from a classic rgb->yuv->rgb and it is faster) from here:
https://www.google.it/amp/s/imdoingi...-blacks-3/amp/
The jhon hable tonemapping from here:
http://filmicworlds.com/blog/filmic-...ing-operators/