Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linear to Log2 Transform Correctness #156

Open
deggua opened this issue Sep 30, 2024 · 0 comments
Open

Linear to Log2 Transform Correctness #156

deggua opened this issue Sep 30, 2024 · 0 comments

Comments

@deggua
Copy link

deggua commented Sep 30, 2024


This line doesn't make sense to me, this would result in pure black having the same Log2 encoding as middle grey

I think it makes more sense to handle the singularity and set lg2 = -infinity, which with proper clamping will result in 0 after normalization

float lg2 = (lin <= 0.0) ? -INFINITY : log2(lin / middleGrey);

Nevermind, the original works because it returns the normalized value, I see that now


This line seems incomplete, it ensures the logNorm is >= 0, but there isn't a corresponding condition to ensure logNorm is <= 1

if (logNorm > 1.0) logNorm = 1.0;

i.e. clamp logNorm to [0, 1] so that lin values > middleGrey * pow(2, maxExposure) map to 1

I may just be confused, I'm not a professional, but I've been working with shader code related to color transforms and tonemapping.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant