113861 Commits

Author SHA1 Message Date
Lukas Stockner
ad35453cd1 Cycles: Add support for light groups
Light groups are a type of pass that only contains lighting from a subset of light sources.
They are created in the View layer, and light sources (lamps, objects with emissive materials
and/or the environment) can be assigned to a group.

Currently, each light group ends up generating its own version of the Combined pass.
In the future, additional types of passes (e.g. shadowcatcher) might be getting their own
per-lightgroup versions.

The lightgroup creation and assignment is not Cycles-specific, so Eevee or external render
engines could make use of it in the future.

Note that Lightgroups are identified by their name - therefore, the name of the Lightgroup
in the View Layer and the name that's set in an object's settings must match for it to be
included.
Currently, changing a Lightgroup's name does not update objects - this is planned for the
future, along with other features such as denoising for light groups and viewing them in
preview renders.

Original patch by Alex Fuller (@mistaed), with some polishing by Lukas Stockner (@lukasstockner97).

Differential Revision: https://developer.blender.org/D12871
2022-04-02 06:14:27 +02:00
Hans Goudey
5387d33e5f Cleanup: Further use of const for object bounding boxes
Also solves two warnings from the previous similar commit,
f688e3cc3130e70e77f0bb0. The change to the grease pencil
modifier is quite suspicious, but doesn't change the behavior,
which was already broken.
2022-04-01 18:30:09 -05:00
Hans Goudey
69c07adb51 Cleanup: Remove object bounding box function
This abstraction doesn't serve any purpose after 11c6d4e88eb919.
The flag on bounding boxes isn't used, except for the dirty tag.
2022-04-01 14:58:32 -05:00
Hans Goudey
59c3194f8e Cleanup: Use float3 type
This can help make some refactoring to bounding boxes slightly easier.
2022-04-01 14:48:48 -05:00
Hans Goudey
11c6d4e88e Cleanup: Remove unused boundbox flag
This flag hasn't been used for around four years. The convention in this
header seems to be commenting out the flag and adding "UNUSED" after it.
2022-04-01 13:55:17 -05:00
Hans Goudey
f688e3cc31 Cleanup: Use const for bounding boxes where possible 2022-04-01 13:45:02 -05:00
Julian Eisel
999f6526b1 Fix compiler error when building without USD and alembic 2022-04-01 20:12:09 +02:00
Stefan Werner
65dcb5ebd3 Cycles: Semantically separate 2D and 3D texture objects
Currently there are no functional changes.

Preparing for an upcoming oneAPI integration where such separation
in types is needed.
2022-04-01 19:44:31 +02:00
Stefan Werner
9c6dff70c8 Cycles: Introduce postfix for kernel body definition
Increases flexibility of code-generation for kernel entry points.

Currently no functional changes, preparing for integration with oneAPI.
2022-04-01 19:44:02 +02:00
Stefan Werner
542c03fed5 Cycles: Use single floating point precision sine/cosine in sky
Should be no functional changes.
2022-04-01 19:43:34 +02:00
Stefan Werner
633c8fc3c8 Cycles: Optimize Nishita sky
Reduce register pressure.
Helps with kernel compile time and render time.

Should be no functional changes.
2022-04-01 19:42:00 +02:00
Bastien Montagne
8bec875586 install_deps: Update Embree to 3.13.3 and OIDN to 1.4.3.
Re {T95206}.
2022-04-01 17:47:15 +02:00
Olivier Maury
1fb0247497 Cycles: approximate shadow caustics using manifold next event estimation
This adds support for selective rendering of caustics in shadows of refractive
objects. Example uses are rendering of underwater caustics and eye caustics.

This is based on "Manifold Next Event Estimation", a method developed for
production rendering. The idea is to selectively enable shadow caustics on a
few objects in the scene where they have a big visual impact, without impacting
render performance for the rest of the scene.

The Shadow Caustic option must be manually enabled on light, caustic receiver
and caster objects. For such light paths, the Filter Glossy option will be
ignored and replaced by sharp caustics.

Currently this method has a various limitations:

