I'm working on a project that will be evaluated in my university class "image processing and computer vision": I'm trying to recreate some experiment we studied in class with Cycles and, in order to do so, i need to access the "sample patter" code: the "correlated multi-jitter" should be the most usefull patter to work on but i can't find the code anywhere. I already checked the documentation and the wiki and asked on a bunch of groups and pages, but nobody seems capable to help.

Thank to all those who'll answer. Have a nice day

  • $\begingroup$ "I need to access the sample pattern code", " I already checked....". Did you download the source code and search among the files? Blender · rB $\endgroup$
    – HikariTW
    Aug 25, 2020 at 9:36

1 Answer 1


The implementation of the correlated multi-jitter can be found in blender/intern/cycles/kernel/kernel_jitter.h . The functions are called cmj_sample_1D and cmj_sample_2D. The code is based on Andrew Kensler, "Correlated Multi-Jittered Sampling", Pixar Technical Memo 13-01, 2013.

Here is how you can find this yourself:

  1. Enabled Python Tooltips in the preferences (Edit > Preferences > Interface)
  2. Hover over the sampling pattern drop-down in the UI until the tooltip appears. Take note of properties name, it is sampling_pattern.
  3. Search for sampling_pattern in Blender's code. This can either be done in your local copy of the code or online through Blender's website or its GitHub mirror.
  4. Find the code that implements the property first and try to figure out how it is used. You will notice that the property can be found in blender/intern/cycles/blender/addon/properties.py and the values that can be select for it come from enum_sampling_pattern.
  5. The type that defines the enums that could be assigned can be seen in blender/intern/cycles/render/integrator.cpp and here. The name of the enum is SamplingPattern. The entry SAMPLING_PATTERN_CMJ is for the correlated multi-jitter.
  6. Searching for the occurrences of SAMPLING_PATTERN_CMJ shows that it is used in blender/intern/cycles/kernel/kernel_random.h. The functions to compute the correlated multi-jitter are called cmj_sample_1D and cmj_sample_2D. Both are implemented in blender/intern/cycles/kernel/kernel_jitter.h .
  • $\begingroup$ Thanks for the hunting-down instructions.. very useful. Q: Why are these function definitions in header files? $\endgroup$
    – Robin Betts
    Aug 25, 2020 at 10:52
  • 1
    $\begingroup$ @RobinBetts I'm not sure, I'd have to ask the other devs. I think it might be, because it allows to use the code for CUDA and OpenCL. $\endgroup$
    – Robert Gützkow
    Aug 25, 2020 at 11:45
  • $\begingroup$ This is really helpfull, thank you a lot. Hope to show you some good result soon! Have a nice day ;) $\endgroup$ Aug 25, 2020 at 12:20
  • $\begingroup$ @LeonardoVezzani If this answer solved your problem, please consider marking it as accepted by clicking on the checkmark next to it. $\endgroup$
    – Robert Gützkow
    Aug 25, 2020 at 12:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .