Commit Graph

7301 Commits

Author SHA1 Message Date
Clément Foucault de2ea031bc Fix EEVE-Next: Broken Parallax
Parallax distance was not actually use.
It was affecting the world and had
unwanted effect if lower than
influence radius.
2023-10-12 12:41:15 +02:00
Clément Foucault 1f12b90ef2 Cleanup: EEVEE-Next: Use references for `bind_resources` 2023-10-12 12:19:41 +02:00
Clément Foucault 1b4b6bc2f4 Fix EEVEE-Next: Forward Pipeline: Missing resource binds 2023-10-12 12:15:15 +02:00
Jeroen Bakker 83b23d37e7 EEVEE: Fix Compilation Errors
The push constant `double_sided` and `Surfel.double_sided` collided. Due
to the macros that the vulkan backend is creating it isn't possible to
use the same attribute name as an existing push constant.

Pull Request: https://projects.blender.org/blender/blender/pulls/113576
2023-10-12 08:57:25 +02:00
Campbell Barton b4504c7840 Cleanup: spelling in comments 2023-10-12 16:03:18 +11:00
Clément Foucault 4bddbe85f6 EEVEE-Next: Move out of experimental options
See #93220
2023-10-11 20:38:28 +02:00
Clément Foucault df523f3bf1 EEVEE-Next: Add back lightprobe influence
I had to do a huge refactor in order to do this.

The way ReflectionProbe were referencing the UBO
data was conflicting with the way EEVEE-Next
object should behave.

So like light, shadow and irradiance grids, every
probe is synced with it's GPU data as base struct
and the data is just copied into the UBO
when using `set_view`.

To simplify many parts of the reflection probe
code, I isolated the atlas coordinate of a probe
to its own struct that can be easily copied.

Pull Request: https://projects.blender.org/blender/blender/pulls/113518
2023-10-11 20:19:37 +02:00
Miguel Pozo 1ba16edaf0 EEVEE-Next: Rename light probes
Update to the new naming convention for `Light Probes`:

`Reflection Cubemap` -> `Sphere`
`Reflection Plane` -> `Plane`
`Irradiance Grid` -> `Volume`

Note that this breaks the Python API (`bpy.types.LightProbe.type`).

Pull Request: https://projects.blender.org/blender/blender/pulls/113452
2023-10-11 19:38:42 +02:00
Sergey Sharybin 926c6782fe Sculpt: Support Float2 attributes for dynamic topology
It was a missing case in the code which is responsible for in the code
which is responsible for filling in VBO data. It is now implemented for
vertex and corner attributes.

Co-Authored-By: Hans Goudey <hans@blender.org>

Pull Request: https://projects.blender.org/blender/blender/pulls/113536
2023-10-11 12:12:37 +02:00
Sergey Sharybin e36626b02d Merge branch 'blender-v4.0-release' 2023-10-11 12:05:26 +02:00
Sergey Sharybin a12a3dc73a Fix #113496: Crash in sculpt mode when Float2 attributes used on Vertices
The old logic had a hard-coded assumption that Float2 attribute is an
UV-map. This assumption is now resolved.

Pair programming session with Hans.

Pull Request: https://projects.blender.org/blender/blender/pulls/113535
2023-10-11 12:04:30 +02:00
Campbell Barton 91ec9bc5a7 Cleanup: don't use DOXYGEN blocks for inline comments 2023-10-11 10:49:07 +11:00
Clément Foucault a82e9586c4 Fix EEVEE-Next: Compilation on Metal 2023-10-10 23:52:04 +02:00
Hans Goudey a6a2af5fdd Fix: Sculpt dynamic topology doesn't draw active/render color attribute
Pass the mesh to the drawing functions so it doesn't have to be
retrieved from the PBVH. It's nice to rely less on the PBVH `me`
pointer, since it's a fairly ugly "back pointer" which isn't necessarily
good design.
2023-10-10 18:22:50 +02:00
Miguel Pozo e235913c0d Fix: EEVEE-Next: Handle ObjectKey padding bytes 2023-10-10 17:55:23 +02:00
Miguel Pozo 26154aae81 Fix: EEVEE-Next: Bake regression
Missing `hiz_buffer.set_source` call after 80a6a8efe9
2023-10-10 17:40:28 +02:00
Miguel Pozo 7d28b8cb5b Merge branch 'blender-v4.0-release' 2023-10-10 15:49:56 +02:00
Miguel Pozo 96d6003b92 Cleanup: Draw: max_orphan_cycles clarification 2023-10-10 15:49:28 +02:00
Jeroen Bakker 25a1cea8e2 EEVEE-Next: Scene Reflection Probe Resolution
This PR reuses the scene specific reflection probe resolution for all
reflection light probes in the scene. The target is to have a automatic
detection for the resolution. But as long as we don't have a mechanism
for detection it is better to not introduce a new UI element that will
be removed within the foreseen future.

This setting is currently used by EEVEE and EEVEE-Next. EEVEE supports
resolutions upto 4096px. This will be clamped to 2048 when using
EEVEE-Next.

The motivation for this is that EEVEE-Next will soon replace
EEVEE and 4096 can then be removed from the choices that the user can
made. Adding as separate option could need synchronization, and that
option would also be temporary as it will be removed by the resolution
detection mechanism.

Pull Request: https://projects.blender.org/blender/blender/pulls/113491
2023-10-10 14:50:17 +02:00
Clément Foucault 80a6a8efe9 EEVEE-Next: Ray-Tracing: Add Planar Tracing
This traces planar lightprobe captures just like
the screen-space tracing does.

This is implemented as a separate shader that
loads the ray before the screen trace and
check if it can be traced against any available
planar probe. If it does it marks the ray as
traced (negative pdf) so that the screen tracing
pass does not override the result or try to
trace it.

Pull Request: https://projects.blender.org/blender/blender/pulls/113453
2023-10-10 12:55:18 +02:00
Jeroen Bakker 9c52b4e606 Fix #113470: EEVEE-Next doesn't stop sampling
After performing a transformation EEVEE-Next non-stops resets the
sampling. The cause is that the `recalc` flag that are stored in the
Object isn't consumed. When transforming it was always filled with
`ID_RECALC_TRANSFORM` and kept on resetting the sampling.

Regression introduced by PR #113252.

Pull Request: https://projects.blender.org/blender/blender/pulls/113484
2023-10-10 11:49:37 +02:00
Campbell Barton 137f8dd7bc Cleanup: spelling in comments 2023-10-10 09:44:57 +11:00
Hans Goudey 8f27baf388 Merge branch 'blender-v4.0-release' 2023-10-09 23:54:43 +02:00
Hans Goudey 976eaae02f Cleanup: Move BKE_object.hh to C++
Simplifies the fix to #111120, where the object bounds functions
may return a C++ type instead of `BoundBox`.

Pull Request: https://projects.blender.org/blender/blender/pulls/113462
2023-10-09 23:41:53 +02:00
Miguel Pozo f54205cfdd EEVEE Next: Optional surfel backface culling
Allow disabling surfels backfaces from contributing to volume probes.

Pull Request: https://projects.blender.org/blender/blender/pulls/113362
2023-10-09 17:02:14 +02:00
Germano Cavalcante ffaf3e30ef DRW: Simplify Selection Engine
The selection engine has some complex tricks that improve performance.
These are:
- Only draws objects whose bounding box intersects the selection
threshold;
- If the viewport or objects are not "dirty", it does not clean the
texture IDs and only adds objects that have not yet been drawn;
- Only updates the depth buffer if a new object is drawn;
- Skip drawing if no object is found;

These tricks were initially implemented so that this engine could be
used for snapping.

But this initial idea has changed and now the engine is only used to
select Vertices, Edges or Faces.

Due to this limited use, these tricks bring no real benefit.
In fact, it's even worse with the Retopology Overlay, as it forces the
Depth buffer to be redrawn.

This commit removes these tricks and only keeps those that indicate
whether the drawing needs to be updated.

Pull Request: https://projects.blender.org/blender/blender/pulls/113308
2023-10-09 11:06:53 -03:00
Jeroen Bakker 701c14acea EEVEE-Next: Support for Intel ARC GPUs
This PR adds support for Intel ARC GPUs. Due barriers inside a non
uniform control flow the Intel ARC can stall the whole system.

