3961 Commits

Author SHA1 Message Date
Brecht Van Lommel
ab7c817509 Merge branch 'blender-v5.0-release' 2025-10-16 18:03:58 +02:00
Brecht Van Lommel
74b7d663e1 Build: Avoid excessive number of threads with CUDA split compile
Only use this feature when building for 1 or 2 CUDA architectures.
Otherwise CMake will build the binaries in parallel, and NVCC will then
also launch multiple threads for each binary.

We could add more manual control for this, but the main use case for
this is local builds and an automatic heuristic seems more likely to
help than an option that developers or users might not discover.

For minimal memory usage WITH_CYCLES_CUDA_BUILD_SERIAL still exists
to use only 1 thread for CUDA compilation.

Pull Request: https://projects.blender.org/blender/blender/pulls/147303
2025-10-16 18:00:39 +02:00
Brecht Van Lommel
6e96f1cca8 Fix: Cycles HIP shadow transparency bugs after recent changes
Just tweaking code to sidestep the apparently compiler bug.

This introduces a performance regression, which we'll fix in
another PR.

Ref #147989

Pull Request: https://projects.blender.org/blender/blender/pulls/148155
2025-10-16 17:59:00 +02:00
Lukas Stockner
ae7226d0a7 Merge branch 'blender-v5.0-release' 2025-10-16 15:39:28 +02:00
u3dreal
b597c0f1ed Fix: Cycles: IES interpolation artifacts at angular boundaries
Fixes artifacts in IES data interpolation where edge samples (e.g., v == 0 or
h_i == h_num-1) were clamped to 0.0f instead of valid intensity values.
2025-10-16 15:38:38 +02:00
Weizhen Huang
82892b6f08 Merge branch 'blender-v5.0-release' 2025-10-15 11:24:11 +02:00
weizhen
6c241737e8 Fix: Cycles volume performance issue on Nvidia
Pass by value instead of reference partially fixes the performance issue
mentioned in #147921

Pull Request: https://projects.blender.org/blender/blender/pulls/147989
2025-10-15 11:23:52 +02:00
Xavier Hallade
3753c70b9c Cycles: Use LIB to pass Windows SDK libraries paths to oneAPI compiler
Related to https://projects.blender.org/blender/blender/pulls/147994 in
which clang-cl builds failed passing the Windows SDK libraries paths to
the compiler.

The previous CMake implementation tried to reverse engineer these paths
at CMake configuration time but failed with `clang-cl`.

The environment variables set by vcvars that could have been useful
aren't always available when cmake is called, so now we keep the `LIB`
environment variable intact at compile time and pass the other
additional compiler libraries paths - that are better defined at CMake
configuration time - separately through `-L` compiler arguments.

Pull Request: https://projects.blender.org/blender/blender/pulls/148035
2025-10-14 18:36:37 +02:00
Hans Goudey
a68d39e9d9 Cleanup: Formatting
Run `make format` after the library update in the previous commit.
2025-10-02 12:55:42 -04:00
Stefan Werner
083aad8a45 Cycles: Specialization constants for Embree/SYCL
Making heavier use of specialization constants in SYCL for Embree.
This reduces code size of the intersection kernels and bring
performance improvement up to 9% in some scenes on
Intel GPUs.

Co-authored-by: Stefan Werner <stefan.werner@intel.com>
Co-authored-by: Nikita Sirgienko <nikita.sirgienko@intel.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/141559
2025-10-02 16:44:24 +02:00
marcopavanello
390f053e32 Fix #146630: Single Scattering Sky has darker pixels near horizon
Store the ground fading of Single Scattering sky directly in the LUT.

Co-authored-by: Lukas Stockner <lukas@lukasstockner.de>
Pull Request: https://projects.blender.org/blender/blender/pulls/146659
2025-09-29 20:56:32 +02:00
Amogh Shivaram
2bd06093c7 Cycles: Thin film iridescence for metals
Applies thin film iridescence to metals in Metallic BSDF and Principled BSDF.

