Commit Graph

15209 Commits

Author SHA1 Message Date
Campbell Barton
e8e188cb7d Cleanup: various non-functional changes for C++ 2025-07-17 12:32:30 +10:00
Campbell Barton
fc07a4d45e Cleanup: quiet ignored qualifier & unused warnings 2025-07-17 12:30:39 +10:00
Campbell Barton
4d227dd593 GHOST: show assertion failures even when WITH_ASERT_ABORT=OFF
This makes GHOST_ASSERT behave like BLI_assert, where any non release
build shows an error even when assert doesn't abort.
2025-07-17 11:43:43 +10:00
Brecht Van Lommel
9cbc44d6fd Fix #142060: Cycles simple adaptive subdivision UVs wrong for non-quads
Also fixes #141983.

Pull Request: https://projects.blender.org/blender/blender/pulls/142111
2025-07-16 19:18:52 +02:00
Alaska
736559f320 Fix #139718: Always treat OSL cameras as inside a volume
Cycles automatically tries to decide if the camera ray should be a
surface or a volume + surface camera ray by checking to see if the
scene contains a volumetric material, and if it does, is it near
where the camera rays are expected to spawn. This step is done
during scene intialization.

With the OSL camera, it is impratical to predict where the
camera rays will spawn during scene intialization, which makes it
impratical to predict if the OSL camera ray will spawn near a
volumetric object. So this commit marks all OSL cameras as
"inside a volume", leading to the spawning of volume + surface camera
rays for OSL cameras while the scene contains a volumetric material.

This leads to increased render times ranging between 1% - 5% in scenes
that use a OSL camera, has a volumetric object in it, and the
volumetric object is far away from the camera. Every other scene should
see no performance impact.

Testing was done on a AMD Ryzen 9 5950X and a NVIDIA GeForce RTX 4090.

Pull Request: https://projects.blender.org/blender/blender/pulls/142036
2025-07-16 16:25:38 +02:00
Campbell Barton
19ee3932c3 Fix #141948: No error on arbitrary assignments to PropertyGroup
Declare `__slots__` to prevent arbitrary assignment.
2025-07-16 17:44:06 +10:00
Brecht Van Lommel
40339e3edd Merge branch 'blender-v4.5-release' 2025-07-14 17:39:16 +02:00
Brecht Van Lommel
c5df70a7d4 Fix #141779: Adaptive subdivision + custom OSL camera crash
This is not an actual solution, it falls back to a perspective camera instead
of crashing. Note full_rastertocamera exists specifically for computing raster
size for adaptive subdivision, and changing it should not affect anything else.

