Commit Graph

8423 Commits

Author SHA1 Message Date
Brecht Van Lommel 7453c5ed67 Merge branch 'blender-v4.1-release' into main 2024-02-16 19:31:31 +01:00
Raul Fernandez 324ff4ddef macOS: Remove unnecessary checks now that minimum version is macOS 11.2
MacOS minimum version is now 11.2 we no longer need to check for lower API versions.

Pull Request: https://projects.blender.org/blender/blender/pulls/118388
2024-02-16 19:03:23 +01:00
Campbell Barton bdd40f167e Merge branch 'blender-v4.1-release' 2024-02-15 11:03:42 +11:00
Hans Goudey a52323d711 Cleanup: Move BKE_duplilist.hh to C++ 2024-02-14 10:51:46 -05:00
Brecht Van Lommel 088ae8d905 Build: Remove LLVM linking no longer needed by OSL
These are now included in the OSL shared libraries, so no reason to
link against it.

The CMake code for WITH_LLVM remains in case it is useful in the future,
but is not enabled by any Blender feature now.

Pull Request: https://projects.blender.org/blender/blender/pulls/118229
2024-02-14 12:06:52 +01:00
Campbell Barton 156fffbfde Merge branch 'blender-v4.1-release' 2024-02-14 14:29:55 +11:00
Brecht Van Lommel dd382be067 Fix #118020: Cycles OptiX OSL crashes
Turns out we were not building OSL with OptiX enabled anymore.
Also check now if the OSL builds has OptiX support and if not
disable it in Cycles.

Building OSL with support for this (still) does not require
either the OptiX SDK or CUDA, it only needs LLVM.

Pull Request: https://projects.blender.org/blender/blender/pulls/118234
2024-02-14 03:40:01 +01:00
Damien Picard 1410615079 Nodes: expose multi-input sockets to custom nodes in the Python API
Currently the multi-input sockets are not exposed to the custom nodes
Python API. This makes some features cumbersome to implement if one
wants a node to process an arbitrary number of inputs.
One workaround is to make inputs duplicate themselves when a link is
created, but a proper multi-input would be easier to use for both
add-on developers and users.

This commit exposes a new `use_multi_input` boolean parameter when
creating a new node socket. This makes it possible to declare a
multi-input, while still leaving the existing `is_multi_input`
property read-only so that existing nodes cannot be made unstable.

The parameter is optional so existing scripts stay compatible. It also
raises an error when used on output sockets, since it makes no sense
for those to be multi-input.

The Custom Node Tree Python template was updated to reflect this
change by making one of the inputs of the custom node multi-input.

Pull Request: https://projects.blender.org/blender/blender/pulls/114474
2024-02-12 20:28:56 +01:00
Nikita Sirgienko c48ea92429 Merge branch 'blender-v4.1-release' 2024-02-12 18:16:19 +01:00
Attila Afra 7b8c438715 Fix: Set OIDN GPU memory limit for all filters 2024-02-12 18:13:23 +01:00
Campbell Barton 3dbbc013de Cleanup: spelling in comments 2024-02-10 22:35:35 +11:00
Thomas Dinges 30a22b92ca Cycles: Rename SSE4.1 kernel to SSE4.2
This commit updates all defines, compiler flags and cleans up some code for unused CPU capabilities.

There should be no functional change, unless it's run on a CPU that supports sse41 but not sse42. It will fallback to the SSE2 kernel in this case.

In preparation for the new SSE4.2 minimum in Blender 4.2.

Pull Request: https://projects.blender.org/blender/blender/pulls/118043
2024-02-09 17:25:58 +01:00
Brecht Van Lommel 01f2c32700 Merge branch 'blender-v4.1-release' into main 2024-02-09 15:16:55 +01:00
Brecht Van Lommel 1e1a8d5c8f Fix: Cycles denoise fails with multi tile render and Use GPU off 2024-02-09 15:11:21 +01:00
Brecht Van Lommel f98468c988 Fix: Cycles uses GPU device for denoise even if disabled for scene 2024-02-09 15:02:46 +01:00
JonasDichelle f2e27ef7b6 Cycles: Override World option per View Layer
This feature is useful for many production scenarios as it allows for the
creation of separate render passes with specific worlds. This would help
workflows that require different skies or other backgrounds for compositing.

Ref #117919

Pull Request: https://projects.blender.org/blender/blender/pulls/117920
2024-02-09 12:16:16 +01:00
Sergey Sharybin 4196cbd175 Merge branch 'blender-v4.1-release' 2024-02-08 17:03:19 +01:00
Miguel Pozo 74b8f99b43 Render: Merge EEVEE and Cycles motion blur settings
Merge duplicated motion blur settings between Cycles and EEVEE,
and move them to `RenderData`/`scene.render`:
* `scene.cycles.motion_blur_position` -> `scene.render.motion_blur_position`
* `scene.eevee.use_motion_blur` -> `scene.render.user_motion_blur`
* `scene.eevee.motion_blur_position` -> `scene.render.motion_blur_position`
* `scene.eevee.motion_blur_shutter` -> `scene.render.motion_blur_shutter`

On the C/C++ side, this also renames `RenderData::blurfac` to
`RenderData::motion_blur_shutter`.

Pull Request: https://projects.blender.org/blender/blender/pulls/117913
2024-02-08 16:49:18 +01:00
Michael Jones 322a2f7b12 Cycles: Future-proof ordering of AppleGPUArchitecture enum
_No response_

Pull Request: https://projects.blender.org/blender/blender/pulls/117982
2024-02-08 16:31:52 +01:00
Nikita Sirgienko 9d0b811da6 Fix #117931: Swap oidn device when changing "Use GPU" during viewport render 2024-02-08 14:53:12 +01:00
Attila Afra e7dcad8599 Fix: Release all OIDN GPU resources when recreating denoiser 2024-02-07 19:44:40 +01:00
Brecht Van Lommel bd8a44e169 Lights: Option to use old point light falloff
Add new "Soft Falloff" option on point and spot light that uses
the old light behavior from Blender versions before 4.0. Blend
files saved with those older versions will use the option.

This option is enabled by default on new lights.

Fix #114241

