Commit Graph

484 Commits

Author SHA1 Message Date
Brecht Van Lommel
a428815716 Fix: Cycles light tree poor when light normalize is off
This option was not exposed in the Blender UI, so no user visible effect.
Take into account light area when building light tree.

Ref #136958
2025-05-22 16:32:44 +02:00
Weizhen Huang
54e748852a Fix #139022: Cycles: Mix Color Node using socket values when constant folded
If Mix Color node clamps the result, we do not bypass the node, but
disconnect other inputs. However, for the case where both inputs were the
same, the disconnected one would use the stored socket value instead, so
set the factor to 0 to only use the intended input.

Pull Request: https://projects.blender.org/blender/blender/pulls/139098
2025-05-20 12:30:20 +02:00
Brecht Van Lommel
358de9e6c9 Fix #139010: Cycles USD motion blur shading artifacts
This code should not have been removed in 47e1b24c29.
2025-05-19 12:12:46 +02:00
Brecht Van Lommel
1e3a7c8c88 Fix #138986: Cycles curve intercept and length rendering wrong
Missed updating these in a previous refactor.
2025-05-19 12:10:46 +02:00
Campbell Barton
b3dfde88f3 Cleanup: spelling in comments (check_spelling_* target)
Also uppercase acronyms: API, UTF & ASCII.
2025-05-17 10:17:37 +10:00
Alexandre-Cardaillac
921c2b9d61 Shader: New Volume Coefficients Shader
Add a new shader node to control volume coefficients (scattering,
absorption and emission) directly, making it easier to model existing
volumes with measured data.

Pull Request: https://projects.blender.org/blender/blender/pulls/136287
2025-05-08 19:19:35 +02:00
Weizhen Huang
64dc9cc98c Fix: Cycles: Inconsistency in transparent bounces for NEE and forward path
Note: this is a partial fix, that makes NEE and forward path consistent
only when `max_transparent_bounce > 0`. It is much more involved to make
forward path tracing support a max transparent bounce of 0, but since we
don't expect people to set up a very low number of transparent bounces,
it is less important to support that specific case.

Pull Request: https://projects.blender.org/blender/blender/pulls/138098
2025-05-05 18:38:02 +02:00
Campbell Barton
9eb9493ecd Fix: build error WITH_CYCLES_OSL & GCC 15.1
Ref !138238
2025-05-02 14:22:27 +10:00
Weizhen Huang
9cc252088e Fix: Cycles: mix weight not applied on volume emission with SVM
Pull Request: https://projects.blender.org/blender/blender/pulls/138081
2025-04-28 12:29:38 +02:00
Lukas Stockner
bf412ed9dd Cycles: Support for custom OSL cameras
This allows users to implement arbitrary camera models using OSL by writing
shaders that take an image position as input and compute ray origin and
direction.

The obvious applications for this are e.g. panorama modes, lens distortion
models and realistic lens simulation, but the possibilities are endless.

Currently, this is only supported on devices with OSL support, so CPU and
OptiX. However, it is independent from the shading model used, so custom
cameras can be used without getting the performance hit of OSL shading.

A few samples are provided as Text Editor templates.

One notable current limitation (in addition to the limited device support)
is that inverse mapping is not supported, so Window texture coordinates and
the Vector pass will not work with custom cameras.

Pull Request: https://projects.blender.org/blender/blender/pulls/129495
2025-04-25 19:27:30 +02:00
Brecht Van Lommel
df053e290d Fix #137621: Cycles curve info random gives wrong value
Caused by filter width changes in 5ce239cc229931b8225.

Pull Request: https://projects.blender.org/blender/blender/pulls/137671
2025-04-17 19:15:05 +02:00
Brecht Van Lommel
d53fdfc7c3 Fix #137517: Cycles adaptive subdivision doesn't use flat normals
Pull Request: https://projects.blender.org/blender/blender/pulls/137677
2025-04-17 19:13:22 +02:00
Weizhen Huang
f9692e10fc Fix #136531: Cycles: missing light update when Emission Sampling is None
When Emission Sampling in None, we loop through
kernel_data.integrator.num_lights to find the light intersection.

