natural-harmonia-gropius / hdr-toys

Componentized Rec.2100 to Rec.709 conversion shader for mpv-player, featuring dynamic curves and a uniform color space.
MIT License
112 stars 1 forks source link

HDR to SDR (question) #59

Open geextahslex opened 4 months ago

geextahslex commented 4 months ago

Hi, I want to ask if there is a chance for a "simple" HDR "bt.2020" (HDR movies on UHD blurays) to SDR (normal TV) profile. This would be very useful.

Thank you

natural-harmonia-gropius commented 4 months ago

"simple" HDR "bt.2020" (HDR movies on UHD blurays)

I don't know what exactly it is, but all profiles in https://github.com/natural-harmonia-gropius/hdr-toys/blob/master/hdr-toys.conf.

geextahslex commented 4 months ago

If you mean the default setup, the results aren't very pleasing. And jedypod gives a more washed out look than lea..

natural-harmonia-gropius commented 4 months ago

the results aren't very pleasing

Screenshots please, or sample files.

jedypod gives a more washed out look than lea..

Try latest version (master branch) rather than release one.

geextahslex commented 4 months ago

ok so I took some time and compared them a bit. If I could pick I would take the color and saturation from the latest jedypod but the luminance from oldschool lea, it's a punchy picture lea lea x jedypod (master) jedy x

natural-harmonia-gropius commented 4 months ago

what about bottosson (master)?

geextahslex commented 4 months ago

bottosson (master) slightly changes the contrast but the "black levels" (marked yellow in the picture) stays overall the same bottosson: botoss h

natural-harmonia-gropius commented 4 months ago

With all things in master (dynamic, bt1886), it still not blacks enough? If so, I'll create another shader for extra contrast, math of lut in lea is most likely wrong.

And if you can, upload a short clip to me for investigate ffmpeg -i input.mkv -ss 00:00 -t 10 output.mkv.

geextahslex commented 4 months ago

here I matched the black levels (in photoshop) between jedypod and lea, this looks awesome jedy x matched2

I never made a clip, how does this work?

natural-harmonia-gropius commented 4 months ago

download ffmpeg https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-essentials.zip open folder of this video copy /bin/ffmpeg.exe into this folder left click with explorer, open in terminal input ./ffmpeg -i input.mkv -ss 00:00 -t 10 output.mkv in terminal. (change input.mkv to your filename, 00:00 to time of this scene.) drag output.mkv to github's input box, waiting for uploading.

geextahslex commented 4 months ago

okay github says "We don’t support that file type. Try again with..." I think .mkv is not supported

natural-harmonia-gropius commented 4 months ago

mp4 should be fine

geextahslex commented 4 months ago

and how do I achieve that?

natural-harmonia-gropius commented 4 months ago

./ffmpeg -i input.mkv -ss 00:00 -t 10 output.mkv

simply change output.mkv to output.mp4

or compress a zip maybe works.

geextahslex commented 4 months ago

okay, the last frame is the one I used in the screenshots https://github.com/natural-harmonia-gropius/hdr-toys/assets/139760266/ef41dae8-a43f-4cef-9c09-a4e058538b47

geextahslex commented 4 months ago

this is the cropped og file test_2.zip

natural-harmonia-gropius commented 4 months ago

This is the screenshot from my current config, try to get a clean setup (master branch). image

