Commit Graph

126005 Commits

Author SHA1 Message Date
Weizhen Huang
ab12d2836b Cycles: add texture to sun light
Using area-preserving mapping from cone to disk. Has somewhat distortion
near 90°.
The texture rotates with the transformation of the light object, can
have negative and non-uniform scaling.

Pull Request: https://projects.blender.org/blender/blender/pulls/109842
2023-07-10 12:20:47 +02:00
Jeroen Bakker
fa4def46c8 Cleanup: Remove Unused use_ambient_occusion Property
`use_ambient_occlusion` is a legacy property and not
connected to anything. The clip editor still write
to it for enabling the ambient occlusion renderpass.

This change will remove the legaccy option and
won't enable ambient occlusion pass anymore due
to visual and performance impact.

Pull Request: https://projects.blender.org/blender/blender/pulls/109783
2023-07-10 11:18:22 +02:00
Jeroen Bakker
080ab8b8b6 Fix: Usage of Incorrect Compile Directive
The WITH_VULKAN_BACKEND/WITH_METAL_BACKEND should be included per
library. However when doing this we used an none existing compile
directive for WITH_METAL_BACKEND. This wasn't detected as
WITH_METAL_BACKEND is also defined globally.

Pull Request: https://projects.blender.org/blender/blender/pulls/109896
2023-07-10 10:43:28 +02:00
Jeroen Bakker
8199cce0c5 Fix: Reflection Probe Negative Shifting
When using many reflection probes with different subdivisions
it can happen that the reflection probe uses texture space that
is already been allocated for another probe.

The cause for that is that negative shift operations result into
undefined behavior, this was fixed previously by clamping the
number of bit shifts to perform, but ignoring to shift into the
other direction

This change also includes `ProbeLocationFinder.print_debug`
for future debugging.

Pull Request: https://projects.blender.org/blender/blender/pulls/109823
2023-07-10 10:30:52 +02:00
rBrenick
18efd11369 UI: Grey out ShapeKey list entry on mute
At a glance, it can be hard to see if a Shape Key has been muted or not.
This change greys out all the UI elements, instead of just the current value number.
All the functionality still works the same, purely a visual change.

Pull Request: https://projects.blender.org/blender/blender/pulls/109857
2023-07-10 10:20:09 +02:00
Sergey Sharybin
9314f97afd Fix #109887: Adding driver from python might crash
Originally was noticed when adding drivers to a rigid body., but
it could potentially happen with any configuration.

The reason for the crash was that the ID which was modified was
not tagged as such.

Modifying drivers from the interface are likely tagging for updates
from the operator. This change makes it so the python function also
does tagging.

It is not really how one would design the system nowadays, but it
is how the Blender historically handles such cases. A bigger refactor
is possible to move tags to the places where modification actually
happens, but it seems to be a better idea to tackle it as a separate
project which will be considered no-functional-changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/109895
2023-07-10 10:11:43 +02:00
Jeroen Bakker
998e7f644f Fix: Eevee-next Compiler issue NVIDIA
This PR fixes a compiler issue when using NVIDIA. It was introduced
when adding the reflection probes. NVIDIA compiler doesn't like
to access elements in a bound resource and pass it directly
as a parameter. It should first be added as a local variable.

