Commit Graph

134583 Commits

Author SHA1 Message Date
Campbell Barton
666ec966b9 Docs: improve code-comments for setup_app_data 2024-03-26 15:49:38 +11:00
Campbell Barton
099ff1a953 Cleanup: various non-functional C++ changes 2024-03-26 15:29:11 +11:00
Hans Goudey
fc0d8ba012 Cleanup: Remove C++ ifdef checks in C++ headers
Pull Request: https://projects.blender.org/blender/blender/pulls/119900
2024-03-26 04:56:03 +01:00
Hans Goudey
893130e6fe Refactor: Remove unnecessary C wrapper for GPUBatch class
Similar to fe76d8c946e5ce7a76d45acaee0a67407cb3b599

Pull Request: https://projects.blender.org/blender/blender/pulls/119898
2024-03-26 03:06:25 +01:00
Jacques Lucke
7314c86869 BLI: add fixed width integer type
This is intended to be used in the new exact mesh boolean algorithm by @howardt.
The new `BLI_fixed_width_int.hh` header provides types like `Int256` and
`UInt256` which are like e.g. `uint64_t` but with higher precision. The code
supports many different integer sizes.

The following operations are supported:
* Addition
* Subtraction
* Multiplication
* Comparisons
* Negation
* Conversion to and from other number types
* Conversion to and from string (based on `GMP`)

Division is not implemented. It could be implemented, but it's more complex and
is not required for the new mesh boolean algorithm.

Some alternatives to having a custom implementation have been discussed in
https://devtalk.blender.org/t/fixed-length-multiprecision-arithmetic/29189/.

Generally, the implementation is fairly straight forward. The main complexity is
the addition/multiplication algorithm which isn't too complicated. It's nice to
have control over this part as it allows us to optimize the code more if
necessary. Also, from what I understand, we might be able to benefit from some
special cases like multiplying a large integer with a smaller one.

I tried some different ways to optimize this already, but so far the normal
compiler optimization turned out to work best. Not sure if the same is true on
windows though, as it doesn't have native support for an `int128` which helps
the compiler understand what I'm doing. Alternatives I tried so far are using
intrinsics directly (mainly `_addcarry_u64` and similar), writing inline
assembly manually and copying the assembly output from the compiler. I assume
the assembly implementation didn't help for me because it prohibited other
compiler optimizations.

Pull Request: https://projects.blender.org/blender/blender/pulls/119528
2024-03-25 23:39:42 +01:00
Hans Goudey
1681e55114 Geometry Nodes: Add 8-bit integer attribute type to store attribute node
We already expose two other types that don't have a directly
corresponding socket type-- float2 and byte colors. This also solves
the inability to write to the nurbs_order attribute in geometry nodes.

Fixes #119843

Pull Request: https://projects.blender.org/blender/blender/pulls/119879
2024-03-25 23:04:11 +01:00
Hans Goudey
ef22826a3c Cleanup: Remove non-creatable option for builtin attributes
This was necessary when attributes were stored embedded in legacy
structs like `MPoly`. Nowadays that isn't the case anymore, and there
doesn't seem to be a reason to restrict the creation of attributes.
2024-03-25 17:05:39 -04:00
Hans Goudey
a6d4845899 Merge branch 'blender-v4.1-release' 2024-03-25 16:58:33 -04:00
Hans Goudey
ccb416322c UI: Add XYZ labels to Set Curve Normal node vector input 2024-03-25 16:58:29 -04:00
Hans Goudey
aa9bfc1b2a Fix: Uninitialized attribute memory read after recent commit
update_on_change_ shouldn't be called when creating an attribute but
not setting the array values. In that case it is UB to not set the values
elsewhere anyway, and that will cause its own update tag.
2024-03-25 16:58:21 -04:00
Hans Goudey
40a5e739e2 Fix #119873: Bake node crash with instanced light objects
4d0936c7d74bee32cd50 explicitly avoids turning non-geometry object
instances into geometry instances. This code is called to prepare
geometry sets for baking, and baking currently assumes that the baked
instances are always geometry sets.

To fix this, just check the instance type and serialize an empty
geometry set for the crashing object instance case. Compared to before
the crash causing commit, there is no change in behavior, since that
would have created empty geometry sets too.

