Commit Graph

1320 Commits

Author SHA1 Message Date
Omar Emara
b229d32086 Compositor: Port GPU Vector Blur to CPU
This patch ports the GPU Vector Blur node to the CPU, which is in turn
ported from EEVEE. This is a breaking change since it produces different
motion blur results that are more similar to EEVEE's motion blur.
Further, the Curved, Minimum, and Maximum options were removed on the
user level since they are not used in the new implementation.

There are no significant changes to the code, except in the max velocity
computation as well as the velocity dilation passes. The GPU code uses
atomic indirection buffers, while the CPU runs single threaded for the
dilation pass, since it is a fast pass anyways. However, we impose
artificial constraints on the precision of the dilation process for
compatibility with the atomic implementation.

There are still tiny differences between CPU and GPU that I haven't been
able to solve, but I shall solve them in a later patch.

Pull Request: https://projects.blender.org/blender/blender/pulls/120135
2024-04-05 09:48:03 +02:00
Sergey Sharybin
9efb8329a1 Cycles: Add regression test for light linking and mesh lights 2024-04-03 11:29:40 +02:00
Hans Goudey
03cc78de31 Tests: Add modifier tests for shrinkwrap target normal project
This code didn't have regression tests yet. Add tests for #120051,
with meshes with and without boundary edges.
2024-03-29 10:11:22 -04:00
Brecht Van Lommel
0334ce5666 Tests: Update references for EEVEE, Workbench, Storm 2024-03-28 16:29:26 +01:00
Omar Emara
db13fc01ad Compositor: Unify Defocus node between CPU and GPU
This patch unifies the Defocus node between the CPU and GPU compositors.
Both nodes now use a variable sized bokeh kernel which is always odd
sized for a center pixel guarantee. Further the CPU implementation now
properly handles half pixel offsets when doing interpolation, and always
sets the threshold to zero similar to the GPU implementation.
2024-03-28 14:35:13 +02:00
Omar Emara
042c50b65f Compositor: Unify Bokeh Image node between CPU and GPU
This patch unifies the CPU and GPU implementation for the Bokeh Image
node. The bokeh is now evaluated at the center of pixels and allows
different sizes for the output kernel.
2024-03-28 13:23:58 +02:00
Weizhen Huang
68253b4937 Fix: Cycles volume light tree using wrong point to compute uncertainty angle
it is not clear from which point the `cos_theta_u` should be computed in
volume segment, so the original implementation was mixing the closest point
and the point where the minimal angle is formed.
Use the closest point on segment as a conservative measure.

Pull Request: https://projects.blender.org/blender/blender/pulls/119965
2024-03-27 15:06:05 +01:00
Omar Emara
4d9678c483 Fix: Sun Beams node is off by half a pixel
The Sun Beams node is off by half a pixel. That's because we add a half
pixel offset to the initial coordinates, but then sample the texture
with the half pixel. To fix thus, use the texture_bilinear_extend
utility to sample the image, which takes care of the half pixel offset.
2024-03-27 12:49:21 +02:00
Omar Emara
5ae5614d1e Fix: Chroma Key differs from reference implementation
The GPU compositor Chroma Key node differs from the reference
implementation. This is caused by a typo, where the acceptance angle was
halved after computing tangent instead of before computing it.
2024-03-27 11:10:49 +02:00
Omar Emara
9aa63aa1e8 Fix: Lens Distortion node is off by half a pixel
The Lens Distortion node is off by half a pixel because their normalized
coordinates were at the pixel corners as opposed to their centers, where
this patch changes the behavior to the latter.
2024-03-27 09:04:34 +02:00
Omar Emara
aa208d3d18 Fix: Plane Deform nodes are off by half a pixel
The Plane Track and Corner Pin nodes are off by half a pixel because
their mask is computed at the pixel corners as opposed to their center,
where this patch changes the behavior to the latter.
2024-03-27 08:54:04 +02:00
Omar Emara
7113692206 Fix: Directional Blur node is off by half a pixel
The Directional Blur node is off by half a pixel because it transforms
the pixels at their corner as opposed to their center, where this patch
changes the behavior to the latter.
2024-03-27 08:50:44 +02:00
Omar Emara
6df333a3c7 Fix: Movie Distort node is off by half a pixel
The Movie Distort node is off by half a pixel because it evaluates the
distortion at the corner of pixels as opposed to their center, where
this patch changes the behavior to the latter.
2024-03-27 08:47:07 +02:00
Brecht Van Lommel
2fb4efc905 Fix: GPU test errors importing gpu module
Pull Request: https://projects.blender.org/blender/blender/pulls/119721
2024-03-26 20:16:02 +01:00
Jesse Yurkovich
9ae24fee48 USD: Add tests to cover curve, light, and point instancer import
The curve variations were used during development of the GeometrySet
changes.