Pull Request: https://projects.blender.org/blender/blender/pulls/109891
2023-07-10 08:35:55 +02:00
Campbell Barton
7e24a0a2ec Fix invalid address-of operator (hidden by a cast)
While in practice this didn't cause problems,
it's misleading & unnecessary.
2023-07-10 12:37:44 +10:00
Campbell Barton
7271ceb057 Fix memory leak when there are unexpectedly more than MAXSEQ strips 2023-07-10 12:37:44 +10:00
Campbell Barton
116861dc2f Cleanup: break early out of rna_SeqTimelineChannel_owner_get
Once the channel was found the for-loop kept searching.
2023-07-10 12:37:44 +10:00
Campbell Barton
0b5eb86e2c Cleanup: check the result of BLI_findindex against -1 instead of < 0
There is only one error value, prefer a specific check.
2023-07-10 12:37:44 +10:00
Campbell Barton
98a2c2229d Fix error in 29bfd03009118792af393b1ddc2277b94a775bd6 2023-07-10 12:36:59 +10:00
Hans Goudey
29bfd03009 Cleanup: Reduce indentation in paint_vertex.cc
The file is easier to read and change when less context is needed at
each step. Also extract some complex-looking flag testing into a
separate function, and move some constant checks out of loops.
2023-07-09 22:25:41 -04:00
Campbell Barton
4da96623ff CMake: use mark_as_advancd for most non WITH_* options
Avoid showing many obscure CMake options by default.
2023-07-10 12:02:15 +10:00
Hans Goudey
2a1ac6145a Cleanup: Use C++ attribute API to add attributes in a few places
This is a bit more flexible and future proof than CustomData.
2023-07-09 20:00:17 -04:00
Hans Goudey
475e8bcd97 Cleanup: Deduplicate color attribute domain and type RNA enums 2023-07-09 19:38:32 -04:00
Campbell Barton
09f1844d75 Cleanup: correct doxy-groups 2023-07-09 21:40:17 +10:00
Campbell Barton
85a10bc4d9 Cleanup: use doxy sections for mesh rip 2023-07-09 21:22:52 +10:00
Campbell Barton
6290451712 Cleanup: spelling in comments 2023-07-09 21:22:45 +10:00
Campbell Barton
043d23e9c6 Cleanup: spelling of variable name 2023-07-09 20:51:51 +10:00
Campbell Barton
7bc806ff25 Cleanup: use BKE_action prefix, return typed enum
Use eAction_TransformFlags typed return value.
2023-07-09 18:23:53 +10:00
Campbell Barton
2f2facef74 Cleanup: use BKE_action prefix, position return arguments last
- BKE_action_frame_range_get  (was BKE_action_get_frame_range)
- BKE_action_frame_range_calc (was calc_action_range)
- BKE_action_has_motion       (was action_has_motion)
2023-07-09 18:17:58 +10:00
Guillermo Venegas
751db88748 Fix #109532: Added missing conversion from wl_fixed to int in Wayland
When blender is not focused and a selection is executed
with the mouse, since there is no conversion from `wl_fixed` to `int`,
the bounds of the selection can cause the selection box to be too large,
causing `draw_select_framebuffer_depth_only_setup` to fail when create
`g_select_buffer.texture_depth`.

Ref !109834
2023-07-09 16:57:37 +10:00
Kévin Dietrich
b183e3ae89 Cleanup: Alembic, use a structure to hold interpolation settings
The Alembic importer can optionnaly interpolate vertex and matrix data.
To detect if two samples can be interpolated `get_weight_and_index`
needs to be called which output the interpolation weight and the indices
for the floor and ceil samples separately. Either the weight or the
indices could be used to determine if interpolation was needed.

This adds a `SampleInterpolationSettings` structure to hold the weight
and indices together so we don't need to manage multiple local
variables, and replaces `get_weight_and_index` with
`get_sample_interpolation_settings` which returns either a
`SampleInterpolationSettings` or nothing if no interpolation is
necessary.

This also modifies `AbcMeshData` to have an optional
`SampleInterpolationSettings` and removes members used for interpolation
from `CDStreamConfig`, which simplifies the latter structure as well as
the check in `read_mverts` to verify if interpolation is needed.

`get_config` also no longer needs a parameter for setting the now removed
`use_vertex_interpolation` member from `CDStreamConfig`. This was only
used for Mesh vertex interpolation despite also being set in the points
reader (which does not yet support any interpolation).

No functional changes.

Pull Request: #109155
2023-07-09 01:26:07 +02:00
Ray Molenkamp
c677f791f0 Cleanup: Make format 2023-07-07 20:41:57 -06:00
Joseph Eagar
0b01b7c1fa Sculpt: Fix #109555: More floating point error fixes
* Renamed BKE_pbvh_raycast_project_ray_root to
          BKE_pbvh_clip_ray_ortho for greater
	  clarity.
* BKE_pbvh_clip_ray_ortho no longer strictly clips
  within the input ray interval.  This is not necassary
  for orthographic views and was too prone to floating
  point error.  The function is only called to clip
  brush rays for orthographic views so this is acceptable.
