Commit Graph

13196 Commits

Author SHA1 Message Date
Campbell Barton
f13f61df98 GHOST/Wayland: follow SDL's method of XDG window initialization
Using SDL's initialization logic, this is mainly a change for XDG
as LIBDECOR already required a configure event before accessing
the underlying XDG window.

While I didn't notice functional changes with this change window
flickering on startup remains an issue with some compositors
(KDE & river). Debugging these issues is simpler when both windowing
decoration systems work in a similar way & window configuration
is guaranteed to have run before the window is returned.
(via #xdg_surface_ack_configure).
2023-09-22 12:43:22 +10:00
Brecht Van Lommel
eadb4ad54d Cleanup: compiler warning 2023-09-21 20:10:01 +02:00
Jeroen Bakker
e93bf13626 Windows: Update Min OpenGL Version
https://archive.blender.org/developer/D13885 has added several
messages that mentioned OpenGL 3.3 as minimum requirement.
Blender 4.0 requires OpenGL 4.3 and this PR updates these messages.

Pull Request: https://projects.blender.org/blender/blender/pulls/112575
2023-09-20 09:20:56 +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
Campbell Barton
085b094f18 Cleanup: use const arguments & variables 2023-09-19 11:09:20 +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
Jeroen Bakker
915256eb0a Vulkan: Enable Device Features for EEVEE-Next
This PR enabled device features that are required for EEVEE-Next.
Enabling these features would allow an initial screen drawn by
EEVEE-Next.

Note:
* Changes to EEVEE-Next after this commit, might require other changes
* Not all features are working, but a basic diffuse cube without shadows
  is.
* Vulkan views are not correct and leads to incorrect lighting.

Pull Request: https://projects.blender.org/blender/blender/pulls/112519
2023-09-18 13:54:02 +02:00
Hans Goudey
2fac2228d0 Cycles: Use Blender headers to access geometry data, avoid copy
Since 34b44878449d67a56fd2, attributes are always made mutable when
accessed from the RNA API. This can result in unnecessary copies, which
increases memory usage and reduces performance.

Cycles is the only user of the C++ RNA API, which we'd like to remove
in the future since it doesn't really make sense in the big picture.
Hydra is now a better alternative for external render engines.

To start that change and fix the unnecessary copies, this commit
moves to use Blender headers directly for accessing attribute and
other geometry data. This also removes the few places that still had
overhead from the RNA API after the changes ([0]) in 3.6. In a simple
test with a large grid, I observed a 1.76x performance improvement,
from 1.04 to 0.59 seconds to extract the mesh data to Cycles.

[0]: https://wiki.blender.org/wiki/Reference/Release_Notes/3.6/Cycles#Performance

Pull Request: https://projects.blender.org/blender/blender/pulls/112306
2023-09-18 02:50:09 +02:00
Campbell Barton
75afef1372 Cleanup: use braces for GHOST Cocoa *.mm sources 2023-09-17 09:16:09 +10: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
Sergey Sharybin
a53329fda7 Cleanup: Strict compiler warnings in Cycles Metal BVH
Pull Request: https://projects.blender.org/blender/blender/pulls/112406
2023-09-15 09:54:37 +02:00
Campbell Barton
635a4eac05 Fix delete key setting a control character in wmEvent::utf8_buf
The check for control characters didn't account for delete (127).
This wasn't noticeable in most cases as delete is mapped to delete text.
Pressing Shift-Delete would enter 127 control character in the
text-editor, 3D text & Python console. This happened X11 & Wayland,
I didn't check other platforms.
2023-09-15 16:01:00 +10: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
Ray Molenkamp
5f8dfa231d CMake: Fix building with WITH_VULKAN_BACKEND
Ghost uses vulkan in its public headers but none of the projects that
depend on ghost had the vulkan headers in its includes nor did
bf_intern_ghost expose this vulkan dependency itself publicly yet.

bf_windowmanager also did not express its dependency on
bf_intern_ghost yet used its headers.

this change fixes both issues.

Pull Request: https://projects.blender.org/blender/blender/pulls/112259
2023-09-12 15:07:41 +02:00
Campbell Barton
057c9364fc Cleanup: use braces around statements 2023-09-12 14:48:20 +10:00
Stefan Werner
d7f1e6fb12 Cycles: GPU denoising refactor
Moved more generic code from OptiX to GPU denoiser in order to reuse
it for OIDN GPU support.

Pull Request: https://projects.blender.org/blender/blender/pulls/112229
2023-09-11 17:09:23 +02:00
Jeroen Bakker
81c6eb9c7f Vulkan: Enable Shader Draw Parameters Support
Shader draw parameter support is needed for Workbench-next. (Almost) All
devices that we support also supports shader draw parameters. This PR
doesn't include a workaround for devices that don't have support.

For end-users this PR will allow workbench-next to render the object on
the correct location. Before this patch they were always drawn on the origin.

The catch is that OpenGL uses gl_InstanceID which always starts counting at 0.
Vulkan has gl_InstanceIndex which holds the correct instance number. By
subtracting the gl_InstanceIndex from gl_BaseInstance will get the correct
gl_InstanceID.

This patch also activates some device extensions to perform in shader printf
statements inside a shader. Documentation for this will be added to the dev
docs how to use them.

Pull Request: https://projects.blender.org/blender/blender/pulls/111461
2023-09-11 15:04:54 +02:00
Lukas Stockner
825cc14e74 Cleanup: Cycles: Remove unused argument 2023-09-10 18:58:43 +02:00
Lukas Stockner
e20f86547a Cycles: Fix compilation of the shader table precomputing tool 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
Xavier Hallade
7c9a02f138 Cycles: oneAPI: keep disabling use of copy engine with new compiler versions
Recent versions of DPC++ dropped using the environment variable
SYCL_PI_LEVEL_ZERO_USE_COPY_ENGINE_FOR_IN_ORDER_QUEUE=0 we were setting.
We're now also setting SYCL_PI_LEVEL_ZERO_USE_COPY_ENGINE=0 by default
to keep a consistent behavior.
2023-09-08 15:51:51 +02:00
Xavier Hallade
01931e213f Cycles: oneAPI: only export necessary symbols
The API for the kernels library is defined, there is no need to
export more than that. This change only affects linux since hidden
visiblity is the default on Windows.
2023-09-08 15:44:39 +02:00
Sergey Sharybin
4b217df080 Fix crash in Cycles when cancelling render during light tree building
The recursive building has an early output, which could leave the node
without the requested child initialized, causing the access to the left
child to crash later on in the builder function.

Simply add an extra is-canceled check to avoid access of possibly
non-initialized tree structure.

Pull Request: https://projects.blender.org/blender/blender/pulls/112132
2023-09-08 15:21:54 +02:00
Campbell Barton
9e41eccc6e Cleanup: spelling in comments 2023-09-08 17:12:29 +10:00
Campbell Barton
4fc5d287ac Cleanup: doxygen parameters, blank comment lines 2023-09-08 16:53:30 +10:00
Weizhen Huang
fedeaab30f Fix #112005: increase ray_sphere_intersect() precision
by doing the subtraction first and then take the dot product. This
offers higher precision than taking the dot product first and then
subtract the result, especially in the cases where the ray origin is
very far away from the sphere center.
2023-09-06 16:23:39 +02:00
ChengduLittleA
bf8d3c157a Fix #111820: Missing type casting in XrGraphicsBinding.cc
The line `oxr_binding.egl.getProcAddress = eglGetProcAddress` supposedly
needs a type casting for it to compile successfully under llvm16.

Pull Request: https://projects.blender.org/blender/blender/pulls/111915
2023-09-06 15:26:51 +02:00
Sergey Sharybin
7e4a51329b Fix shadow linking for Cycles Metal RT
The shadow intersection kernels needs to perform extra checks
to see whether object is really considered a blocker.

Pull Request: https://projects.blender.org/blender/blender/pulls/112012
2023-09-06 15:25:30 +02:00