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).
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).
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).
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
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
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
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.
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
`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
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
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.
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
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
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
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
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.
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.
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
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
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
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
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
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
- 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
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
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
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
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
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