Pull Request: https://projects.blender.org/blender/blender/pulls/141905
2025-07-14 17:36:29 +02:00
Michael Jones
9d9d0a7259 Cycles: MTLAccelerationStructureUsagePreferFastIntersection on macOS>=26
macOS 26 introduces a new BVH usage hint: [MTLAccelerationStructureUsagePreferFastIntersection](https://developer.apple.com/documentation/metal/mtlaccelerationstructureusage/preferfastintersection?changes=_3&language=objc)

This will only be compiled if built with Xcode >= 26.

Pull Request: https://projects.blender.org/blender/blender/pulls/141891
2025-07-14 16:59:47 +02:00
Hans Goudey
c3181490f3 Cleanup: Formatting 2025-07-14 10:22:46 -04:00
Nikita Sirgienko
609f8ddbef Cycles: oneAPI: Fix DPC++ level issues for multi GPU execution
These changes introduce modifications to the SYCL queue creation
in OneapiDevice::create_queue. In case several DPC++ devices are
detected by Blender and exposed through it, we are now creating
a new SYCL context for each device, which allows us to prevent
execution failures due to some known issues in the DPC++ runtime
regarding multi GPU support. As this would have some small
performance impact, few percents, it is only applied to
multi GPU configurations, while the behavior for a single
GPU configuration remains the same.

Pull Request: https://projects.blender.org/blender/blender/pulls/141834
2025-07-14 14:33:42 +02:00
Brecht Van Lommel
c7ae49b99f Refactor: Cycles: Deduplicate get camera object code
Pull Request: https://projects.blender.org/blender/blender/pulls/141796
2025-07-14 12:29:09 +02:00
Brecht Van Lommel
a912102308 Merge branch 'blender-v4.5-release' 2025-07-14 12:25:00 +02:00
Brecht Van Lommel
0cda7fbacf Fix: Adaptive subdivision not updated when camera changes
Regression from ba5cf35d2a. Now that adaptive subdivision is not
excessively updated on all object changes, we need to specifically
check for this case.

Ref #141381

Pull Request: https://projects.blender.org/blender/blender/pulls/141886
2025-07-14 12:23:38 +02:00
Brecht Van Lommel
11246528b4 Fix #141798: Cycles adaptive subdivision doesn't interpolate vertex color
Corner colors were working, but not vertex colors.

Pull Request: https://projects.blender.org/blender/blender/pulls/141886
2025-07-14 12:23:09 +02:00
Campbell Barton
ec8751f826 Cleanup: white-space around C-style comment blocks
Also use C++ style comments for disabling code.
2025-07-13 21:58:53 +10:00
Campbell Barton
6eec7e3bb1 Merge branch 'blender-v4.5-release' 2025-07-13 16:25:52 +10:00
Campbell Barton
2983ea4616 Cleanup: format 2025-07-13 16:25:25 +10:00
Campbell Barton
d4b2f719c3 Merge branch 'blender-v4.5-release' 2025-07-13 15:48:34 +10:00
Campbell Barton
601b5f49f0 Disable fix for #141846
While this works in 4.5x it could lock the UI in some cases in main.
Avoid possible regressions & disable for now.
2025-07-13 15:43:22 +10:00
Campbell Barton
98a949f997 Fix #141846: Successive calls to change the cursor exits on Wayland
Calling wm.progress_update() from Python in a loop would exit
under Wayland.

Resolve by calling wl_display_dispatch after changing the cursor.
2025-07-13 04:56:39 +00:00
Harley Acheson
bea1dbfab0 UI: Cursor Time for RGBA Platforms
The Windows and Wayland platforms can both create antialiased mouse
cursors from SVG sources. Platforms with WM_CAPABILITY_CURSOR_RGBA
can therefore show a better version of "WM_cursor_time". Instead of
four blocky digits in two rows this displays beautiful digits in a
single row.

Pull Request: https://projects.blender.org/blender/blender/pulls/141367
2025-07-12 05:22:41 +02:00
Hans Goudey
8f198a85b4 Refactor: Add RNA_string_get function returning a string
This can replace most uses `RNA_string_get_alloc` and give us
better type safety and generally simpler code.

Internally, this uses the function added in 50076993f3.

Pull Request: https://projects.blender.org/blender/blender/pulls/141358
2025-07-11 16:24:13 +02:00
Brecht Van Lommel
f38b4323f9 Fix: Build error with NDEBUG after recent fix for log level macro 2025-07-10 21:10:36 +02:00
Jorn Visser
035bc3e7ca Fix #115940, #111152: Handle access violations while loading Wintab
Some Wintab drivers can randomly crash while loading. Guard against this
by catching such exceptions using SEH. Also save and restore the current
unhandled exception filter as some drivers replace it with their own for
some reason.

Pull Request: https://projects.blender.org/blender/blender/pulls/141685
2025-07-10 19:59:34 +02:00
Brecht Van Lommel
73fe848e07 Fix: Cycles log levels conflict with macros on some platforms
In particular DEBUG, but prefix all of them to be sure.

Pull Request: https://projects.blender.org/blender/blender/pulls/141749
2025-07-10 19:44:14 +02:00
Harley Acheson
1d83c555fd Core: Clog Needs MINMAX define for Win32
Windows.h, otherwise we can get errors about the use of std::min
and std:max because of a conflict with macro definitions of "min"
and "max" in Windows.h. The reason for this being needed now and
not earlier is because of changes to an updated windows SDK
installed by a recent security update.

Pull Request: https://projects.blender.org/blender/blender/pulls/141696
2025-07-10 18:15:54 +02:00
Miguel Pozo
b5ca00a403 Merge branch 'blender-v4.5-release' 2025-07-10 18:00:04 +02:00
Xavier Hallade
94e9203713 Fix previous 4.5 merge 2025-07-10 17:47:03 +02:00
Xavier Hallade
48f89ff1c3 Merge branch 'blender-v4.5-release' 2025-07-10 17:43:30 +02:00
Michael Jones
7ec0adf033 Fix: Cycles MetalRT motion blur crash in some scenes with static objects
Crash encountered during top-level BVH setup of an Agent 327 asset. Object had no keyframes so `decomp` was empty. Use the object's transform instead.

Pull Request: https://projects.blender.org/blender/blender/pulls/141740
2025-07-10 17:42:49 +02:00
Xavier Hallade
05f27f594e Fix #141661: Crash when selecting oneAPI in preferences with legacy drivers
On systems with multiple Intel GPUs with a mix of recent and old
unsupported drivers (such as 101.3302), the Level-Zero stack may have
troubles initializing, leading to a crash while enumerating devices.

Luckily this condition actually leads to an exception we can catch,
as implemented here in this commit.

Pull Request: https://projects.blender.org/blender/blender/pulls/141674
2025-07-10 17:36:00 +02:00
Campbell Barton
ce7561982a Cleanup: use conventional license formatting
Quiet "make check_licenses" warning.
2025-07-10 00:38:11 +00:00
Campbell Barton
16e06a29f0 Cleanup: typo, spelling 2025-07-10 00:38:09 +00:00
Lukas Stockner
eaa5f63ba2 Cycles: Replace thin-film basis function approximation with accurate LUTs
Previously, we used precomputed Gaussian fits to the XYZ CMFs, performed
the spectral integration in that space, and then converted the result
to the RGB working space.

That worked because we're only supporting dielectric base layers for
the thin film code, so the inputs to the spectral integration
(reflectivity and phase) are both constant w.r.t. wavelength.

However, this will no longer work for conductive base layers.
We could handle reflectivity by converting to XYZ, but that won't work
for phase since its effect on the output is nonlinear.

Therefore, it's time to do this properly by performing the spectral
integration directly in the RGB primaries. To do this, we need to:
- Compute the RGB CMFs from the XYZ CMFs and XYZ-to-RGB matrix
- Resample the RGB CMFs to be parametrized by frequency instead of wavelength
- Compute the FFT of the CMFs
- Store it as a LUT to be used by the kernel code

However, there's two optimizations we can make:
- Both the resampling and the FFT are linear operations, as is the
  XYZ-to-RGB conversion. Therefore, we can resample and Fourier-transform
  the XYZ CMFs once, store the result in a precomputed table, and then just
  multiply the entries by the XYZ-to-RGB matrix at runtime.
  - I've included the Python script used to compute the table under
    `intern/cycles/doc/precompute`.
- The reference implementation by the paper authors [1] simply stores the
  real and imaginary parts in the LUT, and then computes
  `cos(shift)*real + sin(shift)*imag`. However, the real and imaginary parts
  are oscillating, so the LUT with linear interpolation is not particularly
  good at representing them. Instead, we can convert the table to
  Magnitude/Phase representation, which is much smoother, and do
  `mag * cos(phase - shift)` in the kernel.
  - Phase needs to be unwrapped to handle the interpolation decently,
    but that's easy.
  - This requires an extra trig operation in the kernel in the dielectric case,
    but for the conductive case we'll actually save three.

Rendered output is mostly the same, just slightly different because we're
no longer using the Gaussian approximation.

[1] "A Practical Extension to Microfacet Theory for the Modeling of
    Varying Iridescence" by Laurent Belcour and Pascal Barla,
    https://belcour.github.io/blog/research/publication/2017/05/01/brdf-thin-film.html

Pull Request: https://projects.blender.org/blender/blender/pulls/140944
2025-07-09 22:10:28 +02:00
Lukas Stockner
cf92af3ac4 Cycles: Support Thin Film iridescence in the Glass BSDF
Supporting this on the Metallic BSDF will require some extra work,
and on the Glossy BSDF it doesn't make much sense conceptually
(for that kind of shader setup, we'll want to support layering in SVM),
but Glass BSDF just needs to be hooked up so might as well do that.

Pull Request: https://projects.blender.org/blender/blender/pulls/140832
2025-07-09 22:07:24 +02:00
Hans Goudey
e573d9dd24 Revert "Wayland: Set surface color management"
This reverts commit 965b4dce6d.

This commit caused #141688.
2025-07-09 15:11:58 -04:00
Brecht Van Lommel
13ab5067ce Cycles: Detect volume attribute nodes that can use stochastic sampling
Detect which volume attributes nodes have a linear mapping to their usage
as density / color / temperature in volume shader nodes, and use stochastic
sampling for them.

Pull Request: https://projects.blender.org/blender/blender/pulls/132908
2025-07-09 21:04:38 +02:00
Brecht Van Lommel
646dc7fe4d Cycles: Use stochastic sampling to speed up tricubic volume filter
Stochastically turn a tricubic filter into a trilinear one. This
reduces the number of taps from 64 to 8. It combines ideas from
the "Stochastic Texture Filtering" paper and our previous GPU
sampling of 3D textures.

This is currently only used in a few places where we know stochastic
interpolation is valid or close enough in practice.
* Principled volume density, color and temperature
* Motion blur velocity

On an Macbook Pro M3 with the openvdb_smoke.blend regression test
and cubic sampling, this gives a ~2x speedup for CPU and ~4x speedup
for GPU. However it also increases noise, usually only a little. Equal
time renders for this scene show a clear reduction in noise for both
CPU and GPU.

Note we can probably get a bigger speedup with acceptable noise trade-off
using full stochastic sampling, but will investigate that separately.

Pull Request: https://projects.blender.org/blender/blender/pulls/132908
2025-07-09 21:04:38 +02:00
Brecht Van Lommel
4c25b49875 Refactor: Cycles: Deduplicate 3D texture sampling between devices
Pull Request: https://projects.blender.org/blender/blender/pulls/132908
2025-07-09 21:04:38 +02:00
Brecht Van Lommel
b6c4233b28 Refactor: Cycles: Remove now unused 3D image texture support
Pull Request: https://projects.blender.org/blender/blender/pulls/132908
2025-07-09 21:04:38 +02:00
Brecht Van Lommel
7978799e6f Cycles: Always render volume as NanoVDB
All GPU backends now support NanoVDB, using our own kernel side code
that is easily portable. This simplifies kernel and device code.

Volume bounds are now built from the NanoVDB grid instead of OpenVDB,
to avoid having to keep around the OpenVDB grid after loading.

While this reduces memory usage, it does have a performance impact,
particularly for the Cubic filter. That will be addressed by
another commit.

Pull Request: https://projects.blender.org/blender/blender/pulls/132908
2025-07-09 21:04:38 +02:00
Brecht Van Lommel
8cf031ba95 Fix: Wrong Cycles NanoVDB memory alignment on Windows
This was not a problem in practice so far, but will be with upcoming changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/132908
2025-07-09 20:59:27 +02:00
Brecht Van Lommel
8111152c67 Refactor: Cycles: Add some OpenVDB and NanoVDB functions to util
OpenVDB to NanoVDB was moved, a new NanoVDB to OpenVDB mask grid was
added for future use. Some redundant CMake code was simplified.

Pull Request: https://projects.blender.org/blender/blender/pulls/132908
2025-07-09 20:59:27 +02:00
Brecht Van Lommel
bc507861f2 Logging: Some tweaks to capitalization and log levels
For NDOF, Vulkan context, operators and events.

Pull Request: https://projects.blender.org/blender/blender/pulls/140244
2025-07-09 20:59:27 +02:00
Brecht Van Lommel
d7cc940825 Logging: Log GHOST backend, GPU backend and GPU device
Important information that could not be found directly in the logs yet.

Pull Request: https://projects.blender.org/blender/blender/pulls/140244
2025-07-09 20:59:27 +02:00
Brecht Van Lommel
4653b65f7c Logging: Add DEBUG, TRACE severity, replace numeric levels
The numeric levels have no obvious meaning. This removes the distinction
between severity and levels, instead there is a single list of named levels
with defined meaning.

Debug means information that's mainly useful for developers, and trace is for
very verbose code execution tracing.

Pull Request: https://projects.blender.org/blender/blender/pulls/140244
2025-07-09 20:59:26 +02:00
Brecht Van Lommel
15d5f957ac Logging: Use CLOG for render progress
* Add render category, which is automatically enabled when using -f or -a
  command line flags for background rendering.
* Add extra logs to mention scene, view layer and frame ahead of time rather
  than including it in every line.
* Remaining time was removed from Cycles, this will be added back for animations
  at the render pipeline level.

Pull Request: https://projects.blender.org/blender/blender/pulls/140244
2025-07-09 20:59:26 +02:00
Brecht Van Lommel
edf2449e67 Logging: Various changes to CLOG
* Change order and formatting of messages
* Change WARN to WARNING, don't print INFO
* Change filter matching "foo" can be used instead of "foo.*"
* Write timestamp as hh::mm::ss.rrr
* Add memory usage writing
* Add macro to print certain INFO logs without checking level
* Indent multi-line log messages with first line
* Add mutex to avoid garbling multi-line logs
* Enable logging by either setting level or filter

Pull Request: https://projects.blender.org/blender/blender/pulls/140244
2025-07-09 20:59:25 +02:00
Brecht Van Lommel
cf36acbc0c Refactor: Cycles: Replace remaining fprintf with logging
Pull Request: https://projects.blender.org/blender/blender/pulls/140244
2025-07-09 20:59:25 +02:00