2348 Commits

Author SHA1 Message Date
Sergey Sharybin
8348438cae Multires bake: Rework baking high-res displacement
This change makes it so baking displacement to the high-resolution mesh
(Use Low Resolution Mesh option is OFF, displacement is calculated
between top multi-resolution level and subdivided viewport level mesh)
uses texture UVs and tangent space from the high-res mesh.

This matches intended use-case when object baked with such configuration
have subdivision surface applied to them bringing overall resolution to
the same level as the highest multi-resolution level.

The issue was simple to see when baking high-res displacement for an
object which uses "Keep Corners, Junctions" UV smoothing.

The unfortunate aspect is increased memory usage due to calculation of
the grid index and grid UV mapping, but it is not too bad (12 bytes per
loop, so is like 48Mb per million face). Feels like there is a way to
optimize it by utilizing knowledge that high-res mesh faces are created
in a specific order, but also feels it is not that important at this
moment.

Pull Request: https://projects.blender.org/blender/blender/pulls/144935
2025-08-22 18:24:57 +02:00
Sergey Sharybin
e0154de320 Rework Bake from Multires
The main idea is to switch Bake from Multires from legacy DerivedMesh
to Subdiv. On the development side of things this change removes a lot
of code, also making it easier easier to rework CustomData and related
topics, without being pulled down by the DerivedMesh.

On the user level switch to Subdiv means:

- Much more closer handling of the multi-resolution data: the derived
  mesh code was close, but not exactly the same when it comes to the
  final look of mesh.

  Other than less obvious cases (like old DerivedMesh approach doing
  recursive subdivision instead of pushing subdivided vertices on the
  limit surface) there are more obvious ones like difference in edge
  creases, and non-supported vertex creases by the DerivedMesh.

- UV interpolation is done correctly now when baking to non-base level
  (baking to multi-resolution level >= 1).

  Previously in this case the old derived mesh interpolation was used
  to interpolate face-varying data, which gives different results from
  the OpenSubdiv interpolation.

- Ngon faces are properly supported now.

A possible remaining issue is the fact that getting normal from CCG
always uses smooth interpolation. Based on the code it always has been
the case, so while it is something to look into it might be considered
a separate topic to dig into.
2025-08-22 17:59:27 +02:00
Bastien Montagne
9df3b1cd06 Benchmark: Fix bpy/RNA broken 'bpy props get/set' tests, add FloatVectorProperty one.
Not sure why it did not error with the other bpy prop types... It did
was slowing things a lot though, get/set logic was failry broken.
2025-08-20 16:37:52 +02:00
Aaron Carlisle
2725dfe3d1 Tests: Fix RNA manual look up checks
- RNA Patterns Unknown to the Manual -- only print rna_ids that do not return a URL
- Undocumented Sections -- consider the case of types that do not have props (a lot of nodes were returning as false positives)
2025-08-19 22:31:24 -04:00
Hans Goudey
a5d5eca487 Cleanup: Sequencer: Replace seqbasep variable access with function
With the aim of removing `seqbasep` to remove the complicated logic for
repairing pointers within the `Strip` struct when loading files and undo
steps, this commit just moves access of the variable behind a function.
In the future the function will retrieve the list from a Strip pointer,
for now it just returns the existing pointer.

Overall motivation is that blend file pointer manipulation is incompatible
with the changes required for #127706.

Pull Request: https://projects.blender.org/blender/blender/pulls/144624
2025-08-18 15:39:58 +02:00
Jesse Yurkovich
d4b0f02f72 Fix: Incorrect attribute type check during USD shape import
Accidentally changed in 1f92fd7577 and only noticed because there was a
suspicious drop in code coverage for the affected file.

Fix and add tests to ensure it doesn't happen again.

