Thoughts on making Cycles into a spectral renderer

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

I can report that GPU rendering with CUDA and RTX Optix works, although quite slower then regular cycles.

1 Like

Thanks, good to know. Yes, there are a number of things which are going to be causing huge performance issues right now, they should be relatively easy to fix once they become a priority.

1 Like

I’m still amazed by how much more tonality is exposed in the spectral images you produced, I wasn’t expecting such a stark difference.

2 Likes

Seams to me that’s more about intensity differences the RGB lights are most intense hence their overcasting

1 Like

Maybe. I’d love to compare a Filmic version once that exists. Will certainly handle very bright regions more gracefully.

In this test I primarily tried to figure out how much I need to desaturate colors in order for the spectral rendering no longer to matter. It turns out, perhaps unsurprisingly, it depends on what primary you’re looking at. The spectral version of green has a solid overlap with both the red and the blue spectrum, so it’s rather strongly affected, whereas red and blue become pretty similar pretty quickly.

In these six images below, you always see the RGB version on the top and the spectral version below. Colors go from pure primaries to 30% equal parts the other two primaries added on top in a linear gradient from left to right.

22 Likes

So any progress lately? I really can’t wait for volumes on one hand and blackbody lights on the other to work because, from what I recall, one of the biggest motivations for going spectral was to properly model how skin looks like when lit by fire, with the three-light version usually coming out way too saturated and needing a LOT of post processing to make it work.

I assume to properly compare, you’d have to have an actual skin-specialized model modelling the spectral properties of real skin rather than a simple RGB selection, but even with just an RGB picked approximation the differences might be sizeable, if we at least have spectral blackbody lights which should be fairly easy to do.

(And now that I think about it, is there a spectral version of the Disney Hair Shader implementation? I’d imagine that should be doable as well - though that might be more involved, one thing at a time.)

Also really looking forward to that spectral Filmic

3 Likes

Hey @kram1032

I’ve been working on things slowly but I’m running into a pretty big roadblock. Currently the status is (mostly) as follows: anywhere that a bsdf node in a material takes in RGB, I am converting that to a spectrum before computing the light transport. You can provably see the issue here, in that colours are still RGB, and I’m just interpreting them in each bsdf as a spectrum, which means there’s no way of transferring spectrum information from one node to another (even blackbody, since that is actually a colour piped into an emission node).

So, I’ve hit a roadblock. I’ve been trying to make some progress in volumes too but because of the way they’re calculated it is going to be a much larger change than the other bsdfs.

Ill keep chipping away at it, but I would expect progress to be significantly slower for the next little while, while I try to remove the assumption that colour is RGB from the kernel. There will be another phase where I start adding/converting actual nodes in Blender (what you see in the material nodes UI) which I haven’t looked into at all yet. Once I’ve done both of those things, progress would likely speed up again.

5 Likes

Skin SSS can nicely fit into a spectral representation of SSS, but that would probably need to be developed almost from the ground up. Scattering and absorbtion of each wavelength is very hard to extrapolate from RGB values, so it might require some rethinking. Once there, though, I would expect much more realistic results, especially with coloured scenes like skin lit with candle light.

Yeah, I imagine the Disney hair bsdf could be applied in spectral quite easily, most of the calculations would be identical actually. Might be worth looking at that next, unless it is already working.

One thing to note here is that there are two (related) milestones here, the first is spectral light transport, which is pretty much done.
Then there’s the much larger task of spectral material creation. Volume and SSS materials sort of straddle both areas since you need to calculate distances and angles based on a colour, but it isn’t quite in the territory of a full spectral material.
That stage is the hard one to crack and will take significantly longer to do. I’m not even 100% sure it’s a one man job.

It may be a little easier if you remove the current RGB inputs defaults for bsdf and only accept a spectral input socket in its place? Then the only place where RGB to spectral conversion occurs is in input nodes (RGB, Vertex Color, Image texture, Environment texture) who’s outputs can be noodled into the bsdf nodes. The only place where spectral to RGB conversion occurs is just prior to compositing. Still, at some point, you would want to re-enable the user to enter spectral defaults into the nodes, but that has then become a UI issue: you’ll need to replace the RGB color picker i guess.

Maybe, it is useful to present some description or document on what requirements you identify to qualify as a spectral material in your implementation? That’ll open up the job to multiple man like a ‘call for content’?

2 Likes

That’s the plan. There’s just a lot of work to get to that point, considering I don’t yet understand any of the UI code and how data passes through blender and into the cycles kernel. There’s more investigation than anything at this stage, conceptually, everything I need to do is quite straightforward, but it’s how to actually achieve it in Blender which is the challenge.

This sounds like a great idea. Once I’m up to the point where I can convert a bsdf like diffuse, I might make a PR on GitHub that people could use as reference for converting other nodes over. That’d take a lot of the workload off for that part of the change.

6 Likes

Hello, I see great innovation and progress here. My first post on this forum. Have been tinkering with Blender for decades(s) now, once I submitted a project called Flexible Open Source Rendering solution, centered around Blender, but real project topic was what is owed to FSF. From what I have read, to me important things is internally handling spectral type and pseudo-real RNG - or what respected Mr. Adams called Infinite Improbability Drive. On a side note FFT is an old technology, with many implementations. My message is I Love all the great work everyone has done for betterment of 3D graphics and understanding of individuality of people. Love, Marko Radojčić

4 Likes

Slightly off-topic, but interesting in this context, is the just announced Mitsuba 2. It uses clever software engineering and compilation tricks to produce different renderer variants that can be targeted towards a specific type of color information, such as RGB rendering, spectral, polarized, etc (plus many more variations, like differentiable rendering).

2 Likes