To get the complex IOR values for each spectral band from F82 Tint colors,
the code uses the parametrization from "Artist Friendly Metallic Fresnel",
where the g parameter is set to F82. This IOR is used to find the phase shift,
but reflectance is still calculated with the F82 Tint formula after adjusting
F0 for the film's IOR.

Co-authored-by: Lukas Stockner <lukas@lukasstockner.de>
Co-authored-by: Weizhen Huang <weizhen@blender.org>
Co-authored-by: RobertMoerland <rmoerlandrj@gmail.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/141131
2025-09-29 02:58:20 +02:00
Weizhen Huang
2b0a1cae06 Cycles: Add an option to use ray marching for volume rendering
Null Scattering currently has performance and noise issues, and it will
take time to address them. For now add the previous Ray Marching back as
an option.

Co-authored-by: Brecht Van Lommel <brecht@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/146317
2025-09-26 12:14:45 +02:00
Weizhen Huang
8d6b935466 Fix #144711: Cycles: rescale throughput when density is above the majorant
The one-sample Monte Carlo estimator of the radiative transfer equation
is
       <L> = T(t) / p(t) * (L_e + σ_s * L_s + σ_n * L),
Which means we can also use another p(t) than majorant * exp(-majorant * t)
for sampling the distance. Thus, we use the baked σ_max for distance
sampling, but adjust the majorant when we encounter a density that is
larger than σ_max.

Note that this is not really unbiased because such scaling is not always
applied, but seems to work well in practice when the majorant is
reasonable.

Pull Request: https://projects.blender.org/blender/blender/pulls/146589
2025-09-23 11:17:19 +02:00
Lukas Stockner
78147b5db7 Cycles: Add Render Time pass
This implements a basic render time pass,
using HW-based counters to minimize render time impact.

x86-64 uses the TSC instruction for timing, while ARM64 uses the cntvct_el0
register. In theory TSC is not always super reliable (e.g. old CPUs had it tied
to their current clock rate), but for somewhat recent CPU models it should
be fine. If neither is available, it falls back to `std::chrono::steady_clock`,
which should still be very fast.

The output is in milliseconds of CPU-time per pixel.

Pull Request: https://projects.blender.org/blender/blender/pulls/125933
2025-09-22 21:54:08 +02:00
Tenkai Raiko
f8d579d153 Nodes: Add Radial Tiling Node
On its own, the main functionality of the Radial Tiling node
is the ability to divide a 2D Cartesian coordinate system into
as many radial segments as specified by the "Segments" input.
Each segment has its own affinely transformed coordinate system,
provided through the "Segment Coordinates" output, which can be
used to tile textures in a radially symmetric manner.

Additionally, a unique index is provided for every segment through
the "Segment ID" output, the width of each segment at Y-coordinate
of the "Segment Coordinates" output without normalization = 0 is
provided through the "Segment Width" output and the rotation value
of the affine transformation of the coordinate system of each segment
is provided through the "Segment Rotation" output.

The roundness of the coordinate lines of the "Segment Coordinates"
output can be controlled through the "Roundness" inputs.
This can be used to make the coordinate systems of the segments
a mix of Cartesian and polar coordinates.

Lastly, the lines of points of the "Segment Coordinates" output with
constant Y-coordinates have the shape of polygon with rounded corners,
which can be used to procedurally create rounded polygons.

Pull Request: https://projects.blender.org/blender/blender/pulls/127711
2025-09-22 16:02:37 +02:00
Brecht Van Lommel
c2e5622d50 Revert "Shaders: Remove old Preetham and Hosek sky texture models"
These are causing quite a big difference in existing files, which is not
easy to address in versioning. Since the goal of removing this was to
simplify things for us and that's not the case, just revert this change.

This reverts commit ab21755aaf.

Ref #139923

