Commit Graph

13984 Commits

Author SHA1 Message Date
Ray Molenkamp
d761634fb3 Merge remote-tracking branch 'origin/blender-v4.2-release' 2024-06-06 09:11:11 -06:00
Alaska
599f6f612f Cycles: Add tool tips for debug blue noise sampling patterns
Pull Request: https://projects.blender.org/blender/blender/pulls/122816
2024-06-06 16:47:20 +02:00
Sergey Sharybin
a03985d6e4 Merge branch 'blender-v4.2-release' 2024-06-06 12:32:17 +02:00
Sergey Sharybin
7886ce7bd4 Fix: Cycles crash when using multiple devices
Additional requirement is to have OpenImageDenoiser, and the devices
should not support OIDN denoiser.

Reproduced here in the studio with a system on Linux with either double
Quadro GP100 cards, and Limnux with Quadro 6000 + Quadro 6000 ADA.

The reason for the crash is that the find_best_device() might return
nullptr, and it was never checked.

Pull Request: https://projects.blender.org/blender/blender/pulls/122823
2024-06-06 12:31:31 +02:00
Campbell Barton
d98a7a7756 Merge branch 'blender-v4.2-release' 2024-06-06 10:23:16 +10:00
Campbell Barton
7f7648c6ed Cleanup: spelling in code comments & minor edits
- Use uppercase NOTE: tags.
- Correct bNote -> bNode.
- Use colon after parameters.
- Use doxy-style doc-strings.
2024-06-06 09:55:13 +10:00
Lukas Stockner
db991d8ac0 Cycles: Only store per-pixel seed for vertex color baking
Currently, during baking each pixel stores a seed input that comes from the
Blender side. This is only needed for vertex color baking, however -
for regular image baking, we can just as well hash the pixel coordinates.

Therefore, we can save some memory (4 byte per pixel) by splitting the seed
info out into a separate pass and only storing it when needed.

Pull Request: https://projects.blender.org/blender/blender/pulls/122806
2024-06-06 00:45:38 +02:00
Lukas Stockner
a4d933e93e Cycles: Clamp sample number during viewport navigation to max samples
Previously, Cycles would render up to 4SPP during viewport navigation when
using reduced resolution, even when the overall number of samples was set
lower.

This causes problems with the blue-noise pattern, so ensure that the
number of samples is always clamped to the configured maximum.
2024-06-05 23:17:09 +02:00
Lukas Stockner
27ec99c568 Cycles: Fix building without OpenImageDenoise 2024-06-05 20:24:51 +02:00
Nikita Sirgienko
2ced22611a Cycles: Fix missing adjustment for device, used for denoising
This is a proper fix for the issue worked around in 11d311e300.

