Commit graph

744 commits

Author SHA1 Message Date
Sergey Sharybin
819d52f3d2 GSplat: Initial rendering support for Cycles
Based on the "Stochastic ray tracing of transparent 3D Gaussians" paper
by Xin Sun et. al. The basic idea: perform stochastic intersection with
the Gaussian splat based on its transparency.

Gaussian splats are implemented as a dedicated primitive type, but it
shares the same layout for position and radius as points, so a lot of
existing functions (positions, attributes, etc) work for both points
and splats.

For the Embree and hardware intersection it is implemented as a custom
primitive type.

The choice of using bounding spheres mainly comes from a balance between
performance and memory usage. More ideal would be to use OBB, but it is
not supported for custom primitive types in Embree and GPU HW-RT on all
backends.

There is a known limitation that comes from the fact that the datasets
are trained in sRGB space and Cycles work in Linear space: areas with
low opacity and high radiance render noticeably differently from the
ground-truth implementation.

Ref #159470

Pull Request: https://projects.blender.org/blender/blender/pulls/163103
2026-09-16 16:52:10 +02:00
Brecht Van Lommel
61763859fb Fix #161943: Cycles HIP pthread_create crash
This appears to have been caused by invalid use of assert() instead of
kernel_assert() in the kernel. I don't think it's actually hitting that
assert, but maybe it generated an unsupported instruction or something
along those lines?

The one that caused the actual problem is in svm/convert.h. I changed
more instances that are currently CPU only but risk becoming enabled on
the CPU with future code changes.

Thanks to Sahar A. Kashi for finding this.

Pull Request: https://projects.blender.org/blender/blender/pulls/163970
2026-09-16 00:00:00 +02:00
Alex Fuller
3ff1f508e6 Cycles: Fallback value for missing image or attribute in shader
The implements internal support in Cycles for fallback values when an
attribute or image texture is missing in a shader node. It is not yet
exposed in Blender shader nodes.

This is useful to provide an appropriate default value when a shader is
used across objects with different attributes, or when UDIMs don't cover
the entire UV space.

Pull Request: https://projects.blender.org/blender/blender/pulls/162785
2026-09-15 19:45:36 +02:00
Xury Greer
cfc11e52bb Cleanup: Spelling in intern/cycles directory
Fixes the following misspellings:

"equi-angular" -> "equiangular"
"otheriwse" -> "otherwise"
"implememted" -> "implemented"
"tranmissitance" -> "transmittance"
"derivates" -> "derivatives"
"cauzed" -> "caused"
"unsinged" -> "unsigned"
"stochastical" -> "stochastic"
"LighTree" -> "LightTree"
"stdilb" -> "stdlib"
"colospace" -> "colorspace"
"evaulated" -> "evaluated"

Pull Request: https://projects.blender.org/blender/blender/pulls/163850
2026-09-14 12:09:40 +02:00
Jacques Lucke
ba82476ade Shader Nodes: support Integer Math node in EEVEE and Cycles
This adds the Integer Math node to shader nodes. It's the same node that
can already be used in Geometry Nodes and the Compositor.

While creating the regression test, I noticed that the integer math
implementation was a bit broken:
* The integer modulo (`%`) operator on the GPU is undefined for negative
  divisors (the added regression test showed that the behavior is not
  consistent across platforms).
* Use integer power function instead of using float implementation with
  casts.