Pull Request: https://projects.blender.org/blender/blender/pulls/144702
2025-08-18 06:16:57 +02:00
Campbell Barton
990f0863e8 PyDoc: include buffer access in examples, cleanup
Note that buffer access is possible, also minor mathutils test cleanup.
2025-08-16 17:39:35 +10:00
Oxicid
b856b6010e PyAPI: buffer protocol support for mathutils types
Adding buffer protocol support increases the speed of copying a Vector
(3D) array into a `numpy.array` by up to x3.8.

Ref !144401
2025-08-16 06:14:19 +00:00
Weizhen Huang
3dc73a3fda Tests: update GPU volume tests
New files are added since 5646d9a5ca

Pull Request: https://projects.blender.org/blender/blender/pulls/144622
2025-08-15 18:15:34 +02:00
Christoph Neuhauser
7c7af11b9b Tests: Turn VSync off for performance tests
To avoid timings being capped at the display refresh rate.

Ref #143049

Pull Request: https://projects.blender.org/blender/blender/pulls/144555
2025-08-14 16:39:29 +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
Campbell Barton
25c69382fc Fix: frozen mathutils Vector & Matrix types could be resized
It's important that frozen types are immutable, add a generic
check that mathutils types can be resized and check the frozen flag.

Also correct the exception types when Vector's cant be resized,
using a ValueError instead of a TypeError as the type is correct.
2025-08-14 12:56:48 +10:00
Brecht Van Lommel
585af15979 Fix: HDR video output does not preserve the view transform
The float buffer should be tagged with the standard untonemapped colorspace,
so that when we convert to PQ/HLG the tonemapping is preserved.

With this change:
* Using AgX highlights properly go to white.
* Using the ACES configs, we can convert EXRs to a HDR video, exactly
  matching colors with the HDR video on https://dpel.aswf.io/solemates/.

Pull Request: https://projects.blender.org/blender/blender/pulls/144493
2025-08-13 18:36:16 +02:00
Bastien Montagne
c90c4e9cd5 Tests: LibOverride: Simply some code, add 'empty lib' test case.
Code checking for expected amount of local/linked/missing
linked/liboverrides IDs is now cleaner and more efficient.

Also add a test where the whole content of the source library is
removed, to validate that liboverrides using these linked IDs as
reference remain available as 'placeholders'.
2025-08-13 15:16:02 +02:00
Weizhen Huang
5646d9a5ca Cycles: Add and update volume test files 2025-08-13 10:28:50 +02:00
Bastien Montagne
9be8f3d430 Benchmark: Improve RNA performance tests flexibility.
Make registered py-defined property tests more flexible, by allowing to
pass the property type as an argument.

And add basic such tests for Bool and String types.
2025-08-12 20:11:11 +02:00
Bastien Montagne
cbf763e700 LibOverride: Prevent matching collection items only by their index if a name and ID are provided.
If an item name (and ID) is provided, never successfully match only
based on the item index.

This can lead to matching to a complete different ID than the intended
one, which can be catastrophic for the integrity of the next resync.

Also, do not require sucessful match on both source and destination
data, this will always fail in case e.g. an item is removed from a
collection, and can prevent detecting required resync from that
collection then.

This commit also enables new 'harder' test in unittests, added in
previous commit, which is now expected to pass.

Pull Request: https://projects.blender.org/blender/blender/pulls/144429
2025-08-12 14:10:44 +02:00
Bastien Montagne
f3aeb71ea5 Test: LibOverride: Add more complex case for multi-level hierarchy handling.
Add some initial data to test proper handling of resync when there are
specific changes in the reference collection hierarchy (in particular,
when the last child of a given collection is moved somewhere else).

Also will check for correct handling of recursive liboverrides resync in
that case.

The current failing part is commented out for now, until fix is
committed.
2025-08-12 14:10:43 +02:00
Lukas Tönne
dab6b45336 Fix #143551: Cache invalidation causes crash when changing node tree item properties
Changing a node tree item property (such as the default value) was using a very
broad and generic "tag" function which invalidates the runtime items cache.
This also invalidates any python iterators due to the API using the runtime
cache. Changing node tree items in a loop will then crash.

