Commit Graph

6767 Commits

Author SHA1 Message Date
Campbell Barton
32fb40fa76 Cleanup: use function style casts for C++ 2023-07-14 12:31:00 +10:00
Sergey Sharybin
cbdb04d88b Refactor: Move external engine to C++
Pull Request: https://projects.blender.org/blender/blender/pulls/110046
2023-07-13 14:39:32 +02:00
Clément Foucault
1f1c39b980 EEVEE-Next: Rework interactive sampling
This allow multiple effect to require different
amount of samples for interactive mode.
2023-07-12 19:02:29 +02:00
Clément Foucault
a635f8bbf7 EEVEE-Next: Fix uninitialized closure_bits_ 2023-07-12 18:18:38 +02:00
Jacques Lucke
3f33e0c6cd Cleanup: clang format in disabled code segments
This formats code that is disabled using `#if 0`. Formatting was achieved
by temporarily changing `#if 0` to `#if 1 /*something*/`, then formatting,
and then changing it back to `#if 0`.
2023-07-12 14:18:59 +02:00
Hans Goudey
f0b53777c8 Cleanup: Use spans and float3 to store sculpt and PBVH vert positions
Also store the allocated deformed positions in a separate array in PBVH,
so there isn't one pointer that _sometimes_ has ownership of its data.

Pull Request: https://projects.blender.org/blender/blender/pulls/109981
2023-07-11 21:01:53 +02:00
Ray molenkamp
07fe6c5a57 Cleanup: CMake: Modernize bf_blenkernel dependencies
Pretty straightforward

- Remove any blenkernel paths from INC
- Add a dependency though LIB

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/109939
2023-07-11 19:28:01 +02:00
Amelie
f2d3d321bb GPv3: Add access functions for opacity and radius attributes
We need setters and getters for these two very commonly accessed attributes of grease pencil.
The code is based on the implementation of `CurvesGeometry::positions()` and `CurvesGeometry::positions_for_write()`.

Co-authored-by: Falk David <falk@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/109733
2023-07-11 15:11:14 +02:00
bonj
70b05249cb Fix #109040: Don't calculate homogenous offset if viewspace offset is 0
Users were reporting offset issues when the retopology overlay
was disabled. The reason those issues were happening is because of
`vs_offset = min(vs_offset, vs_z * -0.5);`.
That line is necessary for proper functioning of the retopology
overlay, but causes issues at lower offset values (such as zero, when
the retopology overlay is disabled).

Fixes #109640

Pull Request: https://projects.blender.org/blender/blender/pulls/109657
2023-07-11 11:44:15 +02:00
Jason Fielder
232d763af4 Fix #109389: Resolve Z-fighting artifacts in Metal
Resolves z-fighting artifact on Apple Silicon.

Authored by Apple: Michael Parkin-White

Pull Request: https://projects.blender.org/blender/blender/pulls/109922
2023-07-11 09:07:21 +02:00
Ray Molenkamp
04235d0e55 Cleanup: CMake: Modernize bf_blenlib dependencies
Pretty straightforward

- Remove any blenlib paths from INC
- Add a dependency though LIB

Pull Request: https://projects.blender.org/blender/blender/pulls/109934
2023-07-10 22:04:18 +02:00
Hans Goudey
3d383d383f Cleanup: Use C++ Array types for Edit Mesh SoA cache
This helps const correctness since the data can't be changed from a
const EditMeshData struct, and simplifies memory management.

Pull Request: https://projects.blender.org/blender/blender/pulls/109821
2023-07-10 19:49:54 +02:00
Ray Molenkamp
57ad866d81 Cleanup: CMake: Modernize bf_guardedalloc dependencies
Pretty straightforward

- Removes any guardedalloc paths from INC
- Adds a dependency though LIB

Pull Request: https://projects.blender.org/blender/blender/pulls/109925
2023-07-10 18:44:19 +02:00
Clément Foucault
b65dfb26f9 EEVEE-Next: Shadow Tag: Fix uv calculation 2023-07-10 17:04:06 +02:00
Sergey Sharybin
d579ac2b3f Refactor: Use ImBuf to store passes in RenderResult
Doing so avoids having duplicated logic for working with pixel
data which is being passed throughout the render pipeline.

Notable changes:

- ImBug can now store GPU texture.
  This is not very finished part of the API, which will be
  worked further to support tiling for very-high-res images.

- Implicit sharing is removed from the image buffer, as it is
  no longer needed.

There should be no functional changes on user level with this
change.

Ref #108618

Pull Request: https://projects.blender.org/blender/blender/pulls/109788
2023-07-10 16:33:32 +02:00
Ray Molenkamp
7cebb61486 Cleanup: CMake: Modernize bf_dna dependencies
There's quite a few libraries that depend on dna_type_offsets.h
but had gotten to it by just adding the folder that contains it to
their includes INC section without declaring a dependency to
bf_dna in the LIB section.

