Skip to content

bastibe/rawdev

Repository files navigation

A Simple Experimental Shader-Driven Raw Developer

This is an experiment, nothing more. I may continue working on it, or may abandon it. If you like to join the fun, feel free to do so, but no guarantee that I will merge anything that doesn't fit my vision.

This program implements many of darktable's raw development algorithms, but entirely on the GPU. Contrary to most other programs, it always processes the entire raw image in real time. Thus, there is no separate export action; what you see in the editor is already rendered at full resolution, and "exporting" merely saves what you see.

Naturally, you'll need a relatively fast GPU to run this. I haven't spend much time optimizing things, but it runs fine on my Surface 11 Pro tablet, and my M2 Pro Mac Mini.

At the moment, the program is a simple python script, app.py. It requires PySide6 for the GUI rendering, rawpy to load raw files, pillow to save image files, and numpy for some calculations. Wherever you can install these dependencies, the program should run, too. It has only been tested on the above two computers. There is no compilation necessary, as all the fancy stuff happens in the GPU shaders anyway (which are just-in-time compiled when you run the program).

It includes a rudimentary file browser for selecting your next image to work on:

library

And a raw editor that implements Darktable's White Balance, Lens Correction (DNG and Fuji only), Exposure, Tone Equalizer, Color Calibration, Color Balance RGB, and Sigmoid. Internally, it always runs in the ProPhotoRGB color space with no gamma. There's also a drawable exposure mask for dodging and burning, as well as a real-time waveform.

editor

The program consists of a short python script app.py, which loads raw files with rawpy, and then loads the main app from a QML file, app.qml. This, in turns, hands off all significant rendering to shader, which are collected in the content/shaders directory. These shaders are mostly direct translations from Darktable's OpenCL and C source code.

Just to be clear, this is all very experimental code. Any errors within are clearly my own, and in no way attributable to Darktable.

Limitations:

Demosaicing is implemented by rawpy, which is very slow for certain files (Fuji!). This would be better handled in the shader programs, but I haven't implemented it yet.

The white point is currently expressed as temperature/tint, which plays complete havoc if there's no temperature/tint combination for the selected white point. Darktable instead switches to a color wheel when temperature/tint fails, which is more sensible.

I think there's still an error with the output color profile. I get an odd golden cast to most images, that's not supposed to be there.

There is currently no cropping, rotating, or messing with the lens corrections.

The software architecture is not ideal. I picked PySide as it allowed me to prototype quickly, but the handling of shader buffers is not ideal. In particular, there's no good way to pass full-depth shaders from one part of the program to another. It can pass 16 bit TextureInput data from python to the RenderedRawFile.qml, and feed 16 bit data from one Effect to the next, but any effect outside of the main SceneEnvironment is limited to 8 bit. I use this currently for the tone equalizer mask, which is otherwise too slow to calculate. But I'd like to use it for other slow modules as well, which wouldn't work in 8 bit.

There's probably a way to do this outside of the QML SceneEnvironment. But most likely, QML was just not the right technology choice for this project. Several kludges were necessary to work around the limitations of the current implementation.

And of course, there's just loads of stuff that hasn't been implemented yet.

Open Issues:

Processing:

  • load raw file with 16bit precision
  • ensure image data arrives as 16bit in shader
  • apply shader effects to image
  • ensure image data is processed at full resolution
  • save processed image
  • asynchronous loading
  • pixel value picking
  • waveform display
  • white balance
  • tone eq
  • color eq
  • color balance
  • denoise
  • sharpen
  • crop and rotate
  • distortion correction (implemented for Fujifilm only)
  • check if sigmoid is in the correct color space
  • fix image size
  • dodge and burn
  • add dodge and burn strength

Organization:

  • Edit parameter saving/loading
  • XMP saving/loading
  • metadata loading
  • lighttable
  • move sigmoid param calculation out of shader
  • Document and organize the code
  • comment the provenance of each function
  • move tone EQ mask to its own View3D
  • resample vignetting and distortion to 16 taps
  • module presets or script

UI:

  • log histogram
  • tone eq UI
  • colored sliders
  • global color balance sliders
  • improve dodge and burn mask display
  • save and load dodge and burn mask points
  • change dodge and burn mask cursor to concentric circles
  • replace QQuickImageProvider with QQuickAsyncImageProvider
  • magnified view

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published