Commit Graph

7985 Commits

Author SHA1 Message Date
Campbell Barton
9dfb3fc550 CMake: refactor flag checking function to take multiple argument pairs
Many calls to add_check_c_compiler_flag add_check_cxx_compiler_flag
resulted in over long lines & visual noise. Replace with a function that
takes multiple (cache_var flag) pairs to reduce duplication.
2023-08-10 11:28:22 +10:00
Hoshinova
b880485492 Nodes: add Floored Modulo mode to Math nodes
Both the `Math` node and the `Vector Math` currently only explicitly
support modulo using truncated division which is oftentimes not the
type of modulo desired as it behaves differently for negative numbers
and positive numbers.

Floored Modulo can be created by either using the `Wrap` operation or
a combination of multiple `Math` nodes. However both methods obfuscate
the actual intend of the artist and the math operation that is actually
used.

This patch adds modulo using floored division to the scalar `Math` node,
explicitly stating the intended math operation and renames the already
existing `"Modulo"` operation to `"Truncated Modulo"` to avoid confusion.
Only the ui name is changed, so this should not break compatibility.

Pull Request: https://projects.blender.org/blender/blender/pulls/110728
2023-08-08 12:13:00 +02:00
Sergey Sharybin
d7886ee759 Color management: Further relax threshold for sRGB detection
Apparently, the SSE optimization in the OCIO is not nearly as accurate
as a naive implementation. For example, exponent transform of 1 gives
result of 1.000024.

Ref #110685

Pull Request: https://projects.blender.org/blender/blender/pulls/110895
2023-08-07 15:53:03 +02:00
Sergey Sharybin
d50b139b06 Color management: Relax threshold for sRGB detection
The current core was only detecting sRGB transform when it is defined
as sRGB->Linear using srgb.spi1d. If it is defined as an inverse of
Linear->sRGB using srgb_inv.spi1d, or as an analytical formula using
ExponentWithLinearTransform then the code did not detect the color
as sRGB on anything by Apple Silicon platform.

The naming of the checks could be improved to make it more clear that
the check is only used to allow lossless access to 8bit sRGB textures.

Ref #110685

Pull Request: https://projects.blender.org/blender/blender/pulls/110889
2023-08-07 14:32:16 +02:00
Alaska
52ed6a216f Fix #110255: Cover up CPU/GPU differences with small suns in light tree
This pull request covers up a subtle difference between the CPU and GPU
when rendering with a light tree. Specifically a case where the user
has a sun light with a small angle.

The difference was caused by the dot() function being different between
CPU and GPU backends, with the GPU showing more meaningful
floating-point precision losses when working with small suns.

Pull Request: https://projects.blender.org/blender/blender/pulls/110307
2023-08-07 07:29:14 +02:00
Campbell Barton
7f34ad736a Cleanup: spelling in comments 2023-08-05 13:54:25 +10:00
Campbell Barton
0caf227530 License headers: use SPDX-FileCopyrightText for *.inl and *.osl files 2023-08-04 13:24:17 +10:00
Sergey Sharybin
8ea68765fc Fix CUDA error with light linking and emissive world volume
The issue was an out-of-bounds read access when checking whether
the world volume emission needs to be accumulated.

Solution is to check for this case. Done in the generic place, so
that the shade_volume kernel is more readable and no branching
added there, and there is no impact on scenes without the light
linking.

Assume that the world emissive volume belongs to the default light
linking group, as there is no way to link it explicitly to anything.

Pull Request: https://projects.blender.org/blender/blender/pulls/110733
2023-08-03 07:54:06 +02:00
Kaspian Jakobsson
5a9128af25 Fix #109679: incorrect handling of negative Z normal maps after recent fix
Implement clamped scaling on the Z-axis, so that strength zero means the
normal map has no effect.

Ref #109763
2023-08-01 20:23:12 +02:00
Alaska
462dbe9929 Fix NaN in Cycles light tree bone.axis
Fix `NaN` in the light tree `bcone.axis` that can occur when
normalizing direction vectors of 0 length.

