Commit Graph

15240 Commits

Author SHA1 Message Date
Brecht Van Lommel
47f9b7a98e Fix #142022: Cycles undisplaced normal not available
Previously with adaptive subdivision this happened to work with the N
attribute, but that was not meant to be undisplaced. This adds a new
undisplaced_N attribute specifically for this purpose.

For backwards compatibility in Blender 4.5, this also keeps N undisplaced.
But that will be changed in 5.0.

Pull Request: https://projects.blender.org/blender/blender/pulls/142090
2025-07-24 18:16:25 +02:00
Brecht Van Lommel
ba46217b51 Fix: GPU shader error logging doesn't show shader name or stage
This was relying on the souce file and line printing which is now disabled
by default. Also log the shader source without indent for readability.

Pull Request: https://projects.blender.org/blender/blender/pulls/142882
2025-07-24 16:10:19 +02:00
Brecht Van Lommel
264669fc03 Fix #142953: Cycles renders world lightgroup wrong
Pull Request: https://projects.blender.org/blender/blender/pulls/143003
2025-07-24 15:24:03 +02:00
Jonas Holzman
d95c2bc406 GHOST: Rename Metal Context from ContextCGL to ContextMTL
This commit renames the GHOST Metal graphic context class and related
files / references from `GHOST_ContextCGL` to `GHOST_ContextMTL`. When
the Metal backend was first introduced, this context file contained
both the old OpenGL context (CGL, for macOS Core OpenGL API), and the
newer Metal context. Since #110185 all CGL related code was removed
from the class, making it Metal only, and thus rendering the old class
name outdated and potentially misleading. In addition to the rename,
unused OpenGL related forward declarations and old TODOs were also
removed.

Pull Request: https://projects.blender.org/blender/blender/pulls/142519
2025-07-24 13:28:44 +02:00
Michael Jones
f3485cc925 Cycles: MetalRT: Only use extended limits if needed (revisited)
Currently MetalRT renders always use extended limits, which is needed to correctly render scenes where the max primitive count can exceed 2^28 or the instance count can exceed 2^24. This patch adopts Metal best practices of only enabling this flag if it is needed.

This PR is similar to #133364, but there are some notable differences:

1) The old PR made an overly optimistic assumption that all the relevant visibility bits could be squeezed into 8 bits. This new PR adopts the same approach that Optix takes of using 8 bits as a primary HW filter, and checking the full 32 bit mask inside the SW intersection handler.

~~2) I moved the scene scanning check from Scene into MetalDevice. This avoids platform specific details leaking into platform agnostic areas.~~

~~3) In live viewport mode, we always use extended limits in case we tip over the threshold.~~

_EDIT:_
2) The limits are scanned in `Scene::update_kernel_features`, and given to the device by a new `set_bvh_limits` method which returns true if the BVH and kernels need to be reloaded.

Pull Request: https://projects.blender.org/blender/blender/pulls/142401
2025-07-24 13:27:20 +02:00
Campbell Barton
c1b2a1af74 Cleanup: quiet unused warnings 2025-07-24 14:37:28 +10:00
Campbell Barton
c3b8702466 GHOST: ignore GHOST_ASSERT in release builds
Error in [0] made GHOST assert in release builds.

[0]: 4d227dd593
2025-07-24 01:10:25 +00:00
Weizhen Huang
bb689687a7 Fix #140892: Cycles: equiangular sampling numerical issue
When `delta` is significantly larger than the difference between `tmin`
and `tmax`, the precision of `theta_a` and `theta_b` reduces, resulting
in banding artefacts.

For equiangular sampling, we use uniform sampling to fix this case.

For light tree, we use the equality
atan(a) + atan(b) = atan2(a + b, 1 - a*b).

Pull Request: https://projects.blender.org/blender/blender/pulls/142845
2025-07-23 12:56:11 +02:00
Brecht Van Lommel
678ccd4a61 Cycles: Change default material to match Blender and EEVEE
Use Principled BSDF instead of Diffuse BSDF. This is a breaking change but
likely does not affect many scenes significantly. It adds some specularity
when an object does not have a a material assigned.

