In this report, adding the "resolution" attribute didn't clear the
evaluated positions cache. In some cases capturing an attribute on
the mesh might just add the mesh rather than using an attribute
writer.
When manually setting a group's vertex weight, auto-normalization would
fail in some circumstances, such as when all other groups are locked.
The root cause of this issue was our approach for ensuring that the
weight specified by the user remained as-is when possible during
normalization. Rather than "when possible", it erroneously *always*
ensured the weight stayed as-is even when that made normalization
impossible. It came down to this:
1. Normalization is done as a post process, with no knowledge of what
changes were just made to the weights.
2. In order to (try to) make up for that and ensure that the just-set
weight remains as the user specified, the active group was
temporarily locked during normalization, which could prevent
normalization in some cases.
This PR fixes the issue by introducing a new internal-only concept of
"soft locked" vertex groups to the normalization functions, intended to
be used in exactly these cases where there are weights that have just
been set and we want to avoid altering them when possible. Soft-locked
groups are left untouched whenever normalization is achievable without
touching them, but are still modified if normalization can't be achieved
otherwise.
This has been implemented by introducing a new bool array alongside the
"locked" bool array in the core normalization functions. Although all
uses in this PR only ever specify a single group as "soft locked", using
a bool array will make it easy to use this concept in other weight
painting tools in the future, which may modify more than one group at
once.
Pull Request: https://projects.blender.org/blender/blender/pulls/141045
- Add code documentation.
- Use Span and references rather than pointers everywhere.
- Move all core normalization logic into
`BKE_defvert_normalize_lock_map()`, and have the other variants call
that. This keeps all the logic in one place, which will help make
future changes easier since they only need to be made in one place.
- Add unit tests for `BKE_defvert_normalize_lock_map()`.
- Refactor `vgroup_normalize_all()` to be clearer and avoid an
unnecessary `goto`.
- Make both `vgroup_normalize_all()` and `paint_weight_gradient_exec()`
only call into a single core vertex normalization function, rather
than branching into one of many.
No functional change intended.
Refactor from e5a921ad9b did not account for the fact that some
`poll_instance` functions may require valid ID pointers in the checked
node. This is the case e.g. of the node group node, as it also checks
all of the nodes inside the referenced nodegroup.
This commit also fixes a logical mistake in the polling check, that
would systematically prevent pasting of nodes with no `poll_instance`
callback.
Pull Request: https://projects.blender.org/blender/blender/pulls/141729
When duplicating a layer with layer attribute, caught an assert hit
at `attribute_to_writer()` due to size mismatch between attribute
domain (layers count) and attribute length.
Now fixed by moving `add_node()` prior to `foreach_attribute()`. This way,
extra node already added to runtime data and layer count is updated
inside `ensure_nodes_cache` with the next layers() call
Noticed it during review of !141090
Pull Request: https://projects.blender.org/blender/blender/pulls/141722
Make display channel part of the key for the final cache.
The prefetch uses display channel of 0, which is the default. It might
need to be adjusted, but it is unclear whether it was behaving different
prior to the 9e4c26574a.
Pull Request: https://projects.blender.org/blender/blender/pulls/141670
This patch integrate the Sun Beams node into the Glare node as a new
mode. This is done because the Sun Beams node is mostly useless on its
own because it does no thresholding or addition, making it very hard to
use. On the other hand, the Glare node already does thresholding and
addition, so Sun Beams fits perfectly in it.
Pull Request: https://projects.blender.org/blender/blender/pulls/141424
Similar to other removed UI layout functions, this removes uiItemEnumO*
functions and replaces them by calling `uiLayout::op` and writing enum
properties to the returned RNA pointer.
Part of: #117604
Pull Request: https://projects.blender.org/blender/blender/pulls/141632
Previously, we used precomputed Gaussian fits to the XYZ CMFs, performed
the spectral integration in that space, and then converted the result
to the RGB working space.
That worked because we're only supporting dielectric base layers for
the thin film code, so the inputs to the spectral integration
(reflectivity and phase) are both constant w.r.t. wavelength.
However, this will no longer work for conductive base layers.
We could handle reflectivity by converting to XYZ, but that won't work
for phase since its effect on the output is nonlinear.
Therefore, it's time to do this properly by performing the spectral
integration directly in the RGB primaries. To do this, we need to:
- Compute the RGB CMFs from the XYZ CMFs and XYZ-to-RGB matrix
- Resample the RGB CMFs to be parametrized by frequency instead of wavelength
- Compute the FFT of the CMFs
- Store it as a LUT to be used by the kernel code
However, there's two optimizations we can make:
- Both the resampling and the FFT are linear operations, as is the
XYZ-to-RGB conversion. Therefore, we can resample and Fourier-transform
the XYZ CMFs once, store the result in a precomputed table, and then just
multiply the entries by the XYZ-to-RGB matrix at runtime.
- I've included the Python script used to compute the table under
`intern/cycles/doc/precompute`.
- The reference implementation by the paper authors [1] simply stores the
real and imaginary parts in the LUT, and then computes
`cos(shift)*real + sin(shift)*imag`. However, the real and imaginary parts
are oscillating, so the LUT with linear interpolation is not particularly
good at representing them. Instead, we can convert the table to
Magnitude/Phase representation, which is much smoother, and do
`mag * cos(phase - shift)` in the kernel.
- Phase needs to be unwrapped to handle the interpolation decently,
but that's easy.
- This requires an extra trig operation in the kernel in the dielectric case,
but for the conductive case we'll actually save three.
Rendered output is mostly the same, just slightly different because we're
no longer using the Gaussian approximation.
[1] "A Practical Extension to Microfacet Theory for the Modeling of
Varying Iridescence" by Laurent Belcour and Pascal Barla,
https://belcour.github.io/blog/research/publication/2017/05/01/brdf-thin-film.html
Pull Request: https://projects.blender.org/blender/blender/pulls/140944
Supporting this on the Metallic BSDF will require some extra work,
and on the Glossy BSDF it doesn't make much sense conceptually
(for that kind of shader setup, we'll want to support layering in SVM),
but Glass BSDF just needs to be hooked up so might as well do that.
Pull Request: https://projects.blender.org/blender/blender/pulls/140832