Coder Social home page Coder Social logo

natural-harmonia-gropius / hdr-toys Goto Github PK

View Code? Open in Web Editor NEW
106.0 6.0 1.0 1.08 MB

Componentized Rec.2100 to Rec.709 conversion shader for mpv-player, featuring dynamic curves and a uniform color space.

License: MIT License

GLSL 95.54% JavaScript 3.97% Python 0.49%
color-conversion color-management color-transformations gamut-mapping glsl mpv shader tone-mapping

hdr-toys's Introduction

HDR Toys

Componentized Rec.2100 to Rec.709 conversion shader for mpv-player.
Featuring dynamic curves and a uniform color space.

Getting started

Important

Requires vo=gpu-next.

Tip

Full portable_config: natural-harmonia-gropius/mpv-config.

  1. Download hdr-toys.zip, extract it and copy shaders, scripts and hdr-toys.conf to your mpv config folder.
  2. Append include=~~/hdr-toys.conf to your mpv.conf
  • Don't set target-peak, icc-profile...
    Make sure there are no built-in tone map, gamut map, 3DLUT... in "Frame Timings" page.
  • If you are not using a BT.709 display, replace all gamut-mapping/* with gamut-mapping/clip.glsl.
    Then change #define to * to match your display.

Detailed information

Most shaders have a link at the top, if you want to go deeper, you can visit it.

Tone mapping

  • HDR peak defaults to 1000nit, should be the max luminance of video.
    hdr-toys-helper.lua can get it automatically from mpv.
    You can set it manually with set glsl-shader-opts L_hdr=N

  • SDR peak defaults to 203nit, should be the reference white of video.
    In many videos it is 100nit and if so you'll get a dim result.
    Unfortunately you have to guess the value and set it manually.
    You can set it manually with set glsl-shader-opts L_sdr=N

You can change the tone mapping operator by replacing this line.
For example, use bt2446c instead of dynamic.

- glsl-shader=~~/shaders/hdr-toys/tone-mapping/dynamic.glsl
+ glsl-shader=~~/shaders/hdr-toys/tone-mapping/bt2446c.glsl

This table lists the features of operators.

Operator Applied to Conversion peak
dynamic JzCzhz Frame peak
bt2390 ICtCp HDR peak
bt2446a YCbCr HDR peak
bt2446c xyY 1000nit
reinhard YRGB HDR peak
hable YRGB HDR peak
hable2 YRGB HDR peak
lottes maxRGB HDR peak
hejl2015 RGB HDR peak
linear ICtCp HDR peak
clip RGB SDR peak
false Heatmap Infinity

Typical representation of the same curve applied to different color spaces.

RGB YRGB maxRGB Hybrid in JzCzhz
image image image image

Typical representation of static and dynamic curves applied to the same color space.

BT.2446C Dynamic BT.2446C Dynamic BT.2446C Dynamic
image image image image image image

Gamut mapping

Caution

Screenshots are outdated and will be updated in the next release.

clip is the exact conversion, Others are various forms of compression.

clip jedypod bottosson lea toru false
image image image image image image
image image image image image image
  • The result of clip is different from libplacebo, which is due to the black point of BT.1886.
    I consider that the black point should be set to zero for transcoding and conversion.

hdr-toys's People

Contributors

natural-harmonia-gropius avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

quackdoc

hdr-toys's Issues

help create a glsl shader

Hi,
I have an issue with my tone mapping, and I know how to fix it (in Photoshop), but I have no idea about how to create glsl filters. That looks very complicated.
My Issue: I am annoyed with the the LSD style colors in the 0-10 (0-255) brightness range.
My solution is to desaturate the low range 0-4 (brightness), and then make a transition between 4-15 to make it look smooth.

It would be awesome to control A: effect 0-100% and B: the range, to be flexible.

In photoshop it looks like this: a desaturaion layer with these settings:
filter

Example Blue horse
dgdfg

Here its fixed
HDR fix f

[bug] 黑暗场景的严重性错误

目前的shader动态映射方案在明亮场景测试下表现良好,但在某些黑暗场景下发现了严重性错误
测试视频:[subbers]Violet Evergarden the Movie [UHDRip HEVC-yuv420p10 Dolby-Vision FLAC ASSx2 PGS].mkv

bt.2446a dynamic
image image

该测试场景下shader动态映射的画面全黑。由于测试视频是之前剪切的,时间只是确定为章节 ギルベルトの行方 的2分52秒

Peak Nits of Display?

Should I be entering the peak nits of my display (120) somewhere in the mpv.conf?

I do this for MadVR but not sure how to handle with HDR Toys?

Changes in brightness up and down

I'm not sure why this happened, but when I watch some movies like The Martian I noticed that during the same scene brightness changed several times. Any setting to fix this?

Small Read Me Issue

Download hdr-toys.zip, extract it and put it in ~~/shaders

The issue is if you follow this to the letter you end up with a folder called hdr-toys-master but needs to be named hdr-toys.

So if anyone reads this makes sure the folder you unzip into the shaders file is named hdr-toys.

Question on HDR->SDR for Projector users

Interesting approach. I am a MadVR user but looking for an alternative given the unclear path forward with MadVR. On my scenario, I want to tone map HDR to SDR, but keeping BT.2020 as the color space. I also want to take advantage of my projector max nits, which is about 100 nits. That's basically what I do with MadVR v166 today.

What modifications do I need to make to get there?

Thanks

what happend to lea.glsl?

Hi,
I want to ask why did you remove lea? This is actually the one I'm using right now ^^
On the main page you also switched from lea to jedypod. Can I ask why?

A noob friendly tutorial on "HDR to SDR conversion"?

Went through this hdr-toys.
And copied the shaders and config as it is.
and here's the result:
mpv --no-config with hdr file.
normal hdr

Hdr file with your config.
hdr to sdr conversion using your config

Sdr version of a file run with mpv --no-config

normal sdr version

I wanna know maybe I did something wrong? Or this is the actual output expected through your config.

Errors on launch

Seeing both of these errors on launch:

[hdr_toys_helper]
[hdr_toys_helper] stack traceback:
[hdr_toys_helper] [C]: at 0x560587d00f30
[hdr_toys_helper] Lua error: /home/x/.config/mpv/scripts/hdr-toys-helper.lua:1: unexpected symbol near '{'

these show up when using and not using hdr-toys.

mpv 0.36.0 Copyright © 2000-2023 mpv/MPlayer/mplayer2 projects
built on Sun Jul 23 05:49:29 2023
libplacebo version: v5.264.1
FFmpeg version: n6.0
FFmpeg library versions:
libavutil 58.2.100
libavcodec 60.3.100
libavformat 60.3.100
libswscale 7.1.100
libavfilter 9.3.100
libswresample 4.10.100

Improve metering

What I did?

  • Convert linear values to perceptual luminance (PQ)
  • Downscaling image to fixed size (512x288)
  • Spatial filtering for image of metering (fast gaussian blur, default to 2 iterations)
  • Get metered values (max)
  • Temporal filtering for metered values (harmonic mean, default to 1/3 fps samples)

What does Dolby do?

视界·本色|杜比视界全新 L1 元数据介绍

  • Spatial filtering (downscaling, fixed resolution(?), 基于最大空间频率的滤波算法(?))
  • Highlight processing (5 levels analysis tuning, from most to least highlight, default to balance, blurring(?)).
  • Get values (in PQ, max: weighted maxRGB, avg: improved(?), min: minY)
  • Working space (BT.2020)
  • Three-segment spline curve.

What I want

  • Reduce flickering
  • Better black and white clipping, tm(w_in) == w_out, tm(b_in) == b_out
  • Mid-grey adaptation, tm(m_in) == m_out

MadVR settings used in your comparison

First, thanks for the transparency by showing which settings were used in the comparison with MadVR. However, there are a few MadVR tweaks that you should consider when doing the comparison - for example, you are not using the recent TM curves nor the roll-off clipped pixel settings - both considered important improvements added to the most recent versions of MadVR. Here is my suggestion - in case you want to do a new round of comparisons:

  1. Baseline settings (settings recommended by Javs, one of the most active contributors in the AVS thread)
    image

  2. Potential tweaks over the base settings above:

  • Use a more punchy curve - Mercury, and increase the punch a bit (I would not go above 7)
  • uncheck the apply-desat 2-4 option (I don't see the need with the new builds/roll-off option enabled)
  • Use Lum Method - Sep (some folks get a more "punchy" image with Sep) and disable HTSM: No brightening.
  • Enable Dynamic Clipping with a value of around 75-100.

Curious to see the results on your side.

hdr peak explenation please

hdr-toys-helper.lua sets the hdr peak automaticly just by droping it to the scrips folder or there is more necesery steps?

high gpu usage

i noticed that after one of the last updates my gpu tams to 100% utilization.any fix or bypass?
using default code no changes at all beside sder peak to 100

HDR Toys washed out vs Spline

Figured I would open a new issue for this.

HDR Toys seems very washed out to me, almost like a gamma or level issue somewhere. It is very visible with the debug menu even (top Spline bottom HDR Toys).

Spline HTOY this

Flickering

Need a low latency filter function that can be implemented using glsl.

2094-10 "tone-mapping-param" messing up brightness and saturation

Hi, I have a problem with the "tone-mapping-param" with 2094-10. It is constantly shifting around and there is no value to fix it. It somehow resets for every new scene. If you are above (+)0 it effects some scenes and of you are under (-)0 then it effects the others. I just want to not be effected by this "feature".
And this should be possible, because when you use glsl tone mapping (which I don't have for 2094-10), then "tone-mapping-param" never effects the image.

There are conversations, where the one person is "normal" and when the camera goes to the other person in the dialog, then it messes with the brightness, which desaturates the picture.

The way it should look
normal

boosted brightness and desaturated picture
shifted

Tag

不定期打个标记吧,方便我做匹配的版本跟进

Add `--tone/gamut-mapping=clip` in config?

Play PQ video with --target-primary=bt.2020 the gamut map(perceptual) appear.
Play HLG dovi video with --target-trc=hlg the tone map(1001->1000) some times appear.

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

tone-mapping=auto
image
tone-mapping=clip
image

gamut-mapping-mode=auto
image
gamut-mapping-mode=clip
image

And srgb input -> bt709 bt1886 output

gamut-mapping-mode=auto
image
gamut-mapping-mode=clip
image

Samlpe:
All_colors_png16bit

More tone mapping

red understureated

hello
red is very undersaturated in dynamic tone mapping to the point its some times translated to white specialy on highlights any way to fix it?

Noob questions

Hi! I made this account just to ask some noob questions, I hope you don't mind. I'm trying to tonemap hdr to sdr and after 2 weeks of just searching forums and trying hundrends of changes to the settings of different video players I've found that your config with mvp is the closest I've come. To be exact, the tm process changed to hable and +3 added to contrast and brightness and lowering the saturation a bit. I want 4k hdr videos to look exactly or close to their 1080p counterpart, I understand that it's difficult due to many variables but after so much time wasted I'm desperate.
If you have any suggestions to make it even better I would be very grateful, or maybe should I just take it or leave it?
2 further side questions: With you config the interface changes color, can i reverse that? What does the [gray] setting do?
Sorry for the block of text, have a great day.

Update scripts/hdr-toys-helper

Current plans:

  • Port to hdr-toys.js
  • Remove hdr-toys-helper.lua
  • Use hdr-metadata, drop deprecated sig-peak
  • Automatically set L_sdr=100 for PQ, 203 for HLG. (though they all should be 203, but real PQ contents mostly use 100)
  • Automatically set input-primary/transfer, output-primary/transfer
  • Automatically set profile instead of lots of config lines
  • Update dynamic.glsl, if it's needed

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.