Pull Request: https://projects.blender.org/blender/blender/pulls/119892
2024-03-25 21:42:07 +01:00
Hans Goudey
04bcd17dc8 Cleanup: Remove unnecessary builtin attribute provider logic
All builtin attributes are now stored as named attributes, so the old
code path from where they were stored with non-generic types can be
removed. The stored type and attribute type don't have to be tracked
separately anymore either.
2024-03-25 16:01:36 -04:00
Hans Goudey
11afa15361 Revert "Fix #119508: Missing update after "Shade Flat" operator"
This reverts commit 130701763bdb9e104486c9fd789cf128af68d9d5.

73cc27b988420d1ee10aaab808e57947dad55bbd made this unnecessary.
2024-03-25 15:50:27 -04:00
Hans Goudey
73cc27b988 Fix #119886: Set curve node missing normals update tag
The change to use generic "capture field on geometry" utilities for this
node and other nodes like it means `AttributeWriter` with its update
tagging isn't being used anymore, the attribute is just being created
with the new values (for some cases anyway). To fix this, call the
attribute provider's update function when creating the attribute too.
This was noted as useful in 130701763bdb9e104486 too.

The initialization of curve and point cloud runtime structs is moved
because they now have to be allocated before any attributes are added.
2024-03-25 15:49:25 -04:00
Weizhen Huang
2c301c921f Tests: temporarily disable light tree in the new test file
seems to cause problem on other platforms
2024-03-25 19:43:14 +01:00
Weizhen Huang
fdc2962beb Fix #114634: correlated samples in volume when using equiangular sampling and light tree
The same random number was used when sampling from the volume segment
and from the direct scattering position, causing correlation issues with
light tree.

To solve this problem, we ensure the same light is picked for
volume segment/direct scattering, equiangular/distance sampling by
sampling the light tree only once in volume segment. From the direct
scattering position in volume, we sample a position on the picked light
as usual. If sampling from the light tree fails, we continue with
indirect scattering.
For unbiased MIS weight for forward sampling, we retrieve the `P`, `D`
and `t` used in volume segment for traversing the light tree.

The main changes are:
1. `light_tree_sample()` and `light_distribution_sample()` now only pick
lights. Sampling a position on light is done separately via
`light_sample()`.
2. `light_tree_sample()` is now only called only once from volume
segment. For direct lighting we call `light_sample()`.
3. `light_tree_pdf()` now has a template `<in_volume_segment>`.
4. A new field `emitter_id` is added to struct `LightSample`, which just
stores the picked emitter index.
5. Additional field `previous_dt = ray->tmax - ray->tmin` is added to
`state->ray`, because we need this quantity for computing the pdf.
6. Distant/Background lights are also picked by light tree in volume
segment now, because we have no way to pick them afterwards. The direct
sample event for these lights will be handled by
`VOLUME_SAMPLE_DISTANCE`.
7. Original paper suggests to use the maximal importance, this results
in very poor sampling probability for distant and point lights therefore
excessive noise. We have a minimal importance for surface to balance, we
could do the same for volume but I do not want to spend much time on
this now. Just doing `min_importance = 0.0f` seems to do the job
okayish. This way we still won't sample the light with zero
`max_importance`.

The current solution might perform worse with distance sampling, because
the light tree measure is biased towards equiangular sampling. However,
it is difficult to perform MIS between equiangular and distance sampling
if different lights are picked for each method. This is something we can
look into in the future if proved to be a serious regression.

Pull Request: https://projects.blender.org/blender/blender/pulls/119389
2024-03-25 18:50:52 +01:00
Sergey Sharybin
565dc1f22b Merge branch 'blender-v4.1-release' 2024-03-25 18:15:05 +01:00
Sergey Sharybin
6c74d4af15 Fix #118555: Occasional incorrect compositor result with relative transform
In the tiled compositor ensure_delta() can be called from multiple threads,
but without any threading synchronization. This worked fine when the node
only supported absolute transform: multiple threads would do the same work
and assign delta to the same values.