which occasionally lead to the lib building before bf_dna and the
header being missing, while this generally gets fixed in CMake by
adding bf_dna to the LIB section of the lib, however until last
week all libraries in the LIB section were linked as INTERFACE so
adding it in there did not resolve the build issue.

To make things still build, we sprinkled add_dependencies wherever
we needed it to force a build order.

This diff :

Declares public include folders for the bf_dna target so there's
no more fudging the INC section required to get to them.

Removes all dna related paths from the INC section for all
libraries.

Adds an alias target bf:dna to signify it has been updated to
modern cmake

Declares a dependency on bf::dna for all libraries that require it

Removes (almost) all calls to add_dependencies for bf_dna

Future work:

Because of the manual dependency management that was done, there is
now some "clutter" with libs depending on bf_dna that realistically
don't. Example bf_intern_opencolorio itself has no dependency on
bf_dna at all, doesn't need it, doesn't use it. However the
dna include folder had been added to it in the past since bf_blenlib
uses dna headers in some of its public headers and
bf_intern_opencolorio does use those blenlib headers.

Given bf_blenlib now correctly declares the dependency on bf_dna
as public bf_intern_opencolorio will get the dna header directory
automatically from CMake, hence some cleanup could be done for
bf_intern_opencolorio

Because 99% of the changes in this diff have been automated, this diff
does not seek to address these issues as there is no easy way to
determine why a certain dependency is in place. A developer will have
to make a pass a this at some later point in time. As I'd rather not
mix automated and manual labour.

There are a few libraries that could not be automatically processed
(ie bf_blendthumb) that also will need this manual look-over.

Pull Request: https://projects.blender.org/blender/blender/pulls/109835
2023-07-10 15:07:37 +02:00
Jeroen Bakker
ba82b9c47e Fix: Eevee-next Looses Reflective World Light When Switching Shading Modes
When switching shading between material preview and solid modes, the
world reflective light could become uninitialized. The reason was that
the world was only updated when they actually changed. When switching
it might not be the case that the world changed and the world probe
wasn't uploaded to the texture.

This fix will reduce the locations where this information was stored
(removing the `do_world_update` attribute in `ReflectionProbeModule`).
It also doesn't reset the `do_render` flag during syncing, but post-
pone it to the actual drawing.

Pull Request: https://projects.blender.org/blender/blender/pulls/109901
2023-07-10 13:40:47 +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
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
6290451712 Cleanup: spelling in comments 2023-07-09 21:22:45 +10:00
Clément Foucault
b894e90106 EEVEE-Next: Fix shader compilation on Mac 2023-07-07 23:22:13 +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
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
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
Hans Goudey
75b42d1d95 Cleanup: Move BKE_editmesh_cache.h to C++
See #103343
2023-07-07 08:19:52 -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
Campbell Barton
23acedd432 Cleanup: code-comments 2023-07-07 15:11:19 +10:00
Campbell Barton
6a79639ef7 Cleanup: use function style casts, remove void function argument
Also remove redundant parenthesis.
2023-07-06 10:40:25 +10:00
Miguel Pozo
6ac86d0e81 Workbench Next: Release overlay depth shader
Avoid memory leak.
2023-07-05 18:30:21 +02:00
Miguel Pozo
3d62888ed6 Workbench Next: Fix Overlay composition
Set "In Front" objects depth to 0,
so overlays are not drawn on top of them.
2023-07-05 18:11:50 +02:00
Miguel Pozo
6335af74f2 Workbench Next: Fix transparent depth
transparency_depth_ps_ object sync was being skipped after
a639ec3afa
2023-07-05 18:11:50 +02:00
Campbell Barton
785bd13b9a Cleanup: spelling in comments 2023-07-05 14:09:33 +10:00
Joseph Eagar
7e2659e4ab Cleanup: Split BKE_pbvh.h into BKE_pbvh_api.hh
Split much of BKE_pbvh.h into BKE_pbvh_api.hh.
BKE_pbvh.h is included by BKE_paint.h, which in
turn is included by large amounts of code including
RNA.

This makes it extremely difficult to change
or clean up the PBVH API, since each modification
of BKE_pbvh.h can take 20-30 minutes to compile,
even on a quad-core system with an SSD. This
commit fixes that by moving most of BKE_pbvh.h
into another file and just having the core,
external-facing interfaces in BKE_pbvh.h.
2023-07-03 20:01:04 -07:00
Campbell Barton
9e26960b77 Cleanup: code-comments 2023-07-04 12:36:41 +10:00
Hans Goudey
a3bfd6e20d Cleanup: Extract utility for counting indices
This utility counts the number of occurrences of each index in an array.
This is used for building mesh topology maps offsets, or for counting
the number of connected elements. Some users are geometry nodes,
the subdivision draw cache, and mesh to curve conversion.