If the light shader changes, the number of lights might change, so we
need to tag the light manager for update to recount the lights.

Pull Request: https://projects.blender.org/blender/blender/pulls/137605
2025-04-17 19:12:20 +02:00
Weizhen Huang
891448093f Fix #136556: Cycles emission estimate affects the constant emission
Emission estimate from auto conversion is downscaled to avoid building
a light tree that is expensive to evaluate; however, this estimate is
also used as the final emission value in the kernel if the emission is
constant.

Therefore, only downscale the estimate for the EMISSION_SAMPLING_AUTO
case.

Pull Request: https://projects.blender.org/blender/blender/pulls/137606
2025-04-17 19:11:38 +02:00
Jacques Lucke
3ae20bf166 Cleanup: remove foreach macro from .clang-format
The usage of that macro was removed in 60bec183cb,
but it was still in our .clang-format file. This lead to worse formatting when other code
used methods named `foreach`.

Pull Request: https://projects.blender.org/blender/blender/pulls/137468
2025-04-14 16:17:00 +02:00
Brecht Van Lommel
1cb2244e90 Fix: Cycles build error when WITH_CYCLES_OSL=OFF 2025-04-14 11:35:22 +02:00
Campbell Barton
5affe5fc6d Cleanup: spelling in comments (make check_spelling_*) 2025-04-12 19:31:29 +10:00
Brecht Van Lommel
c8f9fdc0c8 Fix: Cycles CUDA errors after recent changes for scene update
Broken by 86b67a20d6. Delay upload of shader data to GPU until
after kernels have been loaded.

Pull Request: https://projects.blender.org/blender/blender/pulls/137349
2025-04-11 19:14:14 +02:00
Brecht Van Lommel
86b67a20d6 Refactor: Cycles: Move scene update earlier in render iteration update
This will be needed to determine if there are volumes in the scene, before
allocation passes to aid volume sampling.

The kernels are now also loaded in the middle of scene update, at a place
where kernel features are known but before the kernels are needed for
displacement and background light evaluation..

Updating the camera to final resolution for progressive refinement still
happens later.

Pull Request: https://projects.blender.org/blender/blender/pulls/137228
2025-04-11 14:28:22 +02:00
Brecht Van Lommel
c4db213127 Refactor: Cycles: Use full resolution for viewplane bounds check
Results should be unchanged, but it's confusing if these use the progressive
refinement resolution instead of the full resolution.

Pull Request: https://projects.blender.org/blender/blender/pulls/137228
2025-04-11 14:28:22 +02:00
Weizhen Huang
c2ec66a75b Fix #136726: Cycles: Area light visible when size is 0
Area light with a size of zero should not contribute to the scene, so
set the light as disabled.

This does not only fix the reported bug where such light is visible to
the camera, but also a regression in 4.2 where the light contributes to
the scene when light tree is off.

Pull Request: https://projects.blender.org/blender/blender/pulls/136763
2025-03-31 16:17:59 +02:00
Alex Fuller
a1b7ce1d22 Cycles: Move UV tangent computation into the core
This makes it available in Cycles standalone, and the implementation
can be shared with Blender. This also makes it possible to compute
tangents after tessellation for adaptive subdivision.

There is a difference in UV map tangents when there are no UVs. They
are now generated from object space coordinates instead of auto
texture space coordinates. This is more efficient, and a corner case
that we don't have to keep compatible.

Co-authored-by: Brecht Van Lommel <brecht@blender.org>

Pull Request: https://projects.blender.org/blender/cycles/pulls/25
2025-03-27 22:07:50 +01:00
Alex Fuller
438ac2a653 Cycles: Add OSL metadata for default geometry attributes
Add support for OSL parameter metadata named `defaultgeomprop`, whose
values are interpreted the same way as the property on MaterialX node
inputs. When set to `Tworld` the tangent is then automatically linked
to the shader and generated for the mesh.

Pull Request: https://projects.blender.org/blender/cycles/pulls/25
2025-03-27 22:07:50 +01:00
Brecht Van Lommel
47e1b24c29 Refactor: Cycles: Apply static transforms later in scene update
It makes more sense to do it after geometry processing, in particular
for the tangent computation that is coming.