2023-07-07 18:53:06 -07:00
Germano Cavalcante
3f90bb6a48 Fix transform updating during some navigation operations
Navigation operations, like those of the trackpad, are not modal and
therefore are confirmed on each call.

To prevent the transform operations from being updated in this case,
add a fake navigation flag.

The removal of this flag is postponed to the next call.
2023-07-07 21:27:12 -03:00
Clément Foucault
b894e90106 EEVEE-Next: Fix shader compilation on Mac 2023-07-07 23:22:13 +02:00
Ray Molenkamp
a0243dd8f9 Cleanup: make format 2023-07-07 14:10:55 -06:00
Brecht Van Lommel
7e55dfcf27 Fix #103918: Cycles point cloud motion blur artifacts on the GPU
Change storage to consistently put xyz + radius in the motion blur attribute.

Pull Request: https://projects.blender.org/blender/blender/pulls/109830
2023-07-07 20:15:36 +02:00
Weizhen Huang
8ad4a24287 EEVEE: Change sun light factor to match Cycles
Ref #108505

Pull Request: https://projects.blender.org/blender/blender/pulls/109831
2023-07-07 19:51:32 +02:00
Ray Molenkamp
4fa30a317d CMake: Fix list_assert_duplicates
`list_assert_duplicates` validates a list that should contain no
duplicates, contains no duplicates, with scope keywords now being
allowed in `INC` sections, there is the situation where multiple
include paths can have the same scope set on them causing
`list_assert_duplicates` to error out.

To remedy this we remove the scope keywords from the list first,
before running the test.
2023-07-07 11:00:29 -06: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
Julian Eisel
59adf9cdd6 GPv3: API tweaks to prepare for drag & drop reordering
Minor tweaks to the API to support drag & drop management in the layer tree UI.

These changes were needed for #109826:
- Add `TreeNode.parent_group()`
- Add `LayerGroup.as_node()`
- Use `TreeNode` instead of `Layer` whenever a link is needed to link or unlink a layer.

Pull Request: https://projects.blender.org/blender/blender/pulls/109824
2023-07-07 18:01:50 +02:00
Lukas Stockner
213204c229 Cycles: Change sun lamp to have uniform intensity at high angles
This fixes the issue described in https://projects.blender.org/blender/blender/issues/108957.

Instead of modeling distant lights like a disk light at infinity, it models them as cones. This way, the radiance is constant across the entire range of directions that it covers.