Pull Request: https://projects.blender.org/blender/blender/pulls/110374
2023-07-31 10:56:15 +02:00
Alaska
18575e411b Cleanup: Cycles device_update_lights
Rearrange and remove some unnecessary lines of code
to improve readability.

Pull Request: https://projects.blender.org/blender/blender/pulls/110377
2023-07-31 10:46:31 +02:00
Alaska
1261272da7 Cleanup: Simplify get centroid in Cycles light tree builder
`scene->lights[object_id` is already available as `lamp`.

Pull Request: https://projects.blender.org/blender/blender/pulls/110376
2023-07-31 10:40:40 +02:00
Brecht Van Lommel
635c2591ff Fix #109683: Cycles AOV render without surface output missing attributes 2023-07-28 17:35:50 +02:00
Harley Acheson
1f4e59a96f Cleanup: Make format
Small format changes in various files (not just mine).
2023-07-27 13:12:52 -07:00
salipourto
9a150b95c5 Fix #109417: Cycles HIP RT crash with multi device rendering
A couple of checks were missing to handle the multi device rendering.

Pull Request: https://projects.blender.org/blender/blender/pulls/110512
2023-07-27 18:29:58 +02:00
Lukas Stockner
c66a694056 Cycles: Replace Sheen model in the Principled BSDF
This replaces the Sheen model used in the Principled BSDF with the
model from #108869 that is already used in the Sheen BSDF now.

The three notable differences are:
- At full intensity (Sheen = 1.0), the new model is significantly
  stronger than the old one. For existing files, the intensity is
  adjusted to keep the overall look similar.
- The Sheen Tint input is now a color input, instead of the
  previous blend factor between white and the base color.
- There is now a Sheen roughness control, which can be used to
  tweak the look between velvet-like and dust-like.

Pull Request: https://projects.blender.org/blender/blender/pulls/109949
2023-07-27 02:17:44 +02:00
Brecht Van Lommel
0fab1f4f68 Fix #110170: Cycles CUDA cloud rendering artifacts with spatial splits
The fix in commit d9273d857 exposed a pre-existing issue in the code.
2023-07-26 17:18:45 +02:00
Xavier Hallade
b0d1226b6c Cycles: refine MSVC version check for /jumptablerdata
MSVC_VER 1937 included 17.7 preview 1 and 2 that didn't support the flag
while developers may be using these versions already because of the
issues with 17.6. We now check for preview 3 specifically.
2023-07-25 19:54:59 +02:00
Xavier Hallade
716f909a4f Cycles: add /jumptablerdata to MSVC compiler flags
Starting with MSVC 17.7 preview 3, /jumptablerdata is available and
allows to ensure switch tables don't get mixed with the code, helping on
performance when there is contention in a large switch statement, such
as in svm.h.

Pull Request: https://projects.blender.org/blender/blender/pulls/110470
2023-07-25 19:19:35 +02:00
Ray molenkamp
4ea2baf4ae CMake: revert last weeks modernizations
The cleanup of blenkernel last weeks , caused the house of cards to
collapse on  top of bf_gpu's shader_builder, which is off by default
but used on a daily basis by the rendering team.

Given the fixes forward in #110394 ran into a ODR violation in OSL that
was hiding there for years, I don't see another way forward without
impeding the rendering teams productivity for "quite a while" as there
is no guarantee the OSL issue would be the end of it.

the only way forward appears to be back.

this reverts :

19422044edbd8e8d524db3d02768c4a52f5274be
a670b53abe82f7a36d2caa0d8ae2c67c2bc8c39a
0f541db97c47e5fcd1c71160d71642235d9ea743
be516e8c814dbf7bc43ea91c6913be9f7f96e006
3e88a2f44c413fa7f671f638409a975d59f8c1fb
4e64b772f5ed8f352c2744baece802f70e2430e7
9547e7a317d6f86ab8fbfb3d440f127c2ab75df2
07fe6c5a57d7bcf89318204c0319db1f4a2f5cbd