Co-authored-by: Weizhen Huang <weizhen@blender.org>
Co-authored-by: Clément Foucault <foucault.clem@gmail.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/117832
2024-02-07 19:07:11 +01:00
Attila Afra 8e80b44796 Cycles: Fix initial OIDN GPU denoiser quality 2024-02-07 17:54:50 +01:00
Attila Áfra c1f55288e9 Fix: Cycles OIDN GPU denoiser bugs
- Incorrect accurate prefiltering of albedo and normal (lower than expected quality)
- Changing the prefiltering mode has no immediate effect
- Default memory limit is too high (more than OIDN default)
- Memory limit is applied only to the main filter
- Quality setting applied only to the main filter

Pull Request: https://projects.blender.org/blender/blender/pulls/117930
2024-02-07 13:34:35 +01:00
Nikita Sirgienko 06dc5363a9 Cycles: Denoise on CPU by default for offline render 2024-02-07 09:43:28 +01:00
Nikita Sirgienko 057b80dc9e Cycles: Log devices that are supported by OIDN 2024-02-06 23:40:57 +01:00
Nikita Sirgienko b2678156fa Cycles: Unify logging for devices discovery 2024-02-06 23:40:57 +01:00
Stefan Werner 31d55e87f9 Cycles: Metal support for OpenImageDenoise
This is supported on Apple Silicon GPUs and macOS 13.0+.

Co-authored-by: Stefan Werner <stefan.werner@intel.com>
Co-authored-by: Attila Afra <attila.t.afra@intel.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/116124
2024-02-06 21:13:23 +01:00
Nikita Sirgienko 280b5c89ae Cycles: Set quality parameter for OIDN
OpenImageDenoise API exposes two modes, high quality and balanced.
This currently only has effect on Nvidia devices, on which it
provides a noticeable performance improvement without visible
difference in quality. This change sets quality to balanced for
the viewport, and high quality for final frame rendering, as
it's what makes the most sense.

Ref #115045

Co-authored-by: Werner, Stefan <stefan.werner@intel.com>
Pull Request: #115265
2024-02-06 20:58:17 +01:00
Nikita Sirgienko c174fd4e06 Cycles: Fix Python error in has_oidn_gpu_devices
Was introduced during refactoring in bc886857f3
2024-02-06 20:26:05 +01:00
Nikita Sirgienko 0100547515 Cycles: Gray out hardware raytracing checkboxes when not available
HWRT checkboxes visibility in the Cycles settings wasn't uniform across devices.
With this change, we unify it and gray out these in case HWRT isn't available.

Pull Request: https://projects.blender.org/blender/blender/pulls/117904
2024-02-06 20:06:13 +01:00
Hans Goudey d9266853c2 Cleanup: Make format 2024-02-06 12:42:26 -05:00
Nikita Sirgienko bc886857f3 Cycles: Option to disable OpenImageDenoise GPU per scene
To reduce memory usage if needed.

Pull Request: https://projects.blender.org/blender/blender/pulls/117874
2024-02-06 17:46:21 +01:00
Alaska a3183fb95f Fix #117771: Incorrect Cycles texture position on emissive triangles
Pull Request: https://projects.blender.org/blender/blender/pulls/117801
2024-02-05 13:56:18 +01:00
Nikita Sirgienko cab974920f Cycles: Remove incorrect dead code for CUDA 32bit textures
Pull Request: https://projects.blender.org/blender/blender/pulls/117818
2024-02-05 13:53:51 +01:00
Brecht Van Lommel 3b1230d318 Cycles: Remove workaround for failing bake tests
This appear to no longer be needed, and this type of memory does not
work with OpenImageDenoise.

Ref #116124
2024-02-05 12:19:21 +01:00
Lukas Stockner b10507ab63 Fix #117586: Cycles: World Lightgroup not updated when creating/deleting LGs 2024-02-04 16:30:55 +01:00
Lukas Stockner 8d7ecd0856 Cycles: Use high value for Transparent BSDF PDF
The transparent BSDF is singular, so MIS shouldn't be applied.

Fixes #117657.
2024-02-04 00:35:54 +01:00
Campbell Barton 8b827a5bb5 Cleanup: spelling in comments 2024-02-02 10:48:22 +11:00
Brecht Van Lommel 1f142b3d44 Fix: Cycles MIS disabled unnecessarily with transparency, causing fireflies
This is a leftover from when there was a global option for transparent
shadows, but since it's now per material this makes no sense anymore.

Solution found by Olivier Maury.

Pull Request: https://projects.blender.org/blender/blender/pulls/117735
2024-02-01 21:23:28 +01:00
Sergey Sharybin 71253e1bb0 Fix Cycles baking forcing denoising of combined pass
This is mistake in the PR #117483

Simple solution: make the pass configuration logic to only disable
denoising, and never allow to enable it.

Pull Request: https://projects.blender.org/blender/blender/pulls/117723
2024-02-01 14:40:50 +01:00
Xavier Hallade 4d4f8bbfe4 Cycles: set num_sort_partition_elements to 8192 for oneAPI
The default value of 65536 wasn't optimal on Intel GPUs, switching to
8192 gives a 0 to 15% performance improvement depending on the scenes.
2024-01-31 17:25:34 +01:00
Xavier Hallade 18a20f373f Cycles: increase min Intel GPU driver version on Windows
With drivers 101.4972 to 101.5085, some Arc and Meteor Lake devices
ignore the prebuilt GPU binaries and since the addition of Meteor Lake
binaries, fail caching newly generated ones on Windows.
This got fixed in drivers 101.5186 so it's preferable to require these
new drivers to be used.
2024-01-31 12:49:30 +01:00
Alaska 58b9240c82 Cycles: Separate the caustics controls for Generalized Schlick
This allows users to turn off reflective and refractive caustics
separately from each other when using the Generalized Schlick material.

This will impact the Principled BSDF and Glass BSDF, along with some
custom OSL scripts.

