Hey guys, nexzstac informed me that my code was wanted so here I am I guess. Sorry to have disappeared for a long time. Hi JawZ!
Anyway I figured that instead of spend days cleaning up my own file for a new release and making you guys sort through it all, it would probably be easier for everyone if I just gave you the tonemapping algorithm and let you implement it the way you want. Some info on the code, it is an implementation of the math found here:
http://www.cg.tuwien.ac.at/research/the ... ode34.html
and it was NOT designed by me. I tried to do it myself but it turns out someone had already done it better than I could have, so I converted it to HLSL and made it work with ENBSeries. I separated it into its own function to make it easier to use, as far as I know there is no point in modifying the function itself at all. So you probably shouldn't change the code. If you want to use it, you would call the function under the "#if POSTPROCESSING == #" thingy and pass in the external parameters of the same names as the ones used in the function declaration.
Using adaptation is mandatory if you are going to use this postprocessing method (and any proper tonemapping method HAS to use adaptation for a correct result), but IMO it is worth it as it produced great results in my testing, it is my favorite tonemapping algorithm that I have worked on so far.
You guys at this point probably know more about doing proper saturation, brightness, contrast and gamma conversion stuff than I do so I left that stuff out, you can add it on your own.
Here is the code then:
Code: Select all
float3 tonemap(in float3 color, in float grayadaptation )
{
#define scalef(Lmax, Lwa, scale)\
scale = 1.f / Lmax * pow ( (1.219f + pow(0.5f * Lmax, 0.4f)) / (1.219f + pow(Lwa, 0.4f)) , 2.5f);
float L_display_max = 1.0f; // maximum display luminance
float scale; // scale factor
// compute world adaptation level
float L_wa = grayadaptation;
scalef(L_display_max, L_wa, scale);
// multiply pixel values with scale factor and clip if necessary
color*=scale;
return saturate(color);
}
Yeah, it's weird looking but there should be no reason to change it anyway so it doesn't matter.
Place the function in the section of the enbeffect.fx file just under the end of the postprocessing method options (or anywhere as long as it's not inside another function and is above the main enb shader functions).
Here is how to call the function if you don't already know:
Code: Select all
color.xyz = tonemap(color.xyz, grayadaptation);
Hopefully it works and someone can get some use out of it.
Cheers, and let me know if I can help you guys with anything. I will try to be more active from now on.