The problematic commit was 07fe6c5a57d7bcf89318204c0319db1f4a2f5cbd
as blenkernel links most of blender, it's a bit of a link order issue
magnet. Given all these commits stack, it's near impossible to revert
just that one without spending a significant amount of time resolving
merge conflicts. 99% of that work was automated, so easier to just
revert all of them, and re-do the work, than it is to deal with the
merge conflicts.

Pull Request: https://projects.blender.org/blender/blender/pulls/110438
2023-07-25 16:43:21 +02:00
Xavier Hallade
aefc9835f8 Cycles: oneAPI: fix kernel host-side compilation with MSVC 17.7
<algorithm> header include is missing from some sycl headers, this will
be fixed upstream with https://github.com/intel/llvm/pull/10424,
meanwhile, we work around it by including it directly.
2023-07-25 12:01:09 +02:00
Campbell Barton
530ee6e7fa Cleanup: make class doc-strings directly above classes
In some cases it wasn't clear if a comment before a class was meant
to be it's doc-string. Remove blank lines between the class & it's
doc-string.
2023-07-25 14:11:42 +10:00
Campbell Barton
ac5be3efde Cleanup: use SPDX copyright in header 2023-07-25 13:59:53 +10:00
Hans Goudey
5e9ea9243b Mesh: Rename "polys" to "faces"
Implements part of #101689.

The "poly" name was chosen to distinguish the `MLoop` + `MPoly`
combination from the `MFace` struct it replaced. Those two structures
persisted together for a long time, but nowadays `MPoly` is gone, and
`MFace` is only used in some legacy code like the particle system.

To avoid unnecessarily using a different term, increase consistency
with the UI and with BMesh, and generally make code a bit easier to
read, this commit replaces the `poly` term with `poly`. Most variables
that use the term are renamed too. `Mesh.totface` and `Mesh.fdata` now
have a `_legacy` suffix to reduce confusion. In a next step, `pdata`
can be renamed to `face_data` as well.

Pull Request: https://projects.blender.org/blender/blender/pulls/109819
2023-07-24 22:06:55 +02:00
Lukas Stockner
b19011e2db Cycles: Fix build error due to missing svm_closure_weight 2023-07-24 16:56:52 +02:00
Lukas Stockner
2c3b095995 Cycles: Don't store SVM closure weight in ShaderData
This is only used as temporary state while evaluating SVM nodes,
there's no point in storing it in the ShaderData for later.
Since ShaderData size is relevant for GPU performance, we should
save the space and only keep it where needed.

Pull Request: https://projects.blender.org/blender/blender/pulls/110366
2023-07-24 16:09:46 +02:00
Lukas Stockner
b220ec27d7 Cycles: Update Velvet BSDF to Sheen BSDF with new Microfiber sheen model
This patch extends the old Velvet BSDF node with a new shading model,
and renames it to Sheen BSDF accordingly.

The old model is still available, but new nodes now default to the
"Microfiber" model, which is an implementation of
https://tizianzeltner.com/projects/Zeltner2022Practical/.

Pull Request: https://projects.blender.org/blender/blender/pulls/108869
2023-07-24 15:36:36 +02:00
Lukas Stockner
56bc24aa9b Cycles: Merge OSL Clearcoat closure into microfacet()
There's no reason why this would need to be its own closure, it was
just a slightly different microfacet distribution with a hardcoded
IOR and intensity multiplier internally.

No functional change, just cleaning up the mess of custom OSL closures.

Pull Request: https://projects.blender.org/blender/blender/pulls/109951
2023-07-22 05:07:11 +02:00
Lukas Stockner
89218b66c2 Cycles: Remove Transmission Roughness from Principled BSDF
This was already unsupported in combination with Multiscattering GGX,
prevented the Principled BSDF from using microfaced-based Fresnel for
Glass materials, and would have made future improvements even trickier.

