Commit Graph

10835 Commits

Author SHA1 Message Date
Campbell Barton c5a13ffcb4 Cleanup: spelling in comments 2021-10-18 12:13:10 +11:00
Brecht Van Lommel b66b3f547c Fix T92032: Cycles panoramic cameras do not support shift 2021-10-15 18:25:45 +02:00
Charlie Jolly 78b5050ff4 Cycles: Voronoi noise, fix uninitialised variable
Caused a debug crash in Windows MSVS.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D12873
2021-10-15 15:01:10 +01:00
Brecht Van Lommel 2f36762def Cleanup: refactor BVH2 shadow intersection for upcoming changes 2021-10-15 15:42:44 +02:00
Brecht Van Lommel 5d565062ed Cleanup: refactor OptiX shadow intersection for upcoming changes 2021-10-15 15:42:44 +02:00
Brecht Van Lommel 509b637d59 Cleanup: don't copy constant memory to GPU multiple times for displacement 2021-10-15 15:42:44 +02:00
Brecht Van Lommel eb71157e2a Cleanup: add utility functions for packing integers 2021-10-15 15:42:44 +02:00
Brecht Van Lommel 2ba7c3aa65 Cleanup: refactor to make number of channels for shader evaluation variable 2021-10-15 15:42:44 +02:00
Brecht Van Lommel 70376154a0 Fix Cycles Python error with pinned materials in properties editor 2021-10-15 15:42:44 +02:00
Brecht Van Lommel 53f25df5bc Fix T92128: Cycles CUDA wrong hair attributes, after recent changes 2021-10-15 15:42:44 +02:00
Michael Jones a0f269f682 Cycles: Kernel address space changes for MSL
This is the first of a sequence of changes to support compiling Cycles kernels as MSL (Metal Shading Language) in preparation for a Metal GPU device implementation.

MSL requires that all pointer types be declared with explicit address space attributes (device, thread, etc...). There is already precedent for this with Cycles' address space macros (ccl_global, ccl_private, etc...), therefore the first step of MSL-enablement is to apply these consistently. Line-for-line this represents the largest change required to enable MSL. Applying this change first will simplify future patches as well as offering the emergent benefit of enhanced descriptiveness.

The vast majority of deltas in this patch fall into one of two cases:

- Ensuring ccl_private is specified for thread-local pointer types
- Ensuring ccl_global is specified for device-wide pointer types

Additionally, the ccl_addr_space qualifier can be removed. Prior to Cycles X, ccl_addr_space was used as a context-dependent address space qualifier, but now it is either redundant (e.g. in struct typedefs), or can be replaced by ccl_global in the case of pointer types. Associated function variants (e.g. lcg_step_float_addrspace) are also redundant.

In cases where address space qualifiers are chained with "const", this patch places the address space qualifier first. The rationale for this is that the choice of address space is likely to have the greater impact on runtime performance and overall architecture.

The final part of this patch is the addition of a metal/compat.h header. This is partially complete and will be extended in future patches, paving the way for the full Metal implementation.

Ref T92212

Reviewed By: brecht

Maniphest Tasks: T92212

Differential Revision: https://developer.blender.org/D12864
2021-10-14 16:14:43 +01:00
Sergey Sharybin aa46459543 Fix shadow catcher behind transparent object on GPU
The assumption about absent shadow path was wrong.

The rest of the changes are to ensure shadow paths are finished prior
to the split, so that they write to the proper passes.

The issue was caught by running regression tests on OptiX.

Differential Revision: https://developer.blender.org/D12857
2021-10-14 09:39:38 +02:00
Sergey Sharybin f71d479556 Fix Cycles viewport after session reset
Happens i.e. when changing compute device.

A more proper follow-up to the on-demand display driver creation change.
2021-10-13 12:01:18 +02:00
Sergey Sharybin 86536e7859 Fix Cycles assert in viewport after recent change
Create display early on, so that ready_to_reset() passes assert test
for use for display actually configured.
2021-10-13 11:46:38 +02:00
Sergey Sharybin f12513a21c Fix Cycles backing issues when using multiple devices
The pixel accessor was not aware of possible offset in the
pixel padding causing some slices of the result not being
properly padded.
2021-10-13 11:20:25 +02:00
Sergey Sharybin 9c412b6e2d Fix possible integer overflow in Cycles baking
Ensure math happens on size_t type instead of int followed by a cast
to the size_t.
2021-10-13 11:20:25 +02:00
William Leeson 3021babf38 Fix: Stops assert when baking in debug mode.
When baking in a debug build running gdb it kept asserting because a GL context was being created outside the main thread.