The lights and point instancer coverage would have helped uncover bugs
earlier. Bugs that eventually had to be fixed in 4.1. Better late than
never.

The one downside is that the light tests is actually a round-trip test,
which is normally fine to do, except it technically does an export
during the import test.

Pull Request: https://projects.blender.org/blender/blender/pulls/119858
2024-03-26 18:58:46 +01:00
Omar Emara
5764173501 Compositor: Update tests for realtime compositor 2024-03-26 12:52:07 +02:00
Weizhen Huang
2c301c921f Tests: temporarily disable light tree in the new test file
seems to cause problem on other platforms
2024-03-25 19:43:14 +01:00
Weizhen Huang
fdc2962beb Fix #114634: correlated samples in volume when using equiangular sampling and light tree
The same random number was used when sampling from the volume segment
and from the direct scattering position, causing correlation issues with
light tree.

To solve this problem, we ensure the same light is picked for
volume segment/direct scattering, equiangular/distance sampling by
sampling the light tree only once in volume segment. From the direct
scattering position in volume, we sample a position on the picked light
as usual. If sampling from the light tree fails, we continue with
indirect scattering.
For unbiased MIS weight for forward sampling, we retrieve the `P`, `D`
and `t` used in volume segment for traversing the light tree.

The main changes are:
1. `light_tree_sample()` and `light_distribution_sample()` now only pick
lights. Sampling a position on light is done separately via
`light_sample()`.
2. `light_tree_sample()` is now only called only once from volume
segment. For direct lighting we call `light_sample()`.
3. `light_tree_pdf()` now has a template `<in_volume_segment>`.
4. A new field `emitter_id` is added to struct `LightSample`, which just
stores the picked emitter index.
5. Additional field `previous_dt = ray->tmax - ray->tmin` is added to
`state->ray`, because we need this quantity for computing the pdf.
6. Distant/Background lights are also picked by light tree in volume
segment now, because we have no way to pick them afterwards. The direct
sample event for these lights will be handled by
`VOLUME_SAMPLE_DISTANCE`.
7. Original paper suggests to use the maximal importance, this results
in very poor sampling probability for distant and point lights therefore
excessive noise. We have a minimal importance for surface to balance, we
could do the same for volume but I do not want to spend much time on
this now. Just doing `min_importance = 0.0f` seems to do the job
okayish. This way we still won't sample the light with zero
`max_importance`.

The current solution might perform worse with distance sampling, because
the light tree measure is biased towards equiangular sampling. However,
it is difficult to perform MIS between equiangular and distance sampling
if different lights are picked for each method. This is something we can
look into in the future if proved to be a serious regression.

Pull Request: https://projects.blender.org/blender/blender/pulls/119389
2024-03-25 18:50:52 +01:00
Weizhen Huang
082b68fcb9 Cycles: improve equiangular sampling in volume
By restricting the sample range along the ray to the valid segment.

Supports

**Mesh Light**
- [x] restrict the ray segment to the side with MIS

**Area Light**
- [x] when the spread is zero, find the intersection of the ray and the bounding box/cylinder of the rectangle/ellipse area light beam
- [x] when the spread is non-zero, find the intersection of the ray and the minimal enclosing cone of the area light beam
*note the result is also unbiased when we just consider the cone from the sampled point in volume segment. Far away from the light source it's less noisy than the current solution, but near the light source it's much noisier. We have to restrict the sample region on the area light to the part that lits the ray then, I haven't tried yet to see if it would be less noisy.*

**Point Light**
- [x] the complete ray segment should be valid.

**Spot Light**
- [x] intersect the ray with the spot light cone
- [x] support non-zero radius

Pull Request: https://projects.blender.org/blender/blender/pulls/119438
2024-03-25 13:02:02 +01:00
Jesse Yurkovich
e9eb2d35f8 USD: Add new test files for curves and point instancing 2024-03-24 21:49:55 -07:00
Lukas Stockner
1f44be97e6 Fix #56355: Cycles: Wrong differentials for panoramic camera
The code to compute differentials mixed up the camera-space locations
of the raster coordinate and the camera itself, which caused the dP
differential to be set even when the ray origin is always the same.