Previously, an incorrect condition adjustment of the device info
was done for a preferred device. Now, this change reverts that
condition, and the adjustment is done correctly and unconditionally.
2024-06-05 11:53:31 +02:00
Lukas Stockner
f3f05f945c Cycles: Add missing make_uintX definitions for Metal 2024-06-05 03:04:04 +02:00
Lukas Stockner
79ddd07e76 Cleanup: Formatting 2024-06-05 03:04:03 +02:00
Lukas Stockner
5246fb5a57 Cycles: Implement blue-noise dithered sampling
This patch implements blue-noise dithered sampling as described by Nathan Vegdahl (https://psychopath.io/post/2022_07_24_owen_scrambling_based_dithered_blue_noise_sampling), which in turn is based on "Screen-Space Blue-Noise Diffusion of Monte Carlo Sampling Error via Hierarchical Ordering of Pixels"(https://repository.kaust.edu.sa/items/1269ae24-2596-400b-a839-e54486033a93).

The basic idea is simple: Instead of generating independent sequences for each pixel by scrambling them, we use a single sequence for the entire image, with each pixel getting one chunk of the samples. The ordering across pixels is determined by hierarchical scrambling of the pixel's position along a space-filling curve, which ends up being pretty much the same operation as already used for the underlying sequence.

This results in a more high-frequency noise distribution, which appears smoother despite not being less noisy overall.

The main limitation at the moment is that the improvement is only clear if the full sample amount is used per pixel, so interactive preview rendering and adaptive sampling will not receive the benefit. One exception to this is that when using the new "Automatic" setting, the first sample in interactive rendering will also be blue-noise-distributed.

The sampling mode option is now exposed in the UI, with the three options being Blue Noise (the new mode), Classic (the previous Tabulated Sobol method) and the new default, Automatic (blue noise, with the additional property of ensuring the first sample is also blue-noise-distributed in interactive rendering). When debug mode is enabled, additional options appear, such as Sobol-Burley.

Note that the scrambling distance option is not compatible with the blue-noise pattern.

Pull Request: https://projects.blender.org/blender/blender/pulls/118479
2024-06-05 02:29:47 +02:00
Weizhen Huang
2ddc936cbb Cleanup: simplify computation in Cycles area light sampling
`diff` in numerator and denominator cancels out, except for the signs,
which we know beforehand since `x1 > x0`, `y1 > y0`

Pull Request: https://projects.blender.org/blender/blender/pulls/122740
2024-06-04 23:37:48 +02:00
Xavier Hallade
a7171e0391 Cycles: oneAPI: Cleanup: Change packed_float3 to float3
float3 is already packed in oneAPI.
No functional change is expected.
2024-06-04 19:42:52 +02:00
zhanghe9702
b7303c5183 Fix: Cycles standalone build failures
Pull Request: https://projects.blender.org/blender/blender/pulls/122718
2024-06-04 19:04:29 +02:00
Michael Jones
5be30b7d2b Cycles: "Struct-of-array-of-packed-structs" for parts of the integrator state
On a M3 MacBook Pro, this change increases the benchmark score by 8% (with classroom seeing a path-tracing speedup of 15%).

The integrator state is currently store using struct-of-arrays, with one array per field. Such fine grained separation can result in poor GPU cache utilisation in cases where multiple fields of the same parent struct are accessed together. This PR changes the layout of the `ray`, `isect`, `subsurface`, and `shadow_ray` structs so that the data is interleaved (per parent struct) instead of separate. To try and keep this change localised, I encapsulated the layout change by extending the integrator state access macros, however maybe we want to do this more explicitly? (e.g. by updating every bit of code that accesses these parts of the state). Feedback welcome.

Pull Request: https://projects.blender.org/blender/blender/pulls/122015
2024-06-04 14:53:30 +02:00
Sergey Sharybin
6e0a49265a Fix #122622: Cycles GPU performance regression in certain scenes
This is an oversight of #122543, for which benchmarking was done in
the headless mode.

The solution is to tweak policy a little bit, and keep refresh intervals
low for the first 10 seconds of render, after which increase updates to
every 15 seconds. Doing so allows:

- Have quick cancel of complex files when the error is noticed during
  the first few samples.
- Have more predictable cancel time after long render.
- Mitigate the performance regression.

This does not fully solve the regression, but it makes it much more
manageable. There are some compromises to be done from the performance
for the UI renders. The interactivity is also not as fantastic, but it
could be solved later by introducing some "Instant Cancel" operations
which would be able to also stop render in the middle of a sample.

Performance measured with the Spring file (path tracing time in seconds):

    Samples:                  300    1024    2048
    Base (prior to #122543):  29.1   85.4    174.1
    This patch:               37.0   95.7    180.2

This is measured on M2 Ultra GPU render.

The penalty is close to a constant time (the time within which a more
interactive cancel is possible.

Pull Request: https://projects.blender.org/blender/blender/pulls/122658
2024-06-04 14:45:46 +02:00
Brad Smith
b0fdca60cd Cleanup: Mikktspace: use sqrtf() function with float type
Pull Request: https://projects.blender.org/blender/blender/pulls/121703
2024-06-04 14:27:17 +02:00
Sergey Sharybin
11d311e300 Fix: Cycles assert in device consistency check
A regression since #118841.

It is possible that the selected preference device is not found, in which
case a default-initialized DeviceInfo would have added to the list. This
device is set to CPU, but with differnet other fields (such as description)
compared to the actual CPU device.

Pull Request: https://projects.blender.org/blender/blender/pulls/122701
2024-06-04 12:49:30 +02:00
Lukas Stockner
e8c83aed17 Cleanup: Formatting 2024-06-04 02:01:44 +02:00
Lukas Stockner
fbc770d58b Cycles: Fallback to area PDF when spherical rectangles are too small
This fixes #69535 and #98930.

We use a equi-solid-angle sampling algorithm for rectangular area lights,
but it is not particularly robust for small area lights (either small
in general and/or small because it's being viewed from grazing angles).

The actual sampling part is fine since it just gets clamped into the
valid area anyways, and the difference isn't notable for small lights.

However, we also need to compute the solid angle to get the sampling PDF,
and that computation is quite sensitive to numerical issues for small
values.

Therefore, this commit adds a fallback path for small values, which instead
uses the classic equi-area sampling PDF term times the area-to-solid-angle
Jacobian term. This approximation assumes that all points on the light have
the same distance and angle to the sampling point, which is of course not
strictly the case, but it's close enough for small area lights and better
than failing altogether.

Pull Request: https://projects.blender.org/blender/blender/pulls/122323
2024-06-04 01:55:26 +02:00
Lukas Stockner
a5dc233aa2 Cycles: Tweak area light sampling to improve numerical robustness
Reformulates some terms in the equi-solid-angle rectangle sampling code to
handle small area lamps better, and allows for some rounding error in the
check whether the sampled position is inside the area light.

Pull Request: https://projects.blender.org/blender/blender/pulls/122323
2024-06-04 01:55:25 +02:00
Lukas Stockner
0566bf11b3 Cycles: Add debugging option to load custom OIDN weights
Pull Request: https://projects.blender.org/blender/blender/pulls/122591
2024-06-04 01:22:44 +02:00
Weizhen Huang
296ac0e9ef Cycles: improve light tree with large spot blend
In the original paper, the falloff inside `bcone.theta_e` is assumed to
be `pi/2`, which is too large for spot light and resulted in an
overestimation near the cone boundary.
To address this issue, attenuate the energy of a spot light using the
minimal possible angle formed by the light axis and the shading point
when traversing the light tree.

Ref: #122362

Pull Request: https://projects.blender.org/blender/blender/pulls/122667
2024-06-03 23:33:29 +02:00
Nikita Sirgienko
4651f8a08f Fix: Respect Blender Cycles setting for GPU denoising
Previously, GPU denoisers were ignoring settings about render
configuration and were using any available GPU. With these changes,
GPU denoisers will use the device selected in Blender Cycles
settings.
This allows any GPU denoiser to be used with CPU rendering.

Pull Request: https://projects.blender.org/blender/blender/pulls/118841
2024-06-03 22:41:25 +02:00
Brecht Van Lommel
a1d52ee950 Fix: Cycles CUDA runtime compilation should mark CUDA 12 as supported 2024-06-03 14:04:30 +02:00
Nikita Sirgienko
e0ecf443d4 Cycles: Fix compile error in 1465076a0a 2024-06-03 11:33:28 +02:00
Nikita Sirgienko
6d87a5d9ed Cleanup: Cycles: Fix type in the OpenImageDenoise name.
There are no functional changes expected.
2024-06-03 11:11:20 +02:00
Nikita Sirgienko
1465076a0a Refactor: Cycles: Unify error reporting code from denoiser's classes
There are no functional changes expected.
2024-06-03 11:11:19 +02:00
Nikita Sirgienko
cb8d2bf4ad Fix: Cycles: Add missing queue init in run_film_convert_kernels 2024-06-03 11:11:19 +02:00
Campbell Barton
7b30f657a5 Fix memory leak on exit with tablet seat data on Wayland 2024-06-01 22:54:52 +10:00
Sergey Sharybin
5f11ae70ea Fix: Cycles is not responsive to cancel render in complex scenes
In some of the complex scenes it could a very long time for Cycles
to respond to cancel request. This is because Cycles only cancels
render at a consistent state of render buffer: when all scheduled
samples are rendered.

This was caused by the render scheduler over-scheduling the number
of samples in an attempt to improve occupancy of the GPU.

This fix makes it so the scheduler only compensates for the low
occupancy if rendering can happen within a desired update time.

There is no visible difference in the benchmark scenes with this
change.

Pull Request: https://projects.blender.org/blender/blender/pulls/122543
2024-05-31 15:54:14 +02:00
Sergey Sharybin
c4d413fdad Fix: Cycles assert when having volumes and objects with displacement
Delay calculation of volume step until bounds are known, avoiding access
to non-valid bounds and fixing assert in debug builds.

This seems to be an oversight from the #121042

Pull Request: https://projects.blender.org/blender/blender/pulls/122549
2024-05-31 15:53:12 +02:00
Sergey Sharybin
6359464507 Fix #122263: Pause Preview icon does not update
Happens when opening a file saved file with preview paused.
This fix covers the typical use-case when the property is modified
from the space it comes from.

Pull Request: https://projects.blender.org/blender/blender/pulls/122502
2024-05-31 11:46:15 +02:00
Xavier Hallade
db8021d61a Cycles: oneAPI: explicitly enable/disable SYSMAN
ZES_ENABLE_SYSMAN is supposed to be set for free_memory queries to be
available.
These queries are then optionally used since
759bb6c768, for the host memory fallback
feature.
Setting SYCL_ENABLE_PCI was leading ZES_ENABLE_SYSMAN to be set by DPCPP
2022-12 but it's not used by newer versions of DPCPP.

We however temporarily disable SYSMAN by default on Linux as builds with
JEMALLOC enabled currently lead to driver runtime issues. These can be
worked around by using LD_PRELOAD=libigsc.so.
2024-05-30 12:16:16 +02:00
Xavier Hallade
0b3157dc93 Cleanup: Cycles: remove unused SYCL environment variable
SYCL_PI_LEVEL_ZERO_USE_COPY_ENGINE_FOR_IN_ORDER_QUEUE has been removed
from SYCL runtime years ago.
2024-05-30 11:43:26 +02:00
Jeroen Bakker
12a5b2977f Vulkan: Do not enable layers
Vulkan layers should not be controlled from application, but
 should be enabled via `vkconfig`. There are configurations
in the layers that are mutual exclusive and hard to maintain from
within an application.

An example is that currently we are not able to use renderdoc efficient,
because there is an validation error triggered from within renderdoc.

This PR removes all vulkan layer configuration from Blender.

Pull Request: https://projects.blender.org/blender/blender/pulls/122473
2024-05-30 11:11:21 +02:00
Nikita Sirgienko
8ee8d01711 Cycles: oneAPI: Fix Out-Of-Memory errors on some integrated GPUs 2024-05-29 21:57:13 +02:00
Sergey Sharybin
fa3eaac0ac Cycles: Limit the number of bounces in the shadow linking intersect kernel
Since the previous fix to properly support volumes and transparent objects
it became very easy to make it so the intersection loop takes all 1024
iterations to find intersections.

This change makes it so the number of intersection is limited by the max
number of volume/transparent bounces.

This should minimize possible performance impact of the previous fix.

Pull Request: https://projects.blender.org/blender/blender/pulls/122448
2024-05-29 21:53:12 +02:00
Brecht Van Lommel
133d6b1a33 Cleanup: Compiler warnings 2024-05-29 20:41:51 +02:00
Brecht Van Lommel
5d213d78e3 Fix #122362: Shadow linking with volumes and transparency misses light
We can't do the optimization to shorten the ray when we might still need
to go through transparent surfaces or volumes to reach the light.

This issue was not light tree specific, however in the test file it was
more noticable because the light tree poorly handles some areas. This in
in turn causes MIS weights for forward path tracing to become higher,
which is where the error was.

Pull Request: https://projects.blender.org/blender/blender/pulls/122404
2024-05-29 17:53:32 +02:00
Campbell Barton
c5a27f011e Cleanup: spelling in comments 2024-05-29 12:49:07 +10:00
Nikita Sirgienko
759bb6c768 Cycles: oneAPI: Enable host memory migration
This enables scenes with all textures not fitting in GPU
memory to finally render. For scenes that are fitting,
no functional change or performance change is expected.

Pull Request: https://projects.blender.org/blender/blender/pulls/122385
2024-05-28 19:04:19 +02:00
Campbell Barton
0cbadd00a3 Cleanup: various non functional changes 2024-05-28 14:09:40 +10:00
Campbell Barton
ca9b105e6c Cleanup: spelling in comments 2024-05-28 13:47:43 +10:00
Hoshinova
de6ff6eb0a Fix #121969: Noise texture outputs 0 with coordinates beyond 8.40*10^6
One of the properties of Perlin noise is that it always evaluates to 0.0
when not normalized (or 0.5 when normalized) when the input consists of
only whole integers in all vector components.

Blender's Perlin noise implementation uses single precision floats with
a machine epsilon of 1.19e-07 meaning that for numbers that are greater
than 1/(1.19e-07) = 8.40e6 there mantissa doesn't have any bits left to
store a rational part of the number, effectively meaning that any number
greater than 8.40e6 is a whole integer as far as Blender is concerned.
Therefore when evaluating Perlin noise for any coordinates greater than
that it always results in 0.0 (or 0.5 when normalized).

This fix works as follows: If the original input number is larger than
1.0e6 it is offset by 0.5 after it underwent modulo, which always outputs
numbers in a [0.0, 1.0e5) range leaving the mantissa room for a rational
part. This way the quantization error still persists however the outputs
are random again instead of a constant 0.0.

Pull Request: https://projects.blender.org/blender/blender/pulls/122112
2024-05-27 12:48:15 +02:00
Amine Bensalem
4708e9ec6d Fix #114780: Cycles: Principled Chiang Hair importance sampling correction
Principled Chiang hair longitudinal importance sampling correction,
according to the new pbrt fix here :
https://github.com/mmp/pbrt-v3/pull/256

Pull Request: https://projects.blender.org/blender/blender/pulls/115241
2024-05-27 09:35:35 +02:00
Lukas Stockner
896ef010f6 Fix #122031: Cycles: OSL implementation of Thin Film is missing 2024-05-24 23:55:12 +02:00
Jeroen Bakker
b6002872a1 Vulkan: Optional device extensions maintenance 4
When VK_EXT_maintenance4 extension is used at device creation its
extension should also be part of the device extension list.

This wasn't the case and would trigger UB in the validation layers.

Pull Request: https://projects.blender.org/blender/blender/pulls/122208
2024-05-24 13:39:04 +02:00