It's not necessary to invalidate the runtime items cache when the actual item
pointers have not changed. Most RNA updates only change superficial properties,
or at most require a recursive node tree update due to change of identifiers or
types.

This PR introduces a simpler "tag" function to only tag for tree updates by not
rebuild the entire runtime items cache. It also renames existing functions and
docstrings to better explain what each of them does and should be used for.

The `NodeTreeInterfaceChangedFlag` is removed completely because it is only ever
used as a simple boolean indicator of "item changes" that require a cache
rebuild. It is replaced with an atomic bool like flags used for runtime caches.

Pull Request: https://projects.blender.org/blender/blender/pulls/143932
2025-08-12 11:00:10 +02:00
Omar Emara
8d1e26865d Compositor: Support strings sockets
This patch adds support for String sockets in the compositor. The
sockets are not yet used anywhere, but are added to aid development.

Pull Request: https://projects.blender.org/blender/blender/pulls/144327
2025-08-12 08:54:13 +02:00
Sean Kim
8ee5fa0737 Cleanup: Use alphabetical order for _ui_tests_ category
Pull Request: https://projects.blender.org/blender/blender/pulls/144394
2025-08-12 00:56:45 +02:00
Jesse Yurkovich
5a5f768938 Tests: USD: Replace USDZ export test with another for better validation
Move the existing USDZ export test from C++ to Python for better
validation. The resulting file is now run through the `usdchecker`
system and we also check the contents of the resulting archive for the
expected texture file. This helped uncover a pathing issue in the
resulting archive where the 'textures' directory was misnamed on win32;
though it was still functional.

Pull Request: https://projects.blender.org/blender/blender/pulls/144176
2025-08-12 00:21:04 +02:00
Brecht Van Lommel
402080f938 Tests: Remove broken image path in tests
This causes EEVEE tests to fail now that these are logged as errors and
`--debug-exit-on-error` is used when running tests.

Pull Request: https://projects.blender.org/blender/blender/pulls/144376
2025-08-11 21:18:38 +02:00
Brecht Van Lommel
af54152b45 Tests: Allow log errors from image loading tests
These include corrupt files, and with upcoming changes to use CLOG in more
places this would otherwise exit on such errors.

Pull Request: https://projects.blender.org/blender/blender/pulls/143447
2025-08-11 14:07:45 +02:00
Christoph Neuhauser
d256cce766 Tests: Overwrite animation FPS limit in EEVEE performance tests
This PR overwrites the FPS limit in the EEVEE performance tests to 1000 FPS.

Background: I have been using the performance tests with, e.g., the Temple scene from the Blender demo files. However, it has configured an animation playback frame rate of 25 FPS. I think for the performance tests it would be more meaningful to render at an unlimited frame rate. Otherwise, one can just see that Temple renders at 25 FPS on pretty much any GPU and it is not possible to measure performance improvements or regressions.

Pull Request: https://projects.blender.org/blender/blender/pulls/142984
2025-08-11 12:07:29 +02:00
Habib Gahbiche
8d078be86b Benchmark: Compositor support
Extend the existing benchmark framework to support the compositor.
Files are added separately.

Example output:
```
$ ./benchmark.py run comp
                                         4.5                  main
ghosts                                   1.2055s              1.0243s
ghosts                                   1.4936s              1.0454s
ghosts                                   0.4414s              0.4330s

file:///Users/habib/blender-git/benchmark/comp/results.html
```

Pull Request: https://projects.blender.org/blender/blender/pulls/136600
2025-08-08 14:28:21 +02:00
Jacques Lucke
24c4e0a3f7 Geometry Nodes: move bundle and closure nodes out of experimental
This moves the bundles and closures features out of experimental,
making them an official part of Blender 5.0.

Also see #134029.

