Commit Graph

4010 Commits

Author SHA1 Message Date
Campbell Barton 499fec6f79 Cleanup: spelling in comments 2022-01-06 13:54:52 +11:00
Sergey Sharybin 8cd6d0fe68 Fix T94169: Missing grease pencil render with tiled rendering
Delay grease pencil for until after the render result is written
to the Blender side.

Differential Revision: https://developer.blender.org/D13740
2022-01-05 17:47:10 +01:00
Sergey Sharybin 3c04b44913 Fix Cycles allocating result too early
When tiled rendering was used the render result was
allocated at the end of every view layer render as
opposite of an intended end of all rendering.

Modify the render_result_end so that it only ensures
pixels are allocated if pixels are actually copied
over.
2022-01-05 17:47:10 +01:00
Sergey Sharybin 924d2b8df6 Fix T94506: Crash in Compositing 2022-01-05 12:31:37 +01:00
Jacques Lucke 7e712b2d6a Nodes: refactor node tree update handling
Goals of this refactor:
* More unified approach to updating everything that needs to be updated
  after a change in a node tree.
* The updates should happen in the correct order and quadratic or worse
  algorithms should be avoided.
* Improve detection of changes to the output to avoid tagging the depsgraph
  when it's not necessary.
* Move towards a more declarative style of defining nodes by having a
  more centralized update procedure.

The refactor consists of two main parts:
* Node tree tagging and update refactor.
  * Generally, when changes are done to a node tree, it is tagged dirty
    until a global update function is called that updates everything in
    the correct order.
  * The tagging is more fine-grained compared to before, to allow for more
    precise depsgraph update tagging.
* Depsgraph changes.
  * The shading specific depsgraph node for node trees as been removed.
  * Instead, there is a new `NTREE_OUTPUT` depsgrap node, which is only
    tagged when the output of the node tree changed (e.g. the Group Output
    or Material Output node).
  * The copy-on-write relation from node trees to the data block they are
    embedded in is now non-flushing. This avoids e.g. triggering a material
    update after the shader node tree changed in unrelated ways. Instead
    the material has a flushing relation to the new `NTREE_OUTPUT` node now.
  * The depsgraph no longer reports data block changes through to cycles
    through `Depsgraph.updates` when only the node tree changed in ways
    that do not affect the output.

Avoiding unnecessary updates seems to work well for geometry nodes and cycles.
The situation is a bit worse when there are drivers on the node tree, but that
could potentially be improved separately in the future.

Avoiding updates in eevee and the compositor is more tricky, but also less urgent.
* Eevee updates are triggered by calling `DRW_notify_view_update` in
  `ED_render_view3d_update` indirectly from `DEG_editors_update`.
* Compositor updates are triggered by `ED_node_composite_job` in `node_area_refresh`.
  This is triggered by calling `ED_area_tag_refresh` in `node_area_listener`.

Removing updates always has the risk of breaking some dependency that no
one was aware of. It's not unlikely that this will happen here as well. Adding
back missing updates should be quite a bit easier than getting rid of
unnecessary updates though.

Differential Revision: https://developer.blender.org/D13246
2021-12-21 15:18:56 +01:00
Campbell Barton c536eb410c Cleanup: spelling in comments 2021-12-17 15:26:28 +11:00
Campbell Barton c097c7b855 Cleanup: correct unbalanced doxygen groups
Also add groups in some files.
2021-12-14 16:17:10 +11:00
Campbell Barton 93ba5e2375 Cleanup: move public doc-strings into headers for 'render'
Ref T92709
2021-12-08 17:12:43 +11:00
Aaron Carlisle 63bd356faf Cleanup: Missing include
This included is needed for the `ATTR_NONNULL` macro used in the header.
As found in a recent c --> c++ if the includes get ordered in a different order
this could result in an error.