Pull Request: https://projects.blender.org/blender/blender/pulls/136576
2025-03-27 22:07:50 +01:00
Brecht Van Lommel
e394fd191b Refactor: Cycles: Sync various build fixes from the standalone repository
Pull Request: https://projects.blender.org/blender/blender/pulls/136576
2025-03-27 22:07:50 +01:00
Brecht Van Lommel
26ccbaf8b5 Fix: Cycles build broken without OpenSubdiv 2025-03-27 22:07:50 +01:00
Brecht Van Lommel
f987ef7b6e Shaders: Add Filter Width input to Bump node
This makes it possible to restore previous Blender 4.3 behavior of bump
mapping, where the large filter width was sometimes (ab)used to get a bevel
like effect on stepwise textures.

For bump from the displacement socket, filter width remains fixed at 0.1.

Ref #133991, #135841

Pull Request: https://projects.blender.org/blender/blender/pulls/136465
2025-03-25 16:29:13 +01:00
Brecht Van Lommel
c448bf16e5 Cycles: Multithread adaptive subdivision dicing
* Perform attribute interpolation as part of dicing.
* Remove temporary subd uv and face index attributes.

On a MacBook M3 with 12 P-cores and 4 E-cores, these changes overall give
a 10x-14x speedup on various scenes. Note that splitting is still single
threaded and can be expensive, and UV subdivision can be optimized more.

Pull Request: https://projects.blender.org/blender/blender/pulls/136411
2025-03-24 09:42:47 +01:00
Brecht Van Lommel
4e16c4bd7d Refactor: Cycles: Tweaks to adaptive subdivision dicing
* Move dicing out of DiagSplit, caller now uses EdgeDice
* Merge, rename and reorder various EdgeDice functions
* Compute triangle indices for subpatches in advance

Pull Request: https://projects.blender.org/blender/blender/pulls/136411
2025-03-24 09:42:45 +01:00
Brecht Van Lommel
990f8df7cc Fix: Build error with OpenImageIO 2.x after OSL manager changes
Ref #135050
2025-03-14 18:44:27 +01:00
Brecht Van Lommel
de821416c7 Cycles: Adaptive subdivision dicing and splitting improvements
* Share vertices between patches instead of using stitch map
* Switch to OpenSubdiv compatible counter-clockwise indexing
* Simplify patch edge reverse direction logic
* Add more comments to splitting and dicing

Pull Request: https://projects.blender.org/blender/blender/pulls/135681
2025-03-11 20:58:33 +01:00
Brecht Van Lommel
e84b377eae Refactor: Simplify subd patch code
* Remove unused linear patch normals
* Renaming for consistency and clarity
* Shuffle order of function definitions

Pull Request: https://projects.blender.org/blender/blender/pulls/135681
2025-03-11 20:58:20 +01:00
Brecht Van Lommel
42846caca1 Cycles: Adaptive subdivision support for modifier options
* Use creases
* Boundary interpolation
* UV interpolation

Pull Request: https://projects.blender.org/blender/blender/pulls/135681
2025-03-11 20:58:17 +01:00
Brecht Van Lommel
82751ca10c Cycles: Adaptive subdivision motion blur support
* Smooth interpolation of vertex coordinates and normals of motion steps
* Fix issues with Blender sync and object device update

Pull Request: https://projects.blender.org/blender/blender/pulls/135681
2025-03-11 20:58:14 +01:00
Brecht Van Lommel
07b60c189b Cycles: Perform attribute subdivision on the host side
* Add SubdAttributeInterpolation class for linear attribute interpolation.
* Dicing computes ptex UV and face ID for interpolation.
* Simplify mesh storage of subd primitive counts
* Remove kernel code for subd attribute interpolation
* Remove patch table packing and upload

The old optimization adds a fair amount of complexity to the kernel, affecting
performance even when not using the feature. It's also not that useful as it
does not work for UVs that needs special interpolation. With this simpler code
it should be easier to make it feature complete.