The MaterialX implementation is omitted for now. I didn't look into it
in detail yet but for the Boolean Math node (#162798) it seemed like
some more work is needed there to support this type.

Pull Request: https://projects.blender.org/blender/blender/pulls/163805
2026-09-14 10:36:19 +02:00
Jacques Lucke
6c74e82ecb Shader Nodes: support Boolean Math node in EEVEE and Cycles
This adds the Boolean Math node to shader nodes. It's the same node that
can already be used in Geometry Nodes and the Compositor.

This also fixes the conversion from other types to boolean values so that
it it consistent across different node tree types. Cycles doesn't have
native support for booleans currently (it encodes them in integers), so
for now this conversion is entirely handled in the inliner.

The MaterialX implementation is omitted for now because it seems to need
more work to properly integrate booleans (right now it appears to ignore
all links going from a float to a boolean socket for example).

Pull Request: https://projects.blender.org/blender/blender/pulls/162798
2026-09-12 14:43:16 +02:00
Sebastian
144e9f6efb Refactor: Cycles: Moving IOR inversion inside the OSL closures
In Cycles we previously assumed that the IOR inversion, when hitting a
surface from the backside, for dielectric closures
(e.g., generalized_schlick, microfacet, refract, etc.) is done by the
user in the OSL code. While experimenting with the OSL code generated
by MaterialX and by looking at the example OSL shaders of the OSL
testrender it shows that OSL assumes that this inversion is done
implicitly, inside the closures. This change matches Cycles IOR
inversion behavior with the one expected by MaterialX and OSL
testrender.

Pull Request: https://projects.blender.org/blender/blender/pulls/162634
2026-09-09 09:12:30 +02:00
Jonas Holzman
c04ad40821 Cleanup: macOS: Remove OSL -faligned-allocation CXX flag
From the comment, this flag was added to suppress allocation warnings on
macOS < 10.14. With the minimum deployment target now being set to 13.0
with !163627, remove this now unused flag. Confirmed to not re-introduce
warnings locally.

Pull Request: https://projects.blender.org/blender/blender/pulls/163669
2026-09-08 15:18:37 +02:00
Weizhen Huang
0fdaf6be0e Cycles: Support anisotropic glass
The functionality is already there, just need to set it up

Implemented for Principled BSDF and Glass BSDF.

Pull Request: https://projects.blender.org/blender/blender/pulls/163343
2026-09-04 10:02:05 +02:00
Sergey Sharybin
0636c92036 Cycles: Add Quaternion attribute type
The main goal is to bring a bit of structure to the use of quaternions
in the Cycles kernel.

Prior to this change there was no dedicated quaternion type and float4
was used instead, and quaternions are stored as (x, y, z, w) matching
naming between the quaternion and float4 fields. However, Blender uses
(w, x, y, z) quaternion order for attributes, which is different from
what Cycles uses. Without dedicated type this either leads to different
quaternion orders depending whether it comes from attribute, or makes
it intrinsically not possible to use implicit sharing.

This change introduces Cycles Quaternion type which is compatible with
Blender attribute math::Quaternion in both layout and alignment, making
it possible to benefit from implicit sharing and use a nice structure
in the kernel.

This change does not modify the existing quaternion usage in the kernel
which is currently used for transform decomposition and interpolation.

There is currently no SIMD for the Quaternion type, which allows to
avoid any special alignment requirement and share attributes with
Blender, but performance might not be ideal.

This attribute type will be used for representing gaussian splat
rotation.

The attribute access and interpolation matches behavior prior to this
change. Added some basic tests for quaternion attribute access for RGB
and alpha, mesh and volume attributes.

Ref #159470

Pull Request: https://projects.blender.org/blender/blender/pulls/163342
2026-09-02 09:08:34 +02:00
Weizhen Huang
df6b084c49 Fix: Shader: wrong coat albedo for fractional coat weight
According to OpenPBR spec v1.1.1 Eq. (9), the correct layering for a
coated substrate is
$$f_\mathrm{layer} = f_\mathrm{coat} + T_\mathrm{coat}(1  - E_\mathrm{coat})f_\mathrm{sub}.$$
For fractional coat weight, we apply Eq. (14), and it becomes
$$
\begin{aligned}
f_\mathrm{weighted-layer}&=(1-w_\mathrm{coat})f_\mathrm{sub}+w_\mathrm{coat}f_\mathrm{layer}\\
&=(1-w_\mathrm{coat})f_\mathrm{sub}+w_\mathrm{coat}(f_\mathrm{coat} + T_\mathrm{coat}(1  - E_\mathrm{coat})f_\mathrm{sub})\\
&=w_\mathrm{coat}f_\mathrm{coat}+(1-w_\mathrm{coat}(1-T_\mathrm{coat}(1-E_\mathrm{coat})))f_\mathrm{sub}
\end{aligned}
$$
Here, \(E_\mathrm{coat}\) does not contain the coat weight nor the
overall weight of the coated closure \(w_\mathrm{layer}\), but our
current way of using `bsdf_albedo()` contains both weight, after which
we apply \(T_\mathrm{coat}\), which is wrong.

To fix this issue, we allow RGB weight for the layer operation, and
directly return a albedo of

$$
A_\mathrm{coat} = w_\mathrm{layer}w_\mathrm{coat}(1-T_\mathrm{coat}(1-E_\mathrm{coat}))
$$
Thus, when we apply the layer operation, we get
$$
\begin{aligned}
&w_\mathrm{layer}\mathrm{layer}(S_\mathrm{sub},S_\mathrm{coat},w_\mathrm{coat})\\
=&w_\mathrm{layer}(1-w_\mathrm{coat})S_\mathrm{sub}+w_\mathrm{layer}w_\mathrm{coat}\mathrm{layer}(S_\mathrm{sub},S_\mathrm{coat})\\
=&w_\mathrm{layer}(1-w_\mathrm{coat})S_\mathrm{sub}+w_\mathrm{layer}w_\mathrm{coat}S_\mathrm{coat} + (w_\mathrm{layer}w_\mathrm{coat}-A_\mathrm{coat})S_\mathrm{sub}\\
=&w_\mathrm{layer}w_\mathrm{coat}S_\mathrm{coat}+(w_\mathrm{layer}-A_\mathrm{coat})S_\mathrm{sub},
\end{aligned}
$$

Which matches the equation for \(f_\mathrm{weighted-layer}\).

A modification to the sheen BSDF was needed to make it not tint the sub
layers.

Pull Request: https://projects.blender.org/blender/blender/pulls/162471
2026-08-26 12:11:08 +02:00
Weizhen Huang
2f61e87ae2 Fix: Cycles: wrong flag for testing closure for emission layering
When the path is being terminated after the current vertex, we also
don't allocate closures, but we still need the weight for layering.
2026-08-26 12:11:07 +02:00
Weizhen Huang
e5e51a6863 Cleanup: Cycles: Reduce duplication in SVM/OSL sheen setup
Also use the MaterialX-compatible `sheen_bsdf()` internally for the old
`sheen()` OSL closure, as they are essentially the same.

Should remove `sheen()` in 6.0
2026-08-26 12:11:07 +02:00
Weizhen Huang
f15daf81bf Cycles: Add dispersion to Principled BSDF
Dispersion is defined by two parameters:
Abbe Number and Dispersion Scale.

This corresponds to OpenPBR v1.1.1

Pull Request: https://projects.blender.org/blender/blender/pulls/162041

Note: dispersion is temporarily disabled when using MNEE (shadow caustics) on oneAPI, due to a compiler bug. Waiting for a fix from the oneAPI side.

![prism.png](/attachments/219c3966-b39d-4846-991b-976f84f83081)
Co-authored-by: Sebastian Herholz <sebastian.herholz@gmail.com>
2026-08-18 11:03:49 +02:00
Weizhen Huang
0b2e8f3562 Refactor: Cycles: Add struct to encompass both reflectance and transmittance
to simplify the code and make future changes easier

Pull Request: https://projects.blender.org/blender/blender/pulls/161854

---------

Co-authored-by: Sebastian Herholz <sebastian.herholz@gmail.com>
2026-08-17 17:13:12 +02:00
Jacques Lucke
216b62e05c Nodes: new Get Vector Component node
This adds a new simple node which retrieves the X, Y or Z component of a vector
by index. This is simpler and more efficient than using workarounds like using a
Separate XYZ with an Index Switch node.

The original motivation for this node came from #149091 where we wanted to
support this using expressions (`vector[i]`).

Co-authored-by: Tibo Stans <stanstibo@gmail.com>
2026-08-12 17:22:43 +02:00
Weizhen Huang
9353fed6d7 Refactor: Cycles: Make dielectric_tint behave the same on OSL and SVM
dielectric_tint is not used on SVM for now, but will be needed for
OpenPBR

Pull Request: https://projects.blender.org/blender/blender/pulls/161853
2026-07-28 19:13:55 +02:00
Weizhen Huang
cc93b7f5a4 Refactor: Cycles: Separate shader flags and runtime flags
We are running out of bits. Split the original `ShaderDataFlag` into
`ShaderRuntimeFlag`, which is determined by closures in the shader and
set up during rendering, and `ShaderDataFlag`, which is the same for the
whole shader graph and hence determined during shader compilation

The size of `ShaderData` did not change due to padding

Pull Request: https://projects.blender.org/blender/blender/pulls/161856
2026-07-27 19:31:18 +02:00
Sergey Sharybin
a950503aed Merge branch 'blender-v5.2-release' 2026-06-26 15:49:40 +02:00
Sergey Sharybin
e54befbe6e Fix #159706: Compilation error on Fedora
Caused by !154576.

Only happens when building Blender against the system-wide OSL,
which has different shaders location.

Pull Request: https://projects.blender.org/blender/blender/pulls/160729
2026-06-26 15:48:45 +02:00
Weizhen Huang
ba40cdca1c Cycles: Skip evaluating emission for volume extinction
Removes a TODO in the code.
2026-06-25 12:45:16 +02:00
Weizhen Huang
f2af4767d6 Cycles: Skip evaluating volume emission for shadows
It was already applied to principled volume and volume coefficients, but
not to the emission BSDF.
2026-06-25 12:45:16 +02:00
Brecht Van Lommel
a176b84a1b Merge branch 'blender-v5.2-release' 2026-06-23 12:50:34 +02:00
Brecht Van Lommel
406577e0d6 Fix #160052: Cycles: Performance regression with CUDA + Blackwell + BVH2
Store positions as separate arrays again. This appears to give better
memory access patterns or layout. This was a regression from fc9917352b
and 0baa98866c.

This is a relatively simple change, rerouting the position attribute to
dedicated arrays, still including motion steps in the same array. The rest
of the refactor is preserved.

Pull Request: https://projects.blender.org/blender/blender/pulls/160110
2026-06-23 12:33:04 +02:00
Miguel Pozo
6e7a0eee32 Cycles: Raycast Visibility Toggle
Cycles implementation of #157799.
Allows removing objects from Raycast Node queries.

Adds `PathRayVisibilityFlag::PATH_RAY_VISIBILITY_RAYCAST` .
OSL adds a new `__raycast__` traceset.

Pull Request: https://projects.blender.org/blender/blender/pulls/158816
2026-06-17 20:37:50 +02:00
Brecht Van Lommel
d82e5e068a Merge branch 'blender-v5.2-release' 2026-06-17 19:18:55 +02:00
Brecht Van Lommel
16951f63fe Fix: Cycles: Principled BSDF noise difference between SVM and OSL
The order of closures was different between the two, which causes
different stochastic picking of BSDFs to sample. Other nodes yield
the same closure order.

This eliminates some differences between tests that seemed like
they may have been related to #159879 but weren't.
2026-06-17 19:17:51 +02:00
Weizhen Huang
377ce8196e Merge branch 'blender-v5.2-release' 2026-06-09 17:35:41 +02:00
Weizhen Huang
d4ee9b9e79 Cycles: Improve smooth thin glass shadow
By allocating transparent BSDF for non-camera rays when roughness is
sufficiently low

Pull Request: https://projects.blender.org/blender/blender/pulls/159798
2026-06-09 17:33:26 +02:00
Raiko
f14783d511 Nodes: Optimize Four Color Mix Modes
The geo nodes implementations of the `mix`, `addition`, `multiplication`
and `subtraction` color mix modes are both faster and have better
numerical properties than the ones we use in Cycles, OSL and EEVEE.

This PR ports the geo nodes implementations of those color mix modes
to Cycles, OSL and EEVEE.

Additionally, the SVM mix function implementation is templatized and
a new function called "endvalue_preserving_mix" is added for the
alternative variant of linear interpolation.

Pull Request: https://projects.blender.org/blender/blender/pulls/158022
2026-06-05 11:54:48 +02:00
Sebastian Herholz
a70c23aa54 Fix: Cycles: Removing legacy scaling of the subsurface radius to match MaterialX
Removing the legacy scaling by 1/(4pi) of the radius scale for the randomwalk
subsurface scattering mode.
Adjusting the default subsurface radius from 0.05 to 0.005 to keep similar
default behavior.
Updating test cases for Cycles and EEVEE.
2026-06-04 19:31:42 +02:00
Sebastian Herholz
99b8ef8bfc Fix: Cycles: Removing legacy scaling of the subsurface radius to match MaterialX
Removing the legacy scaling by 1/(4pi) of the radius scale for the randomwalk
subsurface scattering mode.
Adjusting the default subsurface radius from 0.05 to 0.005 to keep similar
default behavior.
Updating test cases for Cycles and EEVEE.
2026-06-04 18:45:07 +02:00
Weizhen Huang
56331f36d9 Fix #158969: Cycles: Principled Emission not attenuated by coat/sheen in NEE
Allocate BSDF closures locally to attenuate the weight for emission

Pull Request: https://projects.blender.org/blender/blender/pulls/159275
2026-05-29 15:47:25 +02:00
Brecht Van Lommel
fc9917352b Refactor: Cycles: Hair/Point positions include motion, kernel attribute
Motion is now part of the position attribute. On the kernel side, a
combined position + radius attribute is now stored, replacing the
previous motion only attribute.

Legacy motion attributes are now removed.

Pull Request: https://projects.blender.org/blender/blender/pulls/158728
2026-05-27 22:01:25 +02:00
Brecht Van Lommel
0baa98866c Refactor: Cycles: Mesh positions include motion, store kernel attribute
Motion is now part of the position attribute. On the kernel side, this
position is now stored as an attribute as well, replacing the previous
motion only attribute.

Pull Request: https://projects.blender.org/blender/blender/pulls/158728
2026-05-27 22:01:25 +02:00
Sergey Sharybin
fde6280480 Refactor: Cycles: Split off visibility from path flags
The issue this change aims to solve is the fact that we are out of bits
in the PathRayFlag. There is a TODO in the code about the fact that we
might need a flag to record primary scatter for volumes. Additionally,
there are plans to introduce visibility flags for the raycast node
rays.

The choice of the underlying type for the PathRayVisibilityFlag keeps
the raycast visibility in mind.

There is now a dedicated type alias to pass visiiblity around in the
kernel. Currently it is 32 bit, keeping in mind possibility of shift
introduced by the shadow catcher. It is possible to limit it to 16,
but then we'd be limited to only 8 visibility bits (which would be
fine until we introduce other flag after the raycast visibility).
Although, it is not really clear it will brings an actual performance
improvement.