Fix #142538

Pull Request: https://projects.blender.org/blender/blender/pulls/142703
2025-07-22 15:54:30 +02:00
Brecht Van Lommel
474debc348 Refactor: Cycles: Make attribute map a bit smaller when not using OSL 2025-07-22 15:54:29 +02:00
Brecht Van Lommel
f861ad60e1 Fix #142603: Cycles slow updates in camera view with adaptive subdivision
Postpone update of adaptive subdivision until navigation is done, to keep
things a bit more interactive.

Pull Request: https://projects.blender.org/blender/blender/pulls/142730
2025-07-22 15:49:27 +02:00
Clément Foucault
32d64d35bb Refactor: GPU: Texture: Replace eGPUTextureFormat by TextureFormat
This offers better semantic and safety of the API.

Part of #130632

Pull Request: https://projects.blender.org/blender/blender/pulls/142818
2025-07-22 14:58:54 +02:00
Clément Foucault
f0254c2dcf Refactor: GPU: Remove unnecessary C wrappers for textures
This is the first step into merging `DRW_gpu_wrapper.hh` into
the GPU module.

This is very similar to #119825.

Pull Request: https://projects.blender.org/blender/blender/pulls/142732
2025-07-22 09:48:10 +02:00
Thomas Dinges
ce0ae95ed3 Cycles: Bump minimum supported CUDA architecture to sm_50
Pull Request: https://projects.blender.org/blender/blender/pulls/142212
2025-07-21 19:49:21 +02:00
Weizhen Huang
9404db8c7c Fix #141388: Cycles: CPU/GPU difference in pow function with 0 base
If the base is 0 and the exponent is non-zero, return 0 for both CPU and GPU.

Pull Request: https://projects.blender.org/blender/blender/pulls/142678
2025-07-21 14:45:30 +02:00
Weizhen Huang
5a27edcf79 Fix #141136: Cycles Hair black artifacts with direct coloring
fixed by clamping negative input colors

Pull Request: https://projects.blender.org/blender/blender/pulls/142667
2025-07-21 12:15:04 +02:00
Campbell Barton
008ed81d26 Fix #141777: Crash closing an unfocused window on Wayland 2025-07-20 16:31:57 +10:00
Campbell Barton
1762a66b82 Cleanup: use const cast 2025-07-20 15:27:07 +10:00
Jeroen Bakker
4de5da1ea2 OpenXR: Compile without OpenGL backend
This PR allows blender to be compiled with OpenXR, but without
OpenGL support.

For investigating a bug we needed to compile Blender without
OpenGL (`WITH_OPENGL_BACKEND=OFF`) but it would fail to
compile OpenXR (`WITH_XR_OPENXR=ON`). This PR tweakes
the preprocess directives to compile the openxr graphics
binding without OpenGL.

Co-authored-by: Jonas Holzman <jonas@holzman.fr>
Pull Request: https://projects.blender.org/blender/blender/pulls/141668
2025-07-19 21:40:49 +02:00
Sebastian Parborg
17b9759942 CMake: Sync up minimum version to 3.10
Besides being more consistent with the minimum version we use, this also
fixes warnings when using CMake 4.0.

Pull Request: https://projects.blender.org/blender/blender/pulls/142497
2025-07-19 20:37:10 +02:00
Nikita Sirgienko
9875836519 Cycles: oneAPI: Compile only needed device binaries in multi-GPU case
The code of the "oneapi_load_kernels" function before this modification
was loading kernels and compiling them, if needed, for all devices in
the associated GPU context. This makes sense for one GPU execution
scenario, as well as for execution scenario of multi identical GPU,
but in cases where Blender users have several different GPUs in
render, the previous implementation would compile all kernels
for all devices for each device, unnecessarily doing the same
work multiple times. Because of this, I am changing the
implementation so that now compilation happens only for the used
device per used device, ensuring that no unnecessary work is done.

