The import nodes are considered complete enough to expose without
the experimental option. This commit removes the option so they will
be exposed in 4.5. There are still some possible future improvements,
including automatic caching, possibly exposing more input sockets,
and possibly including imported paths in the "Internal Dependencies"
panel. Those are considered non blocking though.
Pull Request: https://projects.blender.org/blender/blender/pulls/135957
This used custom data types before, which was misleading and didn't
scale well because the set of attribute types is different than the set
of grid types we can store. Now just use the grid data type, like how
the store named attribute node uses the attribute type.
This covers backward compatibility, but not forward compatibility.
Pull Request: https://projects.blender.org/blender/blender/pulls/135814
The main reason that didn't work before because undefined custom node groups
have the undefined `bNodeType` (and thus are ignored in various places) but are
actually still groups that can be evaluated. The fix is just to handle custom
node groups a bit more explicitly.
In the future, we may want to have a separate "undefined custom group"
`bNodetype`, but that might a be a bit bigger project.
Pull Request: https://projects.blender.org/blender/blender/pulls/135974
Implement shortcuts for viewer nodes. Viewer nodes are now activated using the operator `bpy.ops.node.activate_viewer()` instead of activating the viewer by setting the node to active.
This also unifies the behavior with viewer shortcuts in the compositor (see attachment in the original PR).
Pull Request: https://projects.blender.org/blender/blender/pulls/134555
This patch provides const variants to the cpu_data accessors that
returns GSpan. This is done to better const correctness. Some code need
non-const data even for read-only data, so we have to const cast those
for the moment.
This patch refactors the result class to replace proxy results with the
possibility of doing data sharing through a shared heap allocated data
reference count. This is more robust and simpler since proxy results no
longer need to be handled as a special case in a lot of the results
code. Additionally, it allows stronger const correctness since inputs to
operations can now be const.
This is somewhat similar to implicit sharing used in other parts of
Blender, so we can look into using that in the future.
Pull Request: https://projects.blender.org/blender/blender/pulls/135778
The main issue of 'type-less' standard C allocations is that there is no check on
allocated type possible.
This is a serious source of annoyance (and crashes) when making some
low-level structs non-trivial, as tracking down all usages of these
structs in higher-level other structs and their allocation is... really
painful.
MEM_[cm]allocN<T> templates on the other hand do check that the
given type is trivial, at build time (static assert), which makes such issue...
trivial to catch.
NOTE: New code should strive to use MEM_new (i.e. allocation and
construction) as much as possible, even for trivial PoD types.
Pull Request: https://projects.blender.org/blender/blender/pulls/135855
This replaces the implicit use of the `radius` attribute on the input
curves with an input field `Scale` that gets evaluated on the point
domain of the input curves to scale the profile.
It wasn't super intuitive that the `radius` would actually act as
a scale of the profile. E.g. if the radius of the input curve was
`1 meter` the resulting profile was unscaled (scaled by 1), but
wouldn't necessarily have a size of `1 meter` (only if the profile
also had a size of 1m)! If imperial units were used, `3.28084 ft`
would correspond to a scale of 1.
This change makes this behavior a lot more clear and potentially
removes the need for the assumption that the default curve radius
is `1.0f` (Ideally, the default curve radius should be `0.01f`).
While we did consider making the `Scale` input use the `radius`
field implicitly by default, we decided against it, because it again
"hides" the dependency on the radius and the fact that the radius
is used as a scale. Letting the user make this decision seems better.
Pull Request: https://projects.blender.org/blender/blender/pulls/134187
**How to reproduce:**
1. Add Cryptomatte Node
2. Enable 'Object' render passes
3. Connect Cryptomatte to output (composite or viewer node)
4. Optional: set matte ID
5. (Do not connect input image)
6. Render
7. Observe invalid output image (or assert in debug build)
(see also PR for an example blend file)
Only CPU is affected. The solution follows the behavior of the GPU backend, where the input color of the single value input image is multiplied with the matte result to produce a non constant output.
Pull Request: https://projects.blender.org/blender/blender/pulls/135786
The Mix Color shader node does not retain the alpha channel of the first
input in both the Linear Light and Soft Light modes, while it is retain
for other modes. Further, result clamping also ignores the alpha due to
using the vector clamp function, which introduces implicit conversion
that removes the alpha.
This does not matter for EEVEE because it does nothing with the alpha
channel. But the code will now be shared with the compositor, which does
care about the alpha channel. So adjust the code accordingly to retain
the alpha in those cases.
Pull Request: https://projects.blender.org/blender/blender/pulls/135632
Unlike the legacy type, the radius isn't included in the bounds for the new
curves type. This hasn't been obvious because the drawing is quite broken
and doesn't use the radius properly.
This commit adds a separate cache for the bounds with the radius, which
is now used by default. The old cache is kept around for backward
compatibility in the bounding box geometry node, where a new
"Use Radius" option accesses the old behavior.
Pull Request: https://projects.blender.org/blender/blender/pulls/135584
The name of each instance geometry is the character. This makes debugging
in the spreadsheet much easier, and the objects from "Visual Geometry to Objects"
are actually usable too.
Pull Request: https://projects.blender.org/blender/blender/pulls/135599
As a small addition to the import node features for 4.5,
this simple node imports a text file as a string. Potential
use cases include retrieving text for motion graphics.
Currently this just allows .txt files. More extensions could
be allowed in the future.
Pull Request: https://projects.blender.org/blender/blender/pulls/135459
The issue was that sometimes the group inputs of a node group were shuffled
around unexpectedly and thus inputs were passed to the wrong sockets.
The `or_socket_usages` function sorts the given span so that the key is more
likely to be reused, reducing the number of nodes inserted in the graph. The
issue was that `build_warning_node` passes `group_output_used_sockets_` into the
function the order of which is important. It thus should not be reordered.
The fix is to just never reorder the span passed to `or_socket_usages` but to
make a local copy instead which can be sorted without problems. Often this copy
is done already anyway when the span is inserted into
`graph_params.socket_usages_combination_cache` as `Vector`.
This fix also makes an assumption about `Map.lookup_or_add_cb` which was not
documented before. Namely it assumes that the key is moved into the map only
after the callback has been called. This behavior is now documented and there is
a unit test for it.
Pull Request: https://projects.blender.org/blender/blender/pulls/135528
Unlike all other nodes, the Mix node did not handle all cases of its
automatic label. This assumption was made in 02281dd26a and caused an
issue with reading uninitialized memory. In order to restrict the nodes
API interface later, this fix simply aligns the behavior of the mix node
with all others.
Pull Request: https://projects.blender.org/blender/blender/pulls/135535
The equivalent operation in edit mode reused existing vertices
rather than taking the new positions from the convex hull output.
This commit implements the same behavior for the geometry node.
Pull Request: https://projects.blender.org/blender/blender/pulls/135536
The general idea is to keep the 'old', C-style MEM_callocN signature, and slowly
replace most of its usages with the new, C++-style type-safer template version.
* `MEM_cnew<T>` allocation version is renamed to `MEM_callocN<T>`.
* `MEM_cnew_array<T>` allocation version is renamed to `MEM_calloc_arrayN<T>`.
* `MEM_cnew<T>` duplicate version is renamed to `MEM_dupallocN<T>`.
Similar templates type-safe version of `MEM_mallocN` will be added soon
as well.
Following discussions in !134452.
NOTE: For now static type checking in `MEM_callocN` and related are slightly
different for Windows MSVC. This compiler seems to consider structs using the
`DNA_DEFINE_CXX_METHODS` macro as non-trivial (likely because their default
copy constructors are deleted). So using checks on trivially
constructible/destructible instead on this compiler/system.
Pull Request: https://projects.blender.org/blender/blender/pulls/134771
Previously, only `,` was a valid delimiter, but it's also common to have e.g.
tab or semicolon. Only single characters are supported as delimiters. A few
characters are not allowed because they have other meanings: `\n`, `\r`, `"`,
`\\`.
Note: The best way to get a tab character is the use the Special Characters node
currently.
Pull Request: https://projects.blender.org/blender/blender/pulls/135468
Adds a mode option to the node to choose between the existing
behavior and new behavior that converts each face to a cyclic curve.
Generally this is much faster than the existing mode because it's
easy to parallelize and because curve offsets and face and corner
attributes can be implicitly shared to avoid copies.
Resolves#134671.
Pull Request: https://projects.blender.org/blender/blender/pulls/134773
The Z Combine node asserts if one of its outputs are unused. That's
because we compete both outputs even if they are not needed. To fix
this, we skip outputs that are not needed by splitting the shaders to
compute each output independently.
The Keying node asserts if its Edges output is unused. That's because we
compete the outputs even if it not needed. To fix this, we skip that
output if not needed.
The Scene Time node asserts if one of its outputs are unused. That's
because we compete both outputs even if they are not needed. To fix
this, we skip outputs that are not needed.
Replace `bNodeInstanceHash` with a `Map`. Move it to the node tree
runtime data. Simplify some code by removing the tag from the hash
value and collecting unused previews directly. Then just remove a
bunch of code that's now unused.
Note that texture node previews haven't been working for a while
anyway, and the experimental shader node previews seem to use
a different system (this one is a remnant of Blender Internal).
Pull Request: https://projects.blender.org/blender/blender/pulls/135310
Adds the option to create a boolean socket that can be used as a panel toggle.
This allows creating simpler and more compact node group UIs when a panel
can be "disabled".
The toggle input is a normal input socket that is just drawn a bit differently in
the UI. Whether a boolean is a toggle input or not does not affect evaluation.
Also see #133936 for guides on how to add and remove panel toggles.
Pull Request: https://projects.blender.org/blender/blender/pulls/133936
This patch implements link validation for compositor node trees. All
links are valid in the compositor, since there is implicit conversion
between all supported types. This is needed for link gather search
operations.
There is no need for amortized growth for the field interface.
Array seems slightly better than Vector because it's smaller and
doesn't give the impression that the size might change.
Pull Request: https://projects.blender.org/blender/blender/pulls/135257
Otherwise it defaults to int. This change can make a few structs
slightly smaller. Also use a signed integer type for the compositor
enum; that's the convention for non-flag enums.
Nodes that are shared between Geometry and Shader nodes use the prefix
sh_fn for their base type and poll functions. The compositor will also
share those nodes very soon, so we generalize the name to use the prefix
"common".
Currently, when selecting a file path using the file browser opened from the
node socket, there is no filter active making it harder than necessary to find
the correct file. This patch adds the proper filter. Something similar is done
when using e.g. the gltf import from the menu.
Supporting this requires changes in a bunch of places:
* `StringPropertyRNA` now has a callback that returns the file path pattern.
This has to be a callback, because the same property is used on all file path
sockets, but the valid extension depends on the node.
* The string socket declaration also has the optional path pattern. This can be
set in the node declarations.
Pull Request: https://projects.blender.org/blender/blender/pulls/134931
Blender crashes when using the Denoise node. That's because the code
assumes normal input would have 4-channels, while this may not be the
case. To fix this, use the channels count from the result or the GPU
texture directly.
Some passes are now interpreted as vectors by the compositor Image node.
This is because it assumes 3-channel passes are always vector, but this
is not the case for passes that are RGB without an alpha channel. To fix
this, we also consider channel IDs to disambiguate the type of the pass.