The old layout of `PointerRNA` was confusing for historic reasons:
```
typedef struct PointerRNA {
struct {
void *data;
} id;
struct StructRNA *type;
void *data;
} PointerRNA;
```
This patch updates it to:
```
typedef struct PointerRNA {
struct ID *owner_id;
struct StructRNA *type;
void *data;
} PointerRNA;
```
Throughout the code base `id.data` was replaced with `owner_id`.
Furthermore, many explicit pointer type casts were added which
were implicit before. Some type casts to `ID *` were removed.
Reviewers: brecht, campbellbarton
Differential Revision: https://developer.blender.org/D5558
The object color property is added as an additional output in
the Object Info node.
Reviewers: brecht
Differential Revision: https://developer.blender.org/D5554
The fract function in OpenCL does more than just return the fraction.
It also writes the floor to the second argument. Which wasn't put
in consideration.
Instead, we use a simple `a - floor(a)` like the Math node.
Reviewers: brecht
Differential Revision: https://developer.blender.org/D5553
The Volume Info node provides the Color, Desnity, Flame, and Temperature
of smoke domains.
Reviewers: brecht
Differential Revision: https://developer.blender.org/D5551
The White Noise node hashes the input and returns a random number in the
range [0, 1]. The input can be a 1D, 2D, 3D, or a 4D vector.
Reviewers: brecht, JacquesLucke
Differential Revision: https://developer.blender.org/D5550
Add Multiply, Divide, Project, Reflect, Distance, Length, Scale, Snap,
Floor, Ceil, Modulo, Fraction, Absolute, Minimum, and Maximum operators
to the Vector Math node. The Value output has been removed from operators
whose output is a vector, and the other way around. All of those removals
has been handled properly in versioning code.
The patch doesn't include tests for the new operators. Tests will be added
in a later patch.
Reviewers: brecht, JacquesLucke
Differential Revision: https://developer.blender.org/D5523
Previously eigens internal include order somehow implicitly provided
M_PI and friends. The recent eigen version bump broke this implicit
behaviour, better to be explicit that we need the math defines for MSVC.
The clamp option is implemented using graph expansion, where a Clamp node
named "clamp" is added and connected to the output. So the final result
is actually from the node "clamp".
Reviewers: brecht
Differential Revision: https://developer.blender.org/D5540
When calling `MEM_guarded_mallocN_aligned` with an alignment of 4,
a pointer that was returned that is 4 byte but not 8 byte aligned.
When freeing this pointer, `MEM_guarded_freeN` thinks that it is an
illegal pointer, because it asserts that `((intptr_t)memh) & 0x7 == 0`.
The fix is to always use at least 8 byte alignment.
Reviewers: brecht
Differential Revision: https://developer.blender.org/D5529
- Implement dynamic inputs. The second input is now unavailable in single
operand math operators.
- Reimplemenet the clamp option using graph expansion for Cycles.
- Clean up code and unify naming between Blender and Cycles.
- Remove unused code.
Reviewers: brecht
Differential Revision: https://developer.blender.org/D5481
This code is needed to implement the Voxel Remesher as well as other features like a better remesh modifier with filters and CSG operations.
Done by Martin Felke and Pablo Dobarro
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D5364
This could happen e.g. when changing smoke type from flow to domain or
connecting a volume shader with to a domain without an actual flow type
around.
Fixes T58569, T68359
Reviewers: brecht
Maniphest Tasks: T58569, T68359
Differential Revision: https://developer.blender.org/D5478
If the option is enabled, the output is clamped to the target range.
The target range is [To Min, To Max]. The option is enabled by default.
The clamp option is implemented in EEVEE by linking to the `clamp_value`
GLSL function. And it is implemented in Cycles using a graph expand
function.
Reviewers: brecht, JacquesLucke
Differential Revision: https://developer.blender.org/D5477
This patch adds a new node that clamps a value between a maximum and
a minimum values.
Reviewers: brecht
Differential Revision: https://developer.blender.org/D5476
This patch adds a new Map Range node that linearly remaps an input
value from a range to another. This node is similar to the compositor's
Map Range node.
Reviewers: brecht, JacquesLucke
Differential Revision: https://developer.blender.org/D5471
We can add more fine grained checks for when these flags are supported so
that adding asan flags manually still has all the workarounds, but for now
compiling succesfully is more important.
The issue was caused by a limitation of GetNumaNodeProcessorMask():
on systems with more than 64 processors, this parameter is set to the
processor mask for the node only if the node is in the same processor
group as the calling thread. Otherwise, the parameter is set to zero.
Patch from Max Dmitrichenko, thanks!
It's extremely slow to compile and run, so just disable it unless
WITH_CYCLES_KERNEL_ASAN is manually enabled. For Clang it's always
enabled since that appears to work ok.
This also limits the -fno-sanitize=vptr flag to the Cycles kernel, as it
was added specifically to work around an issue there.
Differential Revision: https://developer.blender.org/D5404
The partial disabling was causing issues with Clang and ASAN, and it seems we
don't need to restrict it to the kernel anymore now that we are no longer using
boost directly.
The issue is that wayland seems to impose a generic device naming scheme
when using Xwayland For example any table stylus will show up with the
following naming convention: xwayland-stylus:33
For this to work in blender, I had to modify how the identifier string
is extracted. I also renamed the two char pointers in the search
algorithm to be more logical.
Reviewed By: Brecht
Differential Revision: http://developer.blender.org/D5401
In a test file containing 1300 copies of the same shader, this reduces shader update time from 3.1 sec to 0.05 sec.
Thanks to @swerner for noticing this issue.
Reviewers: brecht, sergey, swerner
Subscribers: swerner
Differential Revision: https://developer.blender.org/D5376
During viewport rendering where the viewport samples are set to 0 the UI
showed 16777216 as number of samples. We should not show the number of
samples when the number of viewport samples are set to 0.
Differential Revision: https://developer.blender.org/D5301
The code was missing some checks for whether keyframe selection
went successfully and whether reconstruction has been successfully
initialized.
The interface still gives quite generic message, with the details
printed to the console. This can be addressed separately.
The issue was caused by un-initialized local storage for volume
intersection hits which are supposed to be stored in per-thread
KernelGlobals.
Fix is to make thread_shader() be the same as thread_render() in
respect of KernelGlobals.
Reviewers: brecht
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D5230
The issue was in the optimization code path for opaque shadow rays
which was wrongly considering all primitives in the node to have
same visibility flags.
We want users to go to the current version for their current version
when possible if not point to latest.
/dev should really only be for development related work. End users
should not be browsing /dev unless they are reading about upcoming
features ahead of time.
Before this change doing something like `--verbose 10 --debug-cycles`
did not properly set verbosity, only using those arguments in an other
way around was leading to a correct verbosity level.
Am not even sure that it is possible to use fstrings at all when UI
translation is required (that is, is a sensible, reasonable way that
does not make things even more complicated than they already are), but
one thing is certain, this won't be trivial to get it working, so
definitively not a job for now.
Instead just do not use fstrings for UI translatable strings.
Switch to Gregory basis patches which are tangent continuous across their
boundaries.
Originally we've used BSpline basis patches to be more compatible with the
old subdivision code, but a lot of things changed anyway.
When compute preemption is available we schedule more work which is more
efficient. However the CUDA driver appears to be incorrectly reporting this as
unavailable, even though it should be supported starting with Windows 10 1803
and Pascal and Turing (10x0 and 20x0) graphics cards.
This reduces render time by about a 25% difference on our benchmark scenes. On
Linux compute preemption appears to be reported correctly.
Replace relative threshold for pseudo inverse in sharp remeshing modifier with
0.1 as proposed in the original paper.
Also change pseudo-inverse implementation that works with dynamic heap-allocated
matrix to static 3x3 version, for performance
Differential Revision: https://developer.blender.org/D5078
This is enabled with bl_use_eevee_viewport = True. It allows external engines
to generate an Cycles/Eevee shader node setup to emulate their materials in
the realtime viewport, or to leave it to users to do manually.
Removed bl_use_exclude_layers and bl_use_shading_nodes that did nothing
anymore. This should not break API compatibility, any scripts setting those
should continue to work the same as before.
Also adds descriptions for some RenderEngine settings.
On GPUs that support it, we now present OpenGL contents via CAMetalLayer. This
fixes frame skipping issues found in T60043. If the system does not have a Metal
capable GPU, NSOpenGLView will continue to be used.
Patch by Tomoaki Kawada, with some changes by Brecht Van Lommel.
Differential Revision: https://developer.blender.org/D4619
Previously, bright edges (e.g. caused by rim lighting) would sometimes get
halos around them after denoising.
This change introduces a log(1+x) highlight compression step that is performed
before denoising and reversed afterwards. That way, the denoising algorithm
itself operates in the compressed space and therefore bright edges cause less
numerical issues.
This commit extends dependency graph API with an argument which
denotes that all custom data layers are to be preserved. This
forces modifier stack re-evaluation with more inclusive mask.
Far from ideal, since this might fail in certain configurations
with indirectly used objects which might be missing layers needed
for the current object evaluation. But this is how it worked for
a long time, so should be good enough for until more sophisticated
solution is found.
In order to use this new behavior two things are to be passed:
- Pass keep_all_data_layers=True
- Pass a valid dependency graph.
The dependency graph is only needed if keep_all_data_layers=True
and is NOT to be passed if keep_all_data_layers=False.
If keep_all_data_layers=True the dependency graph MUST be passed.
Reviewers: mont29, brecht
Reviewed By: mont29
Maniphest Tasks: T64994, T64794
Differential Revision: https://developer.blender.org/D4940
Explicitly disable particles in edit for now.
Those were not rendered already, but were attempted to be converted
to Cycles structures (if UVs were not needed for hair nothing was
rendered, but if UVs are needed then crash happened).
Would be nice to bring hair in edit mode back, but this is a bit
more involved change, which will be done later.
* Replace Log view transform with Filmic Log.
* Remove Rec.709, DCI-P3 displays that were incomplete and outdated.
* Remove outdated RRT and Film transforms, replaced by Filmic.
* Remove camera responsive curves that don't work with HDR colors.
* Rename Default view transform to Standard.
We're breaking compatibility now for 2.80, so that we can add future
improvements on a clean config.
Part of the code was contributed by George Vogiatzis in D4782.
Differential Revision: https://developer.blender.org/D4900
This also replaces the Use Alpha setting. We now have these alpha modes:
* Straight: store RGB and alpha channels separately with alpha acting as a
mask, also known as unassociated alpha.
* Premultiplied: transparent RGB pixels are multiplied by the alpha channel.
The natural format for renders.
* Channel Packed: different images are packed in the RGB and alpha channels,
and they should not influence each other. Channel packing is commonly used
by game engines to save memory.
* None: ignore alpha channel from the file and make image fully opaque.
Cycles OSL does not correctly support Channel Packed and None yet, we are
missing fine control over the OpenImageIO texture cache to do that.
Fixes T53672
The same was done for Windows, but some extra changes were needed to make it
work on macOS. This is required because the Blender quit dialog now contains
additional settings for image saving.
There is now a checkbox to enable/disable depth of field per camera. For Eevee
this replace the scene level setting. For Cycles there is now only an F-Stop
value, no longer a Radius.
Existing files are converted based on Cycles or Eevee being set in the scene.
Differential Revision: https://developer.blender.org/D4882
For existing files, it will use the setting from Cycles or Eevee depending on
the render engine in the scene.
Differential Revision: https://developer.blender.org/D4874
We can not access ensured-to-be-evaluated dependency graph from the
render API: some of it is running from within evaluation which makes
it possible for engines to access list of evaluated IDs.
Solved by passing dependency graph to viewport functions, similar to
the final render functions.
One of the usecases is to create mesh from an object is a manner similar to
how Apply Modifiers does it, and have it in the bmain so it can be referenced
by other objects.
This usecase is something what went unnoticed in the previous API changes, so
here is a followup.
Summary of changes:
* bpy.meshes.new_from_object() behaves almost the same as before this change.
The difference now is that it now ensures all referenced data-blocks are
original (for example, materials referenced by the mesh).
* object.to_mesh() now creates free-standing Mesh data-block which is outside
of any bmain. The object owns it, which guarantees the memory never leaks.
It is possible to force free memory by calling object.to_mesh_clear().
Reviewers: brecht
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D4875
The kernel does not use AVX2 vectorization, and trying to use BVH8 was
leading to an empty scenes.
Fixes T64624: Ctest : Win32 + AVX2 fails virtually all cycles tests
Main goal here is to make it obvious and predictable about
what is going on.
Summary of changes.
- Access to dependency graph is now only possible to a fully evaluated
graph. This is now done via context.evaluated_depsgraph_get().
The call will ensure both relations and datablocks are updated.
This way we don't allow access to some known bad state of the graph,
and also making explicit that getting update dependency graph is not
cheap.
- Access to evaluated ID is now possible via id.evaluated_get().
It was already possible to get evaluated ID via dependency graph,
but that was a bit confusing why access to original is done via ID
and to evaluated via depsgraph.
If datablock is not covered by dependency graph it will be returned
as-is.
- Similarly, request for original from an ID which is not evaluated
will return ID as-is.
- Removed scene.update().
This is very expensive to update all the view layers.
- Added depsgraph.update().
Now when temporary changes to objects are to be done, this is to
happen on original object and then dependency graph is to be
updated.
- Changed object.to_mesh() to behave the following way:
* When is used for original object modifiers are ignored.
For meshes this acts similar to mesh-copy, not very useful but
allows to keep code paths similar (i.e. for exporter which has
Apply Modifiers option it's only matter choosing between original
and evaluated object, the to_mesh() part can stay the same).
For curves this gives a mesh which is constructed from displist
without taking own modifiers and modifiers of bevel/taper objects
into account.
For metaballs this gives empty mesh.
Polygonization of metaball is not possible from a single object.
* When is used for evaluated object modifiers are always applied.
In fact, no evaluation is happening, the mesh is either copied
as-is, or constructed from current state of curve cache.
Arguments to apply modifiers and calculate original coordinates (ORCO,
aka undeformed coordinates) are removed. The ORCO is to be calculated
as part of dependency graph evaluation.
File used to regression-test (a packed Python script into .blend):
{F7033464}
Patch to make addons tests to pass:
{F7033466}
NOTE: I've included changes to FBX exporter, and those are addressing
report T63689.
NOTE: All the enabled-by-default addons are to be ported still, but
first want to have agreement on this part of changes.
NOTE: Also need to work on documentation for Python API, but, again,
better be done after having agreement on this work.
Reviewers: brecht, campbellbarton, mont29
Differential Revision: https://developer.blender.org/D4834
This is the angular diameter as seen from earth, which is between 0.526° and
0.545° in reality. Sharing the size with other light types did not make much
sense and meant the unit was unclear.
Differential Revision: https://developer.blender.org/D4819
A better solution would be to not use the callback mechanism anymore for
cases like this where the dependency graph will free volume data, but
that would be a bigger refactor.
The refactoring of texture handles did not take into account that render
services are shared between multiple render session. Now the texture
to handle map is also shared between render sessions.
This makes it easier to set up materials with emission and transparency.
Importers/exporters and add-ons are recommended to now use these rather than
creating separate transparent BSDF and emission nodes.
Cycles lights now use strength and color properties of the light outside
of the shading nodes, just like Eevee. The shading nodes then act as a
multiplier on this, and become optional unless textures, fallof or other
effects are desired.
Backwards compatibility is not exact, as we can't be sure which renderer
the .blend was designed for or even if it was designed for a single one.
If the render engine in the active scene is set to Cycles, lights are
converted to ensure overall light strength remains the same, and removing
unnecessary shader node setups that only included a single emission node.
If the engine is set to Eevee, we increase strength to remove the automatic
100x multiplier that was there to match Cycles.
Differential Revision: https://developer.blender.org/D4588
Cycles now uses the color space on the image datablock, and uses OpenColorIO
to convert to scene linear as needed. Byte images do not take extra memory,
they are compressed in scene linear + sRGB transfer function which in common
cases is a no-op.
Eevee and workbench were changed to work similar. Float images are stored as
scene linear. Byte images are compressed as scene linear + sRGB and stored in
a GL_SRGB8_ALPHA8 texture. From the GLSL shader side this means they are read
as scene linear, simplifying the code and taking advantage of hardware support.
Further, OpenGL image textures are now all stored with premultiplied alpha.
Eevee texture sampling looks a little different now because interpolation
happens premultiplied and in scene linear space.
Overlays and grease pencil work in sRGB space so those now have an extra
conversion to sRGB after reading from image textures. This is not particularly
elegant but as long as engines use different conventions, one or the other
needs to do conversion.
This change breaks compatibility for cases where multiple image texture nodes
were using the same image with different color space node settings. However it
gives more predictable behavior for baking and texture painting if save, load
and image editing operations have a single color space to handle.
Differential Revision: https://developer.blender.org/D4807
It was crashing due to array out of bounds access. This is not a great fix,
but brings back behavior the same as before now. Perhaps images that failed
to load should be stored separately somewhere.
These are the internal changes to Cycles, for Blender integration there are no
functional changes in this commit.
Images are converted to scene linear color space on file load, and on reading
from the OpenImageIO texture cache. 8-bit images are compressed with the sRGB
transfer function to avoid precision loss while keeping memory usages low. This
also means that for common cases of 8-bit sRGB images no conversion happens at
all on image loading.
Initial patch by Lukas, completed by Brecht.
Differential Revision: https://developer.blender.org/D3491
This is the groundwork for supporting loading image textures with arbitrary
color spaces through OpenColorIO.
Initial patch by Lukas, completed by Brecht.
Differential Revision: https://developer.blender.org/D3491
This adds our own OSL texture handle, that has info for OIIO textures or our
own custom texture types. A filename to handle hash map is used for lookups.
This is efficient because it happens at OSL compile time, because the optimizer
can figure out constant strings and replace them with texture handles.
This panel is arguably the most important in the ViewLayer properties, so
the concept of "1 panel open per context" doesn't work. Especially since
the first panel (View Layer) contains only two settings.
This also registers the Passes panels before filter/override so it's sorted in the same way as EEVEE.