Pull Request: https://projects.blender.org/blender/blender/pulls/117617
2024-01-30 10:31:32 +01:00
Alaska 7aca9a1ebb Fix #117611: Cycles NaN in microfacet BSDF with IOR 1.0
Pull Request: https://projects.blender.org/blender/blender/pulls/117622
2024-01-29 15:26:36 +01:00
Campbell Barton be7f89a9f5 Cleanup: spelling in comments 2024-01-29 11:47:42 +11:00
Lukas Stockner 82811cf489 Cycles: Support Type-A IES files
Seems to be a fairly niche type, but some people (apparently mostly in the automotive space) use it.

Also improves the handling of IES files in general and lets Cycles accept IES files that are technically violating the spec - which seems to be most of them...

Pull Request: https://projects.blender.org/blender/blender/pulls/114689
2024-01-29 01:03:47 +01:00
Alaska e6a3d46fe5 Cycles: Improve handling of Principled BSDF Caustics settings
Improve the handling of Principled BSDF Caustics from Metallic
and Transmissive components, improving consistency between SVM and OSL,
and offering more predictable results.

Pull Request: https://projects.blender.org/blender/blender/pulls/115081
2024-01-29 00:37:12 +01:00
Pierrick Bouvier a3d915310b Build: Fix some excessive Visual Studio compile times
While investigating Blender compilation time for windows-arm64, we
identified two compilation units that were taking a long time to compile
(~1h each). This affects windows-x64 builds as well.

Pull Request: https://projects.blender.org/blender/blender/pulls/117534
2024-01-28 12:12:52 +01:00
Sergey Sharybin 6f681105ec Cycles: Skip denoising during bake when pass does not support denoising
This changes fixes the slowdown when baking data passes like Normal with
the denoiser enabled on scene settings.

When baking to 4K textures denoising could take considerable amount of
time, which is better be avoided.

Pull Request: https://projects.blender.org/blender/blender/pulls/117483
2024-01-25 15:56:20 +01:00
Alaska ddc0aceefd Cycles UI: Hide HIP-RT settings on Linux
Hide the HIP-RT setting on Linux since it's not supported there yet.

Pull Request: https://projects.blender.org/blender/blender/pulls/117492
2024-01-25 15:16:13 +01:00
Brecht Van Lommel 8087dd9e96 Cleanup: Cycles: use one fewer object struct member for motion data 2024-01-24 20:17:13 +01:00
Brecht Van Lommel 5b6f2ef5a2 Cleanup: Cycles: rename some legacy names to new ones 2024-01-24 20:17:13 +01:00
Brecht Van Lommel b689027b3a Fix #114028: Cycles displace splits faces with smooth and flat faces
Cycles can use a per face flag to determine if a face is smooth or flat,
and there is no need to use corner normals in such cases. So revert to
not doing that as before, which also saves a bit of memory.

There is a pre-existing issue where faces are split by sharp edges and
autosmooth, which is not solved by this. It's only fixing the regression.
2024-01-24 19:55:31 +01:00
Stefan Werner d16d2bbd3a Cycles: Adding OIDN support for CUDA and OptiX devices
Small changes to turn on support and to build OIDN with the CUDA backend.

Co-authored-by: Werner, Stefan <stefan.werner@intel.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/115828
2024-01-24 08:19:39 +01:00
salipourto dd7a7791d7 Cycles: Remove and update deprecated compiler options for HIP
Pull Request: https://projects.blender.org/blender/blender/pulls/117428
2024-01-23 20:28:39 +01:00
Stefan Werner 4f58cffb4e Cycles: Use default CUDA context instead of creating a new one
This allows for Cycles and OIDN to share the same context.

Co-authored-by: Werner, Stefan <stefan.werner@intel.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/117230
2024-01-23 15:31:45 +01:00
Lukas Stockner b5a9c98e04 Fix #117081: Wrong Roughness when baking Principled BSDF
The pre-4.0 Principled BSDF had a special diffuse BSDF that contained
the roughness value from the node. Since 4.0, the regular Diffuse BSDF is used,
so we need to ignore it when determining the roughness value for baking.
2024-01-23 01:20:12 +01:00
Campbell Barton 5b59be81ba Cleanup: spelling in comments 2024-01-22 12:44:56 +11:00
Brecht Van Lommel cb787a458b Build: use C++17 for CUDA kernels when supported
This helps with compatibility with recent clang versions as host compiler.

Pull Request: https://projects.blender.org/blender/blender/pulls/117311
2024-01-19 15:19:33 +01:00
Damien Picard 3bd41cf9bc I18n: Go over TIP_ and IFACE_ usages, change to RPT_ when relevant
The previous commit introduced a new `RPT_()` macro to translate
strings which are not tooltips or regular interface elements, but
longer reports or statuses.

This commit uses the new macro to translate many strings all over the
UI.

Most of it is a simple replace from `TIP_()` or `IFACE_()` to
`RPT_()`, but there are some additional changes:
- A few translations inside `BKE_report()` are removed altogether
  because they are already handled by the translation system.
- Messages inside `UI_but_disable()` are no longer translated
  manually, but they are handled by a new regex in the translation
  system.

Pull Request: https://projects.blender.org/blender/blender/pulls/116804

Pull Request: https://projects.blender.org/blender/blender/pulls/116804
2024-01-12 13:37:32 +01:00
salipourto b358b89faa Fix #116810: Cycles HIP OpenImageDenoise device not available
Fixed the order of setting device id and querying OIDN.
This check needs info.id to be set.

Pull Request: https://projects.blender.org/blender/blender/pulls/117006
2024-01-11 15:28:43 +01:00
Jacques Lucke a94146b82c Cleanup: move BKE_pointcloud.h to C++
Pull Request: https://projects.blender.org/blender/blender/pulls/116990
2024-01-11 10:54:47 +01:00
Alaska 1f4cf2676f Cycles UI: Fix missing CPU settings under certain conditions
Fixes an issue where CPU specific render settings (e.g. path guiding)
would be hidden when GPU Compute has been selected for rendering,
but a GPU hasn't been selected in preferences.