Pull Request: https://projects.blender.org/blender/blender/pulls/109950
2023-07-22 04:16:49 +02:00
Lukas Stockner
8639bf013c Cycles: Fix MNEE not accounting for closure Fresnel
Previously Glass Fresnel used to get baked into the closure weight,
so the MNEE code could just ignore it.
However, now that it's part of the closure implementation, we need
to account for it in the MNEE throughput calculation as well.
2023-07-22 04:02:14 +02:00
–kaspian.jakobssongmail.com
b767a62f32 Fix #109679: Normal Map node strength interpolation artifacts
Previously the normal strength linearly interpolated and extrapolated
the normal in world space. Instead do it in tangent space, in a way
that ensure the normal remains above the surface and valid.

Pull Request: https://projects.blender.org/blender/blender/pulls/109763
2023-07-17 20:06:41 +02:00
Campbell Barton
caf0024463 Cleanup: add degrees UTF8 symbol, prefer ascii over unicode in comments 2023-07-16 21:54:58 +10:00
Campbell Barton
d594954bf2 Cleanup: use C++ compatible struct declarations for Python API
Also add m_base & ob_base comments.
2023-07-16 18:13:15 +10:00
Campbell Barton
3889baab4f Cleanup: spelling in comments 2023-07-15 15:54:55 +10:00
Weizhen Huang
a86506b741 Cleanup: sort enum KernelFeatureFlag in order
no functional change expected
2023-07-14 12:19:11 +02:00
Brecht Van Lommel
cc1ee96407 Fix Cycles HIP RT kernel not rebuilding on changes
Changes to the kernel source would not update the HIP RT binaries, leading
to render errors due to the kernel being mismatched with Blender.

The code this was copied from was inside a macro that defines the sources
variable, but it's not defined here.

Ref #109418

Pull Request: https://projects.blender.org/blender/blender/pulls/110073
2023-07-13 23:08:14 +02:00
Weizhen Huang
4724147479 Fix #109945: Division by zero in brick texture 2023-07-13 15:44:15 +02:00
Sergey Sharybin
99b962811b Cleanup: Fix typo in Cycles error log
Pull Request: https://projects.blender.org/blender/blender/pulls/110045
2023-07-13 09:37:02 +02:00
Brecht Van Lommel
7f04df62e4 Fix Cycles division by zero in recent distant light texture coordinates 2023-07-12 18:14:11 +02:00
Weizhen Huang
0b3efc9d8c Cleanup: Cycles: remove SHARP distribution internally
this option was already unselectable in the UI, and is treated as GGX
with zero roughness. Upon building the shader graph, we only convert a
closure to `SHARP` when option Filter Glossy is not used and the
roughness is below certain threshold. The benefit is that we can avoid
calling `bsdf_eval()` or return earlier in some cases, but the thresholds
vary across files.
This patch removes `SHARP` closures altogether, and checks if the
roughness value is below a global threshold `BSDF_ROUGHNESS_THRESH`
after blurring, in which case the flag `SD_BSDF_HAS_EVAL` is not set.
The global threshold is set to be `5e-7f` because threshold smaller than
that seems to have caused problem in the past (c6aa0217ac). Also removes
a bunch of functions, variables and arguments that were only there
because we converted closures under certain conditions.

Pull Request: https://projects.blender.org/blender/blender/pulls/109902
2023-07-12 12:36:31 +02:00
Ray molenkamp
07fe6c5a57 Cleanup: CMake: Modernize bf_blenkernel dependencies
Pretty straightforward

- Remove any blenkernel paths from INC
- Add a dependency though LIB

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/109939
2023-07-11 19:28:01 +02:00
Ray Molenkamp
04235d0e55 Cleanup: CMake: Modernize bf_blenlib dependencies
Pretty straightforward

- Remove any blenlib paths from INC
- Add a dependency though LIB

Pull Request: https://projects.blender.org/blender/blender/pulls/109934
2023-07-10 22:04:18 +02:00
Ray Molenkamp
57ad866d81 Cleanup: CMake: Modernize bf_guardedalloc dependencies
Pretty straightforward

- Removes any guardedalloc paths from INC
- Adds a dependency though LIB