Re commits rBc20098e6ec6adee874a12e510aa4a56d89f92838
2021-12-07 13:20:22 -05:00
Jacques Lucke 0f48b37aae Revert moving all shader nodes to c++
This reverts to following commits:
* rB5cad004d716da02f511bd34983ac7da820308676
* rB97e3a2d935ba9b21b127eda7ca104d4bcf4e48bd
* rBf60b95b5320f8d6abe6a629fe8fc4f1b94d0d91c
* rB0bd3cad04edf4bf9b9d3b1353f955534aa5e6740
* rBf72cc47d8edf849af98e196f721022bacf86a5e7
* rB3f7014ecc9d523997062eadd62888af5fc70a2b6
* rB0578921063fbb081239439062215f2538a31af4b
* rBc20098e6ec6adee874a12e510aa4a56d89f92838
* rBd5efda72f501ad95679d7ac554086a1fb18c1ac0

The original move to c++ that the other commits depended upon had some issues
that should be fixed before committing it again. The issues were reported in
T93797, T93809 and T93798.

We should also find a better rule for not using c-style casts going forward,
although that wouldn't have been reason enough to revert the commits.
Introducing something like a `MEM_new<T>` and `MEM_delete<T>`
function might help with the the most common case of casting the return
type of `MEM_malloc`.

Going forward, I recommend first committing the changes that don't
require converting files to c++. Then convert the shading node files
in smaller chunks. Especially don't mix fairly low risk changes like
moving some simple nodes, with higher risk changes.
2021-12-07 13:26:39 +01:00
Aaron Carlisle c20098e6ec Cleanup: Add missing include
Fixes compilation errors after rBd5efda72f501
Re sorted some includes.
2021-12-05 13:33:15 -05:00
Brecht Van Lommel 12fc395436 Fix T93152: Cycles baking multiple selected object to active not working 2021-11-18 17:43:27 +01:00
Campbell Barton b280699078 Cleanup: use elem macros 2021-10-20 11:16:43 +11:00
Sergey Sharybin 596446dbc6 Fix wrong Cycles tile highlight with region render
In previous Blender version the tile highlight was stored in the
full frame (un-cropped)  space. This was changed with the Cycles X
development and now the tiles and render result are always measured
relative to the cropped region.

Differential Revision: https://developer.blender.org/D12779
2021-10-08 15:28:53 +02:00
Campbell Barton df8f507f41 Cleanup: spelling in comments 2021-10-06 14:54:05 +11:00
Sebastian Parborg 88c02bf826 VSE: Free animation strip data if they are not visible
Previously we would only free animation strip data when doing final
renders. If not doing a final render or simply just playing back videos
in the VSE, we would not free decoders or non VSE cache data from the
strips.

This would lead to memory usage exploding in complex VSE scenes.

Now we instead use the dumb apporach of freeing everything that is not
currently visible.
2021-10-05 18:53:58 +02:00
Brecht Van Lommel 0cddbcf1d7 Fix T91803: Freestyle rendering as pass broken after recent changes 2021-09-29 21:14:37 +02:00
Campbell Barton 79290f5160 Cleanup: spelling in comments 2021-09-29 07:29:15 +10:00
Sergey Sharybin 741fa8180c Fix T91679: Crash when saving bordered render as multilayer exr
The related issue which is fixed by this change is the missing noisy
image pass when denoising and border render is used,

Need to allocate passes after the passes has been copied from the
original render result.
2021-09-28 10:49:01 +02:00
Brecht Van Lommel 1bdaf0ebec Fix T91638: image editor Open Cached Render not loading some passes
Previously this was only loading built-in render passes. Now instead of trying
to load the scene render passes, load whatever passes exist in the cache file.
2021-09-23 20:45:42 +02:00
Sergey Sharybin e86cf55667 Fix T91629: Crash in "Open Cached Render" function 2021-09-23 13:03:36 +02:00
Brecht Van Lommel 0803119725 Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.

Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.

Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles

Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)

For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.

Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-21 14:55:54 +02:00
Sergey Sharybin 51f7d24a4e Fix missing passes result when rendering multiple views
Caused by the lazily pass pixels allocation which didn't reset
allocation state of the render result.

Demo file: XXX
2021-09-15 18:53:57 +02:00
Sergey Sharybin 799a2b07ad Fix possible missing render result with `update_result`
Need to ensure render result's pixels are allocated prior to merge.

