Commit Graph

109696 Commits

Author SHA1 Message Date
Lukas Tönne
aa88ced5c2 GPv3: Render boundary strokes with half width to hide gaps on boundaries
The leak detection filter in the fill tool flood-fill method can cause
gaps between filled areas and boundary strokes. This is undesirable, so
the boundary stroke radius is scaled by half for drawing, typically
creating enough overlap between boundaries and the generated fill
strokes to hide artifacts. This behavior is copied from GPv2.

Pull Request: https://projects.blender.org/blender/blender/pulls/122307
2024-05-27 14:43:58 +02:00
Lukas Tönne
dbe39fb202 Fix memory leak when copying materials from evaluated data.
The materials array was being allocated even when `eval_totcol` is zero.
The material code assumes that the array is nullptr when totcol is zero
and would leak that memory. Only allocate the array when the material
count is greater than zero.
2024-05-27 14:27:42 +02:00
Damien Picard
388855132e Fix #115542: Update space when selection end has moved after script error
When an error occurs in the text editor the cursor moves to the
location of the error and selects the word there. However the text
space is only updated if the current cursor position moved, not if the
selection end did. So if the cursor is already at the end of the word,
it looks like nothing has changed while under the hood the word has
been selected.

This commit simply checks whether the selection has moved and updates
the space if so.

Pull Request: https://projects.blender.org/blender/blender/pulls/121658
2024-05-27 14:05:29 +02:00
Philipp Oeser
6256e2a838 Fix #122150: UI: layout.template_search() crash without an active item
`template_search` was introduced in c20c203b82

Seems it assumed an active item is always there.
Without an active item, we are running into a crash trying to get the
textbut width.

So solution is to not draw that text button at all until an active item
is chosen.

This also goes in line with what `template_ID` is doing (it also skips
the text button without an active item).

Pull Request: https://projects.blender.org/blender/blender/pulls/122165
2024-05-27 14:04:32 +02:00
Philipp Oeser
c7dae7e455 Fix #122217 : Datablock Pointers id_properties_ui().update() crashes
It would crash with no `id_type` specified.

Custom Properties Datablock Pointers were introduced in the UI in
b3c7f3c8a9.

When created via python, we dont enforce a `id_type`, when done via the
UI, this should be set though. However, I think when using `update()`,
the `id_type` is optional, so should be possible to just change the
`description` for example and leave the type untouched.

Code was trying to get the id type from the string passed in (None in
this case) and crashed somewhere along the way of
`pyrna_enum_value_from_id` which such NULL string.

So to resolve, just leave the `id_type` untouched if nothing is
specified here.

Pull Request: https://projects.blender.org/blender/blender/pulls/122306
2024-05-27 14:04:00 +02:00
Pratik Borhade
f9e42519ae Fix: Operator search crash when no asset library is present
Appears to be due to missing null check. `filelist->asset_library` is
null if no file path is selected for user library.

Pull Request: https://projects.blender.org/blender/blender/pulls/122134
2024-05-27 13:45:36 +02:00
Sebastian Parborg
241c19a57a Add "Only project onto selected" for curve, GP3, and annotation drawing
Implementation of the proposal in: #121535

When drawing with "project to surface" turned on, it is now possible to restrict the projection to only the selected objects.
This is really useful for drawing onto surfaces that has a lot of detail meshes that you don't want to project onto.
2024-05-27 13:37:36 +02:00
Bastien Montagne
435b6743fd Fix #121733: Linked masks/moviclips/images used by editors get lost on file reload.
This was a consequence of the work done in #106321, where this specific
'active in UI' case was not identified and properly handled.

Now, consider most ID usages from UI (editors) as 'weak links', i.e.
keep a reference to these IDs even if they are only indirectly used.

Note that missing weak links will not create placeholders if the source
data is not found in the library anymore on load. they are just silently
dropped.

Pull Request: https://projects.blender.org/blender/blender/pulls/122207
2024-05-27 13:35:53 +02:00
Sergey Sharybin
f74d32e17f Python API: Expose list of running modal operators
It is accessible via window.modal_operators, and is a collection of
elements of type Operator.

It allows to implement key and operator capture overlay without need
to do low-level ctype style of access to internal data.