The cause is that a barrier is used, but some threads in the shader
have completed. The barriers might wait until it gets the signal from
the exited threads and stalls the system.

Although some implementations support it it is safer to limit the
number of HiZ levels.

Pull Request: https://projects.blender.org/blender/blender/pulls/113447
2023-10-09 15:29:26 +02:00
Hans Goudey f27ac434f6 Fix: Incorrect early return in recent cleanup 2023-10-09 15:27:04 +02:00
Jeroen Bakker f6df5d3514 Fix: EEVEE-Next: Planar Probes First Sample
When the first planar probe is added to the scene, or the last probe
is removed from the scene the samples needs to be reset. This removes
artifacts when only a single sample is used.

Pull Request: https://projects.blender.org/blender/blender/pulls/113440
2023-10-09 14:49:49 +02:00
Miguel Pozo 25160def62 Fix: EEVEE-Next: Nvidia compilation error
Workaround Error: C1317: qualified actual parameter #1 cannot be converted to less qualified parameter
2023-10-09 13:17:19 +02:00
Jeroen Bakker 03040f3b7f Cleanup: Make format 2023-10-09 12:49:02 +02:00
Miguel Pozo 744bdb84f7 Merge branch 'blender-v4.0-release' 2023-10-09 12:13:18 +02:00
Bastien Montagne df0d7c9c3d WM Jobs: Refactor all worker status variables into a single shared struct.
Move the three current 'status variables' (stop, update and progress)
into a single 'WorkerStatus' struct. This is cleaner and will allow for
future workin this area without having to edit tens of 'startjob'
callbacks signatures all the time.

No functional change expected here.

Note: jobs' specific internal code has been modified as little as
possible, in many cases the job's own data still just store pointers to
these three values. Ideally in the future more refactor will be using a
single pointer to the shared `wmJobWorkerStatus` data instead.

Pull Request: https://projects.blender.org/blender/blender/pulls/113343
2023-10-09 12:12:22 +02:00
Miguel Pozo 2b805e777a Fix: Workbench: resolve_shader_cache initialization 2023-10-09 12:10:56 +02:00
Jeroen Bakker 79c0cd0646 Fix: EEVEE-Next: Planar Reflection During Sculpting
This PR fixes an issue that the shading pass isn't filled when
sculpting. Was detected when querying code that landed
in main.

Pull Request: https://projects.blender.org/blender/blender/pulls/113439
2023-10-09 11:03:20 +02:00
Jeroen Bakker 5f49efc084 Fix: EEVEE-Next: Crash Removing Last Planar Probe
When deleting the last planar probe in the scene the color and
depth textures are resized with 0 layers. This isn't allowed.

This is fixed by adding an early exit and creating dummy textures.

Pull Request: https://projects.blender.org/blender/blender/pulls/113437
2023-10-09 09:35:02 +02:00
Jeroen Bakker 61b463d5e4 EEVEE-Next: Planar Probe Pipeline
This PR is contains the initial capture pipeline for planar probes.

It requires work to generate the correct view to capture and to include
the result during ray tracing. These will be developed in a separate PR.

This PR detects if a planar probe is active in the scene. If this is
the case the planar probe pipeline will be activated. During rendering
this is done by querying the depsgraph, during viewport drawing this
is done during sync. If an planar probe is detected and the pipeline
wasn't activated. The pipeline will be activated and the sampling
will be reset to ensure the pipeline is filled with all objects.

Per object the user can set the visibility of the object in planar
reflections.
![image](/attachments/fcfb40f9-f174-491c-bfba-e7f00f49aa1c)

For a reflection plane the resolution and clipping offset can be set.
EDIT: Resolution option was removed because too complex to
implement with the little time we have at the moment.
![image](/attachments/e42ad9ce-8af8-45d1-aa3a-630db1901ad3)

Related to #112966

Co-authored-by: Clément Foucault <foucault.clem@gmail.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/113203
2023-10-08 19:49:58 +02:00
Clément Foucault 3cca8680e0 EEVEE-Next: Split Thickness Approximation
This moves the thickness from shadow map
approximation out of the lighting and shadowing
loop. Instead of using the thickness from
the shadow tracing from each individual light
before SSS evaluation, we precompute the
average thickness from all shadowed light.
This is then mixed with the nodetree thicknes.

## SSS Translucency
This add back SSS transmission support by using
the mentionned thickness computation, and applying the
transmission profile on it. This is then applied on top of a
flipped normal LTC computation.

Pull Request: https://projects.blender.org/blender/blender/pulls/113401
2023-10-08 00:29:06 +02:00
Clément Foucault 7c694c9d04 EEVEE-Next: Refactor Light evaluation
This allow splitting shadow and light evaluation.
This is the first step to deferred shadowing.

The evaluate closure types can be dynamically
set which mean we can have arbitrary BSDF
evaluation inside the same shader.

This also contain some refactor to `light_lib.glsl`
for more consistency and less clutter.

Note that this breaks the SSS translucency
as the shadow evaluation changes for these.
A new solution for this feature is to be found

Pull Request: https://projects.blender.org/blender/blender/pulls/113257
2023-10-08 00:15:41 +02:00
Hans Goudey ce4663403b Cleanup: Return early to reduce indentation for 3D cursor drawing 2023-10-07 09:09:33 -04:00
Campbell Barton 4b3e7b3928 License headers: add SPDX header 2023-10-07 18:13:22 +11:00
Clément Foucault 5e43bf3483 EEVEE-Next: Refactor Lightprobe irradiance evaluation
This refactor the lightprobes sample so that we always query
the spherical probe and the volume probe.

Then, given the BSDF type, we reconstruct the incoming radiance
differently depending on the ray probability blending between
the spherical and volume probe depending on ray probability.

Moreover, we implement cubemap normalization using
volume probe spherical harmonic data at spherical probe
position and at the shading point position.

Pull Request: https://projects.blender.org/blender/blender/pulls/113301
2023-10-06 23:37:38 +02:00
Hans Goudey 5052fe489c Cleanup: Simplify filling constant value per triangle in PBVH draw 2023-10-06 18:33:21 +02:00
Hans Goudey 9d201dc16b Cleanup: Simplify BMesh PBVH draw data upload
Instead of using a lambda with a FunctionRef argument, just write the
loops explicitly. This results in a bit more boilerplate code and a bit
more repetition, but the overall design and flow is much simpler. Based
on the results in f10965dcb8, it can improve performance too.
2023-10-06 18:16:30 +02:00
Sergey Sharybin 9a44445667 Fix assert in PBVH face set drawing code
The assert was assuming that the attribute request is properly
initialized and that was not the case: the "special" data layers
like coordinates, normals, masks, and face sets did not initialize
domain in the attribute request.

The domain is now properly initialized. As well as there is an
assert added in other PBVH types for the face sets. It is possible
to add asserts in more places, but it is not directly related to
this CL.

Pull Request: https://projects.blender.org/blender/blender/pulls/113354
2023-10-06 18:05:59 +02:00
Clément Foucault eb9d765eea Fix EEVEE-Next: Broken compilation on Metal 2023-10-06 17:53:29 +02:00
Hans Goudey 0fc3e3dd98 Fix: Debug build error from incorrect PBVH draw assert 2023-10-06 15:47:54 +02:00
Sergey Sharybin 12e9894a75 Sculpt: Improve support of face sets with dyntopo
Two aspects to this change:

- Do not clear face sets when enabling dynamic topology
- Draw face sets in viewport when dynamic topology is enabled

Newly added faces in the dynamic topology will have face
sets properly assigned. It is only edge collapse which can
potentially lead to undesired results w.r.t face set boundaries.
That will be worked on further as follow up development.

Pull Request: https://projects.blender.org/blender/blender/pulls/113348
2023-10-06 15:42:22 +02:00
Miguel Pozo c567f7ccae Merge branch 'blender-v4.0-release' 2023-10-06 15:36:37 +02:00
Miguel Pozo fe39456ba5 Workbench: Fix: Performance Regressions
Optimize Workbench performance so it's on par with the previous
implementation.
Most of these changes are barely noticeable on powerful GPUs,
but can cause a notable performance improvement on old or low-end
hardware.

* Avoid unnecessary texture copies and draw directly to the viewport
   textures.