With the addition of relative transform in #115947 a code which adjusts
previously calculated delta was added, leading to possible double-applying
relative transform.

The solution is to avoid multiple threads modifying the same data by using
a double-locked check.

This issue does not happen in 4.2 (main branch) because it switched to full
frame compositor, which works differently.

Pull Request: https://projects.blender.org/blender/blender/pulls/119883
2024-03-25 18:13:38 +01:00
Thomas Dinges
4ed88ce44d Merge branch 'blender-v4.1-release' 2024-03-25 18:10:23 +01:00
Thomas Dinges
26caa18173 Release: Bump to 4.1 release 2024-03-25 18:08:02 +01:00
Aaron Carlisle
f032da82af Merge branch 'blender-v4.1-release' 2024-03-25 12:52:47 -04:00
Aaron Carlisle
5a9b292ac4 Docs: Python API: Enable version switch menu 2024-03-25 12:50:01 -04:00
5ff8738dce Cleanup: Anim, reduce indentation in ANIM_animdata_filter
Return early if possible, reducing cognitive complexity.

No functional changes.
2024-03-25 15:26:27 +01:00
Jacques Lucke
6b5a97170c Geometry Nodes: allow overriding bake settings on overridden object
Previously, the bake settings in geometry nodes were not
editable even though they were stored on the overridden
object (instead of the not-overridden but linked node tree).

Pull Request: https://projects.blender.org/blender/blender/pulls/119874
2024-03-25 14:58:45 +01:00
Charles Wardlaw
23fab6b6a6 Fix #99114: USD: Cache file operators now recognize USD as well as Alembic
USD files are now findable from the cachefile.open() and
cachefile.layer_add() operators.  Removed the ".abc" appending when
looking for a file for the first time, as it no longer makes sense.

Pull Request: https://projects.blender.org/blender/blender/pulls/118685
2024-03-25 14:50:59 +01:00
Alaska
43cef92f66 Fix #119692: Cycles render issue with light tree and light linking
When using light linking with the light tree, the root index of a
mesh light subtree can be 0. The current code assumed this wasn't
possible, and as such it caused rendering issues, specifically the
incorrect computation of the PDF of certain mesh lights during
forward path tracing.

So we adjust the code to allow mesh light subtree root node
indices of 0.

This was worked on by Alaska, Sergey, and Weizhen

Pull Request: https://projects.blender.org/blender/blender/pulls/119770
2024-03-25 14:47:18 +01:00
Hans Goudey
aede88be85 Fix: Curves NURBS order attribute validate incorrect clamp 2024-03-25 09:28:53 -04:00
Omar Emara
fa3e47523e Compositor: Port GLSL SMAA to CPU compositor
This patch ports the GLSL SMAA library to the CPU compositor in order to
unify the anti-aliasing behavior between the CPU and GPU compositor.
Additionally, the SMAA texture generator was removed since it is now
unused.

Previously, we used an external C++ library for SMAA anti-aliasing,
which is itself a port of the GLSL SMAA library. However, the code
structure and results of the library were different, which made it quite
difficult to match results between CPU and GPU, hence the decision to
port the library ourselves.

The port was performed through a complete copy of the library to C++,
retaining the same function and variable names, even if they are
different from Blender's naming conversions. The necessary code changes
were done to make it work in C++, including manually doing swizzling
which changes the code structure a bit.

Even after porting the library, there were still major differences
between CPU and GPU, due to different arithmetic precision. To fix this
some of the bilinear samplers used in branches and selections were
carefully changed to use point samplers to avoid discontinuities around
branches, also resulting in a nice performance improvement. Some slight
differences still exist due to different bilinear interpolation, but
they shall be looked into later once we have a baseline implementation.

The new implementation is slower than the existing implementation, most
likely due to the liberal use of bilinear interpolation, since it is
quite cheap on GPUs and the code even does more work to use bilinear
interpolation to avoid multiple texture fetches, except this causes a
slow down on CPUs. Some of those were alleviated as mentioned in the
previous section, but we can probably look into optimizing it further.