Differential Revision: https://developer.blender.org/D12371
2021-09-02 09:28:42 +02:00
Sergey Sharybin d8b445e728 Fix missing render result when using region render
Caused by lazy allocation of passes.
2021-08-31 12:12:34 +02:00
Sergey Sharybin f6d133e2d2 Fix possible wrongly highlighted tiles
Run into it when was re-working tiles in the Cycles X project.
Make sure the storage of highlighted tiles is emptied when the
render is finished or cancelled).

The error is only possible to happen if the engine did not do
something correct, but is still good to deal with such situations
more gracefully.
2021-08-31 11:05:57 +02:00
Campbell Barton d718d6b449 Cleanup: Use C style comments for descriptive text 2021-08-31 14:33:57 +10:00
Sergey Sharybin c52db4c4cf Decouple highlighted tiles from RenderPart
Should be no visible change on user side.
Preparing for render parts removal as part of Cycles X project.

Differential Revision: https://developer.blender.org/D12317
2021-08-26 12:09:03 +02:00
Sergey Sharybin 038f9b7f4a Render: Lazily allocate render passes pixels storage
The idea is to only allocate pixel storage only when there is an actual
data to be written to them.

This moves the code forward a better support of high-res rendering when
pixel storage is not allocated until render engine is ready to provide
pixel data.

Is expected to be no functional changes for neither users no external
engines. The only difference is that the motion and depth passes will
be displayed as transparent for until render engine provides any tile
result (at which point the pixels will be allocated and initialized to
infinite depth).

Differential Revision: https://developer.blender.org/D12195
2021-08-24 16:20:57 +02:00
Kévin Dietrich 51862c8445 Cycles: experimental integration of Alembic procedural in viewport rendering
This patch exposes the Cycles Alembic Procedural through the MeshSequenceCache
modifier in order to use and test it from Blender.

To enable it, one has to switch the render feature set to experimental and
activate the Procedural in the modifier. An Alembic Procedural is then
created for each CacheFile from Blender set to use the Procedural, and each
Blender object having a MeshSequenceCache modifier is added to list of objects
of the right procedural.

The procedural's parameters derive from the CacheFile's properties which are
already exposed in the UI through the modifier, although more Cycles specific
options might be added in the future.

As there is currently no cache controls and since we load all the data at the
beginning of the render session, the procedural is only available during
viewport renders at the moment. When an Alembic procedural is rendered, data
from the archive are not read on the Blender side.

If a Cycles render is not active and the CacheFile is set to use the Cycles Procedural,
bounding boxes are used to display the objects in the scene as a signal that the
objects are not processed by Blender anymore. This is standard in other DCCs.
However this does not reduce the memory usage from Blender as the Alembic data
was already loaded either during an import or during a .blend file read.

This is mostly a hack to test the Cycles Alembic procedural until we have a
better Blender side mechanism for letting renderers load their own geometry,
which will be based on import and export settings on Collections (T68933).

Ref T79174, D3089

Reviewed By: brecht, sybren

Maniphest Tasks: T79174

Differential Revision: https://developer.blender.org/D10197
2021-08-19 14:40:51 +02:00
Campbell Barton bc97d78329 Cleanup: use MEM_SAFE_FREE macro 2021-08-06 14:24:16 +10:00
Campbell Barton f5acfd9c04 Cleanup: remove redundant parenthesis 2021-08-05 16:54:34 +10:00
Brecht Van Lommel 0b0c2901f6 Render: remove unused Blender Internal view layer settings
These should have been removed earlier but were forgotten.
2021-07-29 17:59:03 +02:00
Campbell Barton ced94bc11c Cleanup: code comments punctuation / spacing 2021-07-23 17:03:51 +10:00
Campbell Barton c3a400b73f Cleanup: use single back-tick quoting in comments
While doxygen supports both, conform to our style guide.

Note that single back-tick's are already used in a majority of comments.
2021-07-20 22:58:14 +10:00
Hans Goudey 3b6ee8cee7 Refactor: Move vertex group names to object data
This commit moves the storage of `bDeformGroup` and the active index
to `Mesh`, `Lattice`, and `bGPdata` instead of `Object`. Utility
functions are added to allow easy access to the vertex groups given
an object or an ID.

