FyroxEngine / Fyrox

3D and 2D game engine written in Rust
https://fyrox.rs
MIT License
7.49k stars 339 forks source link

Calculate frame luminance using histogram for HDR #587

Open mrDIMAS opened 5 months ago

mrDIMAS commented 5 months ago

Currently, frame luminance is calculated using downsampling with bilinear filtration, that basically calculates average frame luminance. Average luminance works quite bad in HDR, because a single bright pixel could easily ruin the luminance values. It could be done either on CPU or using a compute shader (this must be gated by checking if compute shaders are actually available).

The-Ladle commented 2 months ago

I want to try and take this issue, but I have no idea where frame luminance is calculated in the engine. If you could let me know, I'd be happy to start and try to fix this.

mrDIMAS commented 2 months ago

It is in HighDynamicRangeRenderer::calculate_avg_frame_luminance and I already did some basic version of histogram-based luminance calculation, but it requires tweaking and probably contains bugs in its implementation.

The-Ladle commented 2 months ago

I have been unable to figure this one out, which means I've effectively given up on it.