* Optimize-out depth/stencil reads, using stencil testing instead.
* Avoid using `Texture::clear` and use framebuffer clears instead.
* Avoid framebuffer state changes (always use the same attachments).
* Avoid constant variation of acquired `TextureFromPool`s.

Fix #113010

Pull Request: https://projects.blender.org/blender/blender/pulls/113251
2023-10-06 15:31:44 +02:00
Miguel Pozo 57cfe20e5b EEVEE-Next: Fix DupliObject ObjectKey
Fixed version of #112544 (reverted).

`DRW_drawdata_get` reuses the same `DrawData` for all duplis,
so they all end up using the same `ObjectHandle` and `ObjectKey`,
which breaks motion vectors.

* Don't rely on `DRW_drawdata_get` for storing `ObjectKey`s.
* Simplify `ObjectKey`.

This also solves the issue of objects created "on the fly" always having
the `ID_RECALC_ALL` flag.

Pull Request: https://projects.blender.org/blender/blender/pulls/113252
2023-10-06 15:29:50 +02:00
Jeroen Bakker 44882ceb7b EEVEE-Next: Several Fixes Reflection Probes Workflow
This fixes several issues related to using reflection probes in EEVEE-Next.

- When using a single sample, the reflection probes weren't always updated.
- Composite world background in reflection probes
- Removing reflection probes wasn't working
- Update UBO when world and reflection probes are active in the scene.

Pull Request: https://projects.blender.org/blender/blender/pulls/113347
2023-10-06 14:43:19 +02:00
Hans Goudey 73e345f85f Sculpt: Draw color attribute during dynamic topology sculpting
Previously the colors were just uploaded as white, the default value.
Even if they aren't interpolated properly, it is still helpful to see
the colors. At worst, the unaffected parts of the mesh will still look
right.

A previous commit made vertex colors interpolate properly, but
face corner colors will still reset to their default value.

As a reminder, only color and byte color attributes are currently
supported for the specialized PBVH drawing.

Pull Request: https://projects.blender.org/blender/blender/pulls/113333
2023-10-06 14:31:25 +02:00
Falk David 7e87435cf4 GPv3: Initial drawing tool
This PR implements an initial drawing tool that can already be used for testing.
While this is not fully feature complete (compared to the current grease pencil draw tool) the following is already implemented:

* Pressure support for radius and opacity.
* Material color and vertex color support.
* New active smoothing algorithm based on curve fitting.
* Simplify algorithm as a post-process step.

Some deliberate limitations include:
* The drawing plane is always the front plane. Drawing on surfaces is also not supported.
*

The current approach has not been optimized for performance yet. The goal was to have a straightforward implementation
first and then focus on performance later.

There are numerous parameters in the code that are hard-coded for now. These should be exposed at some point, potentially as user settings.

Pull Request: https://projects.blender.org/blender/blender/pulls/110093
2023-10-06 10:49:54 +02:00
Clément Foucault c5bf383826 Fix: DRW: Missing braces around array constructor 2023-10-06 10:19:46 +02:00
Campbell Barton 71b1712d79 Cleanup: spelling in comments 2023-10-06 12:50:27 +11:00
Miguel Pozo 40f93532bb Fix: EEVEE-Next: Irradiance Grid baking
Regression caused by e2cef1c713
2023-10-05 19:37:04 +02:00
Jason Fielder 57a3ab29cc Metal: EEVEE Next: Optimize Virtual shadow maps for Apple Silicon
Optimization of EEVEE Next's Virtual Shadow Maps for TBDRs.
The core of these optimizations lie in eliminating use of
atomic shadow atlas writes and instead utilise tile memory to
perform depth accumulation as a secondary pass once all
geometry updates for a given shadow view have been updated.

This also allows use of fast on-tile depth testing/sorting, reducing
overdraw and redundant fragment operations, while also allowing
for tile indirection calculations to be offloaded into the vertex
shader to increase fragment storage efficiency and throughput.

Authored by Apple: Michael Parkin-White

Co-authored-by: Michael Parkin-White <mparkinwhite@apple.com>
Co-authored-by: Clément Foucault <foucault.clem@gmail.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/111283
2023-10-05 19:02:39 +02:00
Bastien Montagne acde11f159 Cleanup: wmJobs: Use defined `startjob` callback type everywhere.
For some reasons, `WM_jobs_stop` and `WM_jobs_kill` would use their own
'type' of function pointer - and not even a matching one!

Among (many) other reasons why this was bad, it required very stupid
casting from code using these functions - and made editing wmJob `startjob`
signature needlessly complicated.
2023-10-05 16:13:15 +02:00
Miguel Pozo b4de568cc4 EEVEE-Next: Tests support
Enable tests for EEVEE Next.

As a workaround for allowing the use of EEVEE Next (still an
experimental feature) with `--factory-startup`, `arg_handle_engine_set`
enables the feature when `-E BLENDER_EEVEE_NEXT` is used.
In addition, EEVEE Next is always registered, so it's available when
calling `WM_init`.
If it's actually disabled, it will be immediately unregistered after that.

Notes:
- `get_gpu_device_type` always fails with error:
  > GPU API is not available in background mode
- Setup and tests are the same as EEVEE. There are many tests that
  only make sense for Cycles, and many EEVEE Next features that are
  not actually tested.

Pull Request: https://projects.blender.org/blender/blender/pulls/112161
2023-10-05 16:02:49 +02:00
Jeroen Bakker 355f457cd4 EEVEE-Next: Fix Reflection Probes Sampling
When the scene has reflection probes the sampling would be reset
each frame making the viewport always redraw and not resolve.

The reason was a logic error that was introduced when we introduced
a less flickering update for reflection probes.

Pull Request: https://projects.blender.org/blender/blender/pulls/113281
2023-10-05 11:27:31 +02:00
Jeroen Bakker f1c0ec3c4b EEVEE-Next: Remove Unused Resources in Probe Capture Pipeline
The probe capture pipeline still had some bindings from the previous
implementation. This could result in overwriting the `gbuf_header_tx`
with the incorrect texture as it was sharing the same binding.

This PR removes the unused light probe bindings.

Pull Request: https://projects.blender.org/blender/blender/pulls/113276
2023-10-05 10:52:47 +02:00
Jeroen Bakker 3d1da2532b EEVEE-Next: Fix Crash With Exact 128 Resources
When the scene has exact 128 resources or a multiple in the scene
Blender crashes as the velocity buffer doesn't allocates the
right amount of space inside its buffer.

Pull Request: https://projects.blender.org/blender/blender/pulls/113277
2023-10-05 10:52:26 +02:00
Campbell Barton 6f23344a7a Merge branch 'blender-v4.0-release' 2023-10-05 13:58:49 +11:00
Campbell Barton 9d20632925 Cleanup: ensure trailing newline, delete trailing space 2023-10-05 13:57:14 +11:00
Germano Cavalcante 72a52520db Select Engine: Use C++ vector types for arrays
No functional changes.
2023-10-04 14:44:46 -03:00
Germano Cavalcante 99a3a4a330 Cleanup: Move select engine headers to C++
See #103343

tmp
2023-10-04 14:34:12 -03:00
Omar Emara 17bdf18397 Realtime Compositor: Implement Keying Screen node
This patch implements the Keying Screen node for the Realtime
Compositor. Draw data was introduced to the Movie Clip ID to allow
caching of the keying screen.

Pull Request: https://projects.blender.org/blender/blender/pulls/113055
2023-10-04 07:35:07 +02:00
Clément Foucault bcf0c117a0 Revert "EEVEE-Next: Fix DupliObject ObjectKey"
This reverts commit 641dff8bf4.
2023-10-03 18:03:27 +02:00
Brecht Van Lommel a2da71d3a9 Merge branch 'blender-v4.0-release' into main 2023-10-03 16:13:12 +02:00
Brecht Van Lommel 8562cecf1b Fix #112991: crash switching from Hydra Storm viewport to other renderer
The viewport render engine was freed outside the DRW OpenGL context, which
resulted in Storm deleting a VAO from another OpenGL context.
2023-10-03 16:12:45 +02:00
Clément Foucault 1b1b1a19bf EEVEE-Next: Add world clip plane support
This add a way to use a software clip plane in the
prepass shader (surf_depth_frag.glsl).

The benefit of using this instead of gl_ClipDistance
is that the rasterization pattern is given to match.
Which means that only the prepass shader have to use
this.