Pull Request: https://projects.blender.org/blender/blender/pulls/116123
2024-01-10 19:52:06 +01:00
Brecht Van Lommel b0d919181d Fix #116792: Cycles render issue velocity attribute and motion steps > 1
In this case the object transform can use more motion steps, but the
geometry needs to have its motion steps fixed since the velocity
attribute completely overrides them.
2024-01-10 19:19:23 +01:00
Brecht Van Lommel dda8d0920a Fix #116211: Cycles light linking incorrect with transparent objects 2024-01-10 18:06:28 +01:00
Jacques Lucke 522f9c9834 Volumes: improve tree access token api
There was one functional issue with the previous API which was its
use in `VolumeGrid<T>::grid_for_write(tree_token)`. The issue was
that the tree token had to be received before the grid is accessed.
However, this `grid_for_write` method might create a copy of the
`VolumeGridData` internally and if it does, the passed in `tree_token`
corresponds to the wrong tree.

The solution is to output the token as part of the method. This has two
additional benefits:
* The API is more safe, because one can't pass an r-value into the methods
  anymore. This generally shouldn't be done, because the token should
  live at least as long as the OpenVDB tree is used and shouldn't be freed
  immediatly.
* The API is a bit simpler, because it's not necessary to call the
  `VolumeGrid.tree_access_token()` method anymore.
2024-01-10 15:20:29 +01:00
Sergey Sharybin 4d2f012049 Fix #115862: Shadow linking causes error on GPU
When a mesh light is shadow-linked to something with a specific
shader network it was possible that the emission_sd_storage was
not bit enough for sampling.

The shade_dedicate_light kernel only evaluates emission of either
light or mesh emitter and then resumes the regular path tracer.
There is no need to store closures.

This change makes it so a smaller storage is used, and also
passes flag to the shader evaluation function indicating that
closures are not to be stored.

Pull Request: https://projects.blender.org/blender/blender/pulls/116907
2024-01-08 18:03:23 +01:00
Brecht Van Lommel 0e4da8d55f Fix macOS ARM build failing with make lite
OpenImageIO headers have a dependency on Imath headers when not on x86_64.
2024-01-08 13:14:34 +01:00
Campbell Barton 617f7b76df Cleanup: comment block formatting 2024-01-08 11:31:43 +11:00
Campbell Barton 0ba83fde1f Cleanup: spelling in comments 2024-01-08 11:24:37 +11:00
Michael Jones 31001b67fd Cycles: Enable floating point atomic support in Metal
Utilises native floating point atomic operations if available. Supported in Metal 3.0+ onwards.
Authored by Apple: Michael Parkin-White

Pull Request: https://projects.blender.org/blender/blender/pulls/116786
2024-01-04 17:08:29 +01:00
Brecht Van Lommel ac70bc3611 Fix: temporarily disable Cycles patch map assert to avoid failing test
After recent 4.1 libraries update update for macOS ARM.
2024-01-04 04:06:19 +01:00
Brecht Van Lommel 364beee159 Tests: add option to build one binary per GTest file
Bundling many tests in a single binary reduces build time and disk space
usage, but is less convenient for running individual tests command line
as filter flags need to be used.

This adds WITH_TESTS_SINGLE_BINARY to generate one executable file per
source file. Note that enabling this option requires a significant amount
of disk space.

Due to refactoring, the resulting ctest names are a bit different than
before. The number of tests is also a bit different depending if this
option is used, as one uses gtests discovery and the other is organized
purely by filename, which isn't always 1:1.

Co-authored-by: Sergey Sharybin <sergey@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/114604
2024-01-03 18:35:50 +01:00
bsavery d2e91fb0d7 Cycles: add ROCm 6 compatibility for HIP
ROCm 6 brings some changes to the HIP API. This pull request is meant to be
backward and forward compatible.

That is Blender could be compiled with either ROCM 6 or 5 and run on either.
The main change is the hipMemoryType enum, which we check based on the
runtime version to use the correct enum values.

Without this, HIP will not work on Windows with upcoming 23.40 driver.

Pull Request: https://projects.blender.org/blender/blender/pulls/116713
2024-01-03 18:16:07 +01:00
Sergey Sharybin d86d86f729 Fix heap buffer overflow in Cycles IES parser
The IES parser in Cycles would lead to heap buffer overflow error
when non-supported or invalid data is provided to it.

The error was caused by the way how stirng is copied to vector
skipping the last null-terminator. Later C-style string utilities
are used for parsing, and they expect the data to be null-terminated.

It is unclear why data needs to be stored as vector: storing it as
string simplifies initialization.

Easiest to reproduce the issue is to use Blender build with address
sanitizer enabled.

Pull Request: https://projects.blender.org/blender/blender/pulls/116752
2024-01-03 18:00:41 +01:00
Brecht Van Lommel f63accd3b6 Cleanup: move CMake test utility functions into testing.cmake
Combining functions from macros.cmake and Modules/GTestTesting.cmake.
It was unusual to have Blender specific code in the Modules folder.

Pull Request: https://projects.blender.org/blender/blender/pulls/116719
2024-01-03 14:49:11 +01:00
Brecht Van Lommel d377ef2543 Clang Format: bump to version 17
Along with the 4.1 libraries upgrade, we are bumping the clang-format
version from 8-12 to 17. This affects quite a few files.

If not already the case, you may consider pointing your IDE to the
clang-format binary bundled with the Blender precompiled libraries.
2024-01-03 13:38:14 +01:00
Brecht Van Lommel 4ce14a639f Revert "Cleanup: move CMake test utility functions into testing.cmake"
This breaks execution of some Windows tests.

This reverts commit 4190a61020.
2024-01-02 19:06:39 +01:00
Alaska 9b3699db67 Fix: Cycles invalid normals in various situations
Fix issues related to NaN normals in some situations by trying
to detect when these cases might occur and just reverting back
to default normals.

As a side effect of these changes, OSL now behaves correctly
when given a non-normalized normal.

Pull Request: https://projects.blender.org/blender/blender/pulls/114960
2024-01-02 16:24:04 +01:00
Brecht Van Lommel 4190a61020 Cleanup: move CMake test utility functions into testing.cmake
Combining functions from macros.cmake and Modules/GTestTesting.cmake.
It was unusual to have Blender specific code in the Modules folder.
2024-01-02 15:34:52 +01:00
Alaska f0fcd553df Fix #116695: Cycles light tree crash with certain light visibility settings
Fixes an issue where triangles (and possibly lights) would not be added
to the light tree if the only visibility option it has enabled is volumetric
scattering.