The main path state is using 16 to store path visibility, as per the
underlying type of the PathRayVisibilityFlag. It is possible to limit
it to 8 bit to keep state size small until even more ray visibility
bits be needed in the future (the unaligned node bit is not used by the
path visibility).

The shadow path state also needs path visibility to check which path
type it deals with.

Ref !157822
2026-05-27 19:22:53 +02:00
Sergey Sharybin
0ed5cd6bfc Refactor: Cycles: Introduce type name alias for visibility
Currently matches the `uint` that is used everywhere. Intended to
be used everywhere in the kernel and in the host where visibility
is passed around.

It might become a narrower type in the future if visibility fits
into 8 bits (it could become uint16_t then, to have space for the
shadow catcher shifts).

Should be no functional changes,

Ref !157822
2026-05-27 19:22:53 +02:00
Sergey Sharybin
dfca81b57e Refactor: Cycles: Use bit operations for visibility manipulation
Should be no functional changes.

Ref !157822
2026-05-27 19:22:53 +02:00
Sergey Sharybin
d61fa843f5 Refactor: Cycles: Rename path visibility flags
Prefix all bits that are mapped to the BVH visibility mask with
`PATH_RAY_VISIBILITY_`.

Should be no functional changes.

Ref !157822
2026-05-27 19:22:53 +02:00
Weizhen Huang
6e2b342c9f Render: Add thin wall mode in Principled BSDF
- Thin glass:
An infinitesimally thin sheet of dielectric, approximated by a reflected
lobe and a trasmitted lobe, the respective weights of both lobes are
analytically computed by summing up infinite geometric series that
account for internal reflections.

