Commit Graph

38 Commits

Author SHA1 Message Date
Brecht Van Lommel
d377ef2543 Clang Format: bump to version 17
Along with the 4.1 libraries upgrade, we are bumping the clang-format
version from 8-12 to 17. This affects quite a few files.

If not already the case, you may consider pointing your IDE to the
clang-format binary bundled with the Blender precompiled libraries.
2024-01-03 13:38:14 +01: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
Campbell Barton
24a8d6425a CMake: include missing files in source files 2023-08-24 11:51:25 +10:00
Brecht Van Lommel
6fa4519b98 Cycles: remove unnecessary transform parameters from lights
The transform matrix already specifies everything, no need to duplicate
this which can lead to mistakes.

Ref #110689
2023-08-11 17:41:06 +02:00
Nicolas Sourd
092251b1fd Fix Cycles Hydra render delegate ignoring the light falloff property
If the falloff is defined with a supported value, a LightFalloffNode is added
to the graph, instead of the default EmissionNode.

Pull Request: https://projects.blender.org/blender/blender/pulls/110690
2023-08-11 17:24:08 +02:00
Nicolas Sourd
23ce783f8d Fix Cycles Hydra render delegate not rendering spot lights
Because axisu and axisv were not initialized. The default null vector led
to NaN values in the lighting code.

Pull Request: https://projects.blender.org/blender/blender/pulls/110689
2023-08-11 17:23:36 +02:00
Campbell Barton
0caf227530 License headers: use SPDX-FileCopyrightText for *.inl and *.osl files 2023-08-04 13:24:17 +10:00
Brecht Van Lommel
f36d8eb064 Cycles Hydra: set background color depending if there are lights
So that there is some lighting when there are no lights in the scene,
and black when there are lights. This matches the behavior of other
Hydra renderers.

Ref #96731
2023-07-07 18:20:57 +02:00
Brecht Van Lommel
05c97df2de USD: improve light units conversion
* Use pi factor to convert between radiant flux and intensity
* Mark lights as normalized on export
* Add spot light export support
* Add treatAsPoint support for import and export
* Empirically match normalized distant light
* Fix wrong unnormalized point/sphere/disk light unit in Cycles

Overall it should be much closer now for all light types. Point and distant
light units are inconsistent between renderers, so not possible to match
everything there.

Ref #109404

Pull Request: https://projects.blender.org/blender/blender/pulls/109795
2023-07-07 18:20:39 +02:00
Campbell Barton
c12994612b License headers: use SPDX-FileCopyrightText in intern/cycles 2023-06-14 16:53:23 +10:00
Brecht Van Lommel
9419f5a289 Fix #107932: crash attempting to load invalid OpenVDB file path on macOS
Add catch all exceptions similar as was done for OpenEXR in #107184, and
also properly handle errors in Hydra delegate.
2023-05-24 17:47:27 +02:00
Campbell Barton
6859bb6e67 Cleanup: format (with BraceWrapping::AfterControlStatement "MultiLine") 2023-05-02 09:37:49 +10:00
Brecht Van Lommel
b288c4004e Cleanup: fix various Cycles compilar warnings
Mainly for the build configuration of the Hydra render delegate and
standalone repo.
2023-04-05 19:48:19 +02:00
Brecht Van Lommel
861debcb10 Fix Cycles standalone and Hydra build issues in some configurations
Bring the build in sync with the Cycles standalone repo.
2023-04-03 17:32:35 +02:00
Alex Fuller
4f0092c1ff Refactor: add native Cycles Normalize option on lights for Hydra
Make it a native Cycles light option instead of counter-acting the inverse
area calculation in Hydra.

Differential Revision: https://developer.blender.org/D16838
2023-04-03 17:23:46 +02:00
Alex Fuller
945579c203 Fix Cycles build issue with USD 23.02
HdRenderDelegate got a change with the interface, adding gpuSupported. It
currently is just a dummy implementation without checking for anything
GPU-related.

Differential Revision: https://developer.blender.org/D17207
2023-04-03 17:23:46 +02: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
Campbell Barton
6797de4e10 Cleanup: spelling in comments 2022-12-17 13:15:33 +11:00
Brecht Van Lommel
e4f9c50928 Fix T102990: OpenVDB files load very slow from network drives
The OpenVDB delay loading of voxel leaf data using mmap works poorly on network
drives. It has a mechanism to make a temporary local file copy to avoid this,
but we disabled that as it leads to other problems.

Now disable delay loading entirely. It's not clear that this has much benefit
in Blender. For rendering we need to load the entire grid to convert to NanoVDB,
and for geometry nodes there also are no cases where we only need part of grids.
2022-12-12 18:28:09 +01:00
Brecht Van Lommel
f627abea2d Fix Cycles Hydra build issue with USD 22.05
Thanks to Alex Fuller for proposing the solution.
2022-12-07 18:34:57 +01:00
Thomas Lindemeier
d70ef8dbf1 Fix Cycles Hydra segmentation fault in usdview
Ensure render buffer is allocated when calling WritePixels.