* Only caustics in shadows of refractive objects work, which means no caustics
  from reflection or caustics that outside shadows. Only up to 4 refractive
  caustic bounces are supported.
* Caustic caster objects should have smooth normals.
* Not currently support for Metal GPU rendering.

In the future this method may be extended for more general caustics.

TECHNICAL DETAILS

This code adds manifold next event estimation through refractive surface(s) as a
new sampling technique for direct lighting, i.e. finding the point on the
refractive surface(s) along the path to a light sample, which satisfies Fermat's
principle for a given microfacet normal and the path's end points. This
technique involves walking on the "specular manifold" using a pseudo newton
solver. Such a manifold is defined by the specular constraint matrix from the
manifold exploration framework [2]. For each refractive interface, this
constraint is defined by enforcing that the generalized half-vector projection
onto the interface local tangent plane is null. The newton solver guides the
walk by linearizing the manifold locally before reprojecting the linear solution
onto the refractive surface. See paper [1] for more details about the technique
itself and [3] for the half-vector light transport formulation, from which it is
derived.

[1] Manifold Next Event Estimation
Johannes Hanika, Marc Droske, and Luca Fascione. 2015.
Comput. Graph. Forum 34, 4 (July 2015), 87–97.
https://jo.dreggn.org/home/2015_mnee.pdf

[2] Manifold exploration: a Markov Chain Monte Carlo technique for rendering
scenes with difficult specular transport Wenzel Jakob and Steve Marschner.
2012. ACM Trans. Graph. 31, 4, Article 58 (July 2012), 13 pages.
https://www.cs.cornell.edu/projects/manifolds-sg12/

[3] The Natural-Constraint Representation of the Path Space for Efficient
Light Transport Simulation. Anton S. Kaplanyan, Johannes Hanika, and Carsten
Dachsbacher. 2014. ACM Trans. Graph. 33, 4, Article 102 (July 2014), 13 pages.
https://cg.ivd.kit.edu/english/HSLT.php

The code for this samping technique was inserted at the light sampling stage
(direct lighting). If the walk is successful, it turns off path regularization
using a specialized flag in the path state (PATH_MNEE_SUCCESS). This flag tells
the integrator not to blur the brdf roughness further down the path (in a child
ray created from BSDF sampling). In addition, using a cascading mechanism of
flag values, we cull connections to caustic lights for this and children rays,
which should be resolved through MNEE.

This mechanism also cancels the MIS bsdf counter part at the casutic receiver
depth, in essence leaving MNEE as the only sampling technique from receivers
through refractive casters to caustic lights. This choice might not be optimal
when the light gets large wrt to the receiver, though this is usually not when
you want to use MNEE.

This connection culling strategy removes a fair amount of fireflies, at the cost
of introducing a slight bias. Because of the selective nature of the culling
mechanism, reflective caustics still benefit from the native path
regularization, which further removes fireflies on other surfaces (bouncing
light off casters).

Differential Revision: https://developer.blender.org/D13533
2022-04-01 17:45:39 +02:00
Julian Eisel
253e4e7ed2 Assets: Enable collection assets (no longer experimental)
With automatic collection previews (810e225c260d) and a toggle for
collection instancing (previous commit) supported, there are no known
blocking issues for collection assets. There are still further
improvements to come as part of regular developemt (e.g. bounding box
based snapping).
2022-04-01 16:51:29 +02:00
Julian Eisel
eb1ede5693 Assets: Instancing operator option for collection asset dropping
Makes it possible to toggle instancing via the "Adjust Last Operation"
panel after dropping a collection asset into the viewport.

A design task that puts this into more context is pending still, but
this is a useful option to have either way.

Differential Revision: https://developer.blender.org/D14507

Reviewed by: Bastien Montagne
2022-04-01 16:44:52 +02:00
Bastien Montagne
1de051a7a9 install_deps: Updated Alembic to 1.8.3 and OSD to 3.4.4.
Re {T95206}.
2022-04-01 16:43:29 +02:00
Kévin Dietrich
e81d7bfcc9 Cycles: enable Alembic procedural for final renders
The Alembic procedural was only enabled during viewport renders
originally because it did not have any caching strategy. Now that
is does, we can allow its usage in final renders.