- Thin subsurface:
An infinitesimally thin sheet of dense scattering material, approximated
by a diffuse lobe and a translucent lobe, the respective weights of both
lobes are given by subsurface anisotropy, with specifies the relative
amount of backward and forward scattering.

Co-authored-by: Jesse Yurkovich <jesse.y@gmail.com>

Pull Request: https://projects.blender.org/blender/blender/pulls/157469
2026-05-22 12:53:43 +02:00
Weizhen Huang
f7332ab9dc Refactor: Cycles: Simplify function signatures by passing float3 instead of struct
Only `sd->wi` is needed in these functions, no need to pass `*sd`.

This might have some performance gain, but I didn't measure.
2026-05-22 12:53:42 +02:00
Cartesian Caramel
2a732a3fba Shaders: Add Scene Time node
This PR adds a Scene Time node to the shader editor.
The goal is for parity with the Compositor and Geometry Nodes.

As recommended by Bretch, this also adds a SceneAttributes class owned
by Scene since there wasn't a good data structure to store scene data
in.

Co-authored-by: Brecht Van Lommel <brecht@blender.org>
Co-authored-by: Clément Foucault <foucault.clem@gmail.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/156850
2026-05-21 15:22:05 +02:00
Weizhen Huang
b962d12de4 Refactor: Cycles: use anisotropic_vdf() in OSL principled volume
`henyey_greenstein()` and `absorption()` are deprecated in OSL new
versions, use `anisotropic_vdf()` instead.

