vkdt - some questions

I’m making my first experiences with vkdt, and I must say I am impressed. The workflow is a bit nerdy (sorry ;-)), but after setting up my default processing pipeline, I achieve fine results with very few mouse clicks - and especially the new filmsim module is fun to play with.

I see some issues however, which may be due to my inexperience, or due to some build weakness (macOS 15 Sequoia, Intel-based, libvulkan.1.4.335):

  • demosaicing with the default setting (gaussian splats) produces a strong green tint. This is with raws from several cameras (Olympus ORF, Canon CR2). I set RCD as my default now, which works fine.
  • denoise has just a very slight effect on a quite noisy image, even when using (as I understand them) extreme parameters strength 1, luma 0, detail 0
  • disabling denoise produces a very dim and magenta tinted image; processing chain is i-raw:main → denoise → hilite → demosaic … shouldn’t disabling simply bypass the module and leave the image untouched?
  • jddcnn crashes immediately with EXC_BAD_ACCESS (SIGSEGV) within the moltenVK library

Any hints from someone more experienced? I hesitate to file bug reports, as I would not rule out user error …

heya,

a few answers inline below:

do you have a test image/screenshot for me? maybe something white balance coefficients for these cameras? i haven’t experienced this, or don’t know what you mean.

this module runs on noise profiles. manually set the noise estimates in the i-raw module or follow the denoise module docs and the noise profiling docs.

also see docs above. this module also crops off the black borders and rescales to black and white points. this might seem like intermingling concerns, but you’ll have to do it anyways and reading/writing the full image to global memory again is not a very performant idea.

does your gpu support the cooperative matrix extension / does it come with tensor cores at all? there is a compatibility layer in place in the code (that you can activate if you’re compiling yourself). i didn’t wire this since this module is extremely slow and i figured running this on a lower end GPU without coopmat support would make it unbearable. didn’t actually try to run it there though, might be good to have the option run-time. also it requires a lot of memory. for >20MP images you definitely want 8GB video ram.

1 Like

Thanks for the quick reply and the help!

Actually for the demosaicing issue, it’s not just a tint but colors are completely off with gaussian splats:

RCD looks competely fine, so I think it should not be related to WB coefficients or camera constants:

And here gaussian splats, manually white balanced on the bottom row of the Colorchecker:

This raw file is from an Olympus OM-D EM-1 III, but I have the same issue with files from OM Systems OM-1, Canon 5D Mark II and Nikon Z5.

Regarding denoise - I was not aware of the need for profiling, should read the docs more carefully :wink:

jddcnn: I have a Radeon Pro 5300 (iMac 2020), so no - I think it does not have the cooperative matrix extensions nor tensor cores. I will live with that for now, thank you!

uhm what’s your default processing graph now? this isn’t even wb but complete lack of input device transform. maybe some module clears the image metadata by accident? my main camera happens to be the Canon 5D Mark II, too. i’m quite sure it’s not green on my end :slight_smile:

This is my default graph (except manually selected gaussian splats to demonstrate the issue). All other modules are at their default, even colour is at “ignore” for the picked input.
The color distortion is the same with the default graph out of the box. I am really wondering what is happening here, can this be an artifact of compiling on macOS? Will compile again and look for warnings …

Happy holidays BTW, and thanks for the support!

okay thanks. i’ll have a look what these modules before the colour one do to the metadata.

might take a few days :slight_smile:

happy holidays indeed!

These are the warnings that I get (there are no other warnings in the log):

On top the output of a previous run. Can the two missing vk extensions cause the issue?

that output looks fine. this is just to indicate vk runs on the metal backend, not missing anything.

maybe the lens module clears meta? i dont usually have it before my colour.

No, it also occurs with the default node graph that you supply. And even with the bare minimum:

vs. RCD:

Anything I could do to debug? Else I am happy with RCD.

