Commit Graph

120055 Commits

Author SHA1 Message Date
Falk David
7b66e2274b GPv3: Draw Tool: Refactor simplify_stroke
Previously the `simplify_stroke` stroke step used the screen
space coordinates to do the simplification.
Instead, this is now refactored to use the more general
`geometry::simplify_curve_attribute`. This means we can
simplify the stroke based on the positions and radii.

The simplify step is also now hooked up to the simplify option
in the tool settings (under the `Stroke` panel).
2024-05-27 17:27:31 +02:00
Falk David
2c44789bc3 GPv3: Draw Tool: Use the Post-Processing toggle
In the `Stroke` panel for the draw tool settings, there is a
toggle to enable/disable post processing. This is now hooked
up in the code.
2024-05-27 17:27:31 +02:00
Falk David
bf7e3e9256 GPv3: Draw Tool: Use input_samples tool setting
This uses the `input_samples` tool setting as a minimum distance
in pixels (screen space) for newly created points.
By default this is 10, which means that the points in a drawn stroke
will all be at a distance of 10px or less (in screen space when
the stroke is drawn).
2024-05-27 17:27:31 +02:00
Falk David
76ed87bcf9 GPv3: Draw Tool: Use hardness value from tool settings
Use the `hardness` value from the grease pencil tool setting
to set the (now called) `softness` attribute of the new stroke.
2024-05-27 17:27:31 +02:00
Jacques Lucke
874dee0670 Fix: crash in data-block lookup with multiple libraries 2024-05-27 17:07:48 +02:00
Hans Goudey
a3fe547bf9 Cleanup: Sculpt: Remove duplicate function
Looks like `calc_sculpt_plane` was duplicated in d93dd85951.
2024-05-27 10:42:14 -04:00
Falk David
a0294e0b9a GPv3: Refactor Layer::frame_at
There were two issues:
* The const and non-const version behaved differently
* The frames map was not used to query the `frame_number`

Now both the const and non-const implementations behave
the same way. Additionally, the frames map is used to do a
lookup first and, on sucess , return the frame immediatly.
Otherwise we do a binary search for a keyframe that starts
before the frame number (and ends after).
2024-05-27 15:42:12 +02:00
Lukas Tönne
f5b9ff15a0 Fix #121356: GPv3: Conversion operators to/from Curves
Adds object conversion between Grease Pencil and Curves types.

GPv3 object is converted to Curves by combining all visible layers at
the current frame.
Curves object is converted to Grease Pencil by constructing a new layer
and keyframe with the curves geometry.

The type enum for the conversion operator gets a dynamic function to
check for the experimental flags and only show the enabled Grease Pencil
object types. It does not currently exclude unsupported type
combinations.

Pull Request: https://projects.blender.org/blender/blender/pulls/122304
2024-05-27 15:27:36 +02:00
Jeroen Bakker
854dc30c63 Fix 122018: EEVEE-Next crashes on Intel
Intel drivers do not follow the OpenGL standards for barriers. Although
the barriers are in balance for any thread, they need to be in a simple
for-loop in order to not crash on intel.

Recently the sun light extraction added new barriers that needed to be
adapted. We also reviewed all barriers to find faulty code-paths.

Previously we were able to change the for-loop with an index based loop.
But for more complex shaders this trick didn't work anymore and the loop
didn't seem to be unrolled anymore. `eevee_reflection_probe_remap_comp.glsl`
has more complexity due to the recent sun light extraction. For this shader
we manually did the unrolling.

**Compatibility**
- This PR was tested with success on Windows/OpenGL and Apple/Metal.

Pull Request: https://projects.blender.org/blender/blender/pulls/122308
2024-05-27 15:20:48 +02:00
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