Pull Request: https://projects.blender.org/blender/blender/pulls/135681
2025-03-11 20:58:07 +01:00
Brecht Van Lommel
afd139f07e Refactor: Split OsdMesh off from OsdData
Pull Request: https://projects.blender.org/blender/blender/pulls/135681
2025-03-11 20:58:05 +01:00
Brecht Van Lommel
189efd8eeb Refactor: Move more subdivision code into subd/
No logic or functional changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/135681
2025-03-11 20:57:59 +01:00
Brecht Van Lommel
6ec541ca4e Refactor: Cycles: Remove face normal attribute
It's already computed on demand in the kernel, no need to have it host side.

Pull Request: https://projects.blender.org/blender/blender/pulls/135681
2025-03-11 20:57:51 +01:00
Brecht Van Lommel
221dd26604 Cleanup: Cycles + lite build compiler warnings 2025-03-11 19:56:04 +01:00
Brecht Van Lommel
48398b223b Cleanup: Fix various divisions by zero reported by ASAN
Pull Request: https://projects.blender.org/blender/blender/pulls/135326
2025-03-06 22:34:23 +01:00
Brecht Van Lommel
dd20f31302 Cleanup: Fix clang-tidy warnings from recent OSL changes 2025-03-06 22:34:22 +01:00
Falk David
e39c83c881 Merge branch 'blender-v4.4-release' 2025-03-06 21:19:31 +01:00
Jesse Yurkovich
4c38380cc6 Fix #134043: Account for frame_offset in Alembic procedurals
There's two places which perform the frame start and end time
calculation and only one of them was respecting the frame_offset.

Pull Request: https://projects.blender.org/blender/blender/pulls/134149
2025-03-06 20:54:22 +01:00
Jesse Yurkovich
3a0e4fe316 Fix #134039: Alembic procedural proxy mesh should be owned by GeometrySet
When using Alembic procedurals, the Mesh Sequence Cache attempts to
replace the original geometry with a plain old cube. However, it never
frees this new cube geometry. Transfer ownership to the underlying
GeometrySet instead.

Investigating the scenario also showed that the `~AlembicProcedural`
dtor was removing an item from the `nodes` vector while iterating over
it, which triggers debug asserts on at least MSVC. I believe the removal
is unnecessary since this is the dtor and ASAN appears clean now.

Pull Request: https://projects.blender.org/blender/blender/pulls/134085
2025-03-06 20:53:52 +01:00
Lukas Stockner
39a6c222b2 Cycles: Split OSLManager out of OSLShaderManager
This is preparation for #129495.

Currently, all of OSL is managed by the OSLShaderManager. This makes it so that the general OSL setup is handled by a general OSLManager, and both the OSLShaderManager and (in the future) the Camera can use it to manage their scripts.

Pull Request: https://projects.blender.org/blender/blender/pulls/135050
2025-03-04 17:27:10 +01:00
Brecht Van Lommel
5caeac4474 Fix: Cycles performance regression after refactor for light objects
Thanks to Xavier Hallade for finding the cause.

Caused by #134846, e813e46327.

Pull Request: https://projects.blender.org/blender/blender/pulls/135309
2025-02-28 17:40:03 +01:00
Sergey Sharybin
d853d994ae Merge branch 'blender-v4.4-release' 2025-02-28 10:42:54 +01:00
Sergey Sharybin
b9c727e255 Fix #135200: Linking linking artifacts with light trees
Ensure that the light tree flattening code does not try to
share node in cases when we need to modify its bit trail.

Pull Request: https://projects.blender.org/blender/blender/pulls/135249
2025-02-28 10:42:29 +01:00
Brecht Van Lommel
655ccf1d7a Fix #135086: Light ray visibility not taken into account without light tree
Re-enable tests that were temporarily disabled for this.

Caused by #134846, e813e46327
2025-02-25 17:24:04 +01:00
Brecht Van Lommel
e813e46327 Cycles: Refactor lights to be objects
This is an intermediate steps towards making lights actual geometry.
Light is now a subclass of Geometry, which simplifies some code.

The geometry is not added to the BVH yet, which would be the next
step and improve light intersection performance with many lights.

This makes object attributes work on lights.

Co-authored-by: Lukas Stockner <lukas@lukasstockner.de>
Pull Request: https://projects.blender.org/blender/blender/pulls/134846
2025-02-24 23:44:14 +01:00