This would lead to an assert during forward sampling because the light
would be treated as if it was in the light tree, and a light index
outside the light tree array would be sampled, which would trigger
the assert.

Pull Request: https://projects.blender.org/blender/blender/pulls/116703
2024-01-02 13:53:56 +01:00
Hans Goudey 06eda2a484 Cleanup: Remove most indirect includes of BKE_customdata.hh
Some common headers were including this. Separating the includes
will ideally lead to better conceptual separation between CustomData
and the attribute API too. Mostly the change is adding the file to
places where it was included indirectly before. But some code is
shuffled around to hopefully better places as well.
2023-12-26 23:59:44 -05:00
Nikita Sirgienko 3cadec1892 Cycles: Log number of scheduled tiles
Pull Request: https://projects.blender.org/blender/blender/pulls/116379
2023-12-21 09:39:16 +01:00
Hans Goudey edf8a776ac Cleanup: Use forward declarations to replace includes of BKE_attribute.hh
Remove most includes of this header inside other headers, to remove unnecessary
indirect includes which can have a impact on compile times. In the future we may
want more dedicated "_fwd.hh" headers, but until then, this sticks with the
solution in existing code.

Unfortunately it isn't yet possible to remove the include from `BKE_geometry_set.hh`.
2023-12-20 13:25:28 -05:00
Hans Goudey 19001c9e6c Cleanup: Move attribute domain enum to C++ header, use enum class
Each value is now out of the global namespace, so they can be shorter
and easier to read. Most of this commit just adds the necessary casting
and namespace specification. `enum class` can be forward declared since
it has a specified size. We will make use of that in the next commit.
2023-12-20 13:25:28 -05:00
Jacques Lucke a72e7a220d Volumes: refactor volume grid storage
This refactors how volume grids are stored with the following new goals in mind:
* Get a **stand-alone volume grid** data structure that can be used by geometry nodes.
  Previously, the `VolumeGrid` data structure was tightly coupled with the `Volume` data block.
* Support **implicit sharing of grids and trees**. Previously, it was possible to share data
  when multiple `Volume` data blocks loaded grids from the same `.vdb` files but this was
  not flexible enough.
* Get a safe API for **lazy-loading and unloading** of grids without requiring explicit calls
  to some "load" function all the time.
* Get a safe API for **caching grids from files** that is not coupled to the `Volume` data block.
* Get a **tiered API** for different levels of `openvdb` involvement:
  * No `OpenVDB`: Since `WITH_OPENVDB` is optional, it's helpful to have parts of the API that
    still work in this case. This makes it possible to write high level code for volumes that does
    not require `#ifdef WITH_OPENVDB` checks everywhere. This is in `BKE_volume_grid_fwd.hh`.
  * Shallow `OpenVDB`: Code using this API requires `WITH_OPENVDB` checks. However, care
  is taken to not include the expensive parts of `OpenVDB` and to use forward declarations as
  much as possible. This is in `BKE_volume_grid.hh` and uses `openvdb_fwd.hh`.
  * "Full" `OpenVDB`: This API requires more heavy `OpenVDB` includes. Fortunately, it turned
  out to be not necessary for the common API. So this is only used for task specific APIs.

At the core of the new API is the `VolumeGridData` type. It's a wrapper around an
`openvdb::Grid` and adds some features on top like implicit sharing, lazy-loading and unloading.
Then there are `GVolumeGrid` and `VolumeGrid` which are containers for a volume grid.
Semantically, each `VolumeGrid` has its own independent grid, but this is cheap due to implicit
sharing. At highest level we currently have the `Volume` data-block which contains a list of
`VolumeGrid`.

```mermaid
flowchart LR
  Volume --> VolumeGrid --> VolumeGridData --> openvdb::Grid
```

The loading of `.vdb` files is abstracted away behind the volume file cache API. This API makes
it easy to load and reuse entire files and individual grids from disk. It also supports caching
simplify levels for grids on disk.

An important new concept are the "tree access tokens". Whenever some code wants to work
with an openvdb tree, it has to retrieve an access token from the corresponding `VolumeGridData`.
This access token has to be kept alive for as long as the code works with the grid data. The same
token is valid for read and write access. The purpose of these access tokens is to make it possible
to detect when some code is currently working with the openvdb tree. This allows freeing it if it's
possible to reload it later on (e.g. from disk). It's possible to free a tree that is referenced by
multiple owners, but only no one is actively working with. In some sense, this is similar to the
existing `ImageUser` concept.

The most important new files to read are `BKE_volume_grid.hh` and `BKE_volume_grid_file_cache.hh`.
Most other changes are updates to existing code to use the new API.

Pull Request: https://projects.blender.org/blender/blender/pulls/116315
2023-12-20 15:32:52 +01:00
Hans Goudey 8dd8f932e2 Cleanup: Rename Mesh loop_data to corner_data
Related to #110434, efbee2d606, 7c69c8827b
2023-12-19 20:39:05 -05:00
Hans Goudey efbee2d606 Mesh: Rename totvert, totedge, and totloop fields
Use the standard "elements_num" naming, and use the "corner" name rather
than the old "loop" name: `verts_num`, `edges_num`, and `corners_num`.
This matches the existing `faces_num` field which was already renamed.

Pull Request: https://projects.blender.org/blender/blender/pulls/116350
2023-12-20 02:21:48 +01:00
Hans Goudey 7c69c8827b Mesh: Rename MLoopTri variable names, and functions
Make the naming consistent with the recent change from "loop" to
"corner". Avoid the need for a special type for these triangles by
conveying the semantics in the naming instead.

- `looptris` -> `corner_tris`
- `lt` -> `tri` (or `corner_tri` when there is less context)
- `looptri_index` -> `tri_index` (or `corner_tri_index`)
- `lt->tri[0]` -> `tri[0]`
- `Span<MLoopTri>` -> `Span<int3>`
- `looptri_faces` -> `tri_faces` (or `corner_tri_faces`)

If we followed the naming pattern of "corner_verts" and "edge_verts"
exactly, we'd probably use "tri_corners" instead. But that sounds much
worse and less intuitive to me.