To fix this the patch only creates the GL context is only created for rendering (when it is actually used).

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D12767
2021-10-13 11:09:22 +02:00
Clément Foucault ad80248875 Revert "GHOST: Unify behavior of offscreen context creation"
Commited by mistake

This reverts commit 6535779c92.
2021-10-12 17:54:52 +02:00
Clément Foucault 6535779c92 GHOST: Unify behavior of offscreen context creation
This makes sure the previously bound context is restored after creating a
new context. This follows what is already happening on windows.

All system backend are patched.

This also removes the goto and some code duplication.

Differential Revision: https://developer.blender.org/D12455
2021-10-12 16:47:41 +02:00
Sergey Sharybin cc04399937 Fix missing Cycles volume stack re-allocation
Need to check allocation size, as the features do not change with
volume stack depth detection.
2021-10-12 11:55:23 +02:00
Peter Kim 9dda65455b XR Controller Support Step 4: Controller Drawing
Addresses T77127 (Controller Drawing).

Adds VR controller visualization and custom drawing via draw
handlers. Add-ons can draw to the XR surface (headset display) and
mirror window by adding a View3D draw handler of region type 'XR' and
draw type 'POST_VIEW'.  Controller drawing and custom overlays can be
toggled individually as XR session options, which will be added in a
future update to the VR Scene Inspection add-on.

For the actual drawing, the OpenXR XR_MSFT_controller_model extension
is used to load a glTF model provided by the XR runtime. The model's
vertex data is then used to create a GPUBatch in the XR session
state. Finally, this batch is drawn via the XR surface draw handler
mentioned above.

For runtimes that do not support the controller model extension, a
a simple fallback shape (sphere) is drawn instead.

Reviewed By: Severin, fclem

Differential Revision: https://developer.blender.org/D10948
2021-10-12 16:18:05 +09:00
Campbell Barton c1c6c11ca6 Cleanup: spelling in comments 2021-10-12 17:55:02 +11:00
Jeroen Bakker 70fd6a313e GHOST: Add option to request (user) cache folder.
Introduces `BKE_appdir_folder_caches` to get the folder that
can be used to store caches. On different OS's different folders
are used.

