Thoughts on making Cycles into a spectral renderer

Daily updated branch build from troy’s github is now available here

GPU kernels did not build, so they have not been included for now, this branch has the same issues i fixed earlier, uses [0] rather than .x

7 Likes

I’ll try to get them fixed soon, I appreciate that though.

1 Like

Nice! Thanks for this!

So awesome to see the progress with this! Would be great to test it with GPU rendering.
Here is a quick test i did:


Pretty big difference!
Left sphere is a 100% saturated blue, Monkey is 100% saturated green, Right sphere is 100% saturated red. Left emissive sphere is 100% saturated red, and right emissive sphere is 100% saturated blue. groundplane is mid grey.
A bit of a odd thing i noticed was that the left emissive sphere was blown out white in preview render, but orange in final render. How come?

2 Likes

Without drilling into it, I strongly suspect that’s a gamut clip issue. The base transforms are not nuanced in any manner.

in this one, at first glance, other than the light sources, there’s not much of a difference, but if you directly compare them (flip back and forth between them), you’ll find that the spectral render shows vastly more detail on the Suzannes. It really shows the range of differences to expect: Basically none in gray areas, very little in even saturated areas that aren’t just pure red, green, or blue, but quite substantial improvements in those extremes.

Also it’s not quite so simple as RGB being brighter than Spectral. If you look closely, you’ll find that the light on the bottom plane actually reaches farther in the Spectral version (the outer edge of the part of the image that isn’t black goes farther), despite being darker in the center. - I just can’t ever be sure in how far that’s simply a tone mapping difference. (This seems to be a pure brightness thing after all, so that could be due to tone mapping, right?) (there’s no tonemapping yet so this is nonsense)

RGB:

Spectral:

GIF comparison:

EDIT: I modified the scene to get rid of much of the direct same-color light by adding this cone:

That pronounced the effects quite a bit. Interestingly, perhaps due to relative darkness, the denoiser struggled more to denoise the RGB version of Green Suzanne’s eyes. You can also see how, on the Suzannes, the colors look quite different, as the diffuse portion of the shader is no longer entirely black for other light sources, and so mixes into the highlights. And the improved overall contrast is also still very much visible.

RGB:

Spectral:

1 Like

It really is more realistic, there’s no doubt about it. I understand it’s somewhat biased because these renders use solid colors but the difference is there.

1 Like

Thanks for all the tests, I’ll try to apply the fix so that GPU rendering can work today.

2 Likes

There is zero gamut mapping happening in the default configuration. It’s a literal dump of scene linear anchored around 0.18 to display linear output.

@LazyDodo would you be able to enable CUDA in the build which you have running? I’ve removed the array notation access from everywhere I can see it is necessary, wanted to see whether it would support GPU now.

Thanks again for setting that up, I really appreciate it.

2 Likes

Looks like you missed one, and there’s a few other errors as well

/kernel_color.h(562): error : no operator "[]" matches these operands operand types are: float4 [ int ]
/kernel_path_state.h(69): error : class "KernelGlobals" has no member "wavelength_low_bound"
/kernel_path_state.h(70): error : class "KernelGlobals" has no member "wavelength_high_bound"
/kernel_path_state.h(77): error : class "KernelGlobals" has no member "wavelength_low_bound"
/kernel_path_state.h(77): error : class "KernelGlobals" has no member "wavelength_high_bound"
/kernel_path_state.h(78): error : class "KernelGlobals" has no member "wavelength_low_bound"
/kernel_path_state.h(78): error : class "KernelGlobals" has no member "wavelength_high_bound"
/kernel_path_state.h(79): error : class "KernelGlobals" has no member "wavelength_low_bound"
/kernel_path_state.h(79): error : class "KernelGlobals" has no member "wavelength_high_bound"
1 Like

Whoops! Fixing it now. I wonder why I could build :thinking: Anyway I don’t need the bounds yet so I’ll remove them.

1 Like

@LazyDodo please try again now, I’ve addressed those errors. Still confused why I wasn’t encountering the ones about KernelGlobals since they do exist :man_shrugging:

1 Like

From a quick test they seem to build now, i enabled them on the builder, which is scheduled to start in the next hour or so

3 Likes

Great! Thanks for that.

1 Like

Thanks, will it be up on graphicall ?
Quick question to @smilebags does it work with RTX? (Optix) or currently only for cuda?

Great question. I’m not sure, I imagine if it compiles it should work, because AFAIK Optix only accelerates the actual raytracing, which is separate to the material processing. If you can try it out once it’s updated on Graphicall, I’d love to know whether it works.

Build has been updates, cuda and optix included (but beyond “it build” it received no testing)

2 Likes

What is Spectral renderer?

1 Like

The short version is that, instead of using three colors to illuminate a scene (namely typically the light sources that correspond to Red, Green, and Blue in sRGB color space), you use a continuum of pure spectral colors (think rainbow).

There’s a bunch of possible future benefits (once it is implemented in full - there’s lots of ways in which this is still very much WIP) but already now, in certain high saturation situations, light sources actually contribute to appearance when they previously wouldn’t have, and these situations also feature higher contrast (as my most recent tests above showed quite clearly, I think).

Meanwhile, for lower-saturation situations (truthfully most of the time), changes as of right now are going to be barely noticeable. Benefits there are gonna start showing up once more parts of this effort have been realized.

4 Likes