This commit fixes that, reorganizes the code so that the Px/Py are
no longer used for both values to avoid future confusion, and skips
some unnecessary calculations stereo rendering isn't being used.
2024-03-24 17:52:22 +01:00
Omar Emara
d5cf430a54 Compositor: Update tests for Hue Correct node 2024-03-21 16:41:30 +02:00
Campbell Barton
6a937d646b Cleanup: remove unused variables 2024-03-21 10:11:54 +11:00
Campbell Barton
9b4683fe0a Tests: update scripts to include SPDX headers 2024-03-20 12:28:33 +11:00
Habib Gahbiche
f9cb2eb988 Cleanup: Tests: update message to refer to git instead of svn
Pull Request: https://projects.blender.org/blender/blender/pulls/119577
2024-03-17 09:47:40 +01:00
Weizhen Huang
b280958372 Tests: update test image due to changes in Cycles NEE 2024-03-15 18:42:30 +01:00
Hans Goudey
a869bae1dc Merge branch 'blender-v4.1-release' 2024-03-15 11:50:04 -04:00
Hans Goudey
1111903416 Fix #119446: Incorrect auto smooth versioning for subsurf modifier
Previously I misunderstood the subsurf modifier's handling of custom
normals. The "use custom normals" check in 4.0 checked if there were
custom normals and whether the auto smooth flag was checked. I wrongly
changed that to check the mesh normals domain instead of whether there
was custom normals. In 4.1, auto smooth isn't required to use custom
normals, but that should be the only change here.

In this PR, that change is done for CPU and GPU subdivision, and for
the versioning which adds a modifier. The versioning now only puts the
new modifier before the subsurf modifier if it would have used the
custom normals interpolation in 4.0.

The last change causes two test failures which I also misunderstood
before. The previous results were arguably incorrect, because the
Cycles experimental adaptive subdivision ignored the auto smooth
angle, which was 5 degrees. It should have been 180 degrees.
I will modify those test files to remove auto smooth from the meshes.

Pull Request: https://projects.blender.org/blender/blender/pulls/119485
2024-03-15 11:32:50 -04:00
Ray Molenkamp
40411b609f tests: update hashes to latest
should fix the failing bots
2024-03-11 22:11:08 -06:00
Brecht Van Lommel
daf3512a51 Merge branch 'blender-v4.1-release' 2024-03-07 20:16:51 +01:00
Brecht Van Lommel
e0c6db81ea Tests: Blacklist microfacet hair test on GPU, due to different curve shape 2024-03-07 19:37:38 +01:00
Campbell Barton
a975c7096a Cleanup: line length in CMake files 2024-03-07 13:26:55 +11:00
Bastien Montagne
8178bffd64 Merge branch 'blender-v4.1-release' 2024-03-06 11:16:00 +01:00
Bastien Montagne
9bfa17e030 Cleanup: make format. 2024-03-06 11:15:27 +01:00
Bastien Montagne
7daedd3e02 Merge branch 'blender-v4.1-release' 2024-03-06 11:02:42 +01:00
Bastien Montagne
253a6e36de Core: Library Linking: Add basic tests that linked animation works.
The new test merely ensures basic Object animation (both through action
and driver) still works as expected with linked data.
2024-03-06 10:59:10 +01:00
Omar Emara
1bff17cc99 Compositor: Unify plane anti-aliasing between CPU and GPU
This patch unifies the anti-aliasing of plane deforms between the CPU
and GPU compositors. The CPU used a multi-sample approach, where the
mask was computed 8 times with a jitter, then averaged to get smooth
edges. The GPU relied on the anisotropic filtering with zero boundaries
to smooth the edges.

Furthermore, the CPU implementation ignored the anti-aliasing for the
deformed image and also relied anisotropic filtering like the GPU, so
its outputs were different.

To unify both implementation, we use the existing SMAA anti-aliasing
algorithm instead, and use the anti-aliased mask for the image output as
well. This affects both the Corner Pin and Plane Deform nodes.

A consequence of this change for the Plane Deform node is that motion
blur will appear to have less samples, that's because it was sampled
8-times more in the previous implementation. But users can just increase
the samples in the node to account for that.

