This caused a discrepancy between Metal and other platforms.
From the MSL specification:
```
atan2(y, x)
Implemented as
if x > 0, atan(y / x),
if x < 0 and y > 0, atan(y / x) + M_PI_F
if x < 0 and y < 0, atan(y / x) – M_PI_F
and if x = 0 or y = 0, the result is undefined
```
Also the GLSL specification:
```
The result is undefined if x=0.
```
Fixed by adding a small epsilon to `atan`.
Pull Request: https://projects.blender.org/blender/blender/pulls/159305
The new intersect_mnee kernel runs before shade_surface, and
shade_surface_mnee is eliminated. That large kernel was causing problems
for some GPU compilers.
MNEE state is packed into a shadow path state to avoid significantly
increasing the path state size. This shadow state is then either turned
into an actual shadow ray state or discarded in shade_surface.
MNEE was re-enabled on HIP RDNA2 as it works again now. Texture cache
misses now also work correctly with MNEE.
This adds some extra code to the regular shade_surface kernel even when
MNEE is not used, to use the MNEE sampled point instead of sampling a
light. But there seems to be no significant performance impact.
Co-authored-by: Sergey Sharybin <sergey@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/158698
This enables support for storing bundles in geometries by default. This provides
the ability to store arbitrary data on a geometry set, allowing it to be passed
whereever the geometry is passed, including across object boundaries.
This opens up significant new opportunities for building declarative systems
where the overall behavior is controlled by multiple objects. For example, it
allows creating force field objects which can be fed into simulation systems.
The geometry bundles can generally store all kinds of data that is supported by
geometry nodes, including fields, closures, other bundles and other geometry.
One notable exception is that anonymous attributes are removed as geometry
leaves geometry nodes, aka at the end of the evaluation of each modifier. This
constraint is necessary currently, because the lifetimes of these attributes
can't be tracked reliably outside of Geometry Nodes.
This adds two new nodes:
* Set Geometry Bundle: Updates the bundle stored in the geometry. If there was a
bundle already, the old one is discarded.
* Get Geometry Bundle: Retrieve the bundle in a geometry, optionally removing it
from the geometry.
Pull Request: https://projects.blender.org/blender/blender/pulls/159175
This fixes missing anonymous attributes when a reference to them is
stored in a geometry bundle.
A regression test that checks for this has been added (it breaks without
this change).
Pull Request: https://projects.blender.org/blender/blender/pulls/159149
The test shows non-deterministic behavior.
The reason is unknown, the max pool size is not exceeded.
The test shows a slightly different result each time, as long as the
volume probe is rendered.
Storing the bake result in the blend file (using a `Volume_Probe_Baked`
object) doesn't fix it.
Given that Linux doesn't seem to fail, it may be a driver issue.
Pull Request: https://projects.blender.org/blender/blender/pulls/159121
This PR adds Geometry Nodes modifier support for empties.
One of the motivations of this is to be able to create simulation
effectors (like wind, turbulence, etc.) using Geometry Nodes modifiers.
But this is also useful for fully procedural effects where original
geometry is not needed.
When creating a new node group for the first modifier in the stack,
the input geometry socket is omitted.
The `Object` > `Convert To` and `Visual Geometry to Mesh` operators have
been updated to also work for empty objects.
The overlay for the empty is not drawn when there's a modifier that
outputs geometry.
The python API `GeometrySet.from_evaluated_object` also has been updated
to work with empty objects.
Co-authored-by: Jacques Lucke <jacques@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/157804
Add a unit test to verify that when bones are renamed while joining
armatures, that the channels of corresponding action constraints are
remapped properly.
This is a follow-up to #153391 and #153449, which were tested with
this, but landed before this.
Pull Request: https://projects.blender.org/blender/blender/pulls/153745
Implement a visibility toggle for Raycast queries.
Available in `Properties Panel > Object > Visibility > Raycast`.
Allows selecting which objects are visible to the Raycast node.
Pull Request: https://projects.blender.org/blender/blender/pulls/157799
Previously, a raw `UString` was used as bundle key. However, that did not
capture all the constraints put on the key (some characters are forbidden). This
patch adds a smaller `BundleKey` wrapper around `UString` that ensures these
constraints during construction so that code using the type does not have to
check it again.
This might also become useful when we want `Bundle` to become a thinner wrapper
around `Map` instead of duplicating large parts of its interface.
Pull Request: https://projects.blender.org/blender/blender/pulls/159023
This adds support to import animations on the various camera properties
and on object visibilities via FCurves for non-sequence Alembic files.
This adds a single routine `create_keyframes` to create FCurves for all
objects which need some for the entire duration of the animation in the
archive.
The FCurves creation and key frame addition are done via some newly
added `FCurveCreationHelper` objects which are created and gathered
during object creation if need be.
For camera data animation, as Alembic does not separate the various
properties into separate sample arrays, we initially create FCurves for
all properties and remove the ones which were unnecessary at the end.
Ref: #69191
Ref: #54050
See PR for video examples.
Pull Request: https://projects.blender.org/blender/blender/pulls/158321
- Thin glass:
An infinitesimally thin sheet of dielectric, approximated by a reflected
lobe and a trasmitted lobe, the respective weights of both lobes are
analytically computed by summing up infinite geometric series that
account for internal reflections.
- Thin subsurface:
An infinitesimally thin sheet of dense scattering material, approximated
by a diffuse lobe and a translucent lobe, the respective weights of both
lobes are given by subsurface anisotropy, with specifies the relative
amount of backward and forward scattering.
Co-authored-by: Jesse Yurkovich <jesse.y@gmail.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/157469
Decompressing the buffers of glTF files needs lots of code that can leads to own bugs & errors.
And may differ from an environment to another, due to algorithm natures.
So, for glTF files with meshopt compression extensions (KHR_meshopt_compression or EXT_meshopt_compression), or with KHR_draco_mesh_compression, we are going to compare only a few part of the export.
- Comparing the list of extension used, to be sure that the roundtrip can import & export with compression
- For meshopt, check that we have 2 buffers, 1 compressed and the other one for fallback
Pull Request: https://projects.blender.org/blender/blender/pulls/158693
After fixing a bunch of issues over the years,
the render tests failure threshold it too high and
let valid errors become undetected.
Divide the fail threshold by 10 in most cases
and by 2 in worst cases.
This reduces the threshold to a very low number since
most EEVEE renders have a low amount of noise.
Some tests are updated to reduce platform differences.
This unveiled quite a few issues that will be fixed
in main later on (see blocklist edits).
Test refinement:
- 🟩 NVidia Opengl (reference)
- 🟩 AMD Opengl
- 🟩 AMD Vulkan
- 🟩 Intel Opengl
- 🟩 Metal
Pull Request: https://projects.blender.org/blender/blender/pulls/158810
Add tests that run the code-paths to address issues exposed
by #158858 & #158032 as well as a test to ensure non-trivial
MDISPS keep their shape when un-subdividing.
Also correct the example command.
Ref !158881
This commit adds support to the autosave functionality to handle images
and allows autosave to work in Texture paint.
This requires two main changes:
* Packing all edited & editable images.
* Allow autosave to function when the most recent step is an image undo
step.
The majority of this PR addresses the first change.
For all images that are to be autosaved, we pack to a new field on the
`Image`, `autosave_packedfiles` and mark the datablock with a new flag,
`IMA_AUTOSAVE_TEMPPACK`.
This field is used to prepopulate the `Image` datablock runtime cache
on file load, which then marks the ImBuf as dirty, so the user will be
informed to either save or discard changes.
If an image is saved, packed, or reloaded, the autosave information
(both the flag and the autosave packed file list) is cleared.
Additionally, the autosave information is cleared when the cache is
populated when loading the file.
As a similar area of concern, we also do this when creating the recovery
file, `quit.blend`
Part of #134518
Pull Request: https://projects.blender.org/blender/blender/pulls/152453
Due to an inconsistency in MTLFramebuffer `default_size` and its current
`size` could show an incorrect error message when reading from the
framebuffer using Python.
This has been fixed by making sure by disconnecting the default size in
Metal and base class. Sizes are set when needed. There is still
inconsistency when running in background.
Pull Request: https://projects.blender.org/blender/blender/pulls/158586
Add two Blender versions to each asset in the online asset listing:
`min` and `until`. The asset is shown in Blender if `min <=
BLENDER_VERSION < until`.
This includes changes to the schema, the listing generator, and
Blender itself to do the filtering.
This is intended for two things:
- Ensuring older Blenders don't see assets that are made with a newer
version of Blender.
- Making it possible to replace assets, where older Blender versions
still see the older version of the asset, and newer versions of
Blender only see the newer asset.
Example listing JSON:
```json
{
"name": "Mrežnica",
"id_type": "WORLD",
"files": ["worlds.blend"],
"bl_versions": {
"min": "5.2"
},
"thumbnail": {
"url": "worlds_thumbnails/World/mreznica.webp",
"hash": "SHA256:9785a7e242dbd8ff973736c51fb09a6a1efe401dfff62d38f38d9fb48b7f6e46"
},
"meta": {
"catalog_id": "efd4ea51-c968-44a6-9781-09c20796e8a6",
"tags": ["River", "Croatia", "HDRi"],
"author": "Sybren A. Stüvel",
"description": "HDRi of river Mrežnica in Croatia"
}
},
```
The listing generator writes the version of Blender that was used to
save the blend file.
Once an asset is downloaded, it will always be shown, regardless of
the version of Blender used. That may be changed in a future PR, but
such filtering is out of scope for this one.
Note: after landing this, all remote asset listings need to be
regenerated. Without a `bl_versions.max` field, the asset will not be
shown in Blender.
Pull Request: https://projects.blender.org/blender/blender/pulls/158768
Compile time here can be long, run bake tests that require shader
ray-tracing separately so that these heavy kernels are compiled
separate from the others and each category fits within the timeout.
Pull Request: https://projects.blender.org/blender/blender/pulls/158770
Rename `scripts/modules/_bpy_internal/assets/remote_library_listing/`
to `.../remote_library/`. The Python module started out as code for
the remote listing, but now has all the asset-related code (so also
downloading the assets themselves).
No functional changes.
Pull Request: https://projects.blender.org/blender/blender/pulls/158651
Download progress is now reported as `DownloadProgress` object, which
contains:
- The number of bytes streamed so far,
- the total number of bytes expected to be streamed (if the HTTP
response included a `content-length` header, otherwise `None`).
- the number of bytes written to disk so far.
This also adds support for servers that did not send a `content-length`
header. In that case it's not possible for the downloader to compute a
percentage, but the user (in our case, the asset system) may know the
expected on-disk size of the asset, and with the 'number of bytes
written to disk so far' number, can still calculate this.
Related: !157644
Co-authored by: Jakub Ružička <yac@noreply.localhost>
Pull Request: https://projects.blender.org/blender/blender/pulls/158340
Each `ImBuf` now behaves as if it can only have one pixel buffer.
- `imbuf.new()` takes a new keyword-only `buffer_type` argument
(FLOAT, BYTE).
- `ImBuf.buffer_type` - new read only attribute.
- `ImBuf.convert_buffer_type(bufrer_type)` - function for
converting between types.
- `ImBuf.with_buffer()` no longer takes a type argument.
- In the unlikely even both buffers are missing,
`ValueError("ImBuf has no pixel data")` is raised.
Removed: (recently added, not regressions)
- `ImBuf.ensure_buffer`
- `ImBuf.has_buffer`
- `ImBuf.clear_buffer`
Ref !158532
This adds back lightprobe plane support for Blended Material
and Shader to RGB evaluation.
This adds a parallax property on the Lightprobe Planes to tweak
the amount of (non-physical) distortion caused by normals.
Unlike legacy EEVEE (4.1) this implementation does not do any
raytracing even if raytracing is enabled in the render options.
Instead, it uses the same heuristic when raytracing was disabled
in 4.1. However, it now uses the new parallax amount from the
planar lightprobe property.
The heuristic fades out reflections if the normal differs from
the reflection direction or if roughness is not small.
To avoid big regression in compile time, the sampling of the
planar probe is done only once for all the BSDFs and using the
average normal.
Fix#135198
Pull Request: https://projects.blender.org/blender/blender/pulls/158483
* Use int64_t to avoid overflows, following our C++ guidelines.
* Add various index range checks for code that runs before mesh
validation.
* Match some loop iteration variables to the size type.
* Ensure number of elements fit into int where needed.
* OBJ vertex weight import issue with || true (debug leftover?).
* USD invalid shape key size check (> instead of >=).
* USD now preserves vertex positions for some invalid topology,
this the reason for usd_mesh_custom.txt test update.
* Note FBX import has fewer checks because ufbx already handles most.
Some of these are defensive, some prevent actual crashes. Tests were
added for various crashes.
These checks are meant to run in combination with mesh validation. We
try to prevent out of bounds access before validation but leave invalid
topology detection to the validation code.
Pull Request: https://projects.blender.org/blender/blender/pulls/158307
* Handle cases where there is a combination of bad vertices, bad corner
edges and duplicate edges. Regenerate edges when corner edges are bad,
which simplifies the code and helps with this.
* Don't check only the first and last face offset, but also ensure face
offsets are monotonically increasing.
* Bad span size in CD_ORIGINDEX checking.
* Material index checking incorrectly assumed there is a mesh to fix
even when only a check should happen.
Pull Request: https://projects.blender.org/blender/blender/pulls/158306
- Instead of using integers 8, 16, 24, 32 (planes), use an enum
ImColorMode (BW, BW_A, RGB, RGBA respectively) and rename the member
to color_mode.
- Change IMB_allocImBuf to always set color mode to RGBA (that was
majority of use cases); code that needs something else can just set
color mode separately.
- Fix several places were checking "can an image possibly contain alpha"
were not handling "grayscale + alpha" (planes==16) case correctly.
E.g. VSE was treating a strip with such an image as opaque, and could
wrongly occlude strips behind it.
- Several image file formats were not roundtripping gray+alpha images
correctly, even when they can; that is now fixed.
- As a side effect, Jpeg 2000 images can be saved as grayscale (BW) now.
- RNA Image.color_mode and color_depth were marked as "enum_bitflag"
seemingly by accident, that is no longer so.
- IRIS image writing code had option to write "Z" channel that was
never used; removed.
- Cineon/DPX writing code had an even number of "wrong arguments" being
passed to logImageCreate; behavior was fine since the errors cancelled
out.
- uiTemplateImageInfo had incorrect check for grayscale format display.
Co-authored-by: Campbell Barton <campbell@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/158207
In Python doc-string function signatures function arguments that had
no docs were reported however arguments that didn't reference known
arguments allowed.
Now warn on both and run tests with `--strict-docs`
so they will cause tests to fail.
Ref !158467
Run the doc generator and stub generator with stub validation.
This helps ensure the doc-strings follow stricter conventions,
and should help avoid errors in the future.
Ref !158397
Various changes in preparation for including documentation generation
in Blender's CTests (not HTML generation, as that takes much longer).
- Collect errors while building docs, print them to the stderr,
then exit with an error exit code.
- Support passing in arguments to its `main(argv=None)`,
so other scripts can invoke documentation generator.
- Use type hints for the doc generator, passes `mypy --strict`.
- Add a helper that type-checks the bundled scripts
against the generated stubs - to help expose issues.
Ref !158399
Currently the stub generation mostly serves to expose gaps/errors in
Python's documentation, although it should be reasonably complete too.
While it is possible to use the generated stubs with mypy,
most scripts generate many errors, mainly because of `bpy.props.*`
annotations which aren't recognized by mypy.
- Generate mypy-compatible `.pyi` stubs from RST (`sphinx_stub_gen.py`).
- Validate stubs via syntax + import check (`sphinx_stub_validate.py`).
- Add `python_stubs` make target.
- Include dunder methods (`__*__` methods) in RST doc-strings,
these used for the stub files, but also available in generated docs.
- Use foldable `.. details::` so as not to add unnecessary noise
to the HTML output.
- Use literal default reprs for Matrix defaults so signatures can be
evaluated.
Ref !156260
When HTTP stream compression was used, it would break conditional HTTP
downloading, because the streamed (so compressed) number of bytes of the
request was compared with the on-disk (so decompressed) size of the
downloaded file.
This is now fixed, and some other size-related fields have been renamed
to make it explicit that they are about the on-disk size.
Since this changes how the HTTP request metadata is stored on disk,
exising entries never match the on-disk file, and so every conditional
download will just re-download the file. This can't be helped, because
it's unknown whether the original request used stream compression or
not.
Pull Request: https://projects.blender.org/blender/blender/pulls/158334
- Because these data-blocks don't use the copy-on-eval system,
they need special handling in the system that creates evaluated
data-blocks for use inside the node tool execution.
- The UI didn't account for the missing support of string name referenced
data-blocks in `template_id`. It already did for font sockets a few lines up
though. Fix the same problem for sound inputs.
Pull Request: https://projects.blender.org/blender/blender/pulls/158301
Caused by 1561c1ea4a
There were a few problems. First, the enum items generation callback
didn't get the pointer I had expected when writing this. Instead, generate
them when registering the operator. Second, the asset meta-data stored
things in a confusing way, resulting in the Python-accessible enum items
using numbers as the identifiers instead of the names like similar properties
on modifiers. Add a test to keep this all working in the future.
Introduce download cancellation functions, for the HTTP downloader in
general, and for asset downloading.
Thumbnails and the downloading of asset library listings cannot be
cancelled. These are expected to be relatively small anyway.
The design:
- The HTTP downloader returns the exact URL that's being downloaded.
This value is returned by the various abstraction layers in between.
This ensures that the correct URL is known, regardless of the
adjustments made by these abstraction layers (turning relative URLs
into an absolute one, adding the expected file hash, etc.)
- The downloading URL is used to identify which download should be
cancelled.
- When the same URL is queued for downloading multiple times, all of
them are cancelled by a single call to the cancel function.
- Cancelling a URL that is not known to the downloader (because it was
never requested, or because it's already fully downloaded) is a
valid operation. It's simply a no-op.
Relevant for the calls from C++:
- `download_asset_file()` now returns the URL that was queued.
- `cancel_download()` takes the URL of the asset library (to identify
the downloader instance) and the URL returned by the function above.
- Cancellation will be reported as 'download error' with
`http_dl.DownloadCancelled` as exception type.
Pull Request: https://projects.blender.org/blender/blender/pulls/158264
Pull Request: https://projects.blender.org/blender/blender/pulls/158264
USD export currently only saves to disk at the very end of export. Due
to how USD de-duplicates data, all timeSamples remain in memory until
that time. This is problematic for cases such as #156402 that, due to
their size, quickly exhausts memory.
The solution is to call Stage Save() throughout the export process
instead of waiting until the end. However, it needs to be configurable.
Incremental saves have caused issues in the past for Google Drive
locations and it will be slower to export (slightly). Additionally, it's
not trivial or elegant to estimate the size of the exported data either.
We leave it up to the user to decide how frequently to save.
The new option will be displayed when the Animation option is selected.
Fixes#156402
Pull Request: https://projects.blender.org/blender/blender/pulls/158069
This patch adds support for Rotation sockets as well as existing nodes
from Geometry Nodes. This includes the Rotate Vector, Invert Rotation,
Rotation to Euler, Euler to Rotation, Rotate Rotation, Rotation to Axis
Angle, Axis Angle to Rotation, Mix Rotation, Rotation to Quaternion,
Quaternion to Rotation, Align Rotation to Vector, and Axes to Rotation
nodes.
Pull Request: https://projects.blender.org/blender/blender/pulls/154845