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

Incorrect gamma scaling #91

Open
eugenesvk opened this issue Dec 12, 2022 · 15 comments
Open

Incorrect gamma scaling #91

eugenesvk opened this issue Dec 12, 2022 · 15 comments

Comments

@eugenesvk
Copy link

When zooming at 50% the picture from this http://www.ericbrasseur.org/gamma.html should not have ugly visual artefacts/become fully gray

@woelper
Copy link
Owner

woelper commented Dec 12, 2022

Challenge accepted!
image

I had degamma/gamma workflow for "per pixel" ops already but disabled them because of performance reasons (saving 2 operations per pixel). I now switched to a different resizing lib and added now degamma/gamma before/after resizing. As a nice side effect you should see dramatically faster resize performance since it is using SIMD optimisation. This will be part of the next release.

@woelper woelper closed this as completed Dec 12, 2022
@eugenesvk
Copy link
Author

This is comparison of Preview (default mac app) and oculante 0.6.30 for zooming out on this pic, could you add the proper scaling algo to the zoom (more frequently used in a viewer than rescaling in the editing ;)) as well?

scale

@woelper
Copy link
Owner

woelper commented Dec 13, 2022

Not sure that is easily possible. This is a texture being drawn as opposed to a resize operation. I am unsure if notan supports that, and what would be necessary to do so - also it will most likely come with a performance penalty.

@eugenesvk
Copy link
Author

Well, you previous upgrade came with a performance bonus, so who knows :)
(but that penalty could be hidden behind an config, usually you can choose the zooming quality algorithm in other viewers)
Don't know anything about notan :(, if you think it's an upstream bug, maybe could file an issue with them?

@eugenesvk
Copy link
Author

Maybe this change of egui to gamma space could help (not yet merged into notan)? emilk/egui#2071
(or maybe this just sounds vaguely similar to to the word gamma ;))

@woelper
Copy link
Owner

woelper commented Dec 13, 2022

Can't believe it, but I think I fixed it. texture format is srgb, and I generate mipmaps so you don't see flickering when zoomed out. Will be in next release.

@eugenesvk
Copy link
Author

Think that's still broken (left is Oculante 0.6.32, right is Preview)
dal

@woelper
Copy link
Owner

woelper commented Dec 14, 2022

Hmm, this is here on linux. Maybe the texture format does not work on mac?
image

@eugenesvk
Copy link
Author

On Windows there is also something wrong
This is XnViewMP at 100% zoom vs the newly opened file in Oculante (supposed to also be 100%, right)?
(there is desktop scaling enabled, maybe oculante doesn't handle it properly?)
XnView_vs_Ocul_100
Then same comparison, but Oculante's image has been zoomed out to ~match the size of XnView
XnView_vs_Ocul_sameVis

@woelper
Copy link
Owner

woelper commented Dec 14, 2022

I've asked in notan here:
Nazariglez/notan#194

@woelper woelper reopened this Dec 14, 2022
@eugenesvk
Copy link
Author

So there is definitely something wrong not accounting for screen scaling
The pics above are taken with monitor Windows scaling at 150%
With the monitor scaling at 100%
XnVsOc_100_100scaling

though some artifacts at other zoom factors remain even with the monitor at 100% (but it doesn't go full gray at least!)
Oc_zoomOut_100scaling

@Nazariglez
Copy link

Hello! I see this working right on MacOS, although I see how it works different between the filter and the zoom preview. When you do a Zoom operation (using the edit button, then filter -> resize) it seems to work fine, but when you do a zoom out using the mouse on the preview, it does not, that's because the gamma correction function is applied only when you use the filter.

Just to be sure, @eugenesvk is this what's happening to you? Are you using the zoom preview? or are you using the resize filter?

Anyway, we probably should apply to the preview the gamma correction too, but that could be expensive for sure to do in real time.

Another option that I can think of, is to add support for custom mipmaps on notan, then auto-generate the mipmaps manually for each image loaded and upload them to the GPU, thought I am not sure if that will work for this case because this is the first time I fight with image scaling.

@eugenesvk
Copy link
Author

This issue is primarily about what you call "zoom preview" since it's the most noticeable, don't remember to what extent I've compared the scaling quality in the editing filters

@Nazariglez
Copy link

I see, do you think that it makes sense to create and display the image using gamma correction even if it's not scaled? That way any version of the image (like the auto-generated mipmaps) will use the version corrected. I can try to do some tests and make a PR for it.

@eugenesvk
Copy link
Author

Yes, I believe oculante should be awesome enough to match Preview's quality!

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

3 participants