This is slow and should only be enabled when needed.
2023-10-03 16:09:12 +02:00
Clément Foucault 23e4cbc86a EEVEE-Next: Split curve attributes to their own interface
This avoid poluting shader interfaces which might not be
optimized by the compilers.
2023-10-03 16:09:12 +02:00
Jeroen Bakker ee92151c3a Overlay-Next: Fix Copy Uninitialized Texture
Overlay engine is currently responsible to initialize the framebuffers
depth_in_front texture. This is a hack and hasn't been ported to
Overlay-Next (yet). This PR skips copying the depth_in_front texture
when it isn't initialized yet.

Issue detected when working on Vulkan backend due its more
strictness.

Pull Request: https://projects.blender.org/blender/blender/pulls/113188
2023-10-03 07:27:36 +02:00
Campbell Barton 9c018def3e Cleanup: spelling in comments 2023-10-03 11:24:48 +11:00
Campbell Barton 74bb280df5 Fix incorrect sizeof argument to memcmp in EEVEE's ObjectKey comparison 2023-10-03 11:14:08 +11:00
Germano Cavalcante c7d9e7be81 Merge branch 'blender-v4.0-release' into main 2023-10-02 17:26:45 -03:00
Germano Cavalcante e7ba91a6f3 Fix #113130: Versioning error in snap type in animation editors
Caused by fb556c75df

