Commit Graph

3366 Commits

Author SHA1 Message Date
Lukas Stockner
d071e0a5fc Fix #113058: Cycles: Bump mapping causing dark edges with subsurface
The refractive entry bounce does not like being below the shading normal,
so use the existing clamping logic.
2023-10-04 13:28:20 +02:00
Brecht Van Lommel
2f3e3cda51 Fix #113034: Cycles sheen breaks with low roughness
Also minor optimization to replace division by multiplication.
2023-10-03 20:30:40 +02:00
Brecht Van Lommel
a455eca7a0 Fix #112931: Cycles mesh light sampling artifacts 2023-10-02 19:18:42 +02:00
Brecht Van Lommel
ed36398e16 Fix #109907: Cycles correlation issue with LCG random numbers
This showed up in 3.6 with multiscatter GGX, but could still be an issue
in current principled hair BSDF implementations.
2023-10-02 18:41:56 +02:00
Lukas Stockner
b1a91c99bc Fix #111588: Cycles: Vector displacement with adaptive subdiv breaks normal
The compact form of the differential is not enough here, we need to store
and use the full vectors for bump evaluation.

Pull Request: https://projects.blender.org/blender/blender/pulls/112987
2023-10-02 02:19:51 +02:00
Alaska
f9dce92767 Fix Cycles missing specular tint for transmissive Principled BSDF
Pull Request: https://projects.blender.org/blender/blender/pulls/112894
2023-09-27 17:44:49 +02:00
Lukas Stockner
2456897d9d Fix #112831: Cycles: Kernel assert and NaN in Sheen 2023-09-27 03:02:07 +02:00
Xavier Hallade
729e86d5a3 Cycles: oneAPI: fix perf regression by inlining svm_node_closure_bsdf
158dbc1b10 introduced a ~9% performance
regression on Intel GPUs, which we recover through this targeted change.

Pull Request: https://projects.blender.org/blender/blender/pulls/112878
2023-09-26 10:53:39 +02:00
Michael Jones
1c1c6ac457 Cycles: Fix last failing unit test (T39823) on MetalRT
This PR fixes T39823, the sole failing unit test when running with MetalRT.  It does so by implementing and binding a missing intersection handler (`__anyhit__cycles_metalrt_volume_test_tri`) which is required for `scene_intersect_volume` (as used by `integrator_volume_stack_update_for_subsurface`) to work as intended. This scene exposed the error as it uses subsurface scattering on a sphere which is intersected by volume.

Pull Request: https://projects.blender.org/blender/blender/pulls/112876
2023-09-25 22:41:27 +02:00
Brecht Van Lommel
3d38b51435 Shaders: add "Weight" to Transmission/Subsurface/Coat/Sheen socket names
Ref #99447
Ref #112848
2023-09-25 19:51:27 +02:00
Brecht Van Lommel
1d265eed5d Shaders: rename Specular to Specular IOR Level in Principled BSDF
To clarify that this is no longer the primary control, but rather
and adjustment on IOR.

Ref #99447
Ref #112552
2023-09-25 19:51:22 +02:00
Alaska
a03ee1af81 Shaders: clamp various shader inputs for Principled BSDF
Ref #99447

Pull Request: https://projects.blender.org/blender/blender/pulls/112774
2023-09-25 19:51:12 +02:00
Lukas Stockner
6e2f29b421 Shader: change Specular input on Principled BSDF to affect IOR
This keeps the behavior similar to the Disney BRDF, where 0.5
is neutral and lower/higher values respectively decrease/increase
the dielectric specular. But it's more correct in that it's not
an arbitrary scale on Fresnel, but rather adjusting the IOR.

Ref #99447
Ref #112848

Pull Request: https://projects.blender.org/blender/blender/pulls/112552
2023-09-25 19:51:02 +02:00
Brecht Van Lommel
3e3bdc9b89 Shader: rename subsurface scattering methods and change default
Clarify that one was specifically designed for skin shading.

Ref #99447
Ref #112848
2023-09-25 19:50:50 +02:00
Brecht Van Lommel
334027063e Shader: use single Principled BSDF input for metallic and specular tint
To match Standard Surface and OpenPBR.

Ref #99447
Ref #112848
2023-09-25 19:50:44 +02:00
Brecht Van Lommel
ca5f1c0f00 Shaders: rename Principled BSDF Emission to Emission Color
Ref #99447
Ref #112848
2023-09-25 19:50:41 +02:00
Weizhen Huang
def9b76207 Shader: Change specular tint in Principled BSDF from float to color
For more artistic control. Tints the reflection of dielectric materials
at normal incidence.