Pull Request: https://projects.blender.org/blender/blender/pulls/109925
2023-07-10 18:44:19 +02:00
Hoshinova
41335edf22 Fix #109254: Voronoi distance output is clamped at 8
The Voronoi distance output is clamped at 8, which is apparent for distance
metrics like Minkowski with low exponents.

This patch fixes that by setting the initial distance of the search loop to
FLT_MAX instead of 8. And for the Smooth variant of F1, the "h" parameter is set
to 1 for the first iteration using a signal value, effectively ignoring the
initial distance and using the computed distance at the first iteration instead.

Pull Request: https://projects.blender.org/blender/blender/pulls/109286
2023-07-10 17:42:24 +02:00
Ray Molenkamp
7cebb61486 Cleanup: CMake: Modernize bf_dna dependencies
There's quite a few libraries that depend on dna_type_offsets.h
but had gotten to it by just adding the folder that contains it to
their includes INC section without declaring a dependency to
bf_dna in the LIB section.

which occasionally lead to the lib building before bf_dna and the
header being missing, while this generally gets fixed in CMake by
adding bf_dna to the LIB section of the lib, however until last
week all libraries in the LIB section were linked as INTERFACE so
adding it in there did not resolve the build issue.

To make things still build, we sprinkled add_dependencies wherever
we needed it to force a build order.

This diff :

Declares public include folders for the bf_dna target so there's
no more fudging the INC section required to get to them.

Removes all dna related paths from the INC section for all
libraries.

Adds an alias target bf:dna to signify it has been updated to
modern cmake

Declares a dependency on bf::dna for all libraries that require it

Removes (almost) all calls to add_dependencies for bf_dna

Future work:

Because of the manual dependency management that was done, there is
now some "clutter" with libs depending on bf_dna that realistically
don't. Example bf_intern_opencolorio itself has no dependency on
bf_dna at all, doesn't need it, doesn't use it. However the
dna include folder had been added to it in the past since bf_blenlib
uses dna headers in some of its public headers and
bf_intern_opencolorio does use those blenlib headers.

Given bf_blenlib now correctly declares the dependency on bf_dna
as public bf_intern_opencolorio will get the dna header directory
automatically from CMake, hence some cleanup could be done for
bf_intern_opencolorio

Because 99% of the changes in this diff have been automated, this diff
does not seek to address these issues as there is no easy way to
determine why a certain dependency is in place. A developer will have
to make a pass a this at some later point in time. As I'd rather not
mix automated and manual labour.

There are a few libraries that could not be automatically processed
(ie bf_blendthumb) that also will need this manual look-over.

Pull Request: https://projects.blender.org/blender/blender/pulls/109835
2023-07-10 15:07:37 +02:00
Brecht Van Lommel
f2705dd913 Fix #109683: Cycles and Eevee missing AOVs when no closure connected
No reason to skip these, and this will be useful for faster shader node
preview rendering based on AOVs.

Pull Request: https://projects.blender.org/blender/blender/pulls/109709
2023-07-10 12:41:44 +02:00
Weizhen Huang
ab12d2836b Cycles: add texture to sun light
Using area-preserving mapping from cone to disk. Has somewhat distortion
near 90°.
The texture rotates with the transformation of the light object, can
have negative and non-uniform scaling.

Pull Request: https://projects.blender.org/blender/blender/pulls/109842
2023-07-10 12:20:47 +02:00
Campbell Barton
4da96623ff CMake: use mark_as_advancd for most non WITH_* options
Avoid showing many obscure CMake options by default.
2023-07-10 12:02:15 +10:00
Campbell Barton
6290451712 Cleanup: spelling in comments 2023-07-09 21:22:45 +10:00
Brecht Van Lommel
7e55dfcf27 Fix #103918: Cycles point cloud motion blur artifacts on the GPU
Change storage to consistently put xyz + radius in the motion blur attribute.

Pull Request: https://projects.blender.org/blender/blender/pulls/109830
2023-07-07 20:15:36 +02:00