I've found that by using standard vector types for this sort of data,
the commonalities with other areas become much clearer, and code ends
up being naturally more data oriented. Besides that, the consistency
is nice, and we get to mostly remove use of `DNA_meshdata_types.h`.

Pull Request: https://projects.blender.org/blender/blender/pulls/116238
2023-12-19 14:57:49 +01:00
Campbell Barton 482ba7806d Cleanup: spelling correction: "adjacent" & spelling in comments 2023-12-19 09:54:53 +11:00
Hoshinova f7e8021b2a Fix #116256: Unintentional override of node type property in API
Rename new noise node type to avoid conflict with node type.

Pull Request: https://projects.blender.org/blender/blender/pulls/116278
2023-12-18 10:35:20 +01:00
Hans Goudey 912c4c60d8 Mesh: Add viewport normals simplify option
Before #108014, toggling "Auto Smooth" was an easy way to disable
evaluation of custom normals and face corner normals for faster
viewport playback performance. Now that corner normals are calculated
automatically as necessary, it's helpful to still have a way to disable
expensive normal computation for faster playback.

This commit adds a "Normals" scene simplify setting. To avoid a bunch
of complexity, it just influences which normals are requested from the
object by viewport rendering. In my tests, skipping calculating at
least doubled viewport FPS in a few test files with a large mesh with
custom normals. This works well because normals are cached and lazily
calculated.

Pull Request: https://projects.blender.org/blender/blender/pulls/113975
2023-12-16 00:18:41 +01:00
Campbell Barton 944e0483a6 Cleanup: clarify naming for MLoopTri
The term `looptri` was used ambiguously for both single & arrays.
The term `tri` was also used, causing `tri->tri`.

Use terms:

- `looptris` for an array or when dealing with multiple items.
- `looptri` is used when dealing with a single item.
- `lt` for a single MLoopTri variables & arguments.

This was already a convention but not followed closely.
2023-12-14 12:32:11 +11:00
Brecht Van Lommel ac753fe9ae Fix: Cycles assert with CPU denoiser 2023-12-13 22:27:46 +01:00
Stefan Werner fd8bb41224 Cycles: Enable HIP devices for OpenImageDenoise
This enables the HIP backend of OpenImageDenoise on supported devices.

Co-authored-by: Werner, Stefan <stefan.werner@intel.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/115854
2023-12-13 21:38:19 +01:00
Weizhen Huang 858349d821 Fix #113728: fireflies in Principled Hair Huang with MIS
The function `has_surface_transparent()` needs to be implemented in
order for hair with elliptical cross-sections to work correctly with MIS.

Pull Request: https://projects.blender.org/blender/blender/pulls/116088
2023-12-12 13:30:53 +01:00
Brecht Van Lommel a43f847d54 Cleanup: compiler warning 2023-12-12 13:27:36 +01:00
Brecht Van Lommel d015e98ee6 Fix Cycles ASAN error with boolean kernel arguments 2023-12-12 13:27:36 +01:00
Campbell Barton dc2d7a4707 License headers: conform copyright to SPDX 2023-12-12 13:03:26 +11:00
Brecht Van Lommel 25e74f0115 Fix (harmless) uninitialized variable usage in Cycles Metal device 2023-12-11 14:46:19 +01:00
Brecht Van Lommel cf1505d2a5 Fix Cycles division by zero with zero length curves 2023-12-11 14:46:19 +01:00
Brecht Van Lommel f9d69da432 Build: remove Cycles build options to disable RTTI
This was required for OSL, which used to be compiled entirely without
RTTI for LLVM. However OSL now only compiles a private part of its code
without RTTI, so this no longer necessary.

Pull Request: https://projects.blender.org/blender/blender/pulls/116035
2023-12-11 14:42:51 +01:00
Brecht Van Lommel 6cdb43195e Refactor: replace NanoVDB kernel side implementation by own code
The NanoVDB headers are not compatible with Metal due to missing address
space qualifiers. We currently have a big patch for NanoVDB header
files, which is difficult to update for OpenVDB 11. Instead extract a
few hundred lines of code from NanoVDB to do just what we need.

Pull Request: https://projects.blender.org/blender/blender/pulls/115992
2023-12-10 19:37:36 +01:00
Brecht Van Lommel 8ba474dc4f Refactor: replace NanoVDB SampleFromVoxels by own code
This makes the GPU tricubic implementation more efficient. The dense
grid code implemented this in terms of trilinear lookups that are
hardware accelerated, but for NanoVDB this just causes unnecessary voxel
reads. Instead match the CPU code.

Pull Request: https://projects.blender.org/blender/blender/pulls/115992
2023-12-10 19:37:36 +01:00
Brecht Van Lommel bbb7e7a6d5 Cycles: update to work with OpenVDB 11
Ref #113157
2023-12-10 19:36:40 +01:00
Brecht Van Lommel 798a0b301e Cycles: update OSL to work with version 1.13.5
This keeps compatibility with older stable versions, but not
older unreleased versions in the 1.13.x series.

Ref #113157

Pull Request: https://projects.blender.org/blender/blender/pulls/116004
2023-12-10 17:08:47 +01:00
Brecht Van Lommel dd9eecaac0 Fix Cycles versioning error after displacement_method removal 2023-12-10 01:35:29 +01:00
Stefan Werner 8a6f7640d6 Cycles: Make OIDN on GPU use the existing SYCL queue
There's already a queue from the Cycles rendering device, so let OIDN use the same instead of creating a new one.

Co-authored-by: Werner, Stefan <stefan.werner@intel.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/115650
2023-12-07 14:16:21 +01:00
Werner, Stefan 3e7b8381cc Cleanup: Removed redundant code in OIDN integration
There was an unused mutex, memory limits can be left at their defaults.
2023-12-07 14:13:49 +01:00
Brecht Van Lommel e06561a27a Build: replace Blender specific DEBUG by standard NDEBUG
NDEBUG is part of the C standard and disables asserts. Only this will
now be used to decide if asserts are enabled.

DEBUG was a Blender specific define, that has now been removed.

_DEBUG is a Visual Studio define for builds in Debug configuration.
Blender defines this for all platforms. This is still used in a few
places in the draw code, and in external libraries Bullet and Mantaflow.