Pull Request: https://projects.blender.org/blender/blender/pulls/146336
2025-09-20 16:52:23 +02:00
Brecht Van Lommel
fc8bc41b84 Cleanup: Compiler warning in GPU kernel compilation
Silence false positive about function not returning.

Pull Request: https://projects.blender.org/blender/blender/pulls/146178
2025-09-20 13:14:35 +02:00
Weizhen Huang
ba23257ec7 Fix: Cycles: volume octree should estimate extrema in the current segment
Was sampling the complete ray segment instead

Pull Request: https://projects.blender.org/blender/blender/pulls/146320
2025-09-16 13:02:50 +02:00
Brecht Van Lommel
033b2f8d5d Cleanup: Initialize closure weight to silence warning on Windows
This appears to be a false positive. It warns when the
function gets called with this argument, but the function
does not actually use it.

Pull Request: https://projects.blender.org/blender/blender/pulls/146175
2025-09-16 11:35:31 +02:00
Lukas Stockner
dcc5ac4e44 Fix: Cycles: Metal error in unrelated test after Sky Texture change
For some reason, the `underwater_caustics` test was failing on Metal
after #140480 even though that test doesn't use the Sky Texture.

After messing with the file for a while, going back to the previous version
and adding the changes back one at a time, I've now arrived at a version
that behaves the same way as the #140480 version without breaking the test.

No idea what is the underlying issue, but we've had problems with the MNEE
kernels before so maybe just a compiler thing.

Pull Request: https://projects.blender.org/blender/blender/pulls/146335
2025-09-16 01:15:18 +02:00
Lukas Stockner
4eee95c0f9 Fix: Cycles: Incorrect thin film IOR for backfacing Glass with OSL
Thanks to @main-menu-theme for noticing this!
2025-09-15 18:21:15 +02:00
marcopavanello
084aefd0e0 Render: Add Multiple Scattering Sky Texture
This mode is based on the same athmospheric model as the previous one, but now
also accounts for multiple scattering and reflections from the ground.
This increases the accuracy, especially at low elevations.

Also renames some options for consistency:
- The previous "Nishita" model is now "Single Scattering"
- "Dust" is now "Aerosols"
- Default altitude is now 100m.

Co-authored-by: Lukas Stockner <lukas@lukasstockner.de>
Pull Request: https://projects.blender.org/blender/blender/pulls/140480
2025-09-15 18:08:28 +02:00
Sergey Sharybin
15fd8ad7a1 Fix: Cycles linear curves on Metal-RT
Metal-RT implementation for curve intersect has an additional self
intersection check happening in curve_ribbon_accept(). It is done
for all curve types that has PRIMITIVE_CURVE_RIBBON bit set on them,
including Thick Linear curves. However, the logic in the function is
hardcoded to handle flat ribbon curves with the Catmull Rom basis.

This change makes it so curve_ribbon_accept() is only called for the
ribbon curve type, not when type has ribbon bit set.

Additionally, other places where curve type was checked as a bitmask
were fixed.

Ref #146072

Pull Request: https://projects.blender.org/blender/blender/pulls/146140
2025-09-12 14:16:09 +02:00
Campbell Barton
3c7f4edd92 Cleanup: spelling in comments & string
Also back-tick quote literals in CMakeLists files.
2025-09-06 09:27:54 +10:00
Amogh Shivaram
11d98c14b7 Fix #144258: Cycles: Subsurface scattering doesn't work with shadow linking
When shadow linking is enabled, `intersect_dedicated_light` is scheduled even
if the `PATH_RAY_SUBSURFACE` flag is set. This checks the flag and schedules
`intersect_subsurface` instead.

Pull Request: https://projects.blender.org/blender/blender/pulls/145621
2025-09-05 15:31:50 +02:00
Brecht Van Lommel
9856615813 Color Management: Change byte color attributes to always be sRGB
These don't really work as scene linear with sRGB transfer function for e.g.
ACEScg, there are not enough bits. If you want wide gamut you need to use
float colors.