- Linux: `~/.cache/blender/`.
- MacOS: `Library/Caches/Blender/`.
- Windows: `(%USERPROFILE%\AppData\Local)\Blender Foundation\Blender\Cache\`.

Reviewed By: Severin

Differential Revision: https://developer.blender.org/D12822
2021-10-12 08:42:25 +02:00
Brecht Van Lommel db851ccd2a Fix T92056: empty sampling pattern in Cycles when opening some existing files 2021-10-11 18:22:54 +02:00
Brecht Van Lommel a94343a8af Cycles: improve SSS Fresnel and retro-reflection in Principled BSDF
For details see the "Extending the Disney BRDF to a BSDF with Integrated
Subsurface Scattering" paper.

We split the diffuse BSDF into a lambertian and retro-reflection component.
The retro-reflection component is always handled as a BSDF, while the
lambertian component can be replaced by a BSSRDF.

For the BSSRDF case, we compute Fresnel separately at the entry and exit
points, which may have different normals. As the scattering radius decreases
this converges to the BSDF case.

A downside is that this increases noise for subsurface scattering in the
Principled BSDF, due to some samples going to the retro-reflection component.
However the previous logic (also in 2.93) was simple wrong, using a
non-sensical view direction vector at the exit point. We use an importance
sampling weight estimate for the retro-reflection to try to better balance
samples between the BSDF and BSSRDF.

Differential Revision: https://developer.blender.org/D12801
2021-10-11 18:22:54 +02:00
Brecht Van Lommel 73a05ff9e8 Cycles: restore Christensen-Burley SSS
There is not enough time before the release to improve Random Walk to handle
all cases this was used for, so restore it for now.

Since there is no more path splitting in cycles-x, this can increase noise in
non-flat areas for the sample number of samples, though fewer rays will be traced
also. This is fundamentally a trade-off we made in the new design and why Random
Walk is a better fit. However the importance resampling we do now does help to
reduce noise.

Differential Revision: https://developer.blender.org/D12800
2021-10-11 18:22:54 +02:00
Sergey Sharybin 4703e125bf Fix active pixels overlay for Cycles viewport
It got missed in some of previous development.

Can not see a reason why the line needed to be removed, maybe just some
accident.
2021-10-11 15:59:07 +02:00
Sergey Sharybin 275d0d3397 Cleanup: Spelling in comment 2021-10-11 14:01:42 +02:00
Sergey Sharybin eca2a41964 Cycles: Improve volume stack size calculation
Only count volume objects after shader optimization.

Allows to discard objects which don't have effective volume
BSDF connected to the shader output (i.e. constant folded,
or non-volume BSDF used by mistake).

Solves memory regression reported in T92014.

There is still possibility to improve memory even further
for cases when there are a lot of non-intersecting volume
objects, but that requires a deeper refactor of update
process. Will happen as a followup development.

Differential Revision: https://developer.blender.org/D12797
2021-10-11 14:01:42 +02:00
Sergey Sharybin 0ceded7bc9 Cycles: Introduce scene host_update function
The longer-term goal is to separate host-only scene update
from device update: make it possible to make kernel features
depend on actual scene state and flags.

This change makes it so shaders are compiled before kernel
load, making checks like "has_volume" available at the
kernel features calculation state.

No functional changes are expected at this point.

Differential Revision: https://developer.blender.org/D12795
2021-10-11 12:27:28 +02:00
Patrick Mours 3a65571195 Fix T90666: Toggling motion blur while persistent data is enabled results in artifacts
Enabling or disabling motion blur requires rebuilding the BVH of affected geometry and
uploading modified vertices to the device (since without motion blur the transform is
applied to the vertex positions, whereas with motion blur this is done during traversal).
Previously neither was happening when persistent data was enabled, since the relevant
node sockets were not tagged as modified after toggling motion blur.

The change to blender_object.cpp makes it so `geom->set_use_motion_blur()` is always
called (regardless of motion blur being toggled on or off), which will tag the geometry
as modified if that value changed and ensures the BVH is updated.
The change to hair.cpp/mesh.cpp was necessary since after motion blur is disabled,
the transform is applied to the vertex positions of a mesh, but those changes were not
uploaded to the device. This is fixed now that they are tagged as modified.

Maniphest Tasks: T90666

Differential Revision: https://developer.blender.org/D12781
2021-10-08 18:03:06 +02:00
Brecht Van Lommel 0c684a7046 Fix T91999: wrong Cycles updates with mesh deformation, after recent changes 2021-10-08 16:11:02 +02:00
Brecht Van Lommel 736be7cf58 Fix T91997: Cycles glass + SSS not rendering correctly 2021-10-08 16:11:02 +02:00
Sergey Sharybin f01c4f27f9 Fix Cycles speed regression after dynamic volume stack change
Only copy required part of volume stack instead of entire stack.

Solves time regression introduced by D12759 and avoids need in
implementing volume stack calculation to exactly match what the
path tracing will do (as well as potentially makes scenes with
a lot of volumes ans a tiny bit of deeply nested ones render
faster).

Still need to look into memory aspect of the regression, but
that is for separate patch.

Ref T92014

Maniphest Tasks: T92014

Differential Revision: https://developer.blender.org/D12790
2021-10-08 15:44:03 +02:00
Sergey Sharybin bd65d3ce97 Cleanup: Explicit specifier for single argument constructor 2021-10-08 10:01:20 +02:00
Sergey Sharybin 3284b5bbde Cleanup: Else after return in Cycles 2021-10-08 10:01:20 +02:00
Campbell Barton de07bf2b13 Cleanup: spelling 2021-10-08 13:23:19 +11:00
Brecht Van Lommel 23791db145 Fix Cycles random walk SSS differences between CPU and GPU
The Embree logic did not match the GPU.
2021-10-07 21:35:24 +02:00
Brecht Van Lommel 4ee97f129a Cleanup: remove unnecessary data from LocalIntersection 2021-10-07 21:35:24 +02:00
Sergey Sharybin 0d4c53ecfe Fix wrong tile size calculated in Cycles
Was causing extra overscan pixels, and was confusing multiple workers
check after fix T91994.
2021-10-07 16:21:28 +02:00
Sergey Sharybin 719c319055 Fix Cycles long start on scene without volumes
The state template iteration had difficult time dealing with 0-sized
arrays, causing iteration for until integer overflows.
2021-10-07 15:54:56 +02:00
Sergey Sharybin 123255be6b Fix T91994: Cycles crash when rendering on multiple devices
The overscan change from D12599 lacked proper handling of window
when slicing buffer for multiple devices.
2021-10-07 15:07:25 +02:00
Brecht Van Lommel 04857cc8ef Cycles: fully decouple triangle and curve primitive storage from BVH2
Previously the storage here was optimized to avoid indirections in BVH2
traversal. This helps improve performance a bit, but makes performance
and memory usage of Embree and OptiX BVHs a bit worse also. It also adds
code complexity in other parts of the code.

Now decouple triangle and curve primitive storage from BVH2.
* Reduced peak memory usage on all devices
* Bit better performance for OptiX and Embree
* Bit worse performance for CUDA
* Simplified code:
** Intersection.prim/object now matches ShaderData.prim/object
** No more offset manipulation for mesh displacement before a BVH is built
** Remove primitive packing code and flags for Embree and OptiX
** Curve segments are now stored in a KernelCurve struct
* Also happens to fix a bug in baking with incorrect prim/object

Fixes T91968, T91770, T91902

Differential Revision: https://developer.blender.org/D12766
2021-10-06 17:52:04 +02:00
Sergey Sharybin 0194e54fd3 Fix compilation error with MSVC
MSVC does not support variable size array definition.
Use maximum possible stack, similar to the GPU case.

Not expected to have user-measurable difference.
2021-10-06 16:51:07 +02:00
Sergey Sharybin c6275da852 Fix T91922: Cycles artifacts with high volume nested level
Make volume stack allocated conditionally, potentially based on the
actual nested level of objects in the scene.

Currently the nested level is estimated by number of volume objects.
This is a non-expensive check which is probably enough in practice
to get almost perfect memory usage and performance.

The conditional allocation is a bit tricky.

For the CPU we declare and define maximum possible volume stack,
because there are only that many integrator states on the CPU.

On the GPU we declare outer SoA to have all volume stack elements,
but only allocate actually needed ones. The actually used volume
stack size is passed as a pre-processor, which seems to be easiest
and fastest for the GPU state copy.

There seems to be no speed regression in the demo files on RTX6000.

Note that scenes with high nested level of volume will now be slower
but correct.

Differential Revision: https://developer.blender.org/D12759
2021-10-06 15:46:32 +02:00
Brecht Van Lommel 03f8c1abd0 Build: add ccache support for CUDA kernels on Linux 2021-10-06 14:21:26 +02:00
Brecht Van Lommel 18c6314e26 Cleanup: don't detect duplicate intersections in Embree
It's unclear why this code was added in the first place, but it seems
unnecessary, it can be restored if we find this breaks something.

The Embree docs mention that the same primitive may be hit multiple times, but
my understanding is that about e.g. curves where both the frontside and backside
may be hit. However those hits would be at different distances.

The context for this change is that we want to add an optimization where we
can immediately update throughput for transparent shadows instead of recording
intersections, and avoid duplicate would require extra work. However there is
an Embree example that does something similar without worrying about duplicate
hits either.
2021-10-06 14:21:11 +02:00
Mikhail Matrosov ca0450feef Fix T91064: Cycles low poly meshes having black edges when shade smoothed
Fixes:{T91064}

Caused by {rBcd118c5581f482afc8554ff88b5b6f3b552b1682}

- Applies `ensure_valid_reflection()` to the normal input on all BSDFs for CPU and GPU.
- This doesn't affect hair.
- Removes `ensure_valid_reflection()` from the output of Bump Map and Normal Map nodes for CPU/GPU as it is not needed.
- The fix doesn't touch OSL.

Reviewed By: brecht, leesonw

Maniphest Tasks: T91064

Differential Revision: https://developer.blender.org/D12403
2021-10-06 10:25:09 +02:00
Campbell Barton df8f507f41 Cleanup: spelling in comments 2021-10-06 14:54:05 +11:00
Jesse Yurkovich 76de3ac4ce Cleanup: Remove data duplication from various lookup tables in Cycles
This effectively undoes some of the following commit:
rB4537e8558468c71a03bf53f59c60f888b3412de2

The tables in question were duplicated 5-6 times into the blender
executable due to the headers being used in multiple translation units.
This contributes ~6.3kb worth of duplicate data into the binary.

Some further details are in the below revision.

Differential Revision: https://developer.blender.org/D12724
2021-10-05 19:09:01 -07:00