As explained in T88951, the list of vertex group names is currently
stored separately per object, even though vertex group data is stored
on the geometry. This tends to complicate code and cause bugs,
especially as geometry is created procedurally and tied less closely
to an object.

The "Copy Vertex Groups to Linked" operator is removed, since they
are stored on the geometry anyway.

This patch leaves the object-level python API for vertex groups in
place. Creating a geometry-level RNA API can be a separate step;
the changes in this commit are invasive enough as it is.

Note that opening a file saved in 3.0 in an earlier version means
the vertex groups will not be available.

Differential Revision: https://developer.blender.org/D11689
2021-07-13 12:10:34 -04:00
Brecht Van Lommel a072e87e04 Fix T89040: dependency graph not handling time remapping correctly
In this bug report it resulted in rendering animations stopping too early,
but this affected more areas.

After the previous cleanup commit, it becomes clear that frame and ctime
values were mixed up.
2021-07-12 17:41:26 +02:00
Brecht Van Lommel 2ea565b0ec Cleanup: improve naming and comments of scene frame/ctime functions
Confusingly, BKE_scene_frame_get did not match the frame number as expected by
BKE_scene_frame_set. Instead it return the value after time remapping, which
is commonly named "ctime".

* Rename BKE_scene_frame_get to BKE_scene_ctime_get
* Add a new BKE_scene_frame_get that matches BKE_scene_frame_set
* Use int/float depending if fractional frame is expected
2021-07-12 17:41:15 +02:00
Campbell Barton 7489427e4d Cleanup: spelling 2021-07-08 13:31:38 +10:00
Campbell Barton f0f7282d9d Cleanup: spelling in comments 2021-07-05 15:54:57 +10:00
Campbell Barton 9b89de2571 Cleanup: consistent use of tags: NOTE/TODO/FIXME/XXX
Also use doxy style function reference `#` prefix chars when
referencing identifiers.
2021-07-04 00:43:40 +10:00
Campbell Barton 501d2443d0 Cleanup: use const arguments for accessor functions 2021-06-30 16:42:19 +10:00
Campbell Barton 1d8648b13a Cleanup: repeated terms in code comments & error messages 2021-06-28 15:46:08 +10:00
Campbell Barton f1e4903854 Cleanup: full sentences in comments, improve comment formatting 2021-06-26 21:50:48 +10:00
Campbell Barton 4b9ff3cd42 Cleanup: comment blocks, trailing space in comments 2021-06-24 15:59:34 +10:00
Campbell Barton 513f566b40 Mesh: optimize object mode face tessellation
- Multi-thread BKE_mesh_recalc_looptri.

- Add BKE_mesh_recalc_looptri_with_normals,
  this skips having to calculate normals for ngons.

Exact performance depends on number of faces, size of ngons and
available CPU cores.

For high poly meshes the isolated improvement to BKE_mesh_recalc_looptri
in my tests was between 6.7x .. 25.0x, with the largest gains seen in
meshes containing ngons with many sides.

The overall speedup for high poly meshes containing quads and triangles
is only ~20% although ngon heavy meshes can be much faster.
2021-06-20 14:39:13 +10:00
Campbell Barton 6c1fdd52c1 Fix invalid polygon normal array access building bake data
Pre computed normals index wasn't properly aligned.
Regression from 2ec00ea0c1.
2021-06-18 18:00:47 +10:00
Thomas Lachmann b84707df17 Python API: option for render engines to disable image file saving
For some custom rendering engines it's advantageous not to write the image files to disk.
An example would be a network rendering engine which does it's own image writing.

This feature is only supported when bl_use_postprocess is also disabled, since render
engines can't influence the saving behavior of the sequencer or compositor.

Differential Revision: https://developer.blender.org/D11512
2021-06-14 14:20:04 +02:00
Campbell Barton b13953b1f2 Cleanup: quiet -Warray-parameter warnings from GCC11
Some warnings remain that require larger changes.
2021-05-21 15:45:25 +10:00
Campbell Barton efc6f4675d Cleanup: spelling 2021-05-06 08:09:05 +10:00