Pull Request: https://projects.blender.org/blender/blender/pulls/119414
2024-03-25 14:21:00 +01:00
Hans Goudey
9d88fa483c Cleanup: Make format 2024-03-25 09:13:33 -04:00
Omar Emara
4971b144a4 Compositor: Unify sRGB to Linear between CPU and GPU
This patch unifies the sRGB to Linear color space conversion between the
CPU and GPU compositors. This is because CPU uses an optimized path that
produces values that are very slightly off. To fix this, for the GPU, we
do the conversion CPU side instead of doing it in a shader. Since images
are cached, the performance implications are not significant.

Another added benefit is that we no longer get differences due to the
order of alpha pre-multiplication and sRGB conversion, demonstrated in
#114305. And we no longer require any preprocessing of the images.

This patch adds some new utilities to the Image Buffer module to assign
float, byte, and compressed buffers along with their color spaces. It
also adds an ownership flag to compressed data. Those were added as a
way to facilitate the implementation.

Pull Request: https://projects.blender.org/blender/blender/pulls/118624
2024-03-25 14:09:54 +01:00
Pratik Borhade
209db414e0 Fix #119860: Undo crash in asset browser poll function
`asset_lib` is null when calling undo in active file browser space.
This causes crash in `asset undo poll`. So exit out of the poll function
when active file space is filebrowser.

Pull Request: https://projects.blender.org/blender/blender/pulls/119870
2024-03-25 14:00:38 +01:00
Pratik Borhade
f6190dcf9f Merge branch 'blender-v4.1-release' 2024-03-25 18:28:23 +05:30
Pratik Borhade
436b9a5aae Fix #119862: poly build crash when adding first vertex in empty geometry
object_index is not found (-1) when all mesh data is deleted hence it
crashes when accessing base from the vector at index -1.
So skip the further execution to prevent crash.

Pull Request: https://projects.blender.org/blender/blender/pulls/119865
2024-03-25 13:55:57 +01:00
Germano Cavalcante
f66cb1e635 UI: rename 'Snap With' and 'Snap To' to 'Snap Base' and 'Snap Target'
Since the `Set Snap Base` feature has been implemented, it would be
convenient to reflect the use of the term `Snap Base` in other areas in
the UI.

Pull Request: https://projects.blender.org/blender/blender/pulls/119723
2024-03-25 13:35:52 +01:00
Hans Goudey
b1c85fa78c Fix: Python import error for GPUVertBuf
Caused by fe76d8c946e5ce7a76d45acaee0a67407cb3b599
2024-03-25 08:10:48 -04:00
Weizhen Huang
082b68fcb9 Cycles: improve equiangular sampling in volume
By restricting the sample range along the ray to the valid segment.

Supports

**Mesh Light**
- [x] restrict the ray segment to the side with MIS

**Area Light**
- [x] when the spread is zero, find the intersection of the ray and the bounding box/cylinder of the rectangle/ellipse area light beam
- [x] when the spread is non-zero, find the intersection of the ray and the minimal enclosing cone of the area light beam
*note the result is also unbiased when we just consider the cone from the sampled point in volume segment. Far away from the light source it's less noisy than the current solution, but near the light source it's much noisier. We have to restrict the sample region on the area light to the part that lits the ray then, I haven't tried yet to see if it would be less noisy.*

**Point Light**
- [x] the complete ray segment should be valid.

**Spot Light**
- [x] intersect the ray with the spot light cone
- [x] support non-zero radius

Pull Request: https://projects.blender.org/blender/blender/pulls/119438
2024-03-25 13:02:02 +01:00
Campbell Barton
ab93a426a0 Fix assert from recent cleanup
Change from [0] didn't account for edit-meshes without faces.

[0]: 3805974b6fa8e15ae4409f597747bc7beee51fa3
2024-03-25 22:28:53 +11:00
Pratik Borhade
2e8259e4d4 GPv3: Clean loose points in draw mode menu
Include `clean loose` operator in draw mode menu.
And move this operator inside `Cleanup menu` (same as GPv2)

Pull Request: https://projects.blender.org/blender/blender/pulls/119782
2024-03-25 12:17:03 +01:00
Campbell Barton
7371b11bb5 Fix #119871: Window contents invalid on startup under Wayland & GNOME
Resolve a glitch where the window contents didn't fit the window
on startup under GNOME. This also avoids flickering whenever the
window manager changed the window size from the requested size.

