4717 Commits

Author SHA1 Message Date
Miguel Pozo
75f3d8c68f Fix #147483: Crash switching scene while rendering animation in main window
When rendering in the main window and changing the active scene,
RE_FreeUnusedGPUResources can free the resources of an active Render,
since no wmWindow references the Scene anymore.

Active Render instances always reference their Scene, so we check those
directly instead.

Pull Request: https://projects.blender.org/blender/blender/pulls/147553
2025-10-08 16:48:38 +02:00
Aras Pranckevicius
8a74f7c0b0 VSE: Execute modifiers in strip-local space (#145688)
Currently when a strip has a transform that does not fill the whole
render area, first the image of the strip is transformed, and then
any modifiers are applied on that. This is mostly in the new
Compositor modifier, where procedural textures, gradients, image
coordinates "stick to the screen" instead of following the transformed
strip.

This changes the behavior so that first the modifiers are applied
to the strip image, and then the strip is transformed. This is
potentially a visually breaking change:
- This can alter visual look of existing strip, especially if they are
  scaled. Previous behavior was first scale filtering, then modifier;
  now it is first modifier, then scale filtering.
- Most obvious change is Compositor modifier (which is new in 5.0).
- Compositor modifier can actually expand the input image (e.g. Blur
  node with "expand bounds" option set), and that works.
- Note that Masks continue to be applied in global/screen space. There
  can be small look differences with rotated/scaled strips that use
  masks, due to Mask application now needing to do filtered mask image
  lookups.
- If anyone needs previous behavior (modifier is applied on the
  "whole screen"), they can put transformed strip into a meta strip,
  and apply the modifier on the meta strip itself.

Compositor modifier examples with images in the PR.

Pull Request: https://projects.blender.org/blender/blender/pulls/146181
2025-10-07 13:51:41 +02:00
Hans Goudey
a68d39e9d9 Cleanup: Formatting
Run `make format` after the library update in the previous commit.
2025-10-02 12:55:42 -04:00
Aras Pranckevicius
ed9fc54e0e Fix #147006: VSE preview crashes with too high output resolution
Check whether creating GPU textures succeeds before using them.
However, currently when that happens there is no indication to the user
that "hey the resolution is maybe too big". Not sure what is the best
way to do that however; e.g. Workbench rendering also does not
indicate that in a similar scenario.

While at it, add GPU_is_safe_texture_size instead of duplicating
the same logic in two places.

Pull Request: https://projects.blender.org/blender/blender/pulls/147043
2025-10-01 10:08:18 +02:00
Omar Emara
d75b8e5b6e Compositor: Make a distinction between inputs and passes
This patch makes a distinction between passes accessed through nodes
like the Render Layers node, and inputs accessed through nodes like the
Group Input node. Previously, the Group Input node returned the passes
of the active scene and view layer accordingly to the name, while now,
it only returns the Image (Combined) pass and the result will be zeros.

Pull Request: https://projects.blender.org/blender/blender/pulls/146831
2025-09-30 11:35:02 +02:00
Brecht Van Lommel
9851e34c71 Refactor: OpenEXR: Simplify multi layer read and write implementation
* Read directly into ExrChannel, eliminate intermediate MultiViewChannelName
* Pass multiple channels to EXR writer together in IMB_exr_add_channels
* Avoid various channel name parsing by passing components separately
* Simplify logic for writing multichannel and multiview metadata
* Remove unused global EXR handle storage
* No longer use void pointer for EXR handle.
* Use blender::Vector and std::string.
* Slightly reshuffle code so multipart support will have smaller diff.
* Add various comments.

Pull Request: https://projects.blender.org/blender/blender/pulls/146650
2025-09-25 22:58:09 +02:00
Brecht Van Lommel
78ae7ec392 Render: Rename render passes for clarity
In very old OpenEXR version there was a limit on the channel names, which meant
the pass names needed to be short like "DiffDir". Change them to be longer like
"Diffuse Direct".

* This breaks forward compatibility. Old Blender version will lose links when
  reading compositing node setups with such passes, but #146571 will fix it
  for 4.5 LTS.
* Add-ons, scripts and compositing setups in other applications that rely on these
  names will also break.
* The find_by_type function for render passes has also been removed, as this was
  already deprecated and replaced by find_by_name.
* We assume spaces in the name are ok, since we have passes with them already
  and have not seen reports about compatibility issues.

Pull Request: https://projects.blender.org/blender/blender/pulls/142731
2025-09-25 18:04:14 +02:00
Hans Goudey
1509985013 Cleanup: Use attribute API and StringRef in bake code
Ref #122398

Pull Request: https://projects.blender.org/blender/blender/pulls/146547
2025-09-21 23:08:59 +02:00
Clément Foucault
9d0fe5573b GPU: FrameBuffer: Remove GPUFrameBuffer wrapper opaque type
This is the first step into merging DRW_gpu_wrapper.hh into
the GPU module.

This is very similar to #119825.

Pull Request: https://projects.blender.org/blender/blender/pulls/146372
2025-09-16 17:50:48 +02:00
Omar Emara
b10d767c4e Fix #134920: File Output writes frame for single render
The File Output node always appends the frame number even if the render
is not an animation. This patch makes it such that the frame number is
only written if the render is an animation. The user can use a frame
variable to manually append the frame number if needed.

The command line rendering interface already uses animation rendering in
all cases, so it should not be affected. However, rendering using the
render.render() operator with animation=False will see the behavior
change, however, setting animation=False and start_frame and end_frame
to the same frame number should be sufficient to restore the old
behavior.

Pull Request: https://projects.blender.org/blender/blender/pulls/141209
2025-09-12 09:01:31 +02:00
Habib Gahbiche
bef15f0ec1 Fix #145633: Revert "Fix #144526: Crash on exit with Video_Editing template"
The fix introduced a high severity bug where exiting Blender after
working with the GPU compositor crashes Blender. We consider #144526 to
be less severe than the newly introduced bug, hence the revert for now.

This reverts commit b2b23e3619.

Pull Request: https://projects.blender.org/blender/blender/pulls/146096
2025-09-11 18:08:52 +02:00
Brecht Van Lommel
6d25aad41f Cycles: Remove Alembic procedural
This was added for a fairly specialezed use case and is no longer being used
as far as we know. A future replacement would be to add a USD/Hydra procedural,
for which most of the groundwork already exists.

Pull Request: https://projects.blender.org/blender/blender/pulls/146021
2025-09-10 16:39:01 +02:00
Brecht Van Lommel
9d7330a223 Refactor: Color Management: Pass ImageFormatData to movie writing
Like image saving, this may be modified from the scene ImageFormatData
to contain the effective color management settings taking into account
overrides.

For upcoming changes, we will need to know the image buffer colorspace when
starting to write the video instead of only on the first frame.

Pull Request: https://projects.blender.org/blender/blender/pulls/145373
2025-09-03 16:32:01 +02:00
Hans Goudey
18fc19b4fe Cleanup: Rename "mloopuv" to "uv_map"
The old name refers to the `MLoopUV` struct which isn't use anymore.

Pull Request: https://projects.blender.org/blender/blender/pulls/145251
2025-08-27 17:44:08 +02:00
Sergey Sharybin
721e227ce3 Fix #145137: Regression: Multires Bake: Broken with UDIM
Make rasterization consistently work in local tile coordinates.

Also avoid memory leak when baking multiple tiles: high resolution bake
mesh has been created for every tile.

Pull Request: https://projects.blender.org/blender/blender/pulls/145163
2025-08-26 10:07:24 +02:00
Sybren A. Stüvel
00abaa571a Rendering: check return value of mkdir before using directory
When rendering to an image/video file, check whether the recursive
directory creation actually succeeded. If not, log an error and stop,
instead of trying to write the file.

This results in easier to understand error messages, and will help to
triage some (what we think are) race conditions with the Blender Studio
render farm.

Pull Request: https://projects.blender.org/blender/blender/pulls/145118
2025-08-25 16:30:40 +02:00
Sergey Sharybin
a020907844 Multires Bake: Implement vector displacement baking
Supports baking to object and tangent space.

Compatible with Cycles Vector Displacement node which has the
(tangent, normal, bitangent) convention.

The viewport situation is a bit confusing: seems that Eevee
does not handle vector displacement properly and rips all faces
apart. Cycles renders the displaced object correctly.

Not entirely happy with the UI, as displacement space does not
really belong to the Output, but so doesn't Low Resolution Mesh.
Perhaps the best would be to have a separate pass to revisit the
settings, and also make it more clear what the Low Resolution Mesh
actually does.

Pull Request: https://projects.blender.org/blender/blender/pulls/145014
2025-08-25 14:23:35 +02:00
Sergey Sharybin
628f53a28c Refactor: Consolidate baking settings into BakeData
Almost all settings were duplicated between BakeData and RenderData.
The only missing field was the bake type, which is stored as a custom
property in Cycles.

This change:
- Removes unused bake_samples and bake_biasdist.
- Migrates settings like bake_margin to BakeData.
- Switches multires baker to use bake_margin.
- Introduces bake type in the BakeData, the same way how it was
  defined in RenderData::bake_mode.

Pull Request: https://projects.blender.org/blender/blender/pulls/144984
2025-08-22 19:18:03 +02:00
Sergey Sharybin
8348438cae Multires bake: Rework baking high-res displacement
This change makes it so baking displacement to the high-resolution mesh
(Use Low Resolution Mesh option is OFF, displacement is calculated
between top multi-resolution level and subdivided viewport level mesh)
uses texture UVs and tangent space from the high-res mesh.

This matches intended use-case when object baked with such configuration
have subdivision surface applied to them bringing overall resolution to
the same level as the highest multi-resolution level.

The issue was simple to see when baking high-res displacement for an
object which uses "Keep Corners, Junctions" UV smoothing.

The unfortunate aspect is increased memory usage due to calculation of
the grid index and grid UV mapping, but it is not too bad (12 bytes per
loop, so is like 48Mb per million face). Feels like there is a way to
optimize it by utilizing knowledge that high-res mesh faces are created
in a specific order, but also feels it is not that important at this
moment.

Pull Request: https://projects.blender.org/blender/blender/pulls/144935
2025-08-22 18:24:57 +02:00
Sergey Sharybin
e0154de320 Rework Bake from Multires
The main idea is to switch Bake from Multires from legacy DerivedMesh
to Subdiv. On the development side of things this change removes a lot
of code, also making it easier easier to rework CustomData and related
topics, without being pulled down by the DerivedMesh.

On the user level switch to Subdiv means:

- Much more closer handling of the multi-resolution data: the derived
  mesh code was close, but not exactly the same when it comes to the
  final look of mesh.

  Other than less obvious cases (like old DerivedMesh approach doing
  recursive subdivision instead of pushing subdivided vertices on the
  limit surface) there are more obvious ones like difference in edge
  creases, and non-supported vertex creases by the DerivedMesh.

- UV interpolation is done correctly now when baking to non-base level
  (baking to multi-resolution level >= 1).

  Previously in this case the old derived mesh interpolation was used
  to interpolate face-varying data, which gives different results from
  the OpenSubdiv interpolation.

- Ngon faces are properly supported now.

A possible remaining issue is the fact that getting normal from CCG
always uses smooth interpolation. Based on the code it always has been
the case, so while it is something to look into it might be considered
a separate topic to dig into.
2025-08-22 17:59:27 +02:00
Sergey Sharybin
0c3136de84 Refactor: Use float2 in the multires baker
Shortens some formulas, and reduces the number of arguments.
Also reduce the variables scope.

No functional changes expected.
2025-08-22 17:15:06 +02:00
Brecht Van Lommel
235fdc6356 Color Management: Fix wrong use of display color space
* PROP_COLOR_GAMMA is sRGB, not display space
* Hex colors are always sRGB
* Image byte buffers are in byte_buffer.colorspace

Fixes for sequencer text, image painting, render stamp and tooltips.
The default display space is sRGB, so this change will not be noticed
in most files.

Ref #144911

Pull Request: https://projects.blender.org/blender/blender/pulls/144565
2025-08-21 15:24:40 +02:00
Campbell Barton
25ec9729dc Build: correct TBB include
`TBB_INCLUDE_DIR` is not meant to be used directly and isn't declared
on Linux. Replace with `TBB_INCLUDE_DIRS`.
2025-08-21 13:37:33 +10:00
Miguel Pozo
b2b23e3619 Fix #144526: Crash on exit with Video_Editing template
The crash is caused by libepoxy GL functions pointing to nullptrs.
libepoxy "Automatically initializes as new GL functions are used.",
so to call a function without a GL context bound, the function must
have been called before with a bound context.

This PR ensures there's a valid GL context bound for the whole
`WM_exit` scope.

(4.5 backport candidate)

Pull Request: https://projects.blender.org/blender/blender/pulls/144572
2025-08-20 15:48:20 +02:00
Campbell Barton
3a8a379ea2 Cleanup: use camel-case/pascal-case for struct names 2025-08-20 11:01:13 +10:00
Campbell Barton
66803e4441 Cleanup: use function style casts 2025-08-12 02:46:51 +00:00
Brecht Van Lommel
402080f938 Tests: Remove broken image path in tests
This causes EEVEE tests to fail now that these are logged as errors and
`--debug-exit-on-error` is used when running tests.

Pull Request: https://projects.blender.org/blender/blender/pulls/144376
2025-08-11 21:18:38 +02:00
Clément Foucault
1388a70914 GPU: Remove wrapper type for gpu::Shader
This is the first step into merging DRW_gpu_wrapper.hh into
the GPU module.

This is very similar to #119825.

Pull Request: https://projects.blender.org/blender/blender/pulls/144229
2025-08-11 09:34:28 +02:00
Sergey Sharybin
8e9c68f6a3 Cleanup: Bake from multires code
This PR contains the following incremental changes:
- Remove dead code of AO multires baker
- Use C++ primitives in multires baker (and cleanup some comments and naming)
- Remove unused bake user scale

Pull Request: https://projects.blender.org/blender/blender/pulls/143707
2025-08-08 12:43:01 +02:00
Damien Picard
5998795aa6 UI: Replace contractions with long-form text
Avoid using contractions for can't, aren't, doesn't, and shouldn't.
Following the writing style guide in the Human Interface Guidelines.

Pull Request: https://projects.blender.org/blender/blender/pulls/143852
2025-08-05 11:16:22 +02:00
Campbell Barton
f3e4b45115 Cleanup: typos in code comments 2025-07-31 06:17:48 +00:00
Brecht Van Lommel
fa007002b1 Refactor: Logging: Move G.quiet to CLOG, replace some printfs
* Replace G.quiet by CLG_quiet_set/get
* CLOG_INFO_NOCHECK prints are now suppressed when quiet, these were
  typically inside a if (!G.quiet) conditional already.
* Change some prints for blend files, color management and rendering to
  use CLOG, that were previously using if (!G.quiet) printf().

Pull Request: https://projects.blender.org/blender/blender/pulls/143138
2025-07-28 13:36:13 +02:00
Omar Emara
6f426f498a Refactor: Move pass name aliasing to context implementation
This patch moves the rules that alias Image to Combined for pass names
to the context implementations. This is because this only makes sense
for contexts that deal with passes, while it wouldn't make much sense
for other possible contexts like VSE modifiers.

Pull Request: https://projects.blender.org/blender/blender/pulls/143419
2025-07-28 10:00:20 +02:00
Campbell Barton
649b89781e Cleanup: ensure UTF8 string copy for DNA & screen data
Use `BLI_strncpy_utf8` & `BLI_snprintf_utf8` for fixed size buffers in
DNA and screen data structures such as panels, menus & operators.

This could be considered a fix as copying a UTF8 string into a smaller
buffer without proper truncation can create an invalid UTF8 sequence.
However identifying which of these users are likely to run into would
be time consuming and not especially useful.
2025-07-26 12:33:15 +00:00
Omar Emara
2582630702 Refactor: Use Bounds for compositing region
This patch uses the new C++ Bounds structure for the composition region
returned by the compositor context.

Pull Request: https://projects.blender.org/blender/blender/pulls/143199
2025-07-25 15:40:45 +02:00
Omar Emara
8cb7aafae2 Refactor: Use generic name for compositor context IO methods
This patch renames some IO methods in the compositor context to be more
generic. This is in preparation for more generic use of the compositor.

Pull Request: https://projects.blender.org/blender/blender/pulls/143193
2025-07-25 14:40:17 +02:00
Omar Emara
b92b47f628 Refactor: Reduce compositor context pure virtual methods
The compositor context has a number of pure virtual methods that could
be optional or removed altogether, so this patch refactors that by
reducing unnecessary pure virtual methods.

Pull Request: https://projects.blender.org/blender/blender/pulls/143091
2025-07-25 07:50:52 +02:00
Omar Emara
e34e6373b6 Compositor: Replace Composite node with Group Output node
This patch replaces the Composite node with the Group Output node as the
primary compositor output. The old node was removed and versioned. This
was done for consistency with Geometry Nodes and in preparation for more
generic use of the compositor in VSE modifiers, layered compositing, NPR
multi-stage compositing, and more.

The Group Output node relies on the node tree interface, so we now have
a default interface of a single input and a single output. For now, only
the first input is considered while the rest are ignored, just like the
Geometry Nodes design. Furthermore, the input is required to be of type
color. Warnings and errors are issues if any of those are not met, also
similar to Geometry Nodes.

This introduces a new limitation: Composite outputs can no longer exist
in node groups, since they obviously then act as their respective group
outputs.

A refactor for the compositor scheduler is needed to simplify the logic
after this change, but this will be done in a separate patch.

Pull Request: https://projects.blender.org/blender/blender/pulls/142232
2025-07-24 13:41:56 +02:00
Campbell Barton
336c85957b Fix: match RenderPass::chan_id size with EXR_PASS_MAXCHAN
Missed in [0] which increased the size in openexr_multi.h but didn't
update RE_pipeline.h.

[0]: d5f1b9c2223333e03f2e4994171ad9df8c1c4f21⏎
2025-07-23 10:30:07 +10:00
Campbell Barton
5c7bc1f9c0 Cleanup: use size-comments checked by "make check_size_comments" 2025-07-23 09:59:26 +10:00
Clément Foucault
32d64d35bb Refactor: GPU: Texture: Replace eGPUTextureFormat by TextureFormat
This offers better semantic and safety of the API.

Part of #130632

Pull Request: https://projects.blender.org/blender/blender/pulls/142818
2025-07-22 14:58:54 +02:00
Clément Foucault
f0254c2dcf Refactor: GPU: Remove unnecessary C wrappers for textures
This is the first step into merging `DRW_gpu_wrapper.hh` into
the GPU module.

This is very similar to #119825.

Pull Request: https://projects.blender.org/blender/blender/pulls/142732
2025-07-22 09:48:10 +02:00
Campbell Barton
c7ac5240d8 Core: use UTF8 string formatting for BKE_image (missed last commit) 2025-07-22 16:50:59 +10:00
Campbell Barton
4d4f518d80 Core: use UTF8 string formatting for BKE_image
Also use UTF8 string functions elsewhere for RenderSlot::name &
RenderView::name.
2025-07-22 16:41:13 +10:00
Campbell Barton
5f6a07240f Cleanup: avoid redundant string formatting 2025-07-22 15:53:14 +10:00
Campbell Barton
13dc1ba1d3 Fix: incorrect string size writing to RenderStats::scene_name
Bytes for the ID-code were subtracted twice when initalizing
render status scene_name for baking.
2025-07-22 14:45:12 +10:00
Campbell Barton
996210999b Cleanup: use C style comments for descriptive text, doxygen doc-strings
Also replace add-hoc groups in BKE_collision.h with doxy groups.
2025-07-22 11:59:43 +10:00
Dawid-Kurek
ccd619bdb2 Hydra: Pass camera's custom croperties to render delegate
Makes it possible to read custom camera properties in a render delegate,
e.g with HdSceneDelegate::GetCameraParamValue().

Pull Request: https://projects.blender.org/blender/blender/pulls/138918
2025-07-18 15:55:18 +02:00
Habib Gahbiche
67ffbcd0ee UI: Rename "Z" pass to "Depth"
This is a UI change only. The Python API still uses `use_pass_z` to
preserve forward and backward compatibility.

The compositor still uses "Z" to refer to depth in the Z-Combine Node.
This is addressed separately in
https://projects.blender.org/blender/blender/pulls/141676

Pull Request: https://projects.blender.org/blender/blender/pulls/141675
2025-07-18 10:27:29 +02:00
Hans Goudey
622e3d4792 Fix: Potential issue with multires bake tangent handling
Mistake in b19696c0b8

Don't reference the data from the `Array` which will just be the inline
buffer if `require_tangent` is false (for displacement baking).

I still observe a crash when multires baking, but that's deep in Cycles
code.
2025-07-17 10:08:43 -04:00