Pull Request: https://projects.blender.org/blender/blender/pulls/122193
2024-05-27 13:04:15 +02:00
Hoshinova
de6ff6eb0a Fix #121969: Noise texture outputs 0 with coordinates beyond 8.40*10^6
One of the properties of Perlin noise is that it always evaluates to 0.0
when not normalized (or 0.5 when normalized) when the input consists of
only whole integers in all vector components.

Blender's Perlin noise implementation uses single precision floats with
a machine epsilon of 1.19e-07 meaning that for numbers that are greater
than 1/(1.19e-07) = 8.40e6 there mantissa doesn't have any bits left to
store a rational part of the number, effectively meaning that any number
greater than 8.40e6 is a whole integer as far as Blender is concerned.
Therefore when evaluating Perlin noise for any coordinates greater than
that it always results in 0.0 (or 0.5 when normalized).

This fix works as follows: If the original input number is larger than
1.0e6 it is offset by 0.5 after it underwent modulo, which always outputs
numbers in a [0.0, 1.0e5) range leaving the mantissa room for a rational
part. This way the quantization error still persists however the outputs
are random again instead of a constant 0.0.

Pull Request: https://projects.blender.org/blender/blender/pulls/122112
2024-05-27 12:48:15 +02:00
Brecht Van Lommel
e7489664ce Fix: Assert about invalid namemap with brush assets
Linking a datablock from a library does not update the namemap, but
there is an assert added in 47672bd06a that checks this at the end
of library linking.

Usually it does not trigger because the namemap does not exist, and it
is cleared at the end of the process. Now clear it earlier, at the
moment the namemap becomes invalid.

Pull Request: https://projects.blender.org/blender/blender/pulls/122182
2024-05-27 12:43:43 +02:00
Brecht Van Lommel
d32a10e6ff Fix #122305: Crash generating API docs for node socket defaults
For the case of documenting node socket classes generically, there is no
specific socket instance to get the default value from.
2024-05-27 12:40:26 +02:00
Brecht Van Lommel
6efd7a6a50 Operators: Add option to give a modal operator priority in event handling
This may be used by add-ons like screencast keys, to log events before a
modal operator like transform handles them.

Pull Request: https://projects.blender.org/blender/blender/pulls/122226
2024-05-27 12:06:01 +02:00
Philipp Oeser
908552e5f3 Fix #122300: F3 crash (missing null check in recent image operator poll)
Caused by own recent f93360b3bb

Pull Request: https://projects.blender.org/blender/blender/pulls/122301
2024-05-27 11:02:01 +02:00
Clément Foucault
e7fc8d5d64 Fix: EEVEE-Next: Incorect GGX reflection PDF
Fix #122291
2024-05-27 10:46:13 +02:00
Jeroen Bakker
da4f84a416 Fix: Reduce compilation warnings
Reduces compilation warnings on
- clang
- GCC < 14
- MSVC

Pull Request: https://projects.blender.org/blender/blender/pulls/122298
2024-05-27 10:30:54 +02:00
Campbell Barton
580ddfbd4b Cleanup: remove outdated reference to "derived" mesh 2024-05-27 12:08:22 +10:00
Campbell Barton
52d34d1a44 Cleanup: spelling in comments 2024-05-27 12:07:03 +10:00
Campbell Barton
db58cde877 Cleanup: suppress template-id-cdtor GCC warnings
Ignoring from CMake didn't suppress the warnings from GPU sources
that include this header. Suppress the warning using a pragma instead.
2024-05-27 11:58:46 +10:00
Clément Foucault
c3b985906d Cleanup: EEVEE-Next: Remove leftover debug printf
It was never meant to be commited.
2024-05-26 22:11:01 +02:00
Clément Foucault
0e11f168db EEVEE-Next: Expose Fast GI ray and step count
This allow to reduce the amount of noise and reduce
the lost energy caused by low thickness and large
stride (low sample count).

Actual number of rays is twice the UI count.
2024-05-26 20:23:42 +02:00
Clément Foucault
fbeb4b5914 Fix: EEVEE-Next: Light transmission influence is 0 in startup file
Was just missing the versionning code for it.
2024-05-26 19:01:48 +02:00
Clément Foucault
9f2f1a5c57 EEVEE-Next: Shadow: Remove per light resolution scale
The reasonning is that we already have a resolution limit
slider per light.

The global shadow resolution scale is usefull as a quick
speedup option to reduce shadow cost for viewport regular
work or for quick rendering. For final render, the per
light resolution limit is more suited  than a LOD scale
since it doesn't modify the filtering of based on distance
from the camera.