The ideal would be to increase the version file, but this would make
the versioning code a bit messy, and it was a recent error
(it shouldn't affect many users).
2023-10-02 17:26:07 -03:00
Miguel Pozo 641dff8bf4 EEVEE-Next: Fix DupliObject ObjectKey
`DRW_drawdata_get` reuses the same `DrawData` for all duplis,
so they all end up using the same `ObjectHandle` and `ObjectKey`,
which breaks motion vectors.

* Don't use `DRW_drawdata_get`.
* Simplify `ObjectKey`.

This also solves the issue of objects created "on the fly" always having
the `ID_RECALC_ALL` flag.

Pull Request: https://projects.blender.org/blender/blender/pulls/112544
2023-10-02 16:52:56 +02:00
Miguel Pozo 68c69a99d3 Merge branch 'blender-v4.0-release' 2023-10-02 16:45:55 +02:00
Miguel Pozo 0ed6172833 Fix #112164: Draw: Circle select tool low performance
Since garbage collection of texture pools happens every time
`drw_manager_init` is called, interleaved calls to different
`DRW_draw`/`DRW_render` functions can result in a constant cycle of
creating/releasing textures.

This PR changes texture pools to only release textures that have not
been used for N garbage collection cycles.
I chose 8 as default since I think is high enough to avoid the issue
while it's unlikely to cause any major spike in memory consumption.

Pull Request: https://projects.blender.org/blender/blender/pulls/113024
2023-10-02 16:43:48 +02:00
Clément Foucault eda7926834 DRW: Add SubPassTransition pass command 2023-10-01 18:01:15 +02:00
Clément Foucault 508fa8d4b8 Fix #112963: EEVEE: Wrong specular from lights
This was caused by the wrong LUT being sampled.

This cleans-up the utilTex layer define usage
and implement the small optimization marked
as todo.
2023-09-27 23:19:18 +02:00
Campbell Barton 5964ff7acb Fix missed header change from a9f0d19197 2023-09-27 16:53:45 +10:00
Campbell Barton a9f0d19197 Fix memory leak with volume shaders with the workbench engine
../lib/tests/render/volume/smoke_fire.blend was leaking memory,
reloading leaked more memory each time.
2023-09-27 16:50:48 +10:00
Campbell Barton 46263a85ab Cleanup: spelling in comments 2023-09-27 13:03:29 +10:00
Clément Foucault f966205022 EEVEE-Next: Add tracing options for diffuse rays
Also fixes diffuse surface always tracing
even when tracing is off.
2023-09-26 23:46:08 +02:00
Clément Foucault 3a4fc2c94e EEVEE-Next: Shadow Map Tracing Initial Implementation
Shadow Map Ray Tracing is a technique that ray cast against the shadow
depth buffer. The technique is described in "Soft Shadows by
Ray Tracing Multilayer Transparent Shadow Maps".
Note that we only implement the single layer approach since storing
multiple depth is prohibitively expensive.

Pull Request: https://projects.blender.org/blender/blender/pulls/111809
2023-09-26 23:42:40 +02:00
Hans Goudey c095962d06 Fix #112900: Asset displaying mesh with hiding and no material indices
The case when there were no material indices, multiple materials, and
the mesh used hiding wasn't handled after 55970fa367.
This is a simple parallel loop adding up the non-hidden triangles.
2023-09-26 15:10:22 -04:00
Miguel Pozo b56d39bdcc EEVEE-Next : Object visibility settings for probes
Replace per-probe visibility collections with global per-object probe
visibility settings.

Pull Request: https://projects.blender.org/blender/blender/pulls/112845
2023-09-26 20:37:15 +02:00
Miguel Pozo f07542d8cb EEVEE-Next: Fix Hair and Curves motion vectors
Hair and Curves need to call `DRW_curves_update` before
`geometry_steps_fill`, otherwise the copied geometry is just
uninitialized data.
However, doing so triggers an assertion:
> DRW_render_instance_buffer_finish had not been called before drawing.

This PR ports the `DRW_hair/curves_pos_buffer_get` functions to the new
`draw::Manager` API, so it can be called at any arbitrary point.
It also changes `VelocityModule::geometry_map` to use `uint64` keys
instead of `ID` pointers, since the same particle system can be used on
different objects and have multiple geometries.

Notes:
* The new functions are only used for
  `VelocityModule::step_object_sync` on image renders. Using them
  elsewhere would require modifying the old draw manager to do the
  init/update/free setup.
* Only the compute shader version has been ported.

Pull Request: https://projects.blender.org/blender/blender/pulls/112425
2023-09-26 19:55:46 +02:00
Miguel Pozo 049cb479b2 EEVEE-Next: Irradiance Grid clip distance and probe alignment
Implement a clip distance to irradiance grids, so surfaces farther than
the threshold don't generate surfels.
Align the capture view matrix to the probe rotation.

Pull Request: https://projects.blender.org/blender/blender/pulls/112863
2023-09-26 19:45:41 +02:00
Miguel Pozo a6536ca9c8 Fix: EEVEE-Next: Irradiance Grid minor fixes
Pull Request: https://projects.blender.org/blender/blender/pulls/112841
2023-09-26 19:27:30 +02:00
Clément Foucault e4c89baf53 EEVEE-Next: Port subsurface to compute shader
This makes the SSS processing more isolated to avoid
side effects in other passes.
Also this allow more optimization using LDS.

The radiance buffer is created by a setup phase using
direct and indirect lighting.

Splitting this into its own compute pass also fixes
a pass merging issue on Metal.

Pull Request: https://projects.blender.org/blender/blender/pulls/112901
2023-09-26 15:52:35 +02:00
Campbell Barton 077832e063 Cleanup: spelling in comments 2023-09-26 19:50:48 +10:00
Clément Foucault a5741e0561 EEVEE: Change `do_multiscatter` to a `bool` internally
This avoid confusion outside of the shader node GLSL code.
The issue also is that Metal allow float to cast to bool
implicitly but this create a compilation error on
OpenGL.
2023-09-26 11:48:51 +02:00
Jeroen Bakker 8f9c14145e EEVEE-Next: Fix World Reflection During Raytracing
Scenes that only uses a world probe would didn't work. Raytracing
would look for the closest light probe, didn't find any and shader
would use undefined behavior to sample in the reflectionProbes texture.

In some cases this resulted in correct results when the world was
located on layer 0 with subdivision 0. In any other case this would
sample incorrect incoming light what lead to black reflections.

This PR fixes this by returning the world probe when no nearest light
probe cound be found.

Pull Request: https://projects.blender.org/blender/blender/pulls/112893
2023-09-26 11:19:04 +02:00
Jeroen Bakker aebcec0493 EEVEE: Fix Shader Compilation
Pull Request: https://projects.blender.org/blender/blender/pulls/112890
2023-09-26 10:24:47 +02:00
Clément Foucault 0a4fa62f51 EEVEE: Add support for metallic F82 tint
This adds a new entry to the split sum LUT to isolate
the effect of the F82 tint.

The application of the tint part is similar to cycles
and uses the same way for precomputing the `b` factor.

Results matches almost perfectly to the extent of the
split sum approximation.

Note that this removes the unused LTC MAG LUT for
EEVEE next to make space for the new table. It can still
be added back if needed.

Pull Request: https://projects.blender.org/blender/blender/pulls/112881
2023-09-26 10:16:39 +02:00
Hans Goudey 916d4c9d9b Cleanup: Move BKE_screen.h to C++
See #103343
2023-09-25 17:53:11 -04:00
Jason Fielder ee03bb38cb Metal: Add support for atomic image operations
Texture Atomics have been added in Metal 3.1
and enable the original implementations of
shadow update and irradiance cache baking.

However, a fallback solution will be
required for versions under macOS 14.0 utilising
buffer-backed textures instead.

This patch also includes a stub implementation if
building/running on older macOS versions which
provides locally-synchronized texture access in
place of atomics. This enables some effects to be
partially tested, and ensures non-guarded use
of imageAtomic functions does not result
in compilation failure.

Authored by Apple: Michael Parkin-White

Pull Request: https://projects.blender.org/blender/blender/pulls/112866
2023-09-25 21:56:46 +02:00
Miguel Pozo 499c39cfb9 Fix #112867: Workbench: Final render fails to render hair
Add missing calls to the old draw manager functions.
2023-09-25 21:15:56 +02:00
Miguel Pozo 0dfcde3fde Fix: EEVEE-Next: Ensure volume property textures are cleared
Clear volume property textures when there's no valid world volume
shader.

Pull Request: https://projects.blender.org/blender/blender/pulls/112871
2023-09-25 19:54:51 +02:00
Brecht Van Lommel 1d265eed5d Shaders: rename Specular to Specular IOR Level in Principled BSDF
To clarify that this is no longer the primary control, but rather
and adjustment on IOR.

Ref #99447
Ref #112552
2023-09-25 19:51:22 +02:00
Lukas Stockner 6e2f29b421 Shader: change Specular input on Principled BSDF to affect IOR
This keeps the behavior similar to the Disney BRDF, where 0.5
is neutral and lower/higher values respectively decrease/increase
the dielectric specular. But it's more correct in that it's not
an arbitrary scale on Fresnel, but rather adjusting the IOR.

Ref #99447
Ref #112848

Pull Request: https://projects.blender.org/blender/blender/pulls/112552
2023-09-25 19:51:02 +02:00
Weizhen Huang def9b76207 Shader: Change specular tint in Principled BSDF from float to color
For more artistic control. Tints the reflection of dielectric materials
at normal incidence.

Ref #99447

Pull Request: https://projects.blender.org/blender/blender/pulls/112192
2023-09-25 19:42:05 +02:00
Clément Foucault f2fb74d30c Fix #112802: EEVEE-Next: Invalid weight when mixing closures
This was caused by a weight of 0 leading to `x = 0 / 0` which
resulted in NaNs and missing closure data.

Pull Request: https://projects.blender.org/blender/blender/pulls/112855
2023-09-25 15:14:45 +02:00
Sybren A. Stüvel eab95fa2aa Anim: enable visual keying of IK-influenced bones
Enable visual keying of bones that are influenced by an IK constraint.
This wasn't possible before, as the visual keying system only checked
constraints on the bone itself, and not whether the bone was part of an
IK chain.

This commit introduces a new `bPoseChannel::constflag` value
`PCHAN_INFLUENCED_BY_IK` that is set whenever the pose bone is part of
an IK chain.

The `pchan->constflag` field is computed during depsgraph evaluation. If
the depsgraph is active, it is now also written back to the original
pchan, so that it can be used in the "should visual keying be used"
function.

Fixes: #76791 "Different results when keyframing visual transforms and
applying transforms manually on IK constraint". Note that visually
keying does *not* copy the visual pose to the current pose. Furthermore,
when visually keying only part of the IK chain, the result of
re-evaluating the IK constraint (for example by moving the scene forward
and then backward by one frame) may still produce a different result, as
the IK chain now has a different start orientation.

Note that commit explicitly does not cover Spline IK constraints. They
can introduce heavy shear, especially with the default settings, which
cannot be represented by keys on loc/rot/scale.

For historical reference: 876cfc837e
introduces the 'use visual keying' preference option, where Blender
automatically chooses whether or not to use visual keying. This is why
there is a function at all that determines whether to use visual keying
or not.
2023-09-25 14:37:22 +02:00
Sybren A. Stüvel caf46c9fbb Refactor: anim, rename flag PCHAN_HAS_TARGET to PCHAN_HAS_NO_TARGET
Rename the `bPoseChannel::flag` `PCHAN_HAS_TARGET` to `PCHAN_HAS_NO_TARGET`
as that is actually the meaning of the flag (in the majority of the code).

Since the flag was so confusingly named, there were some mixups in the
armature overlay drawing code as well, which have been fixed now too.
2023-09-25 14:33:51 +02:00
Sybren A. Stüvel 08f1ec65c7 Refactor: anim, avoid function call in `draw_bone_relations()`
Avoid a call to `bone.as_posebone()`, as the result of that call is already
stored in the `pchan` variable.

No functional changes.
2023-09-25 14:33:51 +02:00
Miguel Pozo 8fbfc991a5 Fix: EEVEE-Next: Surfel debug draw
Regression after 5ad7d81549.
2023-09-25 12:55:23 +02:00
Miguel Pozo eefeb3ee22 Fix #112675: Workbench: Shadows disabled for active object 2023-09-25 12:43:26 +02:00
Campbell Barton e38ff7c06d Cleanup: use C++ comments for disabled code 2023-09-25 17:06:04 +10:00
Campbell Barton caef976ceb Cleanup: correct typo "hardeness" to "hardness" in DNA & variable names 2023-09-25 12:05:50 +10:00
NueSB 4aaae8d0a6 GPencil: Implement nearest neighbor filtering for pixelate effect
The Pixelate effect has an antialiasing switch that cleans up
pixels mostly, but still has some inbetween artifacts that are
a little frustrating to deal with. This makes it so that pixels are
completely hard-edged when AA is disabled.

Pull Request: https://projects.blender.org/blender/blender/pulls/112605
2023-09-24 16:01:31 +02:00
Campbell Barton d4dbbab5d9 Cleanup: locate break statements inside the case body
Follow the convention used almost everywhere in Blender's code.
2023-09-23 21:17:50 +10:00
Jason Fielder c9f44a2f9d EEVEE Next: Add info count for shader optimization jobs in progress
Authored by Apple: Michael Parkin-White

Pull Request: https://projects.blender.org/blender/blender/pulls/112533
2023-09-22 11:38:06 +02:00
Campbell Barton 5fbcb4c27e Cleanup: remove spaces from commented arguments
Also use local enums for `MA_BM_*` in versioning code.
2023-09-22 12:21:18 +10:00
Hans Goudey 867f99c2af Cleanup: Move depsgraph headers to C++
Pull Request: https://projects.blender.org/blender/blender/pulls/110816
2023-09-22 03:18:17 +02:00
Campbell Barton aba119e192 Cleanup: quiet CMake uninitialized variable warning, sort file lists 2023-09-22 11:04:25 +10:00
Campbell Barton 6a8fc659ba Cleanup: spelling in comments 2023-09-22 10:02:05 +10:00
Jeroen Bakker 6d91d36161 GPU: Remove GPU_shader_storage_buffer_objects_support
Blender 4.0 requires OpenGL 4.3 which always support SSBO's.
Platforms that don't support enough SSBO bind points will be marked
as unsupported.

Users who start Blender on those platforms will be informed via a
dialog. This PR also updates the `--debug-gpu-force-workarounds`
to match our minimum requirements. Note that some bugs are still
there that should be solved in other PRs:

* Workbench only renders the object using a unit matrix this is because
  there is a bug in the workaround for shader_draw_parameters
* Navigating with middle mouse button is not working. Unsure what the
  cause is, but might be a missing feature check in the OpenGL backend.

Related to #112224

Pull Request: https://projects.blender.org/blender/blender/pulls/112572
2023-09-21 12:55:51 +02:00
Clément Foucault 89da0cf07d EEVEE-Next: Raytrace: Add Diffuse Ray
This implement the diffuse tracing as simple
screen-space ray trace. This is extremely inefficient
and should only be used for reference purpose.

The real screen space diffuse implementation will
be done in another PR.

Depends on #112507

![image](/attachments/a2c0a9d9-3206-4dc7-acf8-0c37851ad10b)

Pull Request: https://projects.blender.org/blender/blender/pulls/112539
2023-09-20 18:36:59 +02:00
Clément Foucault 7c1cb4bd8b EEVEE-Next: Deferred: Add combine pass
This allow to move the light evaluation up in the deferred pipeline and
avoid coupling two different steps into one. This add more flexibility
in the implementation of deferred lighting and indirect lighting
algorithms.

This splits the reflection probe evaluation to its own
shader since it is quite different now.

Pull Request: https://projects.blender.org/blender/blender/pulls/112507
2023-09-20 17:52:55 +02:00
Clément Foucault e2cef1c713 EEVEE-Next: Port SSS profile to Pre-compute shader
This moves the pre-computation offline and store the pre-computed
table in the binary. The pre-computed tables are quite small and are
not a concern with respect to binary size increase.

This rewrites the precomputation to use manually fitted
approximations for both burley and random walk.
The approximations fix a discrepancy between cycles and EEVEE
SSS translucency look. The absolute maximum error is below 2%.
I believe better results could be achieved with automatic fitting
tools.

Note that Cycles Burley translucency profile has some issues as it
does not give a smooth profile. The profile is biased near the end
of the lower radii. For this reason, the fit was done on a white
diffuse with (1,1,1) radii which does not exhibit this artifact.

Note that while this adds the profile for random walk, it isn't
currently used because the profile type is not yet passed down
the deferred path.

The fitting data can be found attached to this PR.

Pull Request: https://projects.blender.org/blender/blender/pulls/112512
2023-09-20 15:17:27 +02:00
Clément Foucault f079b653c1 EEVEE-Next: Deferred: Add combine pass
This allow to move the light evaluation up in
the deferred pipeline and avoid coupling two
different steps into one. This add more
flexibility in the implementation of
deferred lighting and indirect lighting
algorithms.

This splits the reflection probe evaluation
to its own shader since it is quite different
now.
2023-09-20 15:05:41 +02:00
Jason Fielder 70e99ee8b6 Fix #112258: Resolve broken volumetric world materials in Metal
Ensures correct BuiltinBits Layer flag was specified for materials
using volumetrics.

Authored by Apple: Michael Parkin-White

Pull Request: https://projects.blender.org/blender/blender/pulls/112577
2023-09-19 16:49:00 +02:00
Jeroen Bakker 39e6776689 Fix: GPU Incorrect Padding For Globals
A float array use different alignment and reservation rules on
GPU versus CPU. Before this change the _pad1 was aligned to 16 bytes as
it was defined as an array, but on CPU this alignment doesn't
happen.

This is fixed by using 3 floats in stead of a float array for padding.

Pull Request: https://projects.blender.org/blender/blender/pulls/112565
2023-09-19 12:10:31 +02:00
Campbell Barton d8b8089630 Cleanup: spelling & typo in last commit 2023-09-19 15:53:51 +10:00
Weizhen Huang 1cb7e29123 Fix: EEVEE: implicit cast from `float` to `bool` in Multiscatter GGX 2023-09-18 17:29:10 +02:00
Weizhen Huang e0dacfdda6 EEVEE: use Schlick's approximation instead of real Fresnel for glass
so that we can tint `F0` separately
Ref: #112192 #99447

Mostly affects `IOR < 1`. The overall appearance matches, with some changes in the reflection.

Pull Request: https://projects.blender.org/blender/blender/pulls/112390
2023-09-18 14:26:19 +02:00
Pablo Vazquez a59ec4c936 UI: Rename Eevee to EEVEE in labels/tooltips
Remove ambiguity of Eevee/EEVEE in labels, tooltips, and docs.

The correct spelling is "EEVEE".

Pull Request: https://projects.blender.org/blender/blender/pulls/112501
2023-09-18 12:28:36 +02:00
Campbell Barton 7eae806dda Cleanup: format, spelling 2023-09-17 09:05:40 +10:00
Clément Foucault c00962d038 EEVEE-Next: Raytrace: Add back Screen Space radiance input
This finalize the implementation of the screen space tracing
for EEVEE-Next.

Refractive objects can now have screen space reflection too
and self reflect.

This keeps the feedback radiance buffer principle of the
Classic EEVEE so that we still get infinite bounces by default.

There are some conflict with refraction tracing and ambient
occlusion nodes. Materials using screen space refraction will
not be able to detect occlusion from any refractive surface using
screen space refraction including itself.
They also won't be visible to screen space reflections from other
materials *not* using screen space refraction.
This should be added to the list of limitations for now.

Note that the current approach to feed the radiance is to copy
the radiance buffer. This has the nice property of only containing
the currently rendered objects and not project transparent objects
or other non-yet rendered object onto the depth behind them.

Pull Request: https://projects.blender.org/blender/blender/pulls/112341
2023-09-16 11:48:13 +02:00
Miguel Pozo 264c81a0a0 Fix #112409: Workbench: Cavity disabled when Xray is enabled 2023-09-15 15:35:01 +02:00
Weizhen Huang f014e44e8b Refactor: EEVEE: add utility function for 3D texture read
with manual trilinear interpolation. Currently only used for GGX BSDF LUT

Pull Request: https://projects.blender.org/blender/blender/pulls/112386
2023-09-14 18:46:07 +02:00
Weizhen Huang d10a87da48 Fix: EEVEE: wrong reflectance at `IOR == 0.0`
should be 1 instead of 0
2023-09-14 16:13:14 +02:00
Weizhen Huang 5baf652374 Cleanup: EEVEE: rename glass BTDF to BSDF at several places
because it contains reflectance and transmittance, so BSDF would be a
morep proper name.
Also rename BSDF to BRDF at places where only reflectance is returned.
2023-09-14 16:06:26 +02:00
Weizhen Huang 4e00410d9e Fix: EEVEE: use inverse IOR in BSDF LUT `refract()`
the `refract()` function require the relative IOR of the media where V
is in to the media where L is in. Because this only affects the
visibility term, the difference is quite small
2023-09-14 16:06:26 +02:00
Campbell Barton b7f3e0d84e Cleanup: spelling & punctuation in comments
Also remove some unhelpful/redundant comments.
2023-09-14 13:25:24 +10:00
Miguel Pozo f42b02cccc Workbench: Sculpt fixes
* Fix #112284 and other non-reported sculpt-related regressions in the
   new Workbench.
* Cleanup ObjectState setup.
* Update `sculpt_batches_get` to support getting per material batches
   while passing SculptBatchFeatures.
* Make material indices 0 based in Workbench.

Pull Request: https://projects.blender.org/blender/blender/pulls/112344
2023-09-13 22:36:37 +02:00
Miguel Pozo 27a36ccc0f Fix: EEVEE-Next: SSS image rendering
Compute SSS samples location at the render function,
once sampling.rng functions return valid data.
2023-09-13 21:05:46 +02:00
Miguel Pozo 6e24ecac03 Fix #112289: Workbench: Always clear depth_in_front 2023-09-13 16:35:28 +02: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
Miguel Pozo b7ba7663a7 Fix #112231: Workbench: Texture support in sculpt mode 2023-09-12 18:48:34 +02:00
Miguel Pozo 443254b1a6 Fix #112211: Workbench: Clamp infinite inputs in TAA 2023-09-12 16:27:40 +02:00
Miguel Pozo d81165f3ec Fix #111960, #112200, #112214: EEVEE: Incorrect BuiltinBits::LAYER use
5cf7089e43 added the `BuiltinBits::LAYER` to shaders with a geometry
stage. This causes compilation errors when
`GLContext::layered_rendering_support` is false (otherwise the flag
does nothing).

This PR moves the `LAYER` flags to the `no_geom` shader versions and
adds a check to `ShaderCreateInfo::finalize()` to ensure the `LAYER` flag
is not used in shaders with a geometry stage.

Pull Request: https://projects.blender.org/blender/blender/pulls/112245
2023-09-12 15:39:33 +02:00
Jeroen Bakker f1a0de8415 Overlay: Remove Unused Attribute in edit mesh face shader
`overlay_edit_mesh_face` has an attribute for its vertex normals,
but only used in the vertex shader when it isn't a face shader.

Removing this attribute fixes some performance validation warnings
in the Vulkan backend.

Pull Request: https://projects.blender.org/blender/blender/pulls/112269
2023-09-12 14:47:20 +02:00
Miguel Pozo b3bf8a4e05 EEVEE-Next: Add back data passes UI and missing passes
The `VIEWLAYER_PT_eevee_next_layer_passes_data` class name was
re-used by mistake for Workbench Next in ba982119cd,
and the actual EEVEE Next class was then removed in 678dc456e3.

This adds back the UI as it was, and the missing passes (Vector and
Position) it referenced.

Pull Request: https://projects.blender.org/blender/blender/pulls/112162
2023-09-11 20:14:04 +02:00
Miguel Pozo f25418b730 Fix #112242: Workbench: Allow xray in render mode 2023-09-11 19:52:03 +02:00
Miguel Pozo efb74555fd Fix: EEVEE-Next: Velocity do_deform detection
In image renders, after the first motion blur step,
non deformed geometry was being marked as deformed,
since all their geometry lengths are 0.

This caused velocity_local_pos_get to read wrong/unitialized values.
2023-09-11 19:16:32 +02:00
Miguel Pozo 967d49dba4 Cleanup: Formatting
Fix formatting after e5f6c57f8c
2023-09-08 21:35:13 +02:00
Miguel Pozo e5f6c57f8c EEVEE-Next: Merge UBOs
Merge all the small UBOs used by the engine to save binding slots.
Each module is still responsible for filling its own data (by storing a
reference to it at construction) and this data is still private for other
modules.
The engine instance pushes the data to the GPU at the end of
`end_sync`, so only the modules that modify their data outside of the
sync functions need to manually call `Instance::push_uniform_data()`.

Pull Request: https://projects.blender.org/blender/blender/pulls/112046
2023-09-08 21:03:37 +02:00
Miguel Pozo 1faa522880 Fix: EEVEE-Next: Motion blur on image renders
overscan_changed is always true the first frame.
2023-09-08 20:29:29 +02:00
Campbell Barton 468198a6df License header: add SPDX header 2023-09-08 22:33:32 +10:00
Hans Goudey 006104645a Cleanup: Remove unnecessary struct keyword in C++ code 2023-09-08 08:27:28 -04:00
Campbell Barton 9e41eccc6e Cleanup: spelling in comments 2023-09-08 17:12:29 +10:00
Campbell Barton 4fc5d287ac Cleanup: doxygen parameters, blank comment lines 2023-09-08 16:53:30 +10:00
Campbell Barton 5ab2f61d44 Cleanup: remove use of 'auto' 2023-09-08 16:53:27 +10:00
Hans Goudey 9f998c3e3a Cleanup: Change mesh face triangle count macro to C++ inline function 2023-09-07 08:36:43 -04:00
Hans Goudey 9db02c8617 Cleanup: Change OffsetsIndices::data() to return Span instead of pointer
Accessing the span should be possible. `Span` already allows pointer
access itself.
2023-09-06 22:27:39 -04:00
Miguel Pozo e850df06ee Workbench: Remove next postfix
Pull Request: https://projects.blender.org/blender/blender/pulls/111993
2023-09-06 15:54:50 +02:00
Miguel Pozo 2aa7961e6f Workbench: Remove old implementation 2023-09-06 15:54:48 +02:00
Miguel Pozo fc08f220bf EEVEE Next: Volumes: Lighting integration improvements
Add the features missing from #107176

* Irradiance integration.
* Self-shadows.
* Receive shadows from shadow maps.

Shadow tagging works by iterating all the froxels in a
compute shader and tagging the exact same position
that will be sampled by the volume scatter shader.
Froxels that are fully transmissive, have no scattering,
or are behind opaque geometry, are skipped.

It also adds a LoD bias parameter for shadow tagging,
driven by the volumetric tile size.
This works for punctual shadows, but directional lights
would need a way to support re-direction between levels
at sampling time, which is out of the scope of this PR.

Pull Request: https://projects.blender.org/blender/blender/pulls/110809
2023-09-06 14:35:57 +02:00
Miguel Pozo fdda220a64 FIx: Workbench: Texture-less materials in texture mode
Fallback to material color if there's no texture.
2023-09-05 19:47:28 +02:00
Campbell Barton 0c26c84704 Cleanup: spelling in comments 2023-09-05 11:04:27 +10:00
Clément Foucault 4f3b224141 EEVEE-Next: Irradiance Volume: Add clamp options
This allows to clamp the lighting components
during the baking phase.

Also add back intensity option.

Pull Request: https://projects.blender.org/blender/blender/pulls/110858
2023-09-04 23:27:30 +02:00
Clément Foucault 715eb4d88e Fix: EEVEE-Next: Fix shader compilation on Metal 2023-09-04 19:40:36 +02:00
Jason Fielder 5cf7089e43 GPU: Ensure usage of gpu_Layer is specified
Some shaders using gl_Layer/gpu_Layer were missing
the correct usage bit in the shader create info. Shaders
also need to inherit feature usage bits from included
additional_info.

Authored by Apple: Michael Parkin-White

Pull Request: https://projects.blender.org/blender/blender/pulls/111751
2023-09-04 15:06:20 +02:00
Jason Fielder 5fb952a1a6 EEVEE Next: Resolve out of bounds reads in shadows
Resource IDs and tile shfits often meant buffers were
accessed outside of their valid range. Patch ensures
resource IDs are unpacked and shift ranges are
shifted into the positive range to avoid inconsistent
behaviour with negative modulo operations.

Authored by Apple: Michael Parkin-White

Pull Request: https://projects.blender.org/blender/blender/pulls/111808
2023-09-04 15:03:54 +02:00
Clément Foucault 938d43c317 Fix: EEVEE-Next: Fix LUT translation unit hanging debug build 2023-09-04 11:43:02 +02:00
Clément Foucault 102bdfaed7 Fix: EEVEE-Next: Ambiguous cast compilation error 2023-09-04 09:46:45 +02:00
Clément Foucault 30de3d7c1a EEVEE-Next: Move LUT to C++ and eevee-next folder 2023-09-03 17:22:31 +02:00
Clément Foucault 760aa0e917 Cleanup: EEVEE-Next: Rename LookUpTable to Precompute 2023-09-03 16:42:53 +02:00
Clément Foucault ad71a04de0 EEVEE-Next: Fix G1_V term used to compute the GGX pdf
Thanks goes to @weizhen for spotting the mistake.
2023-09-03 16:42:53 +02:00
Clément Foucault 2aebfb596e Cleanup: EEVEE-Next: Rename G1 to G1_V to avoid confusion 2023-09-03 16:42:53 +02:00
Clément Foucault 2637bbf016 EEVEE-Next: Add LUT test
This avoid the generation code to become desync with
the precomputed tabled.

This is also a good way to test any changes to them.
2023-09-03 16:42:53 +02:00
Clément Foucault 7b54fce723 EEVEE-Next: Port LUT generation code
This ports the LUT using compute shader.
All LUT are computed by the same compute shader
to avoid boiler plate code to add new LUTs.

As for the generation code itself it is mostly the
same except for the use of `hammersley_2d` instead of
regular grid sampling. Regular grid did not improve
anything and was a bit more cumbersome.

This also bumps the number of samples very high
for more precision.

The new utility class for computing the LUT has
methods to write the content to a PFM image file
or as C++ array header.
2023-09-03 16:42:53 +02:00
Campbell Barton e8c812a307 Cleanup: spelling in comments, update dictionary 2023-09-03 21:35:07 +10:00
Campbell Barton 3082037743 Cleanup: spelling in comments 2023-09-03 16:15:01 +10:00
Clément Foucault 5ad7d81549 Cleanup: EEVEE-Next: Fix compilation warning and errors on Metal 2023-09-02 23:17:36 +02:00
Hans Goudey fa34992def Cleanup: Remove unnecessary includes from C++ data structure headers
The hash tables and vector blenlib headers were pulling many more
headers than they actually need, including the C base math header,
our C string API header, and the StringRef header. All of this
potentially slows down compilation and polutes autocomplete
with unrelated information.

Also remove the `ListBase` constructor for `Vector`. It wasn't used
much, and making it easy to use `ListBase` isn't worth it for the
same reasons mentioned above.

It turns out a lot of files depended on indirect includes of
`BLI_string.h` and `BLI_listbase.h`, so those are fixed here.

Pull Request: https://projects.blender.org/blender/blender/pulls/111801
2023-09-01 21:37:11 +02:00
Miguel Pozo 619f38514e Fix: Compilation error after 7e33c405fb 2023-09-01 17:36:30 +02:00
Miguel Pozo 7e33c405fb Fix: EEVEE-Next: Render Region
Fix render regions and make them work with overscan:
- Clarify and improve the naming used by the Film module.
- Convert Display texel coordinates to Film texel coordinates before
  calling `film_process_data`, and convert from Film texel coordinates to
  Render texel coordinates in `film_sample_get`.
- Returns the actual display extent (and not the film extent) in
 `Film::display_extent_get` so the overscan camera matrix is computed
  correctly when using render regions.

Regression caused by 567a2e5a6f.

Pull Request: https://projects.blender.org/blender/blender/pulls/111691
2023-09-01 17:15:38 +02:00
Miguel Pozo fc0f2bd73e Workbench-Next: Support multiple samples for Viewport Image Render
Allow rendering multiple samples from a single draw callback.

Pull Request: https://projects.blender.org/blender/blender/pulls/111661
2023-09-01 15:57:21 +02:00
Miguel Pozo 3d7db929a4 Draw: draw_debug improvements
Allow using the drw_debug API in any shader file.
Remove the drw_debug API from Release builds.

Pull Request: https://projects.blender.org/blender/blender/pulls/111710
2023-09-01 15:40:42 +02:00
Weizhen Huang b45dd4cfac EEVEE: change Principled BSDF to match Cycles
Ref: #99447

Co-authored-by: Clément Foucault <foucault.clem@gmail.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/111754
2023-09-01 11:28:12 +02:00
Weizhen Huang be9555d118 EEVEE: change Glass BSDF to match Cycles
changes include:
* Use microfacet normal instead of macronormal. Previously Cycles used
macronormal for Glass BSDF and Transmission component in Principeld
BSDF, leading to artefacts at grazing angles. This has been corrected
in 5f9b518a8b and 89218b66c2. Now change EEVEE to match this behaviour.
* GGX distribution is now darker due to the shadowing-masking term,
while Multiscatter GGX preserves energy. This now matches Cycles too.

Pull Request: https://projects.blender.org/blender/blender/pulls/111687
2023-09-01 10:59:20 +02:00
Miguel Pozo 8ea2364e36 Fix: Workbench-Next: Image Render crash 2023-08-31 18:07:18 +02:00
Hans Goudey 4e94db97e2 Mesh: Add three cached topology maps
Add three cached topology maps to `Mesh`, to avoid computations when
mesh data isn't changed. Choosing the right maps to cache is a bit
arbitrary, but generally we have to start somewhere. The limiting
factor is memory usage (all the new caches combined have a
comparable footprint to a UV map).

For now, the caches added are:
- Vertex to face corner
- Vertex to face
- Face corner to face

These caches are used in quite a few places already;
- Face corner normal calculation
- UV value merging
- Setting sharp edges from face angles
- Data transfer modifier
- Voxel remesh attribute remapping
- Sculpt mode painting
- Sculpt mode normal calculation
- Vertex paint mode
- Split edges geometry node
- Mesh topology geometry nodes

Caching topology maps means they don't have to be rebuilt every time
they're used. Meshes copied but without topology changes can share
the cache, further reducing re-computations. For example, FPS with a
large mesh using the "Corners of Vertex" node went from 1.8 to 2.3.
Entering sculpt mode is slightly faster too.

There is some obvious work for future commits:
- Use caches in attribute domain interpolation
- More multithreading of second phase of map building
- Update/build caches eagerly in some geometry nodes

Pull Request: https://projects.blender.org/blender/blender/pulls/107816
2023-08-30 23:41:59 +02:00
Campbell Barton cbc14782ff Fix mistaken revert of EEVEE fix in recent commit
[0] unintentionally reverted [1], correcting.

[0]: 3d607be572
[1]: 068e117a8b
2023-08-30 21:23:36 +10:00
Campbell Barton 3d607be572 Cleanup: spelling in comments 2023-08-30 10:57:12 +10:00
Hans Goudey 69c498084a Cleanup: Remove unnecessary Mesh C API functions 2023-08-29 11:47:29 -04:00
Hans Goudey 425b871607 Mesh: Replace EdgeHash and EdgeSet with C++ classes
The `EdgeHash` and `EdgeSet` data structures are designed specifically
as a hash of an order agnostic pair of integers. This specialization can
be achieved much more easily with the templated C++ data structures,
which gives improved performance, readability, and type safety.

This PR removes the older data structures and replaces their use with
`Map`, `Set`, or `VectorSet` depending on the situation. The changes
are mostly straightforward, but there are a few places where the old
API made the goals of the code confusing.

The last time these removed data structures were significantly changed,
they were already moving closer to the implementation of the newer
C++ data structures (aa63a87d37).

Pull Request: https://projects.blender.org/blender/blender/pulls/111391
2023-08-29 17:00:33 +02:00
Miguel Pozo 639a74d236 Fix: EEVEE-Next: Subsurface Scattering regression
Regression caused by 17db856686
Subsurface Scattering uses an additive pass over the radiance output,
so it's always needed even if the deferred pass is not the last one.

Pull Request: https://projects.blender.org/blender/blender/pulls/111534
2023-08-29 15:55:02 +02:00
Weizhen Huang 9fba9f418d Fix: EEVEE: runtime-generated BSDF LUT does not match the precomputed LUT
* `RUNTIME_LUT_CREATION` is disabled by default, but if set to `true`,
the new `bxdf_lut_frag.glsl` should generate the LUT that is submitted
in this commit. This new LUT is very close to the previously stored one.
* Generate the LUT by Monte-Carlo sampling with \(I = 1/N\sum\frac{f}{p}\),
except that the samples are not random, but mapped from a regular grid,
following previous approach to avoid interpolation artefacts caused by
noise.
* Added comments to make the computed quantities and the LUT usage more
clear.
* Glass with `IOR < 1` is now slightly darker due to single-scattering.
The lost energy will be recovered in a future commit.
* The special cases of `IOR == 0`, `roughness == 0` and `roughness == 1`
are handled well during microfacet sampling and evaluation, no need to
clamp.
* When `IOR == 1`, in theory BRDF is zero and BTDF is one, but we do not
make it a special case to allow smooth transition.

Pull Request: https://projects.blender.org/blender/blender/pulls/111632
2023-08-29 15:22:37 +02:00
Weizhen Huang 068e117a8b Fix shader compile error due to `saturate()` not available
use `clamp()` instead
2023-08-29 15:02:42 +02:00
Sybren A. Stüvel 042c5347f4 Anim: move bone colors from bone groups to individual bones
Move control over the color of bones from bone groups to the bones
themselves. Instead of using bone groups (which are defined on the pose,
and thus owned by the object), the color is stored on:

- the bone (`struct Bone`, or RNA `armature.bones['bone_name'].color`)
- a possible override on the pose bone (`struct bPoseChannel`, or RNA
  `ob.pose.bones['bone_name'].color`).

When the pose bone is set to its default color, the color is determined
by the armature bone. In armature edit mode, the armature bone colors
are always used, as then the pose data is unavailable.

Versioning code converts bone group colors to bone colors. If the
Armature has a single user, the group color is stored on the bones
directly. If it has multiple users, the group colors will be stored on
the pose bones instead.

The bone group color is not removed from DNA for forward compatibility,
that is, to avoid immediate dataloss when saving a 3.6 file with 4.0.

This is part of the replacement of bone groups & armature layers with
bone collections. See the design task at #108941.

Pull request: https://projects.blender.org/blender/blender/pulls/109976
2023-08-29 14:31:18 +02:00
Weizhen Huang dc9589d3e4 Cleanup: use utility function for LUTs parametrized by `cos_theta` and `roughness`
Pull Request: https://projects.blender.org/blender/blender/pulls/111651
2023-08-29 14:08:38 +02:00
Weizhen Huang 3876133ef5 Fix wrong factor in EEVEE multi-GGX average color
The original paper is assuming `f90 == 1`. However, it is just an
estimation, and the difference is really subtle.
2023-08-29 14:06:37 +02:00