Differential Revision: https://developer.blender.org/D16272
2022-12-07 18:34:57 +01:00
Brecht Van Lommel
904cab0418 Fix Cycles Hydra build errors
Still initializing GLEW after libepoxy switch, and ellipse area light.
2022-12-07 18:34:27 +01:00
Campbell Barton
bfca876c05 CMake: cleanup, rename INC_HD_CYCLES to SRC_HD_CYCLES_HEADERS
Our convention is to use `INC_*` for include directories,
this caused `make check_cmake` to incorrectly fail as it expected
these files to be include directories.
2022-08-27 14:32:50 +10:00
Sebastian Parborg
8ffc11dbcb Cleanup OpenGL linking and related code after libepoxy merge
This cleans up the OpenGL build flags and linking.
It additionally also removes some dead code.

One of these dead code paths is WITH_X11_ALPHA which actually never was
active even with the build flag on. The call to use this was never
called because the default initializer for GHOST was set to have it off
per default. Nothing called this function with a boolean value to enable it.

These cleanups are needed to support true headless OpenGL rendering.
Without these cleanups libepoxy will fail to load the correct OpenGL
Libraries as we have already linked them to the blender binary.

Reviewed By: Brecht, Campbell, Jeroen

Differential Revision: http://developer.blender.org/D15554
2022-08-15 16:47:20 +02:00
Christian Rauch
a296b8f694 GPU: replace GLEW with libepoxy
With libepoxy we can choose between EGL and GLX at runtime, as well as
dynamically open EGL and GLX libraries without linking to them.

This will make it possible to build with Wayland, EGL, GLVND support while
still running on systems that only have X11, GLX and libGL. It also paves
the way for headless rendering through EGL.

libepoxy is a new library dependency, and is included in the precompiled
libraries. GLEW is no longer a dependency, and WITH_SYSTEM_GLEW was removed.

Includes contributions by Brecht Van Lommel, Ray Molenkamp, Campbell Barton
and Sergey Sharybin.

Ref T76428

Differential Revision: https://developer.blender.org/D15291
2022-08-15 16:10:29 +02:00
Patrick Mours
34f94a02f3 Fix use of OpenGL interop breaking in Hydra viewports that do not support it
Rendering directly to a resource using OpenGL interop and Hgi
doesn't work in Houdini, since it never uses the resulting resource
(it does not call `HdRenderBuffer::GetResource`). But since doing
that simultaneously disables mapping (`HdRenderBuffer::Map` is
not implemented then), nothing was displayed. To fix this, keep
track of whether a Hydra viewport does support displaying a Hgi
resource directly, by checking whether
`HdRenderBuffer::GetResource` is ever called and only enable use
of OpenGL interop if that is the case.

Differential Revision: https://developer.blender.org/D15090
2022-06-03 18:56:30 +02:00
Patrick Mours
fc2c22e90c Cycles: Hydra fixes for stageMetersPerUnit and OpenGL context on Windows
Add "stageMetersPerUnit" render setting for USD files that have that set to
something other than the default (e.g. exported by Blender).

And fix a crash when an application creates a Hydra render pass on a thread
that does not have an OpenGL context current.
2022-04-29 19:19:39 +02:00
Brecht Van Lommel
9b92ce9dc0 Cycles: add USD as a file format for Cycles standalone rendering
Long term, this should replace the XML format. This reuses the Hydra render
delegate implementation, and so supports the same features. The same command
line options and GUI work for both XML and USD also.

The implementation of this is still disabled, waiting for some refactoring of
USD library linking. However we want the Cycles code to be in sync between
repositories for the 3.2 release.

Ref T96731
2022-04-29 19:19:19 +02:00
Brecht Van Lommel
060a50a5f7 Cycles: refactor Hydra render delegate building
* Leave code for building the render delegate against other applications and
  their USD libraries to the Cycles repository, since this is not a great fit.
  In the Blender repository, always use Blender's USD libraries now that they
  include Hydra support.
* Hide non-USD symbols from the hdCycles shared library, to avoid library
  version conflicts.
* Share Apple framework linking between the standalone app and plugin.
* Add cycles_hydra module, to be shared between the standalone app and plugin.
* Bring external libs code in sync with standalone repo, adding various missing
  libraries.
* Move some cmake include directories to the top level cycles source folder
  because we need to control their global order, to ensure we link against the
  correct headers with mixed Blender libraries and external USD libraries.