This feature is really not hard to add back if there is
a compelling use case for it.
2024-05-26 18:56:03 +02:00
Clément Foucault
4bc015310f Fix: EEVEE-Next: Fix broken shadow global resolution scale
It was not connected to anything.
2024-05-26 18:27:18 +02:00
Iliya Katueshenock
4fc8a72780 Fix: correct offset for internal multi-input link
Pull Request: https://projects.blender.org/blender/blender/pulls/109776
2024-05-26 13:37:52 +02:00
Clément Foucault
03bcd70cd1 EEVEE-Next: Improve shadow map filter
This make the filter have a constant width in shadow
space making sure to always filter the correct amount
of pixels.

This uses the receiver slope to put the samples on a
cone with its apex at the shading position instead of
setting up the disk in shading tangent space.

We limit the slope bias to 45 degrees and offset the
cone in normal direction if the angle between light and
receiver is greater than 45 degrees. This avoid any
self shadowing artifacts cause by this technique.

Pull Request: https://projects.blender.org/blender/blender/pulls/122266
2024-05-26 12:53:18 +02:00
Philipp Oeser
f93360b3bb Fix: dont allow image operations on non-editable images
Non-editable is mostly linked (besides some incoming exception for the
Brush Asset project).
If the Image is linked but not packed, conceptually it does not really
make a difference (edits for a linked vs local image would still end up
in the same external file when saved). However when it is linked and
packed we are running into Undo crashes (#122131). Also the image
remains linked, so data remains to be read/loaded from the packed
version from the library (so any edits are lost).

For consistency, disallow image operations for all non-editable images.

ref. #122131
ref. #122033

Pull Request: https://projects.blender.org/blender/blender/pulls/122209
2024-05-26 11:32:50 +02:00
Philipp Oeser
a65df02031 Fix: Dont unpack resources that are packed in linked files (next round)
These remain linked, so data remains to be read/loaded from the packed
version from the library (making this a useless and wasteful
duplication, also changes could be perceived as lost)

Continuation of !122092 which came up in #122033 -- but spread to more
operators / API so it is consistent everywhere

For operators, first intuition was to do it in a poll function, but that
isnt possible because the actual ID might depend on a given (to the
operator) ID name.

NOTE: Still not 100% in which scenarios linked data could still be
editable, but using ID_IS_EDITABLE for this now.

c6aa1fec2b / 918d34a9ed are related

Pull Request: https://projects.blender.org/blender/blender/pulls/122204
2024-05-26 11:32:06 +02:00
Philipp Oeser
9c534cda00 Fix: Still allow unpacking of editable linked datablocks
Similar to 918d34a9ed, enable the button in `template_ID()`

Ref #122092

Pull Request: https://projects.blender.org/blender/blender/pulls/122199
2024-05-26 11:30:56 +02:00
Clément Foucault
4624b1a9ae Cleanup: EEVEE-Next: Group BSDF functions to per BSDF type files
The goal of this is to make it easier to add more BSDF
support in the future. Avoids code fragmentation and
allows easy entry points to all algorithms using BSDFs.

Pull Request: https://projects.blender.org/blender/blender/pulls/122255
2024-05-25 23:40:12 +02:00
Jesse Yurkovich
9daded5d87 USD: Use nodes for alpha-clip behavior instead of material properties
EEVEE-next has removed the MA_BM_CLIP / alpha_threshold material
properties in favor of using nodes for equivalent functionality. This
changes USD to build and traverse node graphs during import and export
accordingly. Indirectly this allows Cycles to correctly render such
materials now too.

A complicating factor is that the UsdPreviewSurface defines its opacity
threshold using greater-than-equals[1], which Blender does not support
(and for which was technically already incorrect as EEVEE-legacy only
used greater-than for its shaders). Due to this we actually need to use
2 nodes: A less-than, followed by a one-minus invert, to arrive at the
proper value. We'll translate UsdPreviewSurface to this form on Import.

For Export we will look for either this 2-node pattern or a Round
node plugged into Alpha. Looking for Round is a result of the glTF
documentation which recommended the use of this node for thresholds of
0.5[2]. It's a tiny addition that seems reasonable to accommodate.

[1] https://openusd.org/release/spec_usdpreviewsurface.html (search for "opacityThreshold")
[2] https://docs.blender.org/manual/en/4.2/addons/import_export/scene_gltf2.html#alpha-modes

See PR for example images

Pull Request: https://projects.blender.org/blender/blender/pulls/122025
2024-05-25 23:30:13 +02:00
Jesse Yurkovich
21db0daa4e USD: Read and write custom attributes for Curves
Add support for reading and writing custom `Curves` attributes.

This allows us to roundtrip Blender's Hair grooms containing UVs and
other attribute data. Note that animated attribute values are not
supported with this change.

This will also address #120042

Pull Request: https://projects.blender.org/blender/blender/pulls/121928
2024-05-25 22:23:40 +02:00
Hans Goudey
d3dbd7bdd0 Cleanup: Slightly simplify crazyspace quats loop
- Use "vert" in variable names instead of "i"
- Declare variables where their values are assigned
- Use float3 instead of pointers
- Avoid empty checks in loop by assigning span differently
2024-05-25 10:41:07 -04:00
Iliya Katueshenock
10befe6de7 Fix: Nodes: Assert on node copy
Fix of issue after fac97d6c49.
If node have dynamic declaration, update of node cause update of the declaration and its sockets.
So, links update have to be in separate loop.

Pull Request: https://projects.blender.org/blender/blender/pulls/122261
2024-05-25 14:55:15 +02:00
Pratik Borhade
200cf730d8 Fix #122241: Apply selected as rest pose not working
Mistake in acd1b0b7f9
This is due to early return from the operator execution when selection
exists.

Thanks @Ruri-Res for finding it.

Pull Request: https://projects.blender.org/blender/blender/pulls/122254
2024-05-25 11:20:28 +02:00
Charles Wardlaw
b2d1979882 USD Export: option to triangulate meshes
This allows for the source of truth data in the Blender scene to remain
untouched while producing triangulated output suitable for game and VR
pipelines, where only triangles are ingested. This addition aligns USD
with some of the other exporters which offer a similar feature.

Co-authored-by: Charles Wardlaw <cwardlaw@nvidia.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/121274
2024-05-25 03:47:35 +02:00
Charles Wardlaw
bfa54f22ce USD Import: Added an option to import only defined prims
Prims in a UsdStage can be created directly (def) or as an over. Overs
might not always be desired at import time. This patch adds the ability
to choose whether to load only defined prims (the default behaviour, and
as it exists currently in main). By unchecking this option at import
time, prims created as overs will also be imported.

Co-authored-by: Charles Wardlaw <cwardlaw@nvidia.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/121321
2024-05-24 23:50:08 +02:00
Jacques Lucke
6b6657405f Fix #76704: resetting socket values always resets to zero instead of default value
The fundamental limitation here was that RNA did not support different default values
for the same property yet (and all sockets of the same type have the same property).
This patch solves this by adding a new callback to rna property types to retrieve a
default value dynamically. Together with the socket declarations it's fairly easy to get
this working nowadays.

This also works for group nodes, because they use the socket declaration internally too.

Pull Request: https://projects.blender.org/blender/blender/pulls/122216
2024-05-24 22:16:59 +02:00
Charles Wardlaw
a6a5fd053a USD Export: filtering option for types to export
Added option for filtering types of objects to export.  Meshes,
materials, lights, cameras, volumes, and curves are all equally
supported.

This is useful for many situations in which a user might want a
subset of objects from a Collection without wanting to build a
sub-collection or otherwise reorganize their scene.  Exporting
Armatures and their animation as UsdSkel objects and UsdSkelAnim
clips, but without meshes, is a good example.

Co-authored-by: Charles Wardlaw <cwardlaw@nvidia.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/121325
2024-05-24 22:16:43 +02:00
Sergey Sharybin
62ebc5f351 Fix Image Save operator locking when saving render result
The issue has been introduced by #122105

The image save operator does exactly the thing which was not supported by
the change and was not caught during development or view: it acquires and
releases image buffers while a render result of the Image data-block is
held acquired.

The solution is to implement a simple user-counter for the render result.
Currently it is only used by the image's render result acquire/release API,
as it is the most important case for now. The render pipeline uses its own
way of protecting the result, for which the user counter is not needed.

Pull Request: https://projects.blender.org/blender/blender/pulls/122231
2024-05-24 20:41:08 +02:00
Sergey Sharybin
30c1e11388 Fix tests on macOS after recent debug shadow changes
Clément says its all good!
2024-05-24 20:37:00 +02:00
Julian Eisel
717389887b Cleanup: Keep panel functions internal to UI code
These were added/exposed in aa03646a74.

There's no need to expose them in the public UI API, and they don't seem
like functions that should be used outside of the UI internals.
2024-05-24 20:29:37 +02:00
Sergey Sharybin
f4a7c42255 Fix crash in viewer node with quick toggle of frame in Compositor
The issue was caused by a non-initialized ibuf_ used to set the non-color
space to. For now limit the tweaks to the image data-block, which is always
ensured. This makes it consistent with the GPU compositor which does not
have access to ibuf at the moment when the meta-data is being checked.

Ideally we do need to set the color space, but it needs to happen consistently,
and in a thread-safe manner. The way how the CPU compositor releases the
ibuf right after acquisition does not feel safe, so less we rely on it is
better.
2024-05-24 19:26:50 +02:00
Clément Foucault
b96b87a75c EEVEE-Next: World: Add shadow options
This adds jitter option and filter option.
2024-05-24 18:41:18 +02:00
Clément Foucault
fb85ea535f Fix: EEVEE-Next: Broken sun soft shadows
The soft shadows were only getting blurred up to a radius
of 1 unit.
2024-05-24 18:41:18 +02:00
Clément Foucault
4c75babf03 EEVEE-Next: Shadow: Improve shadow tagging debugging
The tilemap debug mode now shows updates in the
viewport and cached pages in the bottom tilemaps.
2024-05-24 18:41:18 +02:00
Bastien Montagne
6426de4489 Core: IDManagement: Refactor how 'never unused' IDs are defined.
A few ID types are considered as 'never unused' in Blender (UI related
ones, the Libraries and the Scenes). Local IDs of this type are always
considered as used, even if no other ID links to them.

This was previously fairly weekly defined and implemented (mainly in the
writefile code and the 'tag unused' libquery functions).

This commit formalize this characteristic of ID types by adding a new
`IDTYPE_FLAGS_NEVER_UNUSED` flag, and using this in the few places in
the code that handle unused IDs.
2024-05-24 17:43:22 +02:00
Sergey Sharybin
1b18e07232 Fix #121480: Cryptomatte shows some objects as black
The issue originates to the change in default view transform from Filmic
to AgX, which does slightly different clipping, and clips color to black
if there is any negative values.

This change implements an idea of skipping view transform for viewer
node when it is connected to the Pick output of the cryptomatte node.
It actually goes a bit deeper than this and any operation can tag its
result as a non-color data, and the viewer node will respect that.
It is achieved by passing some extra meta-data along the evaluation
pipeline. For the CPU compositor it is done via MetaData, and for the
GPU compositor it is done as part of Result.

Connecting any other node in-between of viewer and Cryptomatte's Pick
will treat the result as color values, and apply color management.

Connecting Pick to the Composite output will also consider it as color,
since there is no concept of non-color-managed render result.

An alternative approaches were tested, including:

- Doing negative value clamping at the viewer node.
  It does not work for legacy cryptomatte node, as it needs to have
  access to original non-modified Pick result.

- Change the order of components, and store ID in another channel.

  Using one of other of Green or Blue channels might work for some view
  transforms, but it does not work for AgX.

  Using Alpha channel seemingly works better, but it is has different
  issues caused by the fact that display transform de-associates alpha,
  leading to over-exposed regions which are hard to see in the file from
  the report. And might lead to the similar issues as the initial report
  with other objects or view transforms.

- Use positive values in the Pick channel.

  It does make things visible, but they are all white due to the nature
  of how AgX works, making it not so useful as a result.

Pull Request: https://projects.blender.org/blender/blender/pulls/122177
2024-05-24 17:25:57 +02:00
Julian Eisel
ae7edf26ed UI: Remove Outliner element collapse chevron for empty scene elements
Scenes that have no children displayed (either because there was nothing
to display or because we didn't expand the sub-tree, such as in the
"Unused Data" display mode) would always have a chevron icon indicating
the collapsed state, but it wasn't interactive. As such it just felt
broken. This explicit exception to always draw the chevron for scene
elements was added a long time ago (13 years ago or longer), and I
couldn't find any good rationale for it.
2024-05-24 16:34:28 +02:00
Campbell Barton
97e017d89c Unbreak build from missing fmtlib reference on some systems 2024-05-25 00:32:23 +10:00