Pull Request: https://projects.blender.org/blender/blender/pulls/145763
2025-09-05 11:11:33 +02:00
Patrick Mours
b4bb075285 Cycles: Flip image vertically before passing to OptiX denoiser to improve result quality
Experiments have shown that the OptiX denoiser performs best when
operating on images that have their origin at the top-left corner,
while Blender renders with the origin at the bottom-left corner.
Simply flipping the image vertically before and after denoising is a
relatively trivial operation, so this patch introduces this as an
additional preprocessing and postprocessing step for denoising when the
OptiX denoiser is used. Additionally, this patch also removes an unused
helper function, now that OptiX 8.0 is the minimum.

Pull Request: https://projects.blender.org/blender/blender/pulls/145358
2025-09-04 16:04:23 +02:00
Nikita Sirgienko
a984114d5e Cleanup: oneAPI: Fix warnings about unused variables
No performance or functional changes are expected
2025-09-03 11:01:20 +02:00
Campbell Barton
b2abb81b65 Cleanup: repeated word 2025-09-03 17:53:27 +10:00
Brecht Van Lommel
f49b3dabf1 Fix #144786: Cycles curve thickness missing transform in viewport
This should be in world space, like point radius and most other shader nodes.

Pull Request: https://projects.blender.org/blender/blender/pulls/144802
2025-09-02 19:01:50 +02:00
Brecht Van Lommel
c693e72841 Fix #145254: Cycles normal map node strength wrong results with displacement
Can not use tangent space interpolation in this case, as the tangent space
is for the undisplaced normal.

Pull Request: https://projects.blender.org/blender/blender/pulls/145273
2025-09-02 17:50:41 +02:00
Sergey Sharybin
03003365cc Cycles: Switch to HIP SDK 6.4.2 on Windows
This also reverts 367d5b7eabd53229fb7e79465b4761e65e531741,
as the math flags workaround is no longer needed.

Fix #139796
Fix #138646
Fix #139071
Fix #139070

Ref #140278

Co-authored-by: Brecht Van Lommel <brecht@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/145311
2025-08-29 12:49:11 +02:00
Weizhen Huang
f77881a795 Fix #144918: World volume with zero density not rendering correctly
OneAPI has some problem with `exp(-0 * FLT_MAX)`.

Pull Request: https://projects.blender.org/blender/blender/pulls/144979
2025-08-28 10:41:33 +02:00
Patrick Mours
1b42975e94 Cycles: Add support for building with CUDA 13.0 and OptiX 9.0
The compiler in the CUDA 13 toolkit dropped support for Maxwell, Pascal and Volta architectures (sm_5X, sm_6X and sm_70), which affects both CUDA and OptiX kernel compilation for Cycles. This patch makes it so building CUDA kernel binaries for those architectures are skipped when CUDA 13 is used, but it will still build them if there is a CUDA 11 toolkit available (e.g. on buildbot), like how things are handled for other architectures. The OptiX PTX kernel is compiled with the minimum architecture available (compute_75 with CUDA 13, compute_50 with previous CUDA versions).

In addition, loading the PTX kernel after initializing OptiX version 9.0 would fail with a OPTIX_ERROR_INVALID_FUNCTION_USE, due to the use of "optixTrace" within direct callables (as part of the AO and bevel SVM nodes). Starting with OptiX 9.0 this is no longer allowed, rather one has to use "optixTraverse" in those cases. This patch thus changes the affected intersection routines to use "optixTraverse". As a side effect it also simplifies the `scene_intersect_shadow` function, which no longer invokes the closest hit program, and can just quickly return hit status. The minimum OptiX version Cycles requires is already 8.0, which supports "optixTraverse", so it can just be applied always.