Pull Request: https://projects.blender.org/blender/blender/pulls/158772
2026-05-19 12:29:03 +02:00
Weizhen Huang
a55b783f47 Cycles: OSL: Add missing anisotropic_vdf() closure
implement `anisotropic_vdf()` according to the OSL documentation
2026-05-19 12:29:02 +02:00
Brecht Van Lommel
addf95f48a Cycles: Update OSL GPU services for version 1.15
The required free functions for closure allocation changed, only a
single allocation function needs to be defined now.

This is needed to fix the failing tests after the 5.2 libraries update.

Pull Request: https://projects.blender.org/blender/blender/pulls/158507
2026-05-12 23:29:04 +02:00
Campbell Barton
4df665a2fd Cleanup: blank space around C-style comments
Either use no spaces (common for disabled arguments) `/*arg*/`
or spaces `/* Regular comment. */`

Cleanup lop-sided comments such as `/* X*/` or `/*X */`.

Also use doxy-sections for bmesh_structure.hh,
the ad-hoc section comments had become outdated.

Ref !158467
2026-05-12 16:42:20 +10:00
Sergey Sharybin
ce648dd626 Cycles: Implement attribute access in Raycast node
On the user side it is implemented using extensible socket declaration:
user now can add sockets to access attributes. It is done in the node
settings panel: adding attribute creates input and output socket. The
input socket is a string that denotes attribute to sample, and output
socket provides access to the value of the attribute. A little caveat
is that Color attribute create 2 sockets: one for color, and another
for alpha. This is because color in shader nodes is RGB.