See code-comments for details.
2024-03-25 22:08:27 +11:00
Aras Pranckevicius
26337b9fb4 Metal: implement support for compressed textures
Noticed lack of it via #119793. Now DDS images using BC1/BC2/BC3
(aka DXT1/DXT3/DXT5) formats can keep on being GPU compressed
on Metal too, just like e.g. on OpenGL.

Pull Request: https://projects.blender.org/blender/blender/pulls/119835
2024-03-25 11:40:20 +01:00
Sergey Sharybin
bffcb000e8 Fix: Cycles crash on Metal GPU with ASAN builds
Running a very simple files when Blender is built with the
WITH_COMPILER_ASAN=ON and WITH_CYCLES_KERNEL_ASAN=ON CMake options
leads to ASAN reporting an unknown-crash at line where the worker
pool is being filled in.

It is not entirely clear if it is a real issue in the code, since
placing debug prints with `this` address report proper addresses,
however there is no harm on capturing `this` pointer by value and
it does solve the ASAN reporting issues.

It is possible to reproduce the ASAN crash with the following steps:
- Start with --factory-startup
- Enable Metal device in User Preferences
- Switch render device to GPU Compute
- Switch viewport more to Rendered

Pull Request: https://projects.blender.org/blender/blender/pulls/119867
2024-03-25 11:36:15 +01:00
Sergey Sharybin
7e2d54e786 Fix: Assert when exiting Metal rendered viewport
This commit fixes the following assert:
  mtl_command_buffer.mm:165, submit(), at 'MTLBackend::get()->is_inside_render_boundary()'

It happens when toggling rendered state of viewport on macOS, and is
caused by incorrect order of setting active GPU context to null and
calling GPU_render_end.

This change makes the flow of GPU_render_{beign, end} and GPU context
activation closer to what it is in the draw manager's functions
DRW_render_context_{enable, disable}.

Pull Request: https://projects.blender.org/blender/blender/pulls/119868
2024-03-25 11:28:28 +01:00
fb6b4fe75c Merge remote-tracking branch 'origin/blender-v4.1-release' 2024-03-25 11:27:43 +01:00
Jun Mizutani
cc580136c6 Fix #119812: 'Add Child Collection' adds a brother bone collection
Change label from "Add Child Collection" to "Add Bone Collection", as the
newly added collection becomes a sibling, not a child, of the active one.

Pull Request: https://projects.blender.org/blender/blender/pulls/119845
2024-03-25 11:26:30 +01:00
8f015d3bfc Modeling: Merge Vertices, correct spelling of report
Fix the "Merge Vertices" report, replacing "vertice(s)" with either
"vertex" or "vertices". The singular "vertice" is not a word in English,
and thus the regular "append (s)" approach is incorrect.

Pull Request: https://projects.blender.org/blender/blender/pulls/119863
2024-03-25 10:18:13 +01:00
Jun Mizutani
378d37ed3d Fix #119812: 'Add Child Collection' adds a brother bone collection
Change label from "Add Child Collection" to "Add Bone Collection", as the
newly added collection becomes a sibling, not a child, of the active one.

Pull Request: https://projects.blender.org/blender/blender/pulls/119845
2024-03-25 09:25:24 +01:00
Jesse Yurkovich
e9eb2d35f8 USD: Add new test files for curves and point instancing 2024-03-24 21:49:55 -07:00
Bastien Montagne
792f4cc1d1 Merge branch 'blender-v4.1-release' 2024-03-25 10:02:07 +09:00
Bastien Montagne
31aec5ae1d I18N: Updated UI translstions from git/weblate repo (5f533cb92100b). 2024-03-25 09:59:29 +09:00
Lukas Stockner
05a9f96446 Fix: Add missing callback reset in RE_InitRenderCB
This caused an ASan abort while looking into #101993.

From what I can tell, the issue is that when you click the render button on
the Render Layer node, RENDER_OT_render sets the callback. Then, when you
hit F12 later, it reuses the Render from before, including the callback,
but the corresponding handle has been freed already.
2024-03-25 01:38:55 +01:00