after installation steps, any errors in console (press `). If not, press shift+i then press 2, should be these things in here. image

and one more suggestion: add glsl-shader-opts=L_sdr=100 to your mpv.conf, that most movies use this value.

geextahslex commented 4 months ago

okay, so my PC is not capable of running dynamic so I took bt2446c, and here you can see how the blacks are crushed normal mpv old latest master with bt2446c instead of dynamic, with "glsl-shader-opts=L_sdr=100" added new dynamic is better, but is oversaturated and has artifacts, and I can not run it ^^ dynamic

natural-harmonia-gropius commented 4 months ago

For master branch you need to add glsl-shader=~~/shaders/hdr-toys/utils/black_point_compensation.glsl after bt2446c line to fix "black crush"

About saturation, better compared to Windows Media Player (win11 one) with https://apps.microsoft.com/detail/9PLTG1LWPHLF, for dolby vision files, that is the references.

geextahslex commented 4 months ago

okay that black_point_compensation worked, but why isn't it in the profile? how should a user know this?

I don't understand what you mean by the Windows Media Player thing`?

I would recommend setting glsl-shader-opts=L_sdr at 150, cause at 100 the picture looks like it would glow.

natural-harmonia-gropius commented 4 months ago

but why isn't it in the profile?

dynamic and bt2390 included this functionality itself.

how should a user know this?

I will update README, someday.

I don't understand what you mean by the Windows Media Player thing`?

It's dolby's official tonemapper, only works with Windows Media Player. As your clip seems a dolbyvision file.

https://apps.microsoft.com/detail/9WZDNCRFJ3PT https://apps.microsoft.com/detail/9PLTG1LWPHLF

image

image

geextahslex commented 4 months ago

okay but on the main page you are suggesting to use bt2446c instead of dynamic and I myself tried it some time ago, I have seen the crushed blacks and just moved on, so this would be a vital information. Maybe make a * info under or something in brackets.

Yes a readme would be nice like mpv as there are many options (utils) and how to know when to use them, and whats the effect of them.

WMP: okay good to know, the picture looks nice bright and contrasty but using something else than mpv for video playback is out of question, but it's a nice reference point

natural-harmonia-gropius commented 4 months ago

you are suggesting to use bt2446c instead of dynamic

nope, just an old example for replace. dynamic is the only one I tuned; others are in book implement.

geextahslex commented 4 months ago

okay are there any chances for performance gains with dynamic? as I get like 12 FPS on average, lol it seems to be heavy on the gpu not cpu

natural-harmonia-gropius commented 4 months ago

are there any chances for performance gains with dynamic?

I have no idea, although it is indeed many wastes of performance. 😗

geextahslex commented 4 months ago

okay I have made some comparisons. all set to 150 nits my vanilla setup (old lea hdr-toys) normal dynamic bottosson dynamic botoson dynamic jedypod dynamic jedypod bt2446c bottosson 2446c botoson bt2446c jedypod 2446c jedypod bt2390 bottosson 2390 botoson bt2390 jedypod 2390 jedypod

geextahslex commented 4 months ago

so I am now using bt2446c bottosson, and I noticed clipping in the highlights. Do you know how to fix this, is there a glsl for this? clipping on the nose and forehead clipping missing details details

natural-harmonia-gropius commented 4 months ago

"clipping" is well exposure picture, the face below looks dull and bloodless.

Also, jedypod's face is too yellowish, bottosson is better here.

geextahslex commented 4 months ago

clipping is loosing details, you can see the white patch on his beard. I also noticed clipping in clouds

"the face below looks dull and bloodless"

yes but this is only for representation purpose

"Also, jedypod's face is too yellowish, bottosson is better here."

yap, thats why I went with bottosson

okay so any way to compress the highlights? bring them back? if there is a black_point_compensation for crushed blacks, could there not also be a "white_point_compensation" for clipped highlights? just turn the concept around? ^^

okay I made this in photoshop, I took the highlights from the one picture and merged them. it's not perfect but it shows the idea details mix2

natural-harmonia-gropius commented 4 months ago

okay so any way to compress the highlights? bring them back?

2446c curve is https://www.desmos.com/calculator/1dwlw3ultd (red one). in code k1 and k3 as is, t is ip. Generally you can increase k3 to get more highlight details.

image

geextahslex commented 4 months ago

unfortunately this value (k3) only dimms the clipped area but it doesn't recover any highlights :( mackey

natural-harmonia-gropius commented 4 months ago

What about the result of tone-mapping/linear?

geextahslex commented 4 months ago

linear instead of 2446c? looks bad linear

natural-harmonia-gropius commented 4 months ago

I fixed linear in yesterday, update it.

geextahslex commented 4 months ago

okay but now the whole picture gets dark, so now we are back at the beginning where you said:

the face below looks dull and bloodless

linear2

natural-harmonia-gropius commented 4 months ago

There's no silver bullet, try creating a custom curve.

geextahslex commented 4 months ago

it seems so ^^

try creating a custom curve

how? where is the "t" in the glsl 2446c file? bvbvb

do you have a st2094-10 glsl shader?

natural-harmonia-gropius commented 4 months ago

how? where is the "t" in the glsl 2446c file?

ip

do you have a st2094-10 glsl shader?

with hdr-toys.conf

remove

tone-mapping=clip
gamut-mapping-mode=clip

copy bt.2020 target-prim... to others, you can use mpv's tone-mapping with bottosson. image

geextahslex commented 4 months ago

I got them close but the colors behave different now before reinhard1 after (2094-10) 2094

natural-harmonia-gropius commented 4 months ago

I have no idea about 2094-10, It's part of libplacebo(mpv gpu-next).

geextahslex commented 4 months ago

okay, 2094 gives really good luminance, no clipping, bright image but something feels off in dark colors/shadow. Looks weird in this pipeline before (reinhard) before1 after (2094) after 1

natural-harmonia-gropius commented 4 months ago

Again, I have no idea about that. report "feels off" to libplacebo/mpv.

geextahslex commented 4 months ago

is there a way to modify reinhard to don't tame the peaks that much? normal 11111 reinhard 22222

geextahslex commented 4 months ago

I have found a version that is called "Extended Reinhard" it adds a variable "white point". On the screenshots you can see that it allows more controll over the max luminance/the peaks.

ext reinhard f source: https://64.github.io/tonemapping/

normal reinhard reinhardaa Extended Reinhard reinhardbbbb

natural-harmonia-gropius commented 4 months ago

https://github.com/natural-harmonia-gropius/hdr-toys/blob/master/shaders/hdr-toys/tone-mapping/reinhard.glsl is "Extended Reinhard", peak can be modified by glsl-shader-opts=L_hdr=1000.

geextahslex commented 4 months ago

haha you know what? thats what I thought ^^ because of "(1.0 + x / (w * w))" that looked similar okay I played around with glsl-shader-opts=L_hdr but I'm confused. It doesn't matter what I set it to 300 or 10.000 it always makes the image one notch darker. I only wanted to change the highlights not the midtones. no L_hdr change no hdr change with any modification hdr change

natural-harmonia-gropius commented 4 months ago

reinhard is not a piecewise curve, you need something like hable2.

geextahslex commented 4 months ago

I don't know, in this comparison you can see that the only difference are the peaks in the windows and slightly saturation normal reinhard reinhard Reinhard luminance (white point = max luminance) reinhard-luminance source https://64.github.io/tonemapping/

natural-harmonia-gropius commented 4 months ago

hdr-toys' reinhard is luminance.

geextahslex commented 4 months ago

reinhard is not a piecewise curve, you need something like hable2.

hable2 is the darkest of them

natural-harmonia-gropius commented 4 months ago

try to lower the shoulderAngle image