c4d19877cf
- New atmosphering rendering technique based on my own work. - Attempt to fix some remaining transparency issues. - Use a luminance histogram for auto exposure. - Add support for clustered shading. - Add WS 2.0 shaders. - Add 3D cloud shaders. - Add orthoscenery support.
24 lines
695 B
GLSL
24 lines
695 B
GLSL
#version 330 core
|
|
|
|
const float NUM_BINS = 254.0;
|
|
const float INV_NUM_BINS = 1.0 / NUM_BINS;
|
|
|
|
const float MIN_LOG_LUM = -10.0;
|
|
const float LOG_LUM_RANGE = 16.0;
|
|
const float INV_LOG_LUM_RANGE = 1.0 / LOG_LUM_RANGE;
|
|
|
|
uint luminance_to_bin_index(float luminance)
|
|
{
|
|
// Avoid taking the log of zero
|
|
if (luminance < 0.005)
|
|
return 0u;
|
|
float log_lum = (log2(luminance) - MIN_LOG_LUM) * INV_LOG_LUM_RANGE;
|
|
log_lum = clamp(log_lum, 0.0, 1.0);
|
|
// From [0, 1] to [1, 255]. The 0th bin is handled by the near-zero check
|
|
return uint(log_lum * NUM_BINS + 1.0);
|
|
}
|
|
|
|
float bin_index_to_luminance(float bin)
|
|
{
|
|
return exp2(((bin * INV_NUM_BINS) * LOG_LUM_RANGE) + MIN_LOG_LUM);
|
|
}
|