Finally, this patch also adds the `--split-compile=0` argument to nvcc when available, which tells the compiler to internally split the module into pieces that can be processed in parallel on multiple threads (the `=0` notes to use as many threads as there are CPU cores), which can greatly improving compile times, while not making compromises on performance.

Pull Request: https://projects.blender.org/blender/blender/pulls/145130
2025-08-27 14:28:01 +02:00
Michael Jones
193e22ee7e Refactor: Cycles: Simplify Metal backend with direct bindless resource encoding
This re-applies pull request #140671, but with a fix for #144713 where the
non-pointer part of IntegratorStateGPU was not initialized.

This PR is a more extensive follow on from #123551 (removal of AMD and Intel
GPU support).

All supported Apple GPUs have Metal 3 and tier 2 argument buffer support.
The invariant resource properties `gpuAddress` and `gpuResourceID` can be
written directly into GPU structs once at setup time rather than once per
dispatch. More background info can be found in this article:
https://developer.apple.com/documentation/metal/improving-cpu-performance-by-using-argument-buffers?language=objc

Code changes:
- All code relating to `MTLArgumentEncoder` is removed
- `KernelParamsMetal` updates are directly written into
  `id<MTLBuffer> launch_params_buffer` which is used for the "static"
  dispatch arguments
- Dynamic dispatch arguments are small enough to be encoded using the
  `MTLComputeCommandEncoder.setBytes` function, eliminating the need for
  cycling temporary arg buffers

Fix #144713

Co-authored-by: Brecht Van Lommel <brecht@noreply.localhost>
Pull Request: https://projects.blender.org/blender/blender/pulls/145175
2025-08-27 13:58:30 +02:00
Lukas Tönne
12f0bc7736 Fix #138388: Use grid voxel corners as value locations like OpenVDB
Blender grid rendering interprets voxel transforms in such a way that the voxel
values are located at the center of a voxel. This is inconsistent with OpenVDB
where the values are located at the lower corners for the purpose or sampling
and related algorithms.

While it is possible to offset grids when communicating with the OpenVDB
library, this is also error-prone and does not add any major advantage.
Every time a grid is passed to OpenVDB we currently have to take care to
transform by half a voxel to ensure correct sampling weights are used that match
the density displayed by the viewport rendering.

This patch changes volume grid generation, conversion, and rendering code so
that grid transforms match the corner-located values in OpenVDB.

- The volume primitive cube node aligns the grid transform with the location of
  the first value, which is now also the same as min/max bounds input of the
  node.
- Mesh<->Grid conversion does no longer require offsetting grid transform and
  mesh vertices respectively by 0.5 voxels.
- Texture space for viewport rendering is offset by half a voxel, so that it
  covers the same area as before and voxel centers remain at the same texture
  space locations.

Co-authored-by: Brecht Van Lommel <brecht@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/138449
2025-08-26 12:27:20 +02:00
Brecht Van Lommel
1d9bd460fc Fix #144814: Cycles OSL crash accessing geom:name string attribute
This should be a ustring hash now, not a ustring.

Pull Request: https://projects.blender.org/blender/blender/pulls/144881
2025-08-20 21:00:12 +02:00
Brecht Van Lommel
98e9dd1aa2 Revert "Cycles: Simplify Metal backend with direct bindless resource encoding"
This reverts commit b4be954856.

It is causing render artifacts in the barbershop benchmark. There were some
conflicts to resolve when reverting this, mainly related to the removal of
3D textures.

Fix #144713
Ref #140671, #144712

Pull Request: https://projects.blender.org/blender/blender/pulls/144880
2025-08-20 20:53:40 +02:00
Brecht Van Lommel
f41a0d5ab9 Fix: Cycles OptiX + OSL fails to render images with OSL releases
It works with the beta we are using to build Blender 4.5, but the official
release is a bit different. This fix was tested to work with OSL 1.14.7.

Thanks to Paul Zander for finding the OSL commit that lead to this.