Edit: even if I remove everything except demosaic and colour the issue is still present.
I will try to do a build with rawspeed instead of rawler, maybe this can isolate the issue. Actually that’s what I tried first, as I was suspicious about a decoding problem - I just abandoned the effort, as builds that require openmp seem to be notoriously complex to get all the options correct on macOS :frowning: .

i doubt rawspeed will make a difference. i would start debugging by printing the value of img_param->colour_primaries in colour/main.c:commit_params to find out where the demosaic method affects input transform. maybe do the same in various create_nodes callbacks in the modules before that.

img_param->colour_primaries is 0 (“use cam_to_rec2020”) in all modules (denoise, hilite, demosaic, colour) and in both cases, gaussian splats and RCD.

I noticed that the 4th WB coefficient is “nan”, as it comes out of rawloader. Is this as expected? The other coefficients fit to the exif data, for example for an image from Canon 5D Mark II:

Exif: WB RGGB Levels:
1981 1175 1175 2756

vkdt colour module:
wb0 1.685957 | wb1 1.000000 | wb2 2.345532 | wb3 nan

One more thing: the thumbnail in the light table has correct colors, even if gaussian splat is selected and darkroom colors are off; not sure if this persistent or not. The whole behavior is a bit stochastic - I also remember (a few) images that at least temporarily worked with gaussian splats.

Again: I am fine with RCD. But can try to investigate further, if this is of interest to you (and I still do not rule out some user error …).

thumbnails use half size processing, no demosaic.

ouch intermittent failure sounds like some sort of memory garbage. i’d be really interested to track this down.

i think the fourth wb coeff should be unused. if the colour matrix turns nan, that would potentially explain the issue.

Actually it’s > 95% reproducible.

Just sporadically the image is initially ok with gaussian splats, switching then to RCD is also fine, but switching back to gaussian splats it’s off.

Where is white balancing done when gaussian splats are used? I think I see it for RCD in rcd_fill.comp, but I cannot see the equivalent code in gauss.comp or splat.comp?

Edit: I see it is done anyway in colours.

Regarding the stochastic behavior: this might be due to some parameters being stored persistently across runs?

I am able to white balance also with gaussian splats, i.e. achieve very good grey patches on a Colorchecker test image using “picked”, or quite good wb by manually adjusting the rgb parameters in colour.
However, the red channel remains strongly subdued in the other patches of the CC, even though the grey patches are near to perfect grey:

RCD grey patch (3rd in bottom row of CC): 129/129/130
RCD red patch (directly above grey): 118/56/56
Splats grey patch: 136/135/137
Splats “red” patch: 75/72/55

i’m currently travelling/on mobile, will give more detailed answer when back at a computer…

rcd uses luminance gradients, so it depends on some coarse wb being done. the colour module does chromatic adaptation and input device transform, i.e. matrix and wb coefficients in the simple case.

so since the cpu/host side values in commit_params seem to be good, maybe we’d need to look into what is actually sent to the compute shader?

the behaviour you describe sounds more like colour matrix issue than white balance issue to me. simply matching white but then destroying the other colour points… also the green looks like the camera → rec2020 matrix is reverted to the identity. i mean printing the values of the matrix host side might be a good idea too, to try this first. if this looks good, i’d probably go to colour/main-impl.glsl and do some “brain surgery” there. like right around line 213, test some values in the params for plausibility, and then depending on the outcome write some debug values into the vec3 rgb and:

imageStore(img_out, ipos, vec4(rgb, 1));
return;