This also removes the `dag_eval_mode` argument passing to
`ModifierTypeInfo.dependsOnTime` which was originally added to detect if
we are doing a viewport render for enabling the procedural.

Differential Revision: https://developer.blender.org/D14520
2022-04-01 16:30:45 +02:00
Hans Goudey
5c80543c43 Cleanup: Move geometry set fields to a separate header
This commit moves declarations that depend on `FN_field.hh` out of
`BKE_geometry_set.hh` into `BKE_geometry_fields.hh`. This helps to
reduce the number of areas that need to depend on the functions module,
which recently came in in review of D11591.

In the future we may have a library of standard field inputs in order to
make composing algorithms easier, so it makes sense to have a header
that could contain them and some basic related utilities relating the
concepts of geometry and fields.

Reducing use of unnecessary headers may also reduce compilation time.

Differential Revision: https://developer.blender.org/D14517
2022-04-01 08:40:45 -05:00
Hans Goudey
3ecdfd0938 Geometry Nodes: Add search to named attribute input node
This commit adds attribute search the the attribute input field node.
Because it's a field node, finding which attribute to display without
increasing the complexity a lot isn't obvious. In this commit, all
attributes used by nodes in the current group are included.

When an attribute is chosen from the list, the node's data type is
updated, and links connected to the output socket are reconnected.

Ref T96271

Differential Revision: https://developer.blender.org/D14516
2022-04-01 08:33:03 -05:00
Hans Goudey
00ba51d37b Geometry Nodes: Port set handle nodes to new data-block
This commit ports the "Set Handle Positions" and "Set Hanle Type"
nodes to use the new curves data-block. The nodes become simpler
and likely much faster too, though they're usually not the bottleneck
anyway.

Most of the code is ported from `BezierSpline` directly. The majority
of the complexity comes from the interaction between different
automatically calculated handle types. In comparison `BezierSpline`,
the calculation of auto handles is done eagerly-- mostly because it's
simpler. Eventually lazy calculation might be good to add.

Differential Revision: https://developer.blender.org/D14464
2022-04-01 08:12:41 -05:00
Brecht Van Lommel
a250d3d1b7 Fix compositor memory leak after recent color management changes 2022-04-01 15:04:18 +02:00
Aras Pranckevicius
d120a083da Fix T96763: New OBJ Exporter Incorrectly saving the materials in the MTL file
Original report (T96763) only reported the issue of double-space before the texture path, but while adding test coverage I found some other issues that I fixed while at it:

- Incorrectly emits two spaces between `map_Xx` keyword and the texture path, leading to some 3rd party software not finding the textures,
- Emissive texture map (`map_Ke`) was not exported,
- When Mapping node is used on the texture UVs, the "Location" and "Scale" values were mixed up (location written as "scale", scale written as "location).

Added gtest coverage.

Reviewed By: Howard Trickey

Differential Revision: https://developer.blender.org/D14519
2022-04-01 14:59:19 +03:00
Bastien Montagne
b073f58a8e Fix T96930: Cloth Disk cache not being saved and being deleted on files that have been linked and library override enabled.
PointCache handing is just horrible from RNA, makes dealing with
overrides a nightmare...

Ended up having to add a specific 'apply' callback for the `use_disk_cache`
property, that would explicitely NOT call the the `update` callback of
this property, to avoid having the whole disk cache nuked away...

But the whole thing remains fairly britle, to say the least.
2022-04-01 12:41:59 +02:00
Bastien Montagne
1264142f78 LibOverride: RNA Apply: let apply function responsible for calling update or not on overridden properties.
While this is the desired behavior in almost cases, there are a few
hairy nightmares that may require not to do so.

NOTE: this change should should not modify any current behavior at all.
2022-04-01 12:35:25 +02:00
Bastien Montagne
d34c4089f1 Fix T96931: Crash on load with library overrides + multiple cloth cache slots.
Not really clear why that would only show with multiple caches... But
point cache system is beyond brittle anyway.

This fix solves the issue at two different levels:
* General safety check in `rna_Cache_info_length` that we do get a valid
  `pid`.
* Forbid usage of this `PointCache.info` RNA property in any
  diffing/LibOverride processing (since it's by definition runtime, volatile
  data).
2022-04-01 11:05:30 +02:00
Leon Schittek
9a67f9173b Cleanup: Improve variable naming
The variable `ofs` in `widget_numslider` was referring to the radius.
`rad` is more clear and consistent with the other widget functions.
2022-04-01 07:05:50 +02:00
Leon Schittek
aab9047f9d Fix T88785: Keep value slider from clipping
Keep the value slider from clipping through rounded corners for
low values by ensuring the width of the slider rectangle is at least
twice the corner radius.

Reviewed By: Hans Goudey

Differential Revision: https://developer.blender.org/D11474
2022-04-01 06:51:22 +02:00
Clément Foucault
42853bacc9 GPencil: Fix regression with dots uvs
This was introduced by rBeccb0b222e3465baa71430223c5ee2f0206a7b02.
2022-03-31 19:14:31 +02:00
Bastien Montagne
ce5428b294 install_deps: Update OCIO to 2.1.1 and OIIO to 2.3.13.
Re {T95206}.
2022-03-31 17:40:37 +02:00
Bastien Montagne
59681a7ccd install_deps: Update openVDB to 9.0.
Re {T95206}.
2022-03-31 16:56:34 +02:00
Bastien Montagne
3d5085375f install_deps: default boost version to 1.78 and TBB to 2020_U3.
Re  T95206.
2022-03-31 16:25:02 +02:00
Aras Pranckevicius
ca28f376f7 OBJ: mark the new 3.1+ exporter as experimental for now
While it still has known issues/bugs/limitations. Also do not make it the very first export menu item, while at it.

Differential: D14512
2022-03-31 16:15:02 +03:00
Kévin Dietrich
4c1393c202 Fix T76746: Alembic, wrong result importing back exported curves
In Alembic curve topology is stored with an array of values describing
how many points each sub-curve has. Instead of writing the number of
points for the current curve, the Alembic exporter would write the
accumulated number of points.

This error has existed since the initial implementation.
2022-03-31 15:01:27 +02:00
YimingWu
eb4155cc1e Fix T94888: LineArt use the same triangulation as viewport.
This fixes inconsistencies between line art output and viewport triangulation result.
2022-03-31 21:00:26 +08:00
Clément Foucault
2f7171622d DRW: Rename DRW_shgroup_uniform_vec4_array_copy to mat4_copy
This function was not used for anything other than mat4. This
was because of a limitation of the DRW module/
This makes it cleaner for the GLSL and also less tempting to use
it for other unconventional purpose.
2022-03-31 13:48:17 +02:00
Clément Foucault
ca37654b63 Fix T96920 DRW: Regression: Hair strands are drawn in wrong place
This was caused by the recent changes made to the way we handle matrix
copies. The matrix copy assumed that the uniform iteration was the same
as creation order. But this was far from true. The reality was that
the iterator was reverse for `unichunk` but not for `unichunk->uniforms`
so this was recreating wrong matrix.

I rewrote this part to always use reverse iteration and fix the
copy destination.

Also I simplified the code making the assumption this won't be used for
anything else than mat4.
2022-03-31 13:36:04 +02:00
Julian Eisel
0c6dc7c59e Outliner: New "Hierarchies" view mode for Library Overrides
Adds a dropdown for the Library Overrides display mode that lets users
choose between a "Properties" and a "Hierachies" view mode. The former
is what was previously there (a mode that displays all overridden
properties with buttons to edit the values), the latter is new. It
displays the hierarchical relationships between library overridden
data-blocks. E.g. to override the mesh of an object inside a linked
collection, the entire collection > object > mesh hierarchy needs to be
overridden (whereby the former two will be automatically overridden
using system overrides).
The Hierarchies mode will also show the override hierarchies of
data-blocks that were linked and are overridden in the source file. This
information is useful to have, especially for debugging scenes.

Part of T95802.

Differential Revision: https://developer.blender.org/D14440

Reviewed by: Bastien Montagne
2022-03-31 12:21:14 +02:00
Jacques Lucke
2202259e9c Fix T96909: crash when assigning new node group to group node
The node group returned by `bpy.data.node_groups.new(...)` was not
updated properly.
2022-03-31 11:57:45 +02:00
Kévin Dietrich
dc73c71b3b Fix T96915: GPU subdivision modifier: Smooth Shade doesn't work
Simple error in an earlier commit, the flags should be or-ed.
2022-03-31 11:52:46 +02:00
Jacques Lucke
7e54f5c218 Cleanup: make format 2022-03-31 11:00:42 +02:00
Sergey Sharybin
0d223f6aca Cleanup: Unused variable in release build warning 2022-03-31 09:26:46 +02:00
Sergey Sharybin
92f2b77e78 Cleanup: Compilation warnings in gpencil code after DNA C++ changes
Direct replacement of code:
- memcpy of a single point is done as a shallow_copy() assignment.
- memcpy of a range of points is done with an explicit cast to void*
  to tell compiler that we really want to memcpy even a non-trivial
  type.

In some cases it seems that memcpy can be used more (points are copied
in a loop). Those left as-is since this is supposed to be a simple
cleanup.

Differential Revision: https://developer.blender.org/D14505
2022-03-31 09:18:21 +02:00
Campbell Barton
ae1f8315f7 Depsgraph: minor optimization in order of checks
Checking BKE_image_user_id_has_animation loops over ID users
which never needs to run for material & world data-blocks.
2022-03-31 13:07:14 +11:00
Campbell Barton
3d132ead50 Cleanup: spelling, trailing space for comment-blocks 2022-03-31 13:01:41 +11:00
Hans Goudey
41ee5382f6 Cleanup: Remove unnecessary namespace specification 2022-03-30 20:55:40 -05:00
Hans Goudey
762d3a48e8 Cleanup: Avoid storing pointers for attribute search callback
It's better to use some local/stable identifiier to avoid relying on
the data not being freed in between creating the search menu and
the exec function. This is similar to c473b2ce8bdbf8fa.
2022-03-30 20:54:11 -05:00
Gilberto Rodrigues
49858bf526 UI: Fix outliner and buttons icons alignment
029cf23d71b3 changed some icons alignment, but after 9be49a106994
the icons don't align anymore. This commit reverts 029cf23d71b3 and
also makes a couple of other outliner icons left aligned, instead of
right aligned, for consistency and general alignment.

Differential Revision: https://developer.blender.org/D14501
2022-03-30 18:57:24 -05:00
Hans Goudey
8466fd4bd1 Cleanup: Curves draw cache renaming, use references
Also change some remaining cases of "hair object" to "curves object".
2022-03-30 18:25:06 -05:00
Leon Schittek
4edde244da Nodes: Cut hidden links when creating node groups
Add a check to the creation of node groups to remove hidden links
that are connected to the outside of the node group. This avoids
creating sockets in the group's interface that aren't (visibly)
connected to anything within the node group.

Reviewed By: Jacques Lucke, Hans Goudey

Differential Revision: https://developer.blender.org/D14249
2022-03-30 23:07:11 +02:00
Leon Schittek
2670032038 UI: Improve node editor dot background
This commit makes the dot grid used as background in the node editor
more visually stable when zooming in and out.

The dot grid now uses a continuously subdividing pattern, where
each level of subdivision divides the previous five times, similar to
the line grid in the 3D viewport.

The maximum for the "Grid Levels" theme setting is changed to 3, since
any further subdivisions are too small to be visible.
The "Grid Levels" value for the default themes "Blender Dark" and
"Blender Light" is therefore changed to 3, as well.

Reviewed By: Hans Goudey, Pablo Vazquez

Differential Revision: http://developer.blender.org/D13302
2022-03-30 21:21:57 +02:00