Pull Request: https://projects.blender.org/blender/blender/pulls/143750
2025-08-08 13:48:02 +02:00
Jacques Lucke
26d2c7af0d Nodes: remove field inference test
This test can't easily be updated because it relies on the old socket shape
design before #144119. Parts of it could be done from scratch again, but
most of this stuff is also tested by the new structure type inferencing test
in `bl_node_structure_type_inference.py`.

Pull Request: https://projects.blender.org/blender/blender/pulls/144185
2025-08-08 09:18:46 +02:00
Jacques Lucke
4a1020df6c Fix #143585: wrong structure type inferencing for lists
Mixing dynamic data with other data always results in dynamic now. While this
wasn't true without lists, it is true now and also makes sense generally. Also
mixing lists and single values or fields results in a list now.

Pull Request: https://projects.blender.org/blender/blender/pulls/144183
2025-08-08 09:07:20 +02:00
Campbell Barton
1c0b17fb3d Cleanup: use single quotes for enum literals 2025-08-08 06:32:03 +00:00
Jesse Yurkovich
2822b3badf Fix: USD: Use exr instead of hdr for world light texture
The spec for .usdz permits only a small handful of file formats to be
contained in the archive, and HDR is not among those supported[1]. This
also causes validation errors with the `usdchecker` tool (will be
properly tested in a follow up change).

Ignoring the potential for a user to export a .usdz file with materials
referencing unsupported file formats, Blender itself should use only
the supported formats for its business.

[1] https://openusd.org/release/spec_usdz.html#usdz-specification

Pull Request: https://projects.blender.org/blender/blender/pulls/144101
2025-08-07 20:54:22 +02:00
Omar Emara
68dc278fe5 Compositor: Redesign File Output node
This patch redesigns the File Output node to provide better UX and UI.
This is mainly achieved by allowing the user to create inputs by
dragging into an Extend socket and adjust existing inputs using the
familiar UI list design available in Blender. Additionally, various UI
changes were done:

- The Use Node Format option was renamed to Override Node Format for
  clarity.
- Socket types are now fixed and do not change as new links are made,
  allowing users to specify the exact output type and employ implicit
  conversion if needed.
- The distinction between images and Multi-Layer EXR was made clearer.
- Final output paths are drawn in the UI to remove guess work.
- The Base Path was split into a Directory and a File Name.
- Panels were added to group options, include a panel for the node
  format, items, and item formats.

Pull Request: https://projects.blender.org/blender/blender/pulls/141091
2025-08-07 14:46:34 +02:00
Campbell Barton
b07a1adf04 Core: remove use of the environment variable TMP on Unix
This isn't a standard and seems only to be included for historic reasons.

Ref !144100
2025-08-07 10:17:51 +10:00
Campbell Barton
9fcdf4822a Cleanup: correct comment, remove unused variable 2025-08-07 09:22:10 +10:00
Campbell Barton
87c4f47312 Fix #139585: Blender could erase OS root
Temporary directory handling had a logical error, assuming the
"session" temporary directory was owned and created by Blender
and could be recursively removed on exit.