2022-04-29 19:03:06 +02:00
Brecht Van Lommel
a6f951b464 Cycles: make Hydra display driver optional, for USD without OpenGL
OpenGL support was removed from Blender's USD precompiled libraries. This
is currently only useful when building against other applications anyway.
2022-04-29 18:08:41 +02:00
Brecht Van Lommel
0c317e23bf Cleanup: fix various Cycles build warnings with non-default options
* Float/double promotion warnings were mainly meant for avoiding slow
  operatiosn in the kernel. Limit it to that to avoid hard to fix warnings
  in Hydra.
* Const warnings in Hydra iterators.
* Unused variable warnings when building without glog.
* Wrong camera enum comparisons in assert.
* PASS_UNUSED is not a pass type, only for pass offsets.
2022-04-29 17:39:04 +02:00
Patrick Mours
c31b89e76e Cycles: Add support for "stageMetersPerUnit" Hydra render setting
This can be useful to match transforms to what native Cycles
would see in Blender, as USD typically uses centimeters, but
Blender uses meters. This patch also fixes the hardcoded focal
length multiplicator, which is now using the same units as
everything else. Default of "stageMetersPerUnit" is 0.01 to match
the USD default of centimeters.

Differential Revision: https://developer.blender.org/D14630
2022-04-13 12:24:21 +02:00
Brecht Van Lommel
0de0950ad5 Cycles: various Linux build fixes related to Hydra render delegate
* Add missing GLEW and hgiGL libraries for Hydra
* Fix wrong case sensitive include
* Fix link errors by adding external libs to static Hydra lib
* Work around weird Hydra link error with MAX_SAMPLES
* Use Embree by default for Hydra
* Sync external libs code with standalone
* Update version number to match Blender
* Remove unneeded CLEW/GLEW from test executable

None of this should affect Cycles in Blender.

Ref T96731
2022-04-07 19:52:53 +02:00
Campbell Barton
792a481bee Cleanup: clang-format 2022-04-07 14:34:51 +10:00
Patrick Mours
f60cffad38 Cycles: Use USD dependencies when building Hydra render delegate
Adds support for linking with some of the dependencies of a USD
build instead of the precompiled libraries from Blender, specifically
OpenSubdiv, OpenVDB and TBB. Other dependencies keep using the
precompiled libraries from Blender, since they are linked statically
anyway so it does't matter as much. Plus they have interdependencies
that are difficult to resolve when only using selected libraries from
the USD build and can't simply assume that USD was built with all
of them.

This patch also makes building the Hydra render delegate via the
standalone repository work and fixes various small issues I ran into
in general on Windows (e.g. the use of both fixed paths and
`find_package` did not seem to work correctly). Building both the
standalone Cycles application and the Hydra render delegate at the
same time is supported now as well (the paths in the USD plugin JSON
file are updated accordingly).

All that needs to be done now to build is to specify a `PXR_ROOT`
or `USD_ROOT` CMake variable pointing to the USD installation,
everything else is taken care of automatically (CMake targets are
loaded from the `pxrTargets.cmake` of USD and linked into the
render delegate and OpenSubdiv, OpenVDB and TBB are replaced
with those from USD when they exist).

Differential Revision: https://developer.blender.org/D14523
2022-04-05 17:23:52 +02:00
Dalai Felinto
7a028330d2 Cleanup: clang-format 2022-03-24 11:01:12 +01:00
Patrick Mours
5d38b13e61 CMake: Rename "USD_LIBRARY_PREFIX" to "PXR_LIB_PREFIX" for consistency
rBc1909770e7f192574ea62449dd14b4254637e604 introduced "PXR_LIB_PREFIX" for building the
dependencies, so only makes sense to use the same name in the Hydra render delegate CMake too
2022-03-23 16:52:02 +01:00
Patrick Mours
d350976ba0 Cycles: Add Hydra render delegate
This patch adds a Hydra render delegate to Cycles, allowing Cycles to be used for rendering
in applications that provide a Hydra viewport. The implementation was written from scratch
against Cycles X, for integration into the Blender repository to make it possible to continue
developing it in step with the rest of Cycles. For this purpose it follows the style of the rest of
the Cycles code and can be built with a CMake option
(`WITH_CYCLES_HYDRA_RENDER_DELEGATE=1`) similar to the existing standalone version
of Cycles.

Since Hydra render delegates need to be built against the exact USD version and other
dependencies as the target application is using, this is intended to be built separate from
Blender (`WITH_BLENDER=0` CMake option) and with support for library versions different
from what Blender is using. As such the CMake build scripts for Windows had to be modified
slightly, so that the Cycles Hydra render delegate can e.g. be built with MSVC 2017 again
even though Blender requires MSVC 2019 now, and it's possible to specify custom paths to
the USD SDK etc. The codebase supports building against the latest USD release 22.03 and all
the way back to USD 20.08 (with some limitations).

Reviewed By: brecht, LazyDodo

Differential Revision: https://developer.blender.org/D14398
2022-03-23 16:39:05 +01:00