Pull Request: https://projects.blender.org/blender/blender/pulls/115774
2023-12-06 16:05:14 +01:00
Brecht Van Lommel a1804f35f7 Shaders: change default IOR from 1.45 to 1.5
To match OpenPBR and Standard Surface. Most IOR real values are in a range
of 1.3 to 1.6, might as well use the more round and common number.

Pull Request: https://projects.blender.org/blender/blender/pulls/115770
2023-12-04 21:12:29 +01:00
Jesse Yurkovich 0f67cb9c2f Cleanup: Fully remove legacy displacement_method property
The commit[1] to unify the displacement method for both EEVEE and Cycles
left this, now unused, property in place.

[1] a001cf9f2b

Pull Request: https://projects.blender.org/blender/blender/pulls/115738
2023-12-04 19:09:12 +01:00
Hans Goudey 13c145ac02 Cleanup: Grammar in a few comments 2023-11-29 12:39:33 -05:00
Brecht Van Lommel 1c50dd8bb8 Revert "Fix: Cycles: inconsistent normal checks when sampling and evaluating BSDF"
While this code is suspect, better to go back to the old state for now,
as there is no simple fix that doesn't introduce other issues.

Fix #115022
Fix #115414

This reverts commit 063a9e8964.
2023-11-27 17:01:59 +01:00
Brecht Van Lommel 3475ddce46 Fix #115424: Cycles object space normal map wrong with backfaces 2023-11-27 17:01:59 +01:00
Alaska 59a1148ac0 Fix #115206: Sheen renders incorrectly when viewed head on
Fixes an issue where the sheen would render incorrectly when
the normal of the surface is parallel to the incoming direction.

Co-authored-by: Lukas Stockner <lukas.stockner@freenet.de>

Pull Request: https://projects.blender.org/blender/blender/pulls/115286
2023-11-27 11:34:02 +01:00
Campbell Barton 1eff48a838 Cleanup: spelling in code 2023-11-27 10:55:39 +11:00
Campbell Barton 27c660707d Cleanup: spelling in comments, variables 2023-11-27 09:54:36 +11:00
Campbell Barton 343b48663b Cleanup: format 2023-11-27 09:30:52 +11:00
Werner, Stefan b12a87b28a Revert "Cycles: Added quality parameter for OIDN"
This reverts commit 2e2291dd83.
2023-11-23 13:50:00 +01:00
Stefan Werner 2e2291dd83 Cycles: Added quality parameter for OIDN
OpenImageDenoise has two modes, high quality and balanced. This now exposes the modes as user parameters, with viewport denoising defaulting to balanced and final frame rendering set to high quality.

Ref #115045

Co-authored-by: Werner, Stefan <stefan.werner@intel.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/115265
2023-11-23 12:35:30 +01:00
Brecht Van Lommel b9227da2db Cleanup: rename sse2 specific functions to avoid accidentally using them
Ref #115098

Pull Request: https://projects.blender.org/blender/blender/pulls/115098
2023-11-22 19:45:58 +01:00
Leon Marz 6ec0e0104a Fix build error on architectures without SSE or sse2neon
As color_srgb_to_linear is only defined for them.

Pull Request: https://projects.blender.org/blender/blender/pulls/115098
2023-11-22 19:45:53 +01:00
Leon Marz ea1de499b3 Fix: Increase thread stack size for musl libc
Manually set the stack size to 2mb, same as with Apple

Co-authored-by: Damian Kurek <starfire24680@gmail.com>

Pull Request: https://projects.blender.org/blender/blender/pulls/115094
2023-11-22 19:37:13 +01:00
Sergey Sharybin 6207b83194 Revert "CMake: Give kernel compilation targets access to console"
The side effect which wasn't that obvious from the documentation
is that tasks in the console pool are executed sequentially. This
made the compile-gpu step to take a long time, because the parallel
compilation got disabled.

That was unintended change, so reverting the change.

Instead, for the buildbot, increase the time limit for the step.

This reverts commit 4b891b4afe.
2023-11-22 15:18:12 +01:00
Clément Foucault a001cf9f2b EEVEE-Next: Displacement Option
This add the displacement option to EEVEE materials.
This unifies the option for Cycles and EEVEE.

The displacement only option is not matching cycles
and not particularly useful. So we decided to not
support it and revert to displacement + bump.

Pull Request: https://projects.blender.org/blender/blender/pulls/113979
2023-11-21 19:55:38 +01:00
Brecht Van Lommel fa64573434 Cycles: clearer message when denoising in build without OpenImageDenoise
Fix #115200
2023-11-21 18:57:00 +01:00
Brecht Van Lommel 8845dba79d Fix Cycles rare assert in ensure_valid_specular_reflection
When the incoming direction is exactly orthogonal to the normal

Ref #115071
2023-11-21 18:39:56 +01:00
Stefan Werner 02b5e27f89 Cycles: Add Intel GPU support for OpenImageDenoise
OpenImageDenoise V2 comes with GPU support for various backends. This adds a new class, OIDNDenoiserGPU, in order to add this functionality into the existing Cycles post processing pipeline without having to change it much. OptiX and OIDN CPU denoising remain as they are. Rendering on a supported Intel GPU will automatically select the GPU denoiser.

Device support is initially limited to the oneAPI devices that are supported by Cycles, but can be extended.

Ref #115045

Co-authored-by: Stefan Werner <stefan.werner@intel.com>
Co-authored-by: Ray Molenkamp <github@lazydodo.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/108314
2023-11-20 11:12:41 +01:00
Hoshinova 0b11c591ec Nodes: Merge Musgrave node into Noise node
This path merges the Musgrave and Noise Texture nodes into a single
combined Noise Texture node. The reasoning is that both nodes
intrinsically do the same thing, which is the layering of Perlin noise
derivatives to produce fractal noise. So the patch de-duplicates code
and unifies the use of fractal noise for the end use.

Since the Noise node had a Distortion input and a Color output, while
the Musgrave node did not, those are now available to the Musgrave types
as new functionalities.

