Thoughts on making Cycles into a spectral renderer

Is it intended that Gaussian Spectrum kills any transmittance?


Update: Deactivating normalization and multiplication by 2 helped:

I didn’t at all think of actual user input. Fiddling with something like that seems like a very niche-feature.
So basically what it’s gonna do is make more visible wavelengths (in that the response across the three receptors is stronger/brighter) more prominently sampled, more quickly reducing noise involving those wavelengths (and consequently, since they inherently have more effect on the overall image, also reducing noise overall) right?
How are you deciding what colors to sample more? Simply by the sum of responses? Or perhaps by the green response (which tends to be used as proxy for perceptual brightness if I understand right)?

That stuff is super technical and I don’t have any input at all on best practices or what not, just to be clear. I’m simply curious :slight_smile:

Gotta remember, this kind of node is gonna produce a fairly narrow spectrum, filtering out a LOT of colors almost entirely. It will potentially look near opaque very quickly, especially at low widths. Materials rarely are like this though. While it’s fine to use this node for them, it’s probably best used for lighting. (Especially at very narrow width. Think lasers)

Additionally, you’re using this spectrum as a surface. It’s like a glass Suzanne coated with a very thin layer of very dark but clear color. You might want to try using it as volume absorption material instead. It’s also gonna be more realistic (if you’re going for actual thick glass, rather than something coated) as, say, the ears are gonna look somewhat lighter than the bulk of the head.

Also, I noticed that bounce depth matters quite a lot: You’ll probably want to up transmissive and specular bounces. It often makes for MUCH brighter materials.
I know it’s not at all optimal, but I tend to just max out bounces to make sure I don’t get any blackness where there shouldn’t be any.

Btw, on that note about normalization,
@pembem22 what exactly does that mean? Does it normalize to a maximum of 1 or such that the area beneath is 1 or…? And will non-normalized tend to peak higher or lower?
'cause if non-normalized peaks above normalized, isolin’s result is unphysical (stuff actually grows brighter on transmission)

1 Like

Yes you’re right. The current ‘importance’ of each wavelength is the XYZ sum of the wavelength’s coordinate. The idea is that this would be automated in the future using some scene heuristic (total light emitted could be a simple and relatively accurate one), but providing UI for now allow users use scenes with monochromatic light and resolve much, much faster for now.

The normalisation toggle switches between maintaining equal radiometric energy and being a lobe with a maximum of 1. Intended for using it with lights and materials respectively.

Multiplying the Gaussian spectrum by 2 is going to break energy conservation, raising it to a power and using a wider width instead would get a similar result while maintaining the energy conservation

Multiplying the Gaussian spectrum by 2 is going to break energy conservation, raising it to a power and using a wider width instead would get a similar result while maintaining the energy conservation

Ah ok good to know :slight_smile:

1 Like

That’s what I figured. Makes sense.

To add what smilebags said, you’ll want to raise it specifically to a low power (between 0 and 1) to make it effectively wider. - Changing the width parameter to something larger will have a similar but not identical effect.
Raising to a high power (above 1) will make the spectrum even sharper, thus making light less likely to pass through. It’s gonna be a bit like making the width smaller.
Raising to a negative power, meanwhile, will lead to energy non-conservation again.

1 Like

Is it just me or it is possible to simulate how different animals “see” by loading retina(cone) responses with CRF? :thinking:

3 Likes

Yep that would be possible. Not quite possible yet in this branch, but in theory that would be possible once we add the camera virtual primaries. Right now the curves don’t quite represent the spectral response of each ‘channel’ but instead represent the mapping from each wavelength directly to XYZ. We’d need a slightly more generic system to be able to handle that.

1 Like

Technically there’s a lot of extras to consider. For instance, Mantis Shrimp are known for having a TON of different color receptors. But it turns out they use them in a different way from us. The color information from all those receptors aren’t nearly as finely processed as it happens for us. They are surprisingly bad at differentiating colors from what I read.

But what’s certainly theoretically possible is to obtain an image per color channel at least. It’s just not actually what they’d see.

In a similar way you could get what amounts to human night vision images by using the fourth kind of receptor we have as a basis.

3 Likes

It’s still pretty cool, though! I love the direction and amazing progress you guys make!:smiley: Once it becomes per-channel mapping it will open up a world of possibilities for both scientific visualization and look dev for retro and modern “film-look”. Fingers crossed!