No render performance changes are expected.
2025-07-19 14:15:36 +02:00
Sebastian Herholz
20e0fed7da Cycles: Fixing wrong PDF evaluation when BSDF closures are excluded by the light source
Pull Request: https://projects.blender.org/blender/blender/pulls/142323
2025-07-18 17:13:54 +02:00
Brecht Van Lommel
87ff645f5d Fix: Cycles preferences Python error after recent changes
Assigning properties in PropertyGroup has become more strict, define it in
__slots__ since it's a runtime property.

Pull Request: https://projects.blender.org/blender/blender/pulls/142357
2025-07-18 16:07:53 +02:00
Michael Jones
8077384e3a Cycles: Improve Metal kernel specialisation
This improves the existing scene specialisation mechanism by replacing "kernel_data.kernel_features" with a function constant. It doesn't cause any additional compilation requests, but allows the backend compiler to eliminate more dead code. An additional compiler hint is provided for dead-stripping "volume_stack_enter_exit" which results in slightly faster rendering of non-volumetric scenes.

Pull Request: https://projects.blender.org/blender/blender/pulls/142235
2025-07-18 11:18:43 +02:00
Campbell Barton
751cfe4a74 GHOST/Wayland: invert cursor color, pre-multiply alpha
- Cursors in wayland are expected to use pre-multiplied alpha.
  Note that cursor generators create straight alpha,
  pre multiplier in the wayland backend.
- Invert cursor colors on Wayland since dark cursors are often default,
  this could use dark theme settings in the future.
2025-07-18 14:13:38 +10:00
Campbell Barton
4e3b58423c Cleanup: use snake case for GHOST's can_invert_color argument 2025-07-18 12:53:32 +10:00
Campbell Barton
c52c8874e9 GHOST/Wayland: scalable vector cursor support via cursor-generators
Support showing vector cursors at the appropriate size based on each
monitors DPI.

This solves incorrectly sized cursors with Hi-DPI outputs as well as
supporting outputs with different DPI's.

Instead of passing pixel data, pass an object that can generate cursors,
GHOST/Wayland can then ensure the correct size is used based on the
display the cursor is shown on.

While may sound overly complicated it actually simplifies displaying
cursors on Wayland, especially for multiple monitors at different DPI's.
Showing cursors at higher or lower resolutions than the monitor's DPI
also behaves differently on GNOME & Plasma, resulting in situations
where the cursor would show larger/smaller than expected.

Details:

- Take advantage of the recently added SVG cursors & BLF time cursor
  !140990 & !141367.
- Setting bitmap cursors via GHOST_SetCustomCursorShape is now a no-op
  for Wayland since it's no longer used. This was supported in an
  earlier version of this PR and could be restored if needed.
- While fractional scaling works it relies on the compositor downscaling
  the cursors. Ideally they would be rendered at the target size but
  this isn't a priority as the difference isn't noticeable.

Ref !141597
2025-07-18 12:38:52 +10:00
Campbell Barton
9d41b04aec Cleanup: quiet warnings, typo 2025-07-18 12:03:53 +10:00
Brecht Van Lommel
df6d6c0932 Refactor: Cycles: Use logging system for GPU error print
Pull Request: https://projects.blender.org/blender/blender/pulls/142257
2025-07-17 21:14:30 +02:00
Brecht Van Lommel
6f8eb2a1af Fix #142233: Cycles crash due to wrong node type registration order
This was exposed by NanoVDB changes. Properly ensure the base type is
created before the derived type.

Pull Request: https://projects.blender.org/blender/blender/pulls/142261
2025-07-17 21:13:59 +02:00
Philipp Oeser
2fd36b0ab7 Fix #142103: Animation decorator not working on Light Temperature value
When having a checkbox and a value both in one row together with an
animation decorator it is questionable whether the decorator should act
on animating the checkbox or the corresponding value.

We had similar cases before (e.g. 7c04ef210e)

In this case as well, one would think it is more desirable to animate
the actual Temperature **value** (instead of the checkbox), so this is
what this PR does.

Pull Request: https://projects.blender.org/blender/blender/pulls/142192
2025-07-17 15:03:50 +02:00
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