Pull Request: https://projects.blender.org/blender/blender/pulls/144715
2025-08-19 13:22:07 +02:00
Weizhen Huang
df496eb894 Cycles: use one-tap stochastic interpolation for volume
It has ~1.2x speed-up on CPU and ~1.5x speed-up on GPU (tested on Metal
M2 Ultra).

Individual samples are noisier, but equal time renders are mostly
better.

Note that volume emission renders differently than before.

Pull Request: https://projects.blender.org/blender/blender/pulls/144451
2025-08-14 15:22:44 +02:00
Weizhen Huang
0c371ca3c5 Cycles: use deterministic linear interpolation for velocity
Cubic is too costly, stochastic interpolation is inaccurate.
2025-08-14 15:22:43 +02:00
Weizhen Huang
6eb7075fa1 Fix: Cycles: lcg_state uninitialized before volume density baking
_No response_

Pull Request: https://projects.blender.org/blender/blender/pulls/144489
2025-08-13 16:10:06 +02:00
Weizhen Huang
d717c78ca4 Revert "Cycles: Store octree parent nodes in a stack"
This reverts commit bccad10b3be75deb0825b9234087e613678af407.
The stack approach seems slower

Pull Request: https://projects.blender.org/blender/blender/pulls/134460
2025-08-13 10:28:53 +02:00
Weizhen Huang
146ac0d9fe Cycles: Store octree parent nodes in a stack 2025-08-13 10:28:50 +02:00
Weizhen Huang
ed48905b41 Cycles: Use analytic formula for homogeneous volume 2025-08-13 10:28:50 +02:00
Weizhen Huang
a4f8e0bfa2 Cycles: Use RGBE for denoised guiding buffers to reduce memory usage
Co-authored-by: Brecht Van Lommel <brecht@blender.org>
2025-08-13 10:28:50 +02:00
Weizhen Huang
5cb6014efd Cycles: Volume Scattering Probability Guiding
Guide the probability to scatter in or transmit through the volume.
Only applied for primary rays.

Co-authored-by: Brecht Van Lommel <brecht@blender.org>
2025-08-13 10:28:50 +02:00
Weizhen Huang
a7283fc1d5 Cycles: Shade volume with null scattering
The distance sampling is mostly based on weighted delta tracking from
[Monte Carlo Methods for Volumetric Light Transport Simulation]
(http://iliyan.com/publications/VolumeSTAR/VolumeSTAR_EG2018.pdf).

The recursive Monte Carlo estimation of the Radiative Transfer Equation is
\[\langle L \rangle=\frac{\bar T(x\rightarrow y)}{\bar p(x\rightarrow
y)}(L_e+\sigma_s L_s + \sigma_n L).\]
where \(\bar T(x\rightarrow y) = e^{-\bar\sigma\Vert x-y\Vert}\) is the
majorant transmittance between points \(x\) and \(y\), \(p(x\rightarrow
y) = \bar\sigma e^{-\bar\sigma\Vert x-y\Vert}\) is the probability of
sampling point \(y\) from point \(x\) following exponential
distribution.

At each recursive step, we randomly pick one of the two events
proportional to their weights:
* If \(\xi < \frac{\sigma_s}{\sigma_s+\vert\sigma_n\vert}\), we sample
scatter event and evaluate \(L_s\).
* Otherwise, no real collision happens and we continue the recursive
process.

The emission \(L_e\) is evaluated at each step.

This also removes some unused volume settings from the UI:

* "Max Steps" is removed, because the step size is automatically specified
by the volume octree. There is a hard-coded threshold `VOLUME_MAX_STEPS`
to prevent numerical issues.
* "Homogeneous" is automatically detected during density evaluation

An option "Unbiased" is added to the UI. When enabled, densities above
the majorant are clamped.
2025-08-13 10:28:50 +02:00
Weizhen Huang
8c36f9ce49 Cycles: Compute volume transmittance using telescoping 2025-08-13 10:28:50 +02:00