Printf from i-raw, in the path
if(!(test == test))
{ // camera matrix not found in exif or compiled without exiv2

xyz-to-cam: 1.189600 -0.511000 -0.107600
xyz-to-cam: -0.318100 1.137800 0.204800
xyz-to-cam: -0.051900 0.122400 0.516600

This is inline with bin/data/cameras.xml (even taken from there and not from the camera?):
11896 -5110 -1076
-3181 11378 2048
-519 1224 5166

Other data:
colour: p_wb coeffs 1.021910 1.000000 1.053810
colour: p_mat 1 primaries 0
i-raw WB coeffs: 2.148438 1.000000 1.718750 nan

But I find the camera->rec2020 matrix really as identity, as you suspected:
colour create_nodes: cam-to-rec2020: 1.000000 0.000000 0.000000 0.000000 1.000000 0.000000 0.000000 0.000000 1.000000
colour commit_params: cam-to-rec2020: 1.000000 0.000000 0.000000 0.000000 1.000000 0.000000 0.000000 0.000000 1.000000

If I temporarily disable colour, my printf-output from create_nodes and commit_params is still there (would have expected it to disappear?), now with the correct matrix values; but this does not change the image output, still RCD is correct and gaussian splats is off. Same if I comment out the resetting to identity in modify_roi_out() of colour.

I have now deleted all nodes except i-raw, colour and display, even demosaic. Still cam-to-rec2020 in colour shows as identity.

BTW, if there’s a more appropriate communication slot for such a discussion, please advice. I can also post a github issue, if you think I am not just guilty of some user error …

okay thanks for this analysis!

whatever, github issue works the same, but here is fine for me.

maybe the test==test doesn’t work due to some compiler setup/flags? testing nan is a bit wacky anyways. also, this exiv2 thing is copied from the old rawspeed codepath and doesn’t make sense here. if you just remove the if(!(test == test)) line so it always enters the block? i’ll also push a version with that one cleaned up…

The test==test check works, we enter the if clause. This is the output from starting vkdt, lighttable shows up, and then double-clicking on one image (entering darkroom).

[gui] no gamepad found
[gui] loading display profile display.Built-in Retina Display
i-raw WB coeffs: 2.148438 1.000000 1.718750 nan
i-raw: calculate matrix from camera data
i-raw: xyz-to-cam: 1.189600 -0.511000 -0.107600
i-raw: xyz-to-cam: -0.318100 1.137800 0.204800
i-raw: xyz-to-cam: -0.051900 0.122400 0.516600
i-raw: cam-to-xyz: 0.955859 0.426040 0.030192
i-raw: cam-to-xyz: 0.261083 1.034410 -0.355700
i-raw: cam-to-xyz: 0.034171 -0.202285 2.023044
i-raw: cam-to-rec2020: 1.539360 0.414705 -0.334229 -0.214681 1.384880 -0.563210 0.037887 -0.227300 1.921662
i-raw WB coeffs: 2.148438 1.000000 1.718750 nan
i-raw: calculate matrix from camera data
i-raw: xyz-to-cam: 1.189600 -0.511000 -0.107600
i-raw: xyz-to-cam: -0.318100 1.137800 0.204800
i-raw: xyz-to-cam: -0.051900 0.122400 0.516600
i-raw: cam-to-xyz: 0.955859 0.426040 0.030192
i-raw: cam-to-xyz: 0.261083 1.034410 -0.355700
i-raw: cam-to-xyz: 0.034171 -0.202285 2.023044
i-raw: cam-to-rec2020: 1.539360 0.414705 -0.334229 -0.214681 1.384880 -0.563210 0.037887 -0.227300 1.921662
colour create_nodes: cam-to-rec2020: 1.000000 0.000000 0.000000 0.000000 1.000000 0.000000 0.000000 0.000000 1.000000
colour: p_wb coeffs 0.901311 1.000000 1.529600
*colour commit_params: cam-to-rec2020: 1.000000 0.000000 0.000000 0.000000 1.000000 0.000000 0.000000 0.000000 1.000000 *
colour: p_mat 1 primaries 0

Anyway, I removed the test==test check. Results are unchanged, unfortunately.

The color matrix according of exiftool is
Color Matrix : 368 -80 -32 -48 352 -48 6 -72 322
can this fit to the data above? I am unable to relate it …

One additional remark: I did not do anything specifically to install rawloader separately, just cloned your vkdt repository, installed moltenvk and started “make”.
Is there a separate step necessary to install a potentially updated version of rawloader, or is the one coming with vkdt fine?

Guten Rutsch!