Cycles SVM implementation is based on the existing NODE_ATTR SVM node:
Raycast generates a set of these nodes and uses existing attribute
evaluation on the hit_sd.

Cycles OSL implementation required a bit of trickery to make it fit
the AOT type of shader compilation. The node_raycast() shader outputs
attributes as arrays, and there are extra converter shaders compiled
dynamically to convert those arrays to individual values that could be
addressed by the nodes that use those attribute sockets. There is a
limitation: there could be only up to 32 or each of the float, alpha,
or color/vector attributes.

There is also a mechanism now in Cycles for shaders to request global
attributes. Without this Cycles will optimize all attributes that are
not used by a specific geometry, making it quite tedious to setup in a
way that raycast could still access those attributes. Without such
mechanism user would have need to add attribute nodes to every shader
and mix it in with some low non-zero weight to the output so that it
does not get optimized out. The implementation is not really ideal as
it might lead to situation when attributes are requested by unused
shaders, but it is the best we can do without more global refactor.

EEVEE implementation returns 0 for the attributes. It is quite tricky
to implement attribute sampling, so for now it is Cycles-only feature.

Ref #155590

Pull Request: https://projects.blender.org/blender/blender/pulls/157344
2026-04-30 09:09:15 +02:00
Weizhen Huang
8bc0d293b1 Fix: Cycles: Remove volume density cutoff in OSL
The cutoff was removed for SVM in !131696, but the change was not
applied to OSL

Pull Request: https://projects.blender.org/blender/blender/pulls/157654
2026-04-28 10:45:54 +02:00
Brecht Van Lommel
788562390f Fix: Cycles OSL/SVM difference with stochastic volume sampling
There is no need to call `getattribute` a second time for the factor,
it's the same as the average of the color.

Calling it twice gave different results due to stochastic sampling using
the next random number.

Another difference is that OSL only evaluates other inputs when density
is non-zero, an optimization that is not easy to do in SVM. That is not
solved by this change.

Ref #157554

Pull Request: https://projects.blender.org/blender/blender/pulls/157641
2026-04-22 17:59:50 +02:00
Sergey Sharybin
dcac328db3 Fix #157384: Cycles attribute breaks under certain conditions
Caused by 4d6c7718c5.

Under certain conditions it is possible that the offset logic in the
AttributeTableBuilder::add() assigns offset of -1. This value just
happens to match ATTR_STD_NOT_FOUND, leading to false-positive check
that attribute is not found (for example, svm_node_attr_init() that
checks desc.offset != ATTR_STD_NOT_FOUND.

The simplest solution is to tweak the value of the ATTR_STD_NOT_FOUND
to make it very big negative value.

There is now an utility function to check whether AttributeDescriptor
points to an attribute that is found, to help possibly tweaking this
check in the future, and to make code a bit more semantically clear.

Pull Request: https://projects.blender.org/blender/blender/pulls/157410
2026-04-20 16:57:59 +02:00