For smaller angles, the difference is very subtle, but for very large angles it becomes obvious (here's the file from #108957, the angle is 179°):
| Old | New |
| - | - |
| ![old_bigsun.png](/attachments/4ef8e7a7-1a29-4bdf-a74c-3cfa103bf1e7) | ![new_bigsun.png](/attachments/d53c7749-2672-40b6-9048-ccf2fffceeb7) |

One notable detail is the sampling method: Using `sample_uniform_cone` can increase noise, since the sampling method no longer preserves the stratification of the samples. This is visible in the "light tree multi distant" test scene.
Turns out we can do better, and after a bit of testing I found a way to adapt the concentric Shirley mapping to uniform cone sampling. I hope the comment explains the logic behind it reasonably well.

Here's the result, note that even the noise distribution is the same when using the new sampling:
| Method | Old | New, basic sampling | New, concentric sampling |
| - | - |- | - |
| Image | ![old.png](/attachments/b3258a70-f015-4065-a774-193974cce439) | ![new_basic.png](/attachments/a9008576-0af6-4152-a687-c800fd958bbd) | ![new_concentric.png](/attachments/769b6c43-34bc-434e-a4fd-ce69addd1ba5) |
| Render time (at higher spp)| 9.03sec | 8.79sec | 8.96sec |

I'm not sure if I got the `light->normalized` handling right, since I don't really know what the expectation from Hydra is here.

Co-authored-by: Weizhen Huang <weizhen@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/108996
2023-07-07 17:20:19 +02:00
Weizhen Huang
9fe87646d5 Cycles: replace spot light disk sampling with sphere sampling
The spotlight is now treated as a sphere instead of a view-aligned disk.
The implementation remains almost identical to that of a point light,
except for the spotlight attenuation and spot blend. There is no
attenuation inside the sphere. Ref #108505

Other changes include:
## Sampling
Instead of sampling the disk area, the new implementation samples either
the cone of the visible portion on the sphere or the spread cone, based
on which cone has a smaller solid angle. This reduces noise when the
spotlight has a large radius and a small spread angle.
| Before | After  |
|   --   |   --   |
|![spot_size_before.png](/attachments/04ea864a-6bf9-40fe-b11b-61c838ae70cf)|![spot_size_after.png](/attachments/7077eaf9-b7a8-41b1-a8b6-aabf1eadb4f4)
## Texture
Spot light can now project texture using UV coordinates.
<video src="/attachments/6db989d2-7a3c-4b41-9340-f5690d48c4fb"
title="spot_light_texture.mp4" controls></video>
## Normalization
Previously, the normalization factor for the spotlight was \(\pi r^2\),
the area of a disk. This factor has been adjusted to \(4\pi r^2\) to
account for the surface area of a sphere. This change also affects point
light since they share the same kernel type.
## Versioning
Some pipeline uses the `Normal` socket of the Texture Coordinate node for
projection, because `ls->Ng` was set to the incoming direction at the
current shading point. Now that `ls->Ng` corresponds to the normal
direction of a point on the sphere (except when the radius is zero),
we replace these nodes with a combination of the Geometry shader node
and the Vector Transform node, which gives the same result as before.
![versioning.png](/attachments/5bbfcacc-26c5-4f7f-8360-c42bcd851f68)
Example file see https://archive.blender.org/developer/T93676

Pull Request: https://projects.blender.org/blender/blender/pulls/109329
2023-07-07 17:15:18 +02:00
Weizhen Huang
482211b7e0 Fix wrong conversion from power to radiance of area lights
The correct conversion factor should be 1 / (pi * area), see #108505

Co-authored-by: Brecht Van Lommel <brecht@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/109153
2023-07-07 17:03:02 +02:00
Christoph Lendenfeld
c7cca085c6 Fix: assign char instead of string
Using " instead of ' caused a compiler warning
2023-07-07 16:07:04 +02:00
Hans Goudey
ec29d96d11 Cleanup: Simplify replacing component data in geometry set 2023-07-07 09:59:55 -04:00
Jeroen Bakker
f37fa6d0b1 Cleanup: make format 2023-07-07 15:43:04 +02:00
Jeroen Bakker
17a58f7db0 Eevee-next: Reflection Probe Packing
All probes (including the world background probe) are stored in a single texture. Each probe
can be of any resolution as long as it is a power of 2 and not larger than 2048. So valid options
are (2048x2048, 1024x1024, 512x512, etc).

Each probe can be stored in their own resolution and can be set by the user.
> NOTE: Eventually we would like to add automatic resolution selection.

The probes are packed in an 2d texture array with the dimension of 2048*2048. The number of
layers depends on the actual needed layers. If more layers are needed the texture will be recreated.
This can happen when a new reflection probe is added, or an existing reflection probe is made visible
to the scene or its resolution is changed.

### Octahedral mapping

Probes are rendered into a cubemap. To reduce memory needs and improve sampling performance the cubemap
is stored in octahedral mapping space. This is done in `eevee_reflection_probe_remap_comp.glsl`.

The regular octahedral mapping has been extended to fix leakages at the edges of the texture
and to be able to be used on an atlas texture and by sampling the texture once.

To reduce sampling cost and improve the quality we add an border around the
octahedral map and extend the octahedral coordinates. This also allows us to
generate lower resolution mipmaps of the atlas texture using 2x2 box filtering
from a higher resolution.

### Subdivisions and areas

Probes data are stored besides the texture. The data is used to find out where the probe is stored
in the texture. It is also used to find free space to store new probes.

This approach ensures that we can be flexible at storing probes with different
resolutions on the same layer. Lets see an example how that works

Code-wise this is implemented by `ProbeLocationFinder`. ProbeLocationFinder can view a texture in a
given subdivision level and mark areas that are covered by probes. When finding a free spot it returns
the first empty area.

**Notes**

* Currently the cubemap is rendered with a fixed resolution and mipmaps are generated in order to
  increase the quality of the atlas. Eventually we should use dynamic resolution and no mipmaps.
  This will be done as part of the light probe baking change.

Pull Request: https://projects.blender.org/blender/blender/pulls/109688
2023-07-07 15:37:26 +02:00
Ray Molenkamp
f0ee4c3ffe Cleanup: Cmake: use alias target for bf_intern_atomic
This introduces an alias target `bf::intern::atomic` for
`bf_intern_atomic`. This has the following benefits:

- Any target name with `::` in it will be recognized as an actual
target by cmake, rather than a library name it may not know about.
and will be validated by cmake to exist. Which means if you make
a typo in the LIB section, CMake will error out telling you it
doesn't know about this specific target rather than passing it on
to the build system, where you'll either get build or linker errors
because of said typo.

- Given there is quite a cleanup still to do in the build system,
it won't always be obvious which targets have been updated to
modern targets and which still need to be done. Having a namespaced
target name is a good indicator there.

Pull Request: https://projects.blender.org/blender/blender/pulls/109784
2023-07-07 15:37:02 +02:00
Christoph Lendenfeld
79b2e8f211 Animation: Allow setting the slider unit and mode
Split off from [#106952: Animation: Butterworth Smoothing filter](https://projects.blender.org/blender/blender/pulls/106952)

This patch allows the slider to take a different string than just "%",
the use case is on #106952 where we want to display "Hz" instead.

Additionally the slider got the ability to set modes, which determine
how the factor number is displayed.
`SLIDER_MODE_PERCENT` means it will multiply by 100 and display as whole numbers
`SLIDER_MODE_FLOAT` means it will display just floats with one digit after the comma

Additionally to that, because the slider range is now arbitrary and potentially deals with
large numbers, the mouse distance needed to travel from min to max has been normalized
to the range.

Pull Request: https://projects.blender.org/blender/blender/pulls/109768
2023-07-07 15:08:40 +02:00
Christoph Lendenfeld
6332d1b8a8 Animation: Improve drawing of locked FCurves
Locked `FCurves` had 2 visual issues

* the dashing is so short it just creates visual noise
* keyframes are drawn in white looking like they are selected

This PR changes this by

* Increasing the dash width
* Keyframes are drawn in black on locked curves
* To indicate that they can't be selected, draw them in a X shape
* To further reduce visual noise, locked curves no longer draw thicker when selected

This is part of the changes discussed in this design task #104867

Pull Request: https://projects.blender.org/blender/blender/pulls/106052
2023-07-07 15:05:51 +02:00
Hans Goudey
97634b7f6e Cleanup: Make format 2023-07-07 08:50:13 -04:00
Hans Goudey
75b42d1d95 Cleanup: Move BKE_editmesh_cache.h to C++
See #103343
2023-07-07 08:19:52 -04:00
Hans Goudey
ca7f4122da Cleanup: Unused variable in mesh writing, C++ casting 2023-07-07 07:35:56 -04:00
Hans Goudey
7830d9f21e Cleanup: Correct two curves and mesh comments 2023-07-07 07:10:41 -04:00
Hans Goudey
91b27ab637 Refactor: Simplify mesh edit mode modifier evaluation
Instead of keeping track of a local array of positions in the modifier
stack itself, use the existing edit mode SoA "edit cache" which already
contains a contiguous array of positions. Combined with positions as a
generic attribute, this means the state is contained just in the mesh
(and the geometry set) making the code much easier to follow.

To do this we make more use of the mesh wrapper system, where we can
pass a `Mesh` that's actually stored with a `BMesh` and the extra
cached array of positions. This also resolves some confusion-- it was
weird to have the mesh wrapper system for this purpose but not use it.

Since we always created a wrapped mesh in edit mode, there's no need
for `MOD_deform_mesh_eval_get` at all anymore. That function was quite
confusing with "eval" in its name when it really retrieved the original
mesh.

Many deform modifiers had placeholder edit mode evaluation functions.
Since these didn't do anything and since the priority is node-based
deformation now, I removed these. The case is documented more in the
modifier type struct callbacks.

Pull Request: https://projects.blender.org/blender/blender/pulls/108637
2023-07-07 13:07:15 +02:00