The Dimension input of the Musgrave node is analogous to the Roughness
input of the Noise node, so both inputs were unified to follow the same
behavior of the Roughness input, which is arguable more intuitive to
control. Similarly, the Detail input was slightly different across both
nodes, since the Noise node evaluated one extra layer of noise. This was
also unified to follow the behavior of the Noise node.

The patch, coincidentally fixes an unreported bug causing repeated
output for certain noise types and another floating precision bug
#112180.

The versioning code implemented with this patch ensures backward
compatibility for both the Musgrave and Noise Texture nodes. When
opening older Blender files in Blender 4.1 the output of both nodes are
guaranteed to always be exactly identical to that of Blender files
created before the nodes were merged in all cases.

Forward compatibility with Blender 4.0 is implemented by #114236.
Forward compatibility with Blender 3.6 LTS is implemented by #115015.

Pull Request: #111187
2023-11-18 09:40:44 +01:00
Patrick Mours 697114c4b6 Fix #113325: Zero-sized curve leads to OptiX error
Empty hair geometry in Cycles may still report having one curve, even when
there are no actual segments in that curve. This caused an attempt to build
an acceleration structure with zero primitives, which due to other setup
OptiX rejected with an error. Fix that by checking the number of segments
rather than the number of curves in the hair geometry, since the former will
always be zero for empty geometry.

Pull Request: https://projects.blender.org/blender/blender/pulls/115044
2023-11-17 17:20:57 +01:00
Michael Jones 0334ca0617 Cycles: Fix #114919: Disable MetalRT-by-default if macOS < 14.0
This PR fixes the issue of Cycles renders ending in compilation failure on base M3 machines which are still on their factory installed OS, older than14.0.

Pull Request: https://projects.blender.org/blender/blender/pulls/114920
2023-11-15 15:39:27 +01:00
Hans Goudey cda624032d Merge branch 'blender-v4.0-release' 2023-11-10 09:19:03 +01:00
Michael Jones c30c6b2d4e Cycles: Fix Metal API validation error when Metal motion blur workaround is applied
Following #114544: When running with Metal API validation enabled, allocating a zero-sized buffer results in validation errors. This silences that.

Pull Request: https://projects.blender.org/blender/blender/pulls/114680
2023-11-09 22:23:37 +01:00
Xavier Hallade e317831a82 Cycles: oneAPI: adjust reported device capabilities
It notably adds driver version as it can be helpful when triaging
end-user issues.
2023-11-09 21:46:27 +01:00
Brecht Van Lommel 7b26c3d517 Merge branch 'blender-v4.0-release' into main 2023-11-09 18:24:05 +01:00
salipourto 13171183fa Fix Cycles HIP RT issues with deformation motion blur
The first problem was triangles with motion blur were all grouped into
one category without separating the ones with and without triangle
motion steps.

The second problem was HIP RT uses the generic motion triangle
intersection function and this function checks prim_visibility buffer.
HIP RT doesn't provide the buffer per primitive but passes it to HIP RT
core per instance.

The buffer name was changed to prim_visibility from visibility to be
the same as what Cycles uses but when the motion triangle intersection
function is called from HIP RT kernels, the instance id is passed to
the function instead of primitive id.

Pull Request: https://projects.blender.org/blender/blender/pulls/114555
2023-11-09 18:22:59 +01:00
Campbell Barton 58ea0e051f Cleanup: spelling in comments 2023-11-09 09:54:28 +11:00
Campbell Barton 6bba008325 Cleanup: format 2023-11-09 09:34:49 +11:00
Werner, Stefan b414187efb Build: Update OpenImageDenoise to 2.1.0
Major new feature in v2 is GPU support. This is not enabled yet,
this commit only changes the library version without enabling new
functionality.

Pull Request: https://projects.blender.org/blender/blender/pulls/112143
2023-11-08 10:12:05 +01:00
Michael Jones 051ce95628 Cycles: Use Metal Program Scope Global Built-ins on macOS >= 14.0
This PR simplifies the kernel entrypoints by using [Metal Program Scope Global Built-ins](https://developer.apple.com/metal/Metal-Shading-Language-Specification.pdf) when available (macOS >= 14.0).

Pull Request: https://projects.blender.org/blender/blender/pulls/114535
2023-11-07 11:20:16 +01:00
Brecht Van Lommel adb41fe6b2 Merge branch 'blender-v4.0-release' into main 2023-11-06 19:13:18 +01:00
Brecht Van Lommel fe9e28c086 Fix build error on macOS x86, after Metal motion blur workaround
Ref #114544
2023-11-06 18:50:25 +01:00
Michael Jones 4f52ab0b49 Cycles: Workaround MetalRT TLAS build hanging in some motion blur scenes
This PR works around an issue where zero-filled motion TLAS instance descriptors can cause unexpected hangs during downstream TLAS builds on M3. Instead of zeroing the descriptor we insert an explicit "null" BLAS, achieving the same result.

Pull Request: https://projects.blender.org/blender/blender/pulls/114544
2023-11-06 17:30:48 +01:00
Miguel Pozo 6d0b5e2ace EEVEE-Next: New shadow settings
Remove `Material > Shadow Mode` and use `Object > Shadow Ray Visibility`
and `Material > Transparent Shadows` instead.

The versioning system auto-updates objects/materials in EEVEE
scenes so their behavior is as close as possible to the previous one.

Update Cycles to use the native `use_transparent_shadow` property.

Note:
Material changes don't set any `recalc` flag on the objects that use
them, so the EEVEE Next shadow maps don't update when changing
settings/nodes.
Fixing this issue is required for 4.1, but it's out of the scope of this PR.

Pull Request: https://projects.blender.org/blender/blender/pulls/113980
2023-11-06 15:45:00 +01:00
Campbell Barton 2b508f7ae3 Cleanup: cmake indentation 2023-11-04 16:41:18 +11:00
Campbell Barton 134393e846 Cleanup: spelling in comments 2023-11-04 14:08:13 +11:00
Brecht Van Lommel 14f470cdae Merge branch 'blender-v4.0-release' into main 2023-11-02 19:02:35 +01:00
Brecht Van Lommel 49c3dc9d7f Fix 114336: Cycles crash switching render pass in the viewport 2023-11-02 17:24:54 +01:00