Ref #99447

Pull Request: https://projects.blender.org/blender/blender/pulls/112192
2023-09-25 19:42:05 +02:00
Lukas Stockner
86156566a7 Cycles: Add Metallic Tint to Principled BSDF using F82-Tint model
With the default value, this is backwards-compatible.

Ref #99447

Pull Request: https://projects.blender.org/blender/blender/pulls/112551
2023-09-25 19:42:05 +02:00
Lukas Stockner
7eead8912d Fix Cycles OSL potentially skipping closures when using layering
Pull Request: https://projects.blender.org/blender/blender/pulls/112213
2023-09-25 19:42:05 +02:00
Campbell Barton
e38ff7c06d Cleanup: use C++ comments for disabled code 2023-09-25 17:06:04 +10:00
Campbell Barton
2721b937fb Cleanup: use braces in headers 2023-09-24 14:52:38 +10:00
Brecht Van Lommel
eadb4ad54d Cleanup: compiler warning 2023-09-21 20:10:01 +02:00
Weizhen Huang
cae90106ac Fix: Cycles: assert error in microfacet BSDF
due to assigning values to `*eval` and `*pdf` when the label is `LABEL_NONE`.
2023-09-19 15:02:47 +02:00
Campbell Barton
d8b8089630 Cleanup: spelling & typo in last commit 2023-09-19 15:53:51 +10:00
Weizhen Huang
05c053cd25 Cycles: make transmission color in Pricipled BSDF match the base color
since the color is applied both at entry and exit, using the square root
of the color would make the perceived color closer to the desired one.
This also makes the transition smoother when changing the `Transmission`
value in the UI, and matches the behaviour of EEVEE.
2023-09-18 18:18:49 +02:00
Weizhen Huang
e894e6a411 Fix: Cycles: wrong refractive index in path guiding
should be the relative IOR of the outgoing media to the incoming media,
depending on `bsdf->ior` and whether the interaction is refraction.
Reference paper: [Robust Fitting of Parallax-Aware Mixtures for Path Guiding](https://uni-tuebingen.de/fakultaeten/mathematisch-naturwissenschaftliche-fakultaet/fachbereiche/informatik/lehrstuehle/computergrafik/lehrstuhl/veroeffentlichungen/robust-fitting-of-parallax-aware-mixtures-for-path-guiding/) Eq (35)

Pull Request: https://projects.blender.org/blender/blender/pulls/112157
2023-09-18 16:20:48 +02:00
Weizhen Huang
57990ec3fc Refactor: Cycles: adjust microfacet lobe selection pdf by tint
Now that there are different Fresnel types and the reflectance can be tinted,
it is better to sample based on the actually used Fresnel type, instead of
the original Fresnel. This also avoids computing Fresnel multiple times.

Pull Request: https://projects.blender.org/blender/blender/pulls/112158
2023-09-18 15:32:46 +02: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
Jacques Lucke
c001fbb623 Cleanup: fix debug build 2023-09-16 10:58:43 +02:00
Lukas Stockner
5939810b3c Cycles: Remove unused Normal input on Hair BSDF
This was causing a warning when using OSL, since the OSL implementation
didn't implement the input.
Since the socket isn't really implemented on the Blender side anyways,
just get rid of it.

Also, the SVM code uses the shading normal while OSL used the geometric normal.
2023-09-16 03:29:46 +02:00
Lukas Stockner
c963e22a0c Cycles: Fix Geometry node Tangent output for curves when using OSL 2023-09-16 03:29:46 +02:00
Lukas Stockner
02ace97df7 Cycles: Also use maybe_ensure_valid_specular_reflection for OSL
The SVM logic was changed a while ago to not adjust normals for curves,
but this wasn't applied to OSL as well, causing differences in SVM/OSL renders.
2023-09-16 03:29:46 +02:00
Lukas Stockner
1b92284f86 Cycles: Pack Chiang Hair local coordinates into BSDF normal field
This has two main advantages: First, it allows to get rid of the extra closure
since the remaining float can just be moved to the main closure allocation.
Second, previously sd->N was completely unused and therefore unintialized,
which ended up causing issues for the Normal render pass.
2023-09-16 03:29:46 +02:00
Campbell Barton
b7f3e0d84e Cleanup: spelling & punctuation in comments
Also remove some unhelpful/redundant comments.
2023-09-14 13:25:24 +10:00
Lukas Stockner
26ed117049 Cycles: Fix OSL layering in combination with emission evaluation
When evaluating emission, no closures can be allocated, so the existing code
would end up returning albedo 1.0, which then caused the layering code to set
the weight of lower layers to zero.
2023-09-14 04:22:22 +02:00
Lukas Stockner
c082e43f1e Cycles: Specify roughness for Subsurface OSL node
The Subsurface node doesn't expose this option yet, so follow SVM and set it
to 1.0 for now.
2023-09-14 04:21:43 +02:00
Lukas Stockner
65d56143ab Cycles: Don't invert backfacing IOR in generalized_schlick_bsdf
SVM doesn't do this, neither does the OSL testrender from what I can tell, and
in other cases we already handle the inversion on the OSL side if needed.
2023-09-14 04:13:56 +02:00
Harley Acheson
092b568a90 Cleanup: Make format
Formatting changes resulting from Make Format
2023-09-13 11:03:43 -07:00
Michael Jones
6c98cb73ac Cycles: Use new MetalRT curve primitives for 3D curves and ribbons
This patch updates the experimental MetalRT code path to use new [curve primitives](https://developer.apple.com/videos/play/wwdc2023/10128/) which were recently added in macOS 14. This replaces the previous custom box intersection implementation, allowing the driver to better optimise curve acceleration structures for the GPU. On existing hardware, this can speed up MetalRT renders by up to 40% for scenes that use hair / curve primitives extensively.

The MetalRT option will only be available on macOS >= 14, and requires Xcode >= 15 to build (otherwise the option will be compiled out).

Authored by Marco Giordano, Michael Jones, and Jason Fielder

---
Before / after render times (M1 Max MacBook Pro, macOS 14 beta, MetalRT enabled):
```
                  Custom box intersection      MetalRT curve primitives       Speedup
fishy_cat           111.5                         80.5                         1.39
koro                114.4                         86.7                         1.32
sinosauropteryx     291.8                        279.2                         1.05
spring              142.3                        142.2                         1.00
victor              442.7                        347.7                         1.27
```

---

Pull Request: https://projects.blender.org/blender/blender/pulls/111795
2023-09-13 16:02:49 +02:00
Lukas Stockner
e6296acdba Cycles: Only compute Coat Normal if needed 2023-09-13 03:16:43 +02:00
Lukas Stockner
4c229070a9 Cycles: Rework Principled BSDF Emission
- Changes defaults from Emission Color 0.0, Emission Strength 1.0 to be the
  other way around (Color 1.0, Strength 0.0), suggested by @brecht
- Makes emission component occluded by sheen and coat
  (to simulate e.g. dust-covered light sources)
- Moves transparency into the Principled SVM/OSL node, to allow for future
  support for e.g. transparent shadows in thin sheet mode.

Note that there are optimization opportunities here (mostly skipping the
non-transparent components for transparent shadow evaluation, and skipping
the parts that don't affect emission for light evaluation), but I have a
separate point for those in the Principled V2 planning since there's some
other optimization topics as well.

Co-authored-by: Weizhen Huang <weizhen@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/111155
2023-09-13 03:05:27 +02:00
Lukas Stockner
d7aee5a580 Cycles: Tweak Principled BSDF Subsurface parameters
Previously, the Principled BSDF used the Subsurface input to scale the radius.
When it was zero, it used a diffuse closure, otherwise a subsurface closure.
This sort of scaling input makes sense, but it should be specified in distance
units, rather than a 0..1 factor, so this commit changes the unit and renames
the input to Subsurface Scale.

Additionally, it adds support for mixing diffuse and subsurface components.
This is part of e.g. the OpenPBR spec, and the logic behind it is to support
modeling e.g. dirt or paint on top of skin. Before, materials would be either
fully diffuse (radius=0) or fully subsurface.

For typical materials, this mixing factor will be either zero or one
(just like metallic or transmission), but supporting fractional inputs makes
sense for e.g. smooth transitions at boundaries.

Another change is that there is no separate Subsurface Color anymore - before,
this was mixed with the Base Color using the Subsurface input as the factor,
but this was not really useful since that input was generally very small.

And finally, the handling of how the path enters the material for random walk
subsurface scattering is changed. Before, this always used lambertian (diffuse)
transmission, but this caused some problems, like overly white edges.

Instead, two different methods are now used, depending on the selected mode.
In Fixed Radius mode, the code assumes a simple medium boundary, and performs
refraction into the material using the main Roughness and IOR inputs.

Meanwhile, when not using Fixed Radius, the code assumes a more complex
boundary (as typically found on organic materials, e.g. skin), so the entry
bounce has a 50/50 chance of being either diffuse transmission or refraction
using the separate Subsurface IOR input and a fixed roughness of 1.
Credit for this method goes to Christophe Hery.

Pull Request: https://projects.blender.org/blender/blender/pulls/110989
2023-09-13 02:45:33 +02:00
Lukas Stockner
158dbc1b10 Cycles: Rework Principled BSDF Clearcoat
- Adds tint control, which simulates volumetric absorption inside the coating.
  This results in angle-dependent saturation and affects all underlying layers
  (diffuse, subsurface, metallic, transmission). It provides a physically-based
  alternative to ad-hoc effects such as tinted specular highlights.
- Renames the component from "Clearcoat" to "Coat", since it's no longer
  necessarily clear now. This matches naming in e.g. other renderers or OpenPBR.
- Adds an explicit Coat IOR input, in preparation for future smarter IOR logic
  around the interaction between Coat and main IOR. This used to be hardcoded
  to 1.5.
- Removes hardcoded 0.25 weight multiplier, and adds versioning code to update
  existing files accordingly. OBJ import/export still applies the factor.
- Replaces the GTR1 microfacet component with regular GGX. This removes a corner
  case in the Microfacet code, solves #53038, and makes us more consistent with
  other standard surface shaders. The original Disney BSDF used GTR1, but it
  doesn't appear that it caught on in the industry.

Co-authored-by: Weizhen Huang <weizhen@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/110993
2023-09-13 00:03:11 +02:00
Lukas Stockner
825cc14e74 Cleanup: Cycles: Remove unused argument 2023-09-10 18:58:43 +02:00
Weizhen Huang
063a9e8964 Fix: Cycles: inconsistent normal checks when sampling and evaluating BSDF
was mixing real geometry normal, smoothed geometry normal and
bump-mapped normal.
Use `(sd->type & PRIMITIVE_CURVE) ? sc->N : sd->Ng` consistently instead.
2023-09-08 19:00:01 +02:00
Weizhen Huang
4c6164e292 Cleanup: fix typo in path guiding code 2023-09-08 17:17:12 +02:00
Weizhen Huang
1b7d41eba7 Cleanup: add TODOs in bsdf_microfacet.h 2023-09-08 16:53:26 +02:00
Weizhen Huang
f96b9db610 Cleanup: remove redundant fresnel_dielectric()
We already have two other functions doing very much the same thing.
`bsdf_microfacet_sample()` seems to be the only place where this
function was used; there we always sample visible normals, so the extra
`inside` check is not needed.
2023-09-08 16:53:12 +02:00
Weizhen Huang
21ca47d81f Cleanup: rearrange code in bsdf_microfacet.h for better readability
1. move early-out logic even earlier
2. reduced the scope of some variables
3. return `label` at the end of `bsdf_microfacet_sample()`. Return
`LABEL_NONE` in the invalid case. The previous distinction was
unnecessary because samples with zero contribution are assigned with
`LABEL_NONE` in `integrate_surface_bsdf_bssrdf_bounce()` anyway.
2023-09-08 16:52:59 +02:00
Weizhen Huang
bf82f9442c Cycles: remove defensive sampling in BSDF picking
the motivation was to give closures with low weight a higher pdf to pick
at the first bounce, in case the next interaction has high contribution.
However, there are several issues:

1. this is too much fine-tuned for a specific case, and only works well
when there is a strong contribution after reflection and very little
contribution after the transmission;
2. the logic in `bsdf_microfacet.h` was added when merging reflection
and refraction into a glass closure, since then it doesn't even work
well in the above case when mixed with other closures;
3. The behavior is inconsistent in `bsdf_microfacet_eval()` and
`bsdf_microfacet_sample()`;
4. such cases should be handled by more modern and more general methods
such as path guiding and denoiser;
5. it makes the code flow harder to follow

Delete this trick for now to pick the closures solely based on their
`sample_weight`. Can be added back (with proper fix in
`bsdf_microfacet`) if indeed necessary.
2023-09-08 16:52:42 +02:00