However, it's possible creating the session sub-directory fails,
in that case the temporary directory was used for the "session".
This meant setting `C:\` as the temporary directory in the preferences
would attempt to recursively remove `C:\` on exit.

Resolve with the following changes:

- Only perform a recursive removal on the temporary directory
  if a session sub-directory was created.

- If the creating the user-preferences temporary "session" sub-directory
  fails fall back to the systems temporary directory and try to
  create the "session" directory there.

  Previously this was only done if the preference path didn't exist.
  The preferences path was still used if it existed but couldn't be
  written to.

Include a test to ensure this is working as expected.

Ref !144042
2025-08-06 23:13:58 +00:00
Mattias Fredriksson
a57c3558cd Curves: Unit tests for curves::nurbs::calculate_evaluated_num()
Unit tests veryfying expectation for curves::nurbs::calculate_evaluated_num().
Expectation is computed from closed form expressions rather then hard coded
values. Purpose for this is to make the tests easier to adjust if, for example,
parameter sampling pattern is changed. It should also make them easier to read
and understand.

Additional purpose is to create a baseline and verify changes for #144000.

Implementation is essentially examples from:
https://link.springer.com/book/10.1007/978-3-642-59223-2

Pull Request: https://projects.blender.org/blender/blender/pulls/143920
2025-08-06 13:59:10 +02:00
Habib Gahbiche
00f82920ef Tests: Compositor: update File Output Node tests
'exr multilayer passes' had an invalid input, so its output was updated

The rest of the tests had outdated output sockets after some 'Color'
sockets were converted into 'Vector' sockets

Pull Request: https://projects.blender.org/blender/blender/pulls/144004
2025-08-05 15:42:14 +02:00
Ian Yoo
f6523e619a Tests: Add group node test for missing output node
This adds a test case for #142944 where the compositor crashes when
there is a missing group output node inside a group node.

Pull Request: https://projects.blender.org/blender/blender/pulls/143150
2025-08-05 11:06:44 +02:00
Bastien Montagne
f453c189f8 make format 2025-08-05 11:02:21 +02:00
Bastien Montagne
d3f6523536 tests: Add basic performance test for bpy/RNA API.
These tests check performances of ID python wrapper creation (these are
cached), regular RNA struct wrapper creation, acess to IDProperties,
(un)registering of py-defined PropertyGroup, and access to py-defined
properties (without and without custom get/set).

The goal of these tests is mainly to follow performances impact of
on-going refactors and improvements in the BPY/RNA area.
2025-08-05 10:41:08 +02:00
Jacques Lucke
2c435ce8df Fix #141469: Geometry Nodes: use safer approach to modifying each instance geometry
Many nodes operate on all the instances that are passed into them. For example,
the Subdivision Surface node subdivides the mesh at the root but also instanced
meshes. This works well for most nodes, but there are a few nodes were the old
`modify_geometry_sets` function was not very well defined and it was tricky to
use correctly.

The fundamental problem was that the behavior is not obvious when a node creates
or modifies instances and how those are integrated with the already existing
instances.

This patch solves this with the following changes:
* Remove the old `GeometrySet::modify_geometry_sets` and related
  `*_during_modify` methods.
* Add a new `blender::geometry::foreach_real_geometry` function that is similar
  to the old `modify_geometry_sets` but has a more well-defined interface:
  * It never passes instances into the callback. So existing instances can't be
    modified with it.
  * The callback is allowed to create new instances. This will automatically be
    merged back with potentially already existing instances. The callback does
    not have to worry about accidentally invalidating existing instances like
    before.
* A few existing usages used `modify_geometry_sets` to actually modify existing
  instances (usually just removing attributes). Those can't use the new
  `foreach_real_geometry`, so they just get a custom simple recursive
  implementation instead of using a generic function.

Pull Request: https://projects.blender.org/blender/blender/pulls/143898
2025-08-05 06:25:20 +02:00
Jesse Yurkovich
da1846ebe1 Tests: Add options controlling verbosity of output for IO report
Add two sets of options to the IO Report class that allows tests to
control the verbosity of output.
- Add `Report.context_lines` controlling how many lines of context the
  diff uses when there are failures (3 by default)
- Add `Report.side_to_print_single_line` (5 by default) and
  `Report.side_to_print_multi_line` (3 by default) controlling how many
  items are written out

The first option helps when a failure in the test might not produce
enough lines of output to know which object is affected. The second set
of options allows individual tests to ensure more values are taken into
consideration for test validation.

They are exposed as class variables due to all the inner methods using
them being static.

Pull Request: https://projects.blender.org/blender/blender/pulls/143922
2025-08-04 19:18:16 +02:00
Dawid Kurek
9afa991316 Hydra: Handle dome light rotation
This refactors the code for world to dome light to be shared between USD and
Hydra, and makes rotations work for Hydra the same way they do in USD.

One small behavior change is that missing image files now render black,
matching Cycles and EEVEE more closely.

Co-authored-by: Brecht Van Lommel <brecht@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/143035
2025-08-04 15:58:37 +02:00
Amogh Shivaram
ff4d840cf8 Cycles: Add polarized Fresnel function for conductors
This PR adds a new `fresnel_conductor_polarized` function, which calculates reflectance and phase shift (if requested) for both parallel and perpendicular polarized light. This is needed for applying thin film iridescence to conductors (see !141131).

For consistency, this PR also makes `fresnel_conductor` call `fresnel_conductor_polarized` instead of using a fast approximation of the Fresnel equations that is inaccurate at lower n and k values. This will change the output of some Metallic BSDF renders using Physical Conductor and prevent discrepancies when enabling thin film iridescence.

I didn't do any rigorous performance testing, but from timing the functions outside of Blender, `fresnel_conductor_polarized` is significantly slower than the approximation, between 1.5-3x depending on the compiler. This makes sense because it has three square roots and the approximation has none. In some informal tests with metallic_multiggx_physical.blend modified to have more spheres, the new renders took around 1-2% longer on both CPU and GPU.

There are some avoidable inefficiencies in this approach of just calling `fresnel_conductor_polarized`:

- one of the three square roots could be saved since `fresnel_conductor` never needs the phase shift and there are simplifications possible when only calculating the reflectance
- there are several unnecessary multiplications by 1.0 since `fresnel_conductor` uses relative IOR and `fresnel_conductor_polarized` doesn't, though those could get optimized out if inlined

Pull Request: https://projects.blender.org/blender/blender/pulls/143903
2025-08-04 15:36:36 +02:00
Christoph Neuhauser
a5043308f2 Fix: Tests: Avoid RecursionError in EEVEE performance tests
The EEVEE performance tests call scene.frame_set at the end of the warmup stage, which recursively
calls frame_change_handler. Eventually, this leads to a RecursionError. This PR adds a guard for
checking if frame_set is currently active and returns early for this recursive call of the function.

Pull Request: https://projects.blender.org/blender/blender/pulls/143203
2025-08-04 08:54:10 +02:00
Ian Yoo
62b532040d Tests: Reduce glare streaks threshold
The current glare streaks threshold for highlights is too high so the
 input is just a black image, and no effects are output.
The threshold was reduced from 2.0 to 0.2 to produce a visible change.

Pull Request: https://projects.blender.org/blender/blender/pulls/142320
2025-08-01 20:36:11 +02:00
Ian Yoo
903fefff48 Tests: Add pixelate test
`node_pixelate` sets the output pixel size to 1, meaning no
transformation occurs and it is essentially the same as a single value
input. This will add a new test that pixelates the image, and renames
the original test to better reflect that edge case

Coverage:
- Function: 62.50% -> 100%
- Line: 37.36% -> 100%
- Region: 45.83% -> 100%
- Branch: 20.00% -> 90.00%

Pull Request: https://projects.blender.org/blender/blender/pulls/142438
2025-08-01 19:49:57 +02:00
Christoph Neuhauser
0cce8536dc Fix: Tests: Two-stage shader compilation in EEVEE performance tests
The EEVEE performance tests wait for shader compilation to finish before
beginning to record performance. However, shader compilation can also
happen after the first frame. This PR adds a check to the warmup phase
to see if shader compilation is still happening. This happens, e.g., for
the Mr. Elephant demo scene.

Pull Request: https://projects.blender.org/blender/blender/pulls/143690
2025-08-01 18:35:27 +02:00
Habib Gahbiche
142d491064 Tests: Compositor: tests for Value Map node
Pull Request: https://projects.blender.org/blender/blender/pulls/143795
2025-08-01 16:42:21 +02:00
Brecht Van Lommel
24a7c42766 Cleanup: Remove unused and outdated render test files
Pull Request: https://projects.blender.org/blender/blender/pulls/143438
2025-08-01 16:02:48 +02:00