4 Likes

As a canonical reference implementation, PBRT v4 was just made public:


“Rendering computations are always performed using point-sampled spectra; the use of RGB color is limited to the scene description (e.g., image texture maps), and final image output.”
5 Likes

Thanks for the link. I’ll take a look to see how they’ve addressed wavelength-dependency in materials such as refractive glass. That’s the biggest hurdle right now.

3 Likes

#linux-build

After a few weeks I tried to make a new Linux build, but this time without success. There are currently two errors when trying to build from @troy_s repo:

  1. make update fails with
git submodule update --init --recursive
Submodule 'release/datafiles/locale' (https://github.com/sobotka/blender-translations.git) registered for path 'release/datafiles/locale'
Submodule 'release/scripts/addons' (https://github.com/sobotka/blender-addons.git) registered for path 'release/scripts/addons'
Submodule 'release/scripts/addons_contrib' (https://github.com/sobotka/blender-addons-contrib.git) registered for path 'release/scripts/addons_contrib'
Submodule 'source/tools' (https://github.com/sobotka/blender-dev-tools.git) registered for path 'source/tools'
Cloning into '/content/blender/release/datafiles/locale'...
Cloning into '/content/blender/release/scripts/addons'...
Cloning into '/content/blender/release/scripts/addons_contrib'...
Cloning into '/content/blender/source/tools'...
Submodule path 'release/datafiles/locale': checked out 'bc6623180aee561cba84ac11f5959b31016612ef'
Submodule path 'release/scripts/addons': checked out '1bc96468a144750348ea6b134d4aaf457d7cc6cf'
Submodule path 'release/scripts/addons_contrib': checked out 'f2f4a8b3bfa36ee49f7bdb3a1acb40ef4b39ee3a'
fatal: remote error: upload-pack: not our ref 44ae9d181c734c14ae22feb0d33ad39a626f8ce7
fatal: The remote end hung up unexpectedly
Fetched in submodule path 'source/tools', but it did not contain 44ae9d181c734c14ae22feb0d33ad39a626f8ce7. Direct fetching of that commit failed.
GNUmakefile:505: recipe for target 'update' failed
make: *** [update] Error 1
  1. Then make itself fails at OptiX kernel:
Scanning dependencies of target cycles_kernel_optix
[  6%] Generating kernel_optix.ptx
/usr/include/x86_64-linux-gnu/bits/stdint-uintn.h(27): error: invalid redeclaration of type name "uint64_t"
/content/blender/intern/cycles/kernel/../kernel/kernel_compat_optix.h(35): here

1 error detected in the compilation of "/tmp/tmpxft_00002515_00000000-6_kernel_optix.cpp1.ii".
intern/cycles/kernel/CMakeFiles/cycles_kernel_optix.dir/build.make:262: recipe for target 'intern/cycles/kernel/kernel_optix.ptx' failed
make[3]: *** [intern/cycles/kernel/kernel_optix.ptx] Error 1
CMakeFiles/Makefile2:1466: recipe for target 'intern/cycles/kernel/CMakeFiles/cycles_kernel_optix.dir/all' failed
make[2]: *** [intern/cycles/kernel/CMakeFiles/cycles_kernel_optix.dir/all] Error 2
make[2]: *** Waiting for unfinished jobs....
[  6%] Building CXX object intern/libmv/CMakeFiles/bf_intern_libmv.dir/libmv/simple_pipeline/camera_intrinsics.cc.o
[  6%] Building CXX object intern/libmv/CMakeFiles/bf_intern_libmv.dir/libmv/simple_pipeline/detect.cc.o
[  6%] Building CXX object intern/libmv/CMakeFiles/bf_intern_libmv.dir/libmv/simple_pipeline/distortion_models.cc.o
[  6%] Building CXX object intern/libmv/CMakeFiles/bf_intern_libmv.dir/libmv/simple_pipeline/initialize_reconstruction.cc.o
[  6%] Building CXX object intern/libmv/CMakeFiles/bf_intern_libmv.dir/libmv/simple_pipeline/intersect.cc.o
[  6%] Building CXX object intern/libmv/CMakeFiles/bf_intern_libmv.dir/libmv/simple_pipeline/keyframe_selection.cc.o
[  6%] Building CXX object intern/libmv/CMakeFiles/bf_intern_libmv.dir/libmv/simple_pipeline/modal_solver.cc.o
[  6%] Building CXX object intern/libmv/CMakeFiles/bf_intern_libmv.dir/libmv/simple_pipeline/pipeline.cc.o
[  6%] Building CXX object intern/libmv/CMakeFiles/bf_intern_libmv.dir/libmv/simple_pipeline/reconstruction.cc.o
[  6%] Building CXX object intern/libmv/CMakeFiles/bf_intern_libmv.dir/libmv/simple_pipeline/reconstruction_scale.cc.o
[  6%] Building CXX object intern/libmv/CMakeFiles/bf_intern_libmv.dir/libmv/simple_pipeline/resect.cc.o
[  6%] Building CXX object intern/libmv/CMakeFiles/bf_intern_libmv.dir/libmv/simple_pipeline/tracks.cc.o
[  7%] Building CXX object intern/libmv/CMakeFiles/bf_intern_libmv.dir/libmv/tracking/brute_region_tracker.cc.o
[  7%] Building CXX object intern/libmv/CMakeFiles/bf_intern_libmv.dir/libmv/tracking/hybrid_region_tracker.cc.o
[  7%] Building CXX object intern/libmv/CMakeFiles/bf_intern_libmv.dir/libmv/tracking/klt_region_tracker.cc.o
[  7%] Building CXX object intern/libmv/CMakeFiles/bf_intern_libmv.dir/libmv/tracking/pyramid_region_tracker.cc.o
[  7%] Building CXX object intern/libmv/CMakeFiles/bf_intern_libmv.dir/libmv/tracking/retrack_region_tracker.cc.o
[  7%] Building CXX object intern/libmv/CMakeFiles/bf_intern_libmv.dir/libmv/tracking/track_region.cc.o
[  7%] Building CXX object intern/libmv/CMakeFiles/bf_intern_libmv.dir/libmv/tracking/trklt_region_tracker.cc.o
[  7%] Linking CXX static library ../../lib/libbf_intern_libmv.a
[  7%] Built target bf_intern_libmv
Makefile:162: recipe for target 'all' failed
make[1]: *** [all] Error 2
GNUmakefile:308: recipe for target 'all' failed
make: *** [all] Error 2

New build available! What’s new:

  • Fixed bugs with reroute nodes connected to spectral sockets
  • Fixed nodes with spectral sockets not properly muted
  • Added wavelength importance sampling (automatically generates from CRF)
  • Added new Curves widget type dedicated to spectrum (background is generated from CRF)
    image
  • Small bug fixes and optimizations to Curves widget (merged to master as well)
  • Updated Blender
19 Likes

@kram1032 this scene should work properly now.

2 Likes

@pembem22 For Linux the issue with updating submodules is fine now, but during build I still get the same error causing it to crash. The standard Blender branch builds without problems.

[  4%] Generating kernel_optix.ptx
/usr/include/x86_64-linux-gnu/bits/stdint-uintn.h(27): error: invalid redeclaration of type name "uint64_t"
/content/blender/intern/cycles/kernel/../kernel/kernel_compat_optix.h(35): here

1 error detected in the compilation of "/tmp/tmpxft_00001b4e_00000000-6_kernel_optix.cpp1.ii".
intern/cycles/kernel/CMakeFiles/cycles_kernel_optix.dir/build.make:262: recipe for target 'intern/cycles/kernel/kernel_optix.ptx' failed
make[3]: *** [intern/cycles/kernel/kernel_optix.ptx] Error 1
CMakeFiles/Makefile2:1466: recipe for target 'intern/cycles/kernel/CMakeFiles/cycles_kernel_optix.dir/all' failed
make[2]: *** [intern/cycles/kernel/CMakeFiles/cycles_kernel_optix.dir/all] Error 2
make[2]: *** Waiting for unfinished jobs....

Any idea where this comes from? Does the spectral branch additionally reference stdint-uintn.h or does it declare typedef unsigned long long uint64_t; elsewhere? The file kernel_compat_optix.h looks the same in both branches: master and spectral.

What awesome progress @pembem22, really nice work on this one. Absolutely couldn’t have gotten this far without you.

1 Like

Looks like stdint-uintn.h is included in stdint.h. This header is included in two places in the Cycles code and neither has any differences when comparing to the master branch. I’m not sure what’s the reason.