Pull Request: https://projects.blender.org/blender/blender/pulls/118853
2024-02-29 12:30:16 +01:00
Omar Emara
56f8c1c0f6 Compositor: Unify variable size blur between CPU and GPU
This patch unifies the variable size blur between the CPU and GPU
compositor. The difference is due to how weights are computed and used.
The CPU computed a nested array of weights for every possible size, that
is, from size 1 to the base size. Then, it assumed the kernel was
separable and reconstructed a 2D kernel by selecting two 1D weights
array and multiplying them for every pixel of the blur window.

The GPU on the other hand computes a single quadrant of the 2D weights
kernel and sampled it directly in the blur window. We favor the GPU
implementation since it makes no assumptions about the separability of
the weights kernel and since the CPU has no performance advantage even
with the assumption in place.

Pull Request: https://projects.blender.org/blender/blender/pulls/118834
2024-02-29 11:08:49 +01:00
Omar Emara
aa17aca9ec Compositor: Use original variable size in Blur node
Currently, the CPU compositor smoothes its input size in variable size
mode. It is unclear why this is the case, but it seems the logic is that
sharp transitions in the size input are undesirable. Alternatively, this
is similar to the morphological blurring step in the Defocus node. But
it does not use standard weights and it is not morphological in nature
at all.

This patch removes the smoothing step and uses the original size
provided by the user. Looking at resources online, it seems users almost
always expect the size inputs to be used directly, so there is no reason
for force smooth their inputs.

Pull Request: https://projects.blender.org/blender/blender/pulls/118757
2024-02-29 10:57:18 +01:00
Campbell Barton
4f8db2ee67 Cleanup: use static sets for contains checks, remove f-string use 2024-02-28 11:02:49 +11:00
Bastien Montagne
bef276ab0b LibOverride: Cleanup unused&missing data after resync.
Often when the reference linked data is significantly modified, a lot of
'ghost' linked data remain referenced by liboverrides, even after
resync. This is due to the fact that missing data is ignored (skipped)
during resync process, to avoid potential destruction of data in case
the linked data is actually missing.

However, after all resync has been done, we can consider that missing
linked references and their liboverrides can be safely deleted, if the
later are not user-edited or hierarchy roots.
2024-02-27 16:43:31 +01:00
Lukas Tönne
b1636bc781 Fix #118769: Remove parent parameter from new_panel function
Nested panels are not supported currently, and this parameter serves no
actual purposes. Only the root panel supports adding child panels and it
is not user-accessible (adding the root panel is done using a nullptr
for the parent).

Pull Request: https://projects.blender.org/blender/blender/pulls/118792
2024-02-27 13:30:13 +01:00
Brecht Van Lommel
f9e8f2d857 Tests: Update EEVEE renders for motion blur and roughness changes 2024-02-26 14:46:44 +01:00
Brecht Van Lommel
5c7df5ef85 Tests: Update and add new workbench reference renders 2024-02-23 19:22:43 +01:00
Miguel Pozo
014979f9f2 Update shader math images 2024-02-23 16:53:39 +01:00
Weizhen Huang
95d11b0d33 Fix Cycles area light using MIS when the spread is zero
area light with zero spread was introduced in bf18032977. Such paths can
only be sampled with NEE, so MIS should not be used.
This fixes the discrepancy when Direct Light Sampling is set to MIS or NEE.

Pull Request: #118584
2024-02-23 12:40:48 +01:00
Weizhen Huang
f7c94754a0 Tests: Update microfacet hair reference render for changes 2024-02-23 12:36:55 +01:00
Campbell Barton
292b39b7f4 Tests: update default library path for batch blendfile loader 2024-02-23 14:57:05 +11:00
Weizhen Huang
a3f0ff6184 Cycles: make Principled Hair Huang a near- and far-field model
for a camera ray, compute the actual range of the hair width that the
current pixel covers, and only integrate that subset, to prevent a
ribbon-like appearance in close-up looks.
When the hair covers less than one pixel on the screen or when the ray
is not camera ray, the model works the same as before.

Pull Request: https://projects.blender.org/blender/blender/pulls/116094
2024-02-22 18:18:14 +01:00
Weizhen Huang
1d8ec32473 Fix Cycles area light using MIS when the spread is zero
area light with zero spread was introduced in bf18032977. Such paths can
only be sampled with NEE, so MIS should not be used.
This fixes the discrepancy when Direct Light Sampling is set to MIS or NEE.

Pull Request: https://projects.blender.org/blender/blender/pulls/118584
2024-02-22 17:10:46 +01:00