18 Commits

Author SHA1 Message Date
Brecht Van Lommel
59b4842117 Cycles: Adaptive subdivision triangular patches
There is a corner case where one side of a quad needs splitting and the other
side has only one segment. Previously this would produce either gaps or after
recent changes to stitch together geometry, uninitialized memory.

Now solve this by splitting into triangular patches, as suggested in the
DiagSplit paper. These triangular patches can be further subdivided themselves.
Dicing has special cases for 1 or 2 segments on edges. For more segments it
works the same as: quad dicing: A regular inner triangle grid stitched to the
outer edges.

Fix #136973: Inconsistent results with adaptive subdivision

Pull Request: https://projects.blender.org/blender/blender/pulls/139062
2025-05-19 12:04:11 +02:00
Brecht Van Lommel
d6b42d3eac Refactor: Rename subpatch members to prepare for triangular patch
Pull Request: https://projects.blender.org/blender/blender/pulls/139062
2025-05-19 12:03:58 +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
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
17fbfbc2d5 Refactor: Cycles: Subdivision avoids writing vertices multiple times
For performance and determinism with upcoming multithreading.

Pull Request: https://projects.blender.org/blender/blender/pulls/136411
2025-03-24 09:42:43 +01:00
Brecht Van Lommel
b1559b3ff4 Cycles: Adaptive subdivision patches without inner grid
Means low res patches can have 2 instead of 4 triangles.

Pull Request: https://projects.blender.org/blender/blender/pulls/135681
2025-03-11 20:58:36 +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
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
57ff24cb99 Refactor: Cycles: Add const keyword to more function parameters
Pull Request: https://projects.blender.org/blender/blender/pulls/132361
2025-01-03 10:23:24 +01:00
Brecht Van Lommel
dd51c8660b Refactor: Cycles: Add const keyword where possible, using clang-tidy
Check was misc-const-correctness, combined with readability-isolate-declaration
as suggested by the docs.

Temporarily clang-format "QualifierAlignment: Left" was used to get consistency
with the prevailing order of keywords.

Pull Request: https://projects.blender.org/blender/blender/pulls/132361
2025-01-03 10:23:20 +01:00
Brecht Van Lommel
3c2a6fbb9c Refactor: Cycles: Use nullptr instead of NULL
Pull Request: https://projects.blender.org/blender/blender/pulls/132361
2025-01-03 10:22:43 +01:00
Campbell Barton
5b9740c913 Cleanup: use braces for sources in intern/
Omitted intern/itasc as some of these sources are from KDL:
https://www.orocos.org/kdl.html
2023-09-17 09:05:40 +10:00
Campbell Barton
c12994612b License headers: use SPDX-FileCopyrightText in intern/cycles 2023-06-14 16:53:23 +10:00
Sergey Sharybin
d32d787f5f Clang-Format: Allow empty functions to be single-line
For example

```
OIIOOutputDriver::~OIIOOutputDriver()
{
}
```

becomes

```
OIIOOutputDriver::~OIIOOutputDriver() {}
```

Saves quite some vertical space, which is especially handy for
constructors.

Pull Request: https://projects.blender.org/blender/blender/pulls/105594
2023-03-29 16:50:54 +02:00
Brecht Van Lommel
9cfc7967dd Cycles: use SPDX license headers
* Replace license text in headers with SPDX identifiers.
* Remove specific license info from outdated readme.txt, instead leave details
  to the source files.
* Add list of SPDX license identifiers used, and corresponding license texts.
* Update copyright dates while we're at it.

Ref D14069, T95597
2022-02-11 17:47:34 +01:00
Brecht Van Lommel
fd25e883e2 Cycles: remove prefix from source code file names
Remove prefix of filenames that is the same as the folder name. This used
to help when #includes were using individual files, but now they are always
relative to the cycles root directory and so the prefixes are redundant.

For patches and branches, git merge and rebase should be able to detect the
renames and move over code to the right file.
2021-10-26 15:37:04 +02:00