For metal version after 3.2 it's possible to log debugging messages, it
works similar to `printf()`, except for a few differences:
- `%s` is not supported,
- `double` doesn't exist, so no casting to double for `%f`,
- no `\n` needed at the end of the format string.
To see the print in the console, environment variables `MTL_LOG_LEVEL`
should be set to `MTLLogLevelDebug`, and `MTL_LOG_TO_STDERR` should be
set to `1`. See
https://developer.apple.com/documentation/metal/logging-shader-debug-messages
Right now `printf()`, `print_float()`, `print_float2()`,
`print_float3()` and `print_float4()` are supported.
Thanks to @fclem for finding this out.
Pull Request: https://projects.blender.org/blender/blender/pulls/146585
We used to set shader->osl_surface_ref during shader compilation and then
pushed it into the shared vectors.
This worked as long as everything was serial - but after the multithreading
change, we a) compile everything and then b) build the shared vectors since
just pushing into them from multiple threads would not work.
However, if there are multiple devices, then each shader will be compiled
multiple times - so in the end, shader->osl_surface_ref etc. will be set
to the last device's value. Then, we end up pushing that value into every
device's vectors, which breaks for the earler devices.
The fix is simple - just preallocate the vectors and pass the correct index
into the compilation function. This way, each thread can safely store its
result and we can get rid of shader->osl_surface_ref entirely.
Note that while multiple shaders are compiled in parallel, the loop over
devices for a given shader is serial, so there's no concern of conflicts
over other shader internals.
Pull Request: https://projects.blender.org/blender/blender/pulls/146617
Applies thin film iridescence to metals in Metallic BSDF and Principled BSDF.
To get the complex IOR values for each spectral band from F82 Tint colors,
the code uses the parametrization from "Artist Friendly Metallic Fresnel",
where the g parameter is set to F82. This IOR is used to find the phase shift,
but reflectance is still calculated with the F82 Tint formula after adjusting
F0 for the film's IOR.
Co-authored-by: Lukas Stockner <lukas@lukasstockner.de>
Co-authored-by: Weizhen Huang <weizhen@blender.org>
Co-authored-by: RobertMoerland <rmoerlandrj@gmail.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/141131
This expands Cycles' support for handling OSL property metadata for
Custom camera parameters and translating it to Blender's UI.
Specifically, it adds support for:
- Translation inputs (`string vecsemantics = "POINT"`)
- Normal inputs (`string vecsemantics = "NORMAL"`)
- File inputs (`string widget = "filename"`)
- Angle inputs (`string unit = "radians"`)
- Distance inputs (`string unit = "m"`)
- Time inputs (`string unit = "s"` or `string unit = "sec"`)
- Enum inputs (`string widget = "mapper", string options = "left:0|right:1"`)
It also sets the default value correctly, and corrects a warning string to
also mention cameras in addition to nodes as possible users of OSL shaders.
Co-authored-by: Lukas Stockner <lukas@lukasstockner.de>
Pull Request: https://projects.blender.org/blender/blender/pulls/146736
The workaround of forcing BVH building into single thread
execution on the Blender side is not needed anymore,
because the problem was properly fixed in the upstream
since Embree upgrade in Blender 4.5
This reverts commit c0f0e2ca6f.
Pull Request: https://projects.blender.org/blender/blender/pulls/146859
New `--log-list-categories` command line argument to list all available
logging categories. This improves documentation of logging, allowing
users to understand what logging categories are available for use. It is
also useful for developers to understand what logging categories already
exist before making a change.
Implemented using static initializers to register all logrefs on startup.
Ref #141754
Pull Request: https://projects.blender.org/blender/blender/pulls/146456
This PR moves the ownership of vulkan memory allocator from gpu/device
to GHOST/context/device. This will allow in the future a cleaner control
flow between OpenXR and Vulkan. Currently as the ownership is in the gpu
module many objects would need to pass from GHOST to the GPU module to be
shared between the 2 allocators. Moving both (OpenXR/Context) allocator
to GHOST would reduce the complexity.
Pull Request: https://projects.blender.org/blender/blender/pulls/146819
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
Signed integer overflow is undefined, but works reliably enough for us
anyway, so just silence it like the Blender implementation already does.
This also caused some tests like cycles_displacement_cpu to run much slower
(3s -> 42s) due to the overhead of detecting and ignoring repeated warnings.
Pull Request: https://projects.blender.org/blender/blender/pulls/146783
* Add adaptive subdivision properties natively on the subdivision surface
modifier, so that other engines may reuse them in the future. This also
resolve issues where they would not get copied properly.
* Remove "Feature Set" option in the render properties, this was the last
experimental one.
* Add space choice between "Pixel" and "Object". The latter is new and can
be used for object space dicing that works with instances. Instead of
a pixel size an object space edge length is specified.
* Add object space subdivision test.
Ref #53901
Pull Request: https://projects.blender.org/blender/blender/pulls/146723
For wide line rendering it is preferred to use polyline shaders. However
creating a custom shader is complicated and a stone to far for many
scriptors.
This PR allows using line_width_set when wide line rendering is
supported by the platform.
Pull Request: https://projects.blender.org/blender/blender/pulls/146762
This is the first step of moving the create infos
back inside shader sources.
All info files are now treated as source files.
However, they are not considered in the include tree
yet. This will come in another following PR.
Each shader source file now generate a `.info` file
containing only the create info declarations.
This renames all info files so that they do not
conflict with their previous versions that were
copied (non-generated).
Pull Request: https://projects.blender.org/blender/blender/pulls/146676
Currently `MEM_delete` frees pointers expecting that they match to the
pointers allocated with `MEM_new`, otherwise it can cause undefined
behavior when freeing memory(using `--debug-memory` flag breaks in
place, if not it can corrupts other data, generating a incorrect back-traces).
However polymorphic objects lifetime can be managed by pointer of their
most derived type or by any pointer in their ancestor tree that defines
a virtual destructor, which sometimes can differ in offset when pointing to
the same object.
This changes ensures the correct pointer is being freed, by using the pointer
to the most derived type (returned by`dynamic_cast<void *>(...);`[0]).
----------
[0] = [dynamic_cast](https://en.cppreference.com/w/cpp/language/dynamic_cast.html): `a) If expression is a pointer to (possibly cv-qualified) void, the result is a pointer to the most derived object pointed to by expression.`
-----------
As an example, given the followings structs:
```c++
struct A {
int a;
virtual ~A() = default;
};
struct B {
int b;
virtual ~B() = default;
};
struct Derived : public A , public B {
int c;
};
std::unique_ptr<A> a_ptr = std::make_unique<Derived>();
std::unique_ptr<B> b_ptr = std::make_unique<Derived>();
```
Using std smart pointers to manage `Derived` objects can be done with `A`
or `B` pointers.
However if a `Derived` object memory is managed with `MEM_delete`,
using a `B` pointer for freeing the memory currently may silently break Blender,
since it don't accounts for the full object memory layout, the `dynamic_cast<void *>(ptr);`
cast gives a more safe pointer for freeing the memory.
Note that object destruction is successfully handled through the virtual destructor.
----------
This instead could be an assert to ensure polymorphic objects to be deleted
as the most derived object type.
Pull Request: https://projects.blender.org/blender/blender/pulls/146269
MTLAccelerationStructureMotionCurveGeometryDescriptor.controlPointCount should specify the per-step control point count. Although the previous initialisation wasn't manifesting as incorrect behaviour it was technically wrong.
Pull Request: https://projects.blender.org/blender/blender/pulls/146568
The one-sample Monte Carlo estimator of the radiative transfer equation
is
<L> = T(t) / p(t) * (L_e + σ_s * L_s + σ_n * L),
Which means we can also use another p(t) than majorant * exp(-majorant * t)
for sampling the distance. Thus, we use the baked σ_max for distance
sampling, but adjust the majorant when we encounter a density that is
larger than σ_max.
Note that this is not really unbiased because such scaling is not always
applied, but seems to work well in practice when the majorant is
reasonable.
Pull Request: https://projects.blender.org/blender/blender/pulls/146589
This implements a basic render time pass,
using HW-based counters to minimize render time impact.
x86-64 uses the TSC instruction for timing, while ARM64 uses the cntvct_el0
register. In theory TSC is not always super reliable (e.g. old CPUs had it tied
to their current clock rate), but for somewhat recent CPU models it should
be fine. If neither is available, it falls back to `std::chrono::steady_clock`,
which should still be very fast.
The output is in milliseconds of CPU-time per pixel.
Pull Request: https://projects.blender.org/blender/blender/pulls/125933
On its own, the main functionality of the Radial Tiling node
is the ability to divide a 2D Cartesian coordinate system into
as many radial segments as specified by the "Segments" input.
Each segment has its own affinely transformed coordinate system,
provided through the "Segment Coordinates" output, which can be
used to tile textures in a radially symmetric manner.
Additionally, a unique index is provided for every segment through
the "Segment ID" output, the width of each segment at Y-coordinate
of the "Segment Coordinates" output without normalization = 0 is
provided through the "Segment Width" output and the rotation value
of the affine transformation of the coordinate system of each segment
is provided through the "Segment Rotation" output.
The roundness of the coordinate lines of the "Segment Coordinates"
output can be controlled through the "Roundness" inputs.
This can be used to make the coordinate systems of the segments
a mix of Cartesian and polar coordinates.
Lastly, the lines of points of the "Segment Coordinates" output with
constant Y-coordinates have the shape of polygon with rounded corners,
which can be used to procedurally create rounded polygons.
Pull Request: https://projects.blender.org/blender/blender/pulls/127711
These are causing quite a big difference in existing files, which is not
easy to address in versioning. Since the goal of removing this was to
simplify things for us and that's not the case, just revert this change.
This reverts commit ab21755aaf.
Ref #139923
Pull Request: https://projects.blender.org/blender/blender/pulls/146336
For some reason, the `underwater_caustics` test was failing on Metal
after #140480 even though that test doesn't use the Sky Texture.
After messing with the file for a while, going back to the previous version
and adding the changes back one at a time, I've now arrived at a version
that behaves the same way as the #140480 version without breaking the test.
No idea what is the underlying issue, but we've had problems with the MNEE
kernels before so maybe just a compiler thing.
Pull Request: https://projects.blender.org/blender/blender/pulls/146335
This mode is based on the same athmospheric model as the previous one, but now
also accounts for multiple scattering and reflections from the ground.
This increases the accuracy, especially at low elevations.
Also renames some options for consistency:
- The previous "Nishita" model is now "Single Scattering"
- "Dust" is now "Aerosols"
- Default altitude is now 100m.
Co-authored-by: Lukas Stockner <lukas@lukasstockner.de>
Pull Request: https://projects.blender.org/blender/blender/pulls/140480
"Use Nodes" was removed in the compositor to simplify the compositing
workflow. This introduced a slight inconsistency with the Shader Node
Editor.
This PR removes "Use Nodes" for object materials.
For Line Style, no changes are planned (not sure how to preserve
compatibility yet).
This simplifies the state of objects; either they have a material or
they don't.
Backward compatibility:
- If Use Nodes is turned Off, new nodes are added to the node tree to
simulate the same material:
- DNA: Only `use_nodes` is marked deprecated
- Python API:
- `material.use_nodes` is marked deprecated and will be removed in
6.0. Reading it always returns `True` and setting it has no effect.
- `material.diffuse_color`, `material.specular` etc.. Are not used by
EEVEE anymore but are kept because they are used by Workbench.
Forward compatibility:
Always enable 'Use Nodes' when writing blend files.
Known Issues:
Some UI tests are failing on macOS
Pull Request: https://projects.blender.org/blender/blender/pulls/141278
Metal-RT implementation for curve intersect has an additional self
intersection check happening in curve_ribbon_accept(). It is done
for all curve types that has PRIMITIVE_CURVE_RIBBON bit set on them,
including Thick Linear curves. However, the logic in the function is
hardcoded to handle flat ribbon curves with the Catmull Rom basis.
This change makes it so curve_ribbon_accept() is only called for the
ribbon curve type, not when type has ribbon bit set.
Additionally, other places where curve type was checked as a bitmask
were fixed.
Ref #146072
Pull Request: https://projects.blender.org/blender/blender/pulls/146140
Only use when Windows Automatic Color Management (ACM) is enabled.
That way we know Windows will automatically convert from extended sRGB
linear to the appropriate color space for the display.
When we previously tried this there were some issues, but I think it was due
to ACM being off. This has been confirmed to work on NVIDIA and AMD, and
Intel is not expected to support this (yet) for the same reasons there is no HDR.
Pull Request: https://projects.blender.org/blender/blender/pulls/146041
`GHOST_SwapWindowBuffers` doesn't fit well when using swapchains. In
that case an approach where swap chain images are acquired and released
would map better. This PR introduces `GHOST_SwapWindowBufferAcquire`
and `GHOST_SwapWindowBufferRelease` to be more in line with vulkan swap
chains.
Previous implementation would first record all GPU commands based on
the last used swap chain. In case a swapchain needed to be recreated
(window resize, move to other monitor) the recorded commands would
not match the swap chain and could lead to artifacts.
OpenGL only implements the release functions as they don't
have a mechanism to acquire a swap chain image. (Need to validate with
the Metal API how this is working and adapt is needed).
Currently when starting blender on a HDR capable display the first frame
would be based on an sRGB surface and presented on an extended RGB
(or other) surface. As these don't match the first frame could be incorrect and
also lead to UBs as another surface is expected.
Pull Request: https://projects.blender.org/blender/blender/pulls/145728
Always enforce tiling of some size, up to the 8k tile size.
Rendering very big images without tiles have a lot of challenges.
While solving those challenges is not impossible, it does not seem to
be a practical time investment.
The internals of the way how Cycles work, including Cycles Standalone
is not affected by this change.
A possible downside is that path guiding might not work exactly how one
would expect it to due to lack of information sharing across multiple
tiles. This is something that never worked nicely, and camera animation
and border render has the same issues, so it is not considered a stopper
for this change.
Fixes#145900
Co-authored-by: Brecht Van Lommel <brecht@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/146031
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
HIP-RT device:
- Add missing flags from the common flags query to the final compiler options
- Switch logging utility from printf to LOG_INFO_IMPORTANT
- Remove redundant compiler options already covered by common flags
HIP device:
- Add compiler command to logging
- Update C++ standard to C++17 to resolve compiler warnings
Pull Request: https://projects.blender.org/blender/blender/pulls/145284
This adds a function that can turn an existing `bNodeTree` into an inlined one.
The new node tree has all node groups, repeat zones, closures and bundles
inlined. So it's just a flat tree that ideally can be consumed easily by render
engines. As part of the process, it also does constant folding.
The goal is to support more advanced features from geometry nodes (repeat zones,
etc.) in shader nodes which the evaluator is more limited because it has to be
able to run on the GPU. Creating an inlined `bNodeTree` is likely the most
direct way to get but may also be limiting in the future. Since this is a fairly
local change, it's likely still worth it to support these features in all render
engines without having to make their evaluators significantly more complex.
Some limitations apply here that do not apply in Geometry Nodes. For example,
the iterations count in a repeat zone has to be a constant after constant
folding.
There is also a `Test Inlining Shader Nodes` operator that creates the inlined
tree and creates a group node for it. This is just for testing purposes.
#145811 will make this functionality available to the Python API as well so that
external renderers can use it too.