See #109628
2023-07-03 18:47:03 -04:00
Clément Foucault
91d15a3613 EEVEE-Next: Fix shader compilation on Metal 2023-07-03 23:08:53 +02:00
Falk David
3d99d05f00 GPv3: Add separate paint mode
This patch adds a separate paint mode for Grease Pencil 3.0.

Pull Request: https://projects.blender.org/blender/blender/pulls/109453
2023-07-03 16:34:30 +02:00
Miguel Pozo
9c955a20fe EEVEE Next: Use draw_gpencil_new
Avoid shader validation errors from overlapping resources.
GPencil drawing is not fully implemented yet, so this doesn't cause any functional change.
2023-07-03 16:01:49 +02:00
Jeroen Bakker
590f3582c9 Eevee-next: Lookdev HDRI Switcher
This PR adds support to override the world with the HDRI of the
viewport.

Blurring of the background and camera based rotation isn't supported.
Switching the HDRI would still use the world diffuse light as that is
baked into the irradiance cache.

These issues have been added to #109646

![image](/attachments/2613adff-064a-4f81-8bdd-f687ab8ffcfb)

Pull Request: https://projects.blender.org/blender/blender/pulls/109548
2023-07-03 15:34:11 +02:00
Falk David
de95539ced Cleanup: Rename grease pencil modes to legacy
Renames `OB_MODE_EDIT_GPENCIL`, `OB_MODE_PAINT_GPENCIL`,  `OB_MODE_SCULPT_GPENCIL`,  `OB_MODE_WEIGHT_GPENCIL`, `OB_MODE_VERTEX_GPENCIL, and the context modes` to `*_LEGACY`.

Pull Request: https://projects.blender.org/blender/blender/pulls/109648
2023-07-03 15:15:54 +02:00
Jeroen Bakker
c6c69c0656 Eevee-next: Octahedral mapping
Use octahedral mapping to store probe textures. Octahedral textures are easier to sample
and will increase performance. When extracting the world probe it will first be rendered into
a cubemap. This cubemap will then be remapped using octahedral texture coordinates.

* `CaptureView` captures the world light into a cubemap.
* `CaptureView` triggers the reflection probe module to update the octahedral texture using
   the cubemap.
* When sampling reflection probes it will convert the (cubemap) direction to octahedral
   coordinate and read from the octahedral texture.

![image](/attachments/d3331660-f893-41b7-8c17-ae12ddf2ad11)

Pull Request: https://projects.blender.org/blender/blender/pulls/109559
2023-07-03 15:14:34 +02:00
Jeroen Bakker
c2c1d6f67b Metal: EEVEE Next shadow unit test enablement
Ensure correct SSBO bindings are present for shadow tests.
Metal validation errors occur if SSBO bindings that are expected are
not bound. In this case, we can bind empty SSBOs, but these should
be of the correct type for the tests.

Also adding missing zero-initializations for required members within
LightData. Without these, unit tests fail with various issues including
prevalence of OOB reads.

Co-authored-by: Michael Parkin-White <mparkinwhite@apple.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/109645
2023-07-03 14:24:34 +02:00
Clément Foucault
8fa8f1ca78 Cleanup: DRW: Remove uneeded point cloud vertex inputs 2023-07-03 11:51:53 +02:00
Campbell Barton
e06a341546 License headers: add SPDX-FileCopyrightText 2023-07-03 19:20:39 +10:00
Miguel Pozo
903f9ad178 Workbench Next: Point Clouds
Point Cloud support for the new Draw Manager and Workbench Next.

Pull Request: https://projects.blender.org/blender/blender/pulls/109568
2023-07-03 11:16:44 +02:00
Germano Cavalcante
dd4f0cebae Fix #109577: Wireframe edge factor is sometimes random
In some situations the loop value might not be set.
2023-07-02 19:25:08 -03:00
Campbell Barton
f7d6b7973a Cleanup: minor C++ changes (use nullptr, correct parameter names) 2023-07-02 19:54:27 +10:00
Campbell Barton
69aee8ba6b Cleanup: remove redundant (void) for functions with no args in C++ 2023-07-02 19:54:27 +10:00
Campbell Barton
345d1a4b44 Cleanup: simplify struct declarations in C++
Replace `typedef struct X {} X;` with `struct X {};`

In some cases the first and last name didn't match although this
is rarely useful, even a typo in some cases, e.g. TrachPathPoint.
2023-07-02 19:54:26 +10:00