Commit Graph

9958 Commits

Author SHA1 Message Date
Clément Foucault
e19e9e57ee EEVEE: Split eevee_shader_shared.hh into multiple files
The goal of this patch is to reduce final shader code footprint to
hopefully reduce shader compile time (see #145347).

This also contains a pass over most shader file to remove unused
include or use more granular ones to reduce final shader code
length.

Testing with the same setup as #145347:
|          | main (ms) |  PR (ms) |   Delta (ms) |
| -------- | ----------- | ------------ |------------ |
| Nvidia   |         257 |  207 (1.24x) |         50 |
| Mesa AMD |         323 |  295 (1.09x)    |        28 |

In barbershop test scene however the saving are not so noticeable:
|          | main (s) |  PR (s) |   Delta (s) |
| -------- | ----------- | ------------ |------------ |
| Nvidia (OpenGL)  |         40 |  39 (1.02x) |         1 |
| Nvidia (Vulkan)   |         29 |  29 (1.0x) |         0 |

Pull Request: https://projects.blender.org/blender/blender/pulls/145803
2025-09-12 14:09:35 +02:00
Campbell Barton
1e2ed785f7 Cleanup: use assume attribute to quiet array bounds warning for GCC 15
Ref !146150
2025-09-12 22:03:35 +10:00
Sean Kim
a426e70bf6 Fix: Use new USER_DEVELOPER_TOOL_TEST macro where appropriate
Missed in fb91e576ca

Changes all of the non-sanitized, always available options to use the
new macro to match previous behavior.

Pull Request: https://projects.blender.org/blender/blender/pulls/146118
2025-09-12 01:42:52 +02:00
Sergey Sharybin
963569caf4 Fix #146086: Regression: OpenSubdiv: GPU Shaders gets recompiled for each evaluation
Regression in 1e4764a9a5 which accidentally removed use of
the g_subdiv_evaluator_cache.

Pull Request: https://projects.blender.org/blender/blender/pulls/146097
2025-09-11 17:17:30 +02:00
Clément Foucault
5561b97aa0 Cleanup: Metal: Avoid MSL warning in curves interpolation shader 2025-09-10 20:26:53 +02:00
Clément Foucault
6148d50105 GPU: Shader: Remove section of code guarded by #if directives
These lines can be removed to avoid parsing them.
This allow to keep the same processing for shared host files.

Also removes a few lines of code to reduce the size of
shader sources.

This also contains a rewrite of the include parsing using
the shader parser.

Pull Request: https://projects.blender.org/blender/blender/pulls/146025
2025-09-10 16:35:41 +02:00
Clément Foucault
36b80971de Cleanup: EEVEE: Typo in interlieved_gradient_noise 2025-09-10 12:47:49 +02:00
Clément Foucault
455d749c52 Fix: GPU: Implicit cast from int to bool in assert()
These are not valid in GLSL.
2025-09-10 12:20:59 +02:00
Clément Foucault
f0806ac6b4 Fix #145743: EEVEE: Instance leak when Stereoscopy is enabled
The `eevee_render_to_image` can be called multiple time in the
case of multiview rendering.

To avoid the leak, free the previous instance before allocating
the new one. Reusing the instance doesn't seems to work here.

Another fix will follow this one to fix it more gracefuly.
This fix is kept simple for backporting purpose.

Pull Request: https://projects.blender.org/blender/blender/pulls/146015
2025-09-10 12:18:49 +02:00
Clément Foucault
c302b7de7b Refactor: EEVEE: Simplify Gbuffer packing
Implementation of #145417

For more information see pull request.

Pull Request: https://projects.blender.org/blender/blender/pulls/145520
2025-09-10 12:17:21 +02:00
luz paz
0c3005ca0c Cleanup: Fix typos in source/blender/draw
Fixes user-facing and non-user-facing typos.
Found via codespell

Pull Request: https://projects.blender.org/blender/blender/pulls/145972
2025-09-10 11:19:36 +02:00
Clément Foucault
91614ee5d6 Fix #145203: Switching armatures in pose mode fails when behind mesh
The code introduced in a08de337db
did not account for the special case of `SELECT_PICK_NEAREST`
where the depth data is actually bitshifted.

Pull Request: https://projects.blender.org/blender/blender/pulls/145924
2025-09-10 10:52:21 +02:00
Jacques Lucke
32c301e3cf Shader Nodes: support repeat zones, closures and bundles
This adds a function that can turn an existing `bNodeTree` into an inlined one.
The new node tree has all node groups, repeat zones, closures and bundles
inlined. So it's just a flat tree that ideally can be consumed easily by render
engines. As part of the process, it also does constant folding.

The goal is to support more advanced features from geometry nodes (repeat zones,
etc.) in shader nodes which the evaluator is more limited because it has to be
able to run on the GPU. Creating an inlined `bNodeTree` is likely the most
direct way to get but may also be limiting in the future. Since this is a fairly
local change, it's likely still worth it to support these features in all render
engines without having to make their evaluators significantly more complex.

Some limitations apply here that do not apply in Geometry Nodes. For example,
the iterations count in a repeat zone has to be a constant after constant
folding.

There is also a `Test Inlining Shader Nodes` operator that creates the inlined
tree and creates a group node for it. This is just for testing purposes.

#145811 will make this functionality available to the Python API as well so that
external renderers can use it too.
2025-09-09 16:15:43 +02:00
Clément Foucault
51b5ae24f5 Fix #145028: Regression: 3D cursor misaligned with axes
The port in 38ce310c17
missed that axes in 3D view are drawn using the perspective
projection matrix and not the 2D one.

Pull Request: https://projects.blender.org/blender/blender/pulls/145927
2025-09-09 14:45:37 +02:00
Clément Foucault
7761b8cfb2 Fix: Overlay: Outline of subpixel Curves produce high aliasing
Issue introduced by #143180. The code was there beforehand but
was not clear. It was left commented out.
Modify it so that it matches the new code.
2025-09-09 14:15:55 +02:00
Clément Foucault
ff468e44ee Fix #144213: Overlay: Transparency ordering issue in texture paint
Caused by missing depth of in front objects in in-front buffer.
Forcing a depth prepass fixes the issue.
2025-09-08 12:55:16 +02:00
Clément Foucault
f8303efd57 Revert "Draw: Use ResourceHandleRange"
This reverts commit 8adb3e758f.
This is a partial revert that just always use the fallback
path.

The new optimized path is causing issues with overlays #145446 and
volumes #145420.

The new path will be enabled back when we fix those issues.
2025-09-08 12:00:14 +02:00
Clément Foucault
af1af75006 Fix #145783: Edit Mesh: Crash when selecting edge in some setup
This was caused by DRW_select_buffer_elem_get not being
failsafe. Handling the failure case properly fixes the issue.
2025-09-08 12:00:13 +02:00
Campbell Barton
34feb2cefd Fix #145770: UV sync select hides unselected faces
Regression [0] from fix for  #144035 caused the meaning of sync-select
to be flipped in drawing code, causing UV sync select to display
incorrectly in edit-mode.

Resolve by reversing the value returned by `skip_bm_face` as well as
checks in the drawing code.

Co-authored-by: Eitan Traurig <eitant13@gmail.com>

[0]: e02eb13a59
2025-09-07 00:23:29 +00:00
W_Cloud
43fdf067ab Geometry Nodes: improve Viewer Attribute Text Readability
- Corner Domain Text Overlap: Text is now offset along the angle bisector of
  each corner. The offset distance is dynamically adjusted based on the view
  zoom and corner angle sharpness.
- Wrap Long Line: Split Vectors, Colors, and Quaternions into labeled line for
  each component.

Pull Request: https://projects.blender.org/blender/blender/pulls/145290
2025-09-05 13:46:03 +02:00
Jeroen Bakker
4f4104d047 EEVEE: Fix pointcloud rendering for Vulkan
When using Vulkan the point clouds were not drawn correctly
in EEVEE. The reason is that only the back faces were drawn.

Pull Request: https://projects.blender.org/blender/blender/pulls/145787
2025-09-05 13:29:15 +02:00
Brecht Van Lommel
9856615813 Color Management: Change byte color attributes to always be sRGB
These don't really work as scene linear with sRGB transfer function for e.g.
ACEScg, there are not enough bits. If you want wide gamut you need to use
float colors.

Pull Request: https://projects.blender.org/blender/blender/pulls/145763
2025-09-05 11:11:33 +02:00
Brecht Van Lommel
ffa4f8c7ad Refactor: Split off lighter BLI_color_types.hh from BLI_color.hh
Functions for convert between the color types and ostream support are
now outside the classes.

Many files were changed to fix cases where direct includes for headers
were missing.

Pull Request: https://projects.blender.org/blender/blender/pulls/145756
2025-09-05 11:11:32 +02:00
Mattias Fredriksson
1789a7c3d1 Fix #145600: UV Editor crash with Text objects
Introduced with e02eb13a59

Pull Request: https://projects.blender.org/blender/blender/pulls/145601
2025-09-04 02:50:27 +02:00
Bart van der Braak
a80b4ce22b Fix #145566: Crash in GPU_shader_builtin_warm_up when unbound GL context
glCreateProgram was called without a valid OpenGL context after
DRW_gpu_context_create unbound it. Rebind context before GPU_init
to prevent crash.

Fixes #145566

Pull Request: https://projects.blender.org/blender/blender/pulls/145606

Co-Authored-By: Miguel Pozo <pragma37@gmail.com>
2025-09-03 12:39:29 +02:00
Campbell Barton
59949b04b3 Cleanup: sort file lists in CMake 2025-09-03 17:54:04 +10:00
Brecht Van Lommel
f59446624d Fix #145182: Bone custom shape mesh does not have subdivision
This uses a special delayed extraction code path that is not used by
any other drawing code. Ensure we have the subdivided mesh when GPU
subdivision is off similar to the other code paths.

Pull Request: https://projects.blender.org/blender/blender/pulls/145268
2025-09-02 13:16:39 +02:00
Jeroen Bakker
fc17013cf3 Cleanup: EEVEE: Remove Metal/AMD workaround
This PR removes an unused workaround.
AMD GPUs aren't supported on Metal since Blender 5.0.

Pull Request: https://projects.blender.org/blender/blender/pulls/145564
2025-09-02 12:41:41 +02:00
Jeroen Bakker
42a8c695bf Fix #144636: EEVEE Invalid hit during raytracing
Raytracing pipeline in EEVEE interpolates in time for better results.
But depending on the interpolation could try to load a sample that isn't
available.

This PR fixies this for planar probes and screen tracing. In screen
tracing the issue wasn't visible as it the background samples are
always cleared.

This has an expected performance penalty but it could require an
overhaul of EEVEE raytracing for a more efficient solution.

Pull Request: https://projects.blender.org/blender/blender/pulls/145508
2025-09-02 07:49:16 +02:00
Omar Emara
5c450290ff Fix #145403: Viewport Compositor error always persists
Errors produces by the viewport compositor always persists even after
their cause is fixed. That's because the error message is not cleared
before execution, which this patch fixes.
2025-09-01 10:25:23 +03:00
Sean Kim
c84b81003f Refactor: Use container types for Subdiv face_ptex_offset
This commit changes the face_ptex_offset from a manually managed int
array to a blender::Array. This required a number of changes:

* The `Subdiv` struct is no longer trivial, so MEM_new and MEM_delete
  need to be used
* The Draw module API has an overloaded set of `origindex_buffer`
  methods created to take in a Span instead of an int pointer and size

Pull Request: https://projects.blender.org/blender/blender/pulls/141702
2025-08-29 21:52:19 +02:00
Miguel Pozo
18b7b64dd4 Fix #145396: Selection doesn't consider viewport visibility
Missing check.
Regression from 8adb3e758f
2025-08-29 15:44:37 +02:00
Hans Goudey
c01d4a4ee6 Refactor: Deduplicate position transform utilities
The pattern of transforming many position vectors at once is quite
common, both with separate source and result arrays, and when modifying
an array in place. In some cases at least we used a separate function
with a consistent name across files, but there were also many duplicate
parallel transform implementations.

This commit adds these utilities to the BLI_math_matrix.hh API and uses
them where many positions from contiguous arrays are transformed at
once. While there might be a more ideal location for these utilities,
it's consistent with 3936d7a93e, and certainly better
than duplicating them.

This also reduces binary size of my build by 15 KB.

Pull Request: https://projects.blender.org/blender/blender/pulls/145352
2025-08-28 19:27:17 +02:00
Sean Kim
e02eb13a59 Fix #144035: Image Editor ignores face selection
Introduced in 24d08e0bae

The above commit introduced a new batch for drawing UVs in the Image
editor that does not consider face selection when drawing the
corresponding UV map. This was done to reuse the IBO used in object
mode.

Unfortunately, this change didn't account for the case of being able to
select faces in the 3D Viewport (i.e. in Edit or Texture Paint mode)
while also viewing the Image Editor in Paint Mode.

To fix this, the following changes have been made:

* Introduce a new case when drawing the `MeshUV` overlay for objects
  being edited.
* Add two new IBO types and a new batch type to clearly differentiate
  between the above cases when extracting mesh data.
* Fixes some incorrect usage of the `sync_selection` concept

Pull Request: https://projects.blender.org/blender/blender/pulls/144105
2025-08-28 03:11:21 +02:00
Hans Goudey
d61064ae9b Cleanup: Remove unnecessary operator< in draw code
There was a misunderstanding when these types were
added that operator< was necessary for blender::Map.

Pull Request: https://projects.blender.org/blender/blender/pulls/145199
2025-08-27 17:46:41 +02:00
Miguel Pozo
928e654b9a Fix: Draw: Attribute Viewer doesn't work
Regression from 8adb3e758f.

Pull Request: https://projects.blender.org/blender/blender/pulls/145249
2025-08-27 17:05:17 +02:00
Clément Foucault
ba4589e894 DRW: New Curve Drawing
Implementation of the design task #142969.

This adds the following:
- Exact GPU interpolation of curves of all types.
- Radius attribute support.
- Cyclic curve support.
- Resolution attribute support.
- New Cylinder hair shape type.
![image.png](/attachments/a8e7aea0-b0e5-4694-b660-89fb3df1ddcd)

What changed:
- EEVEE doesn't compute random normals for strand hairs anymore. These are considered legacy now.
- EEVEE now have an internal shadow bias to avoid self shadowing on hair.
- Workbench Curves Strip display option is no longer flat and has better shading.
- Legacy Hair particle system evaluates radius at control points before applying additional subdivision. This now matches Cycles.
- Color Attribute Node without a name do not fetch the active color attribute anymore. This now matches Cycles.

Notes:
- This is not 100% matching the CPU implementation for interpolation (see the epsilons in the tests).
- Legacy Hair Particle points is now stored in local space after interpolation.

The new cylinder shape allows for more correct hair shading in workbench and better intersection in EEVEE.

|      | Strand | Strip | Cylinder |
| ---- | --- | --- | --- |
| Main | ![main_strand.png](/attachments/67d3b792-962c-4272-a92c-1c0c7c6cf8de) | ![main_strip.png](/attachments/f2aa3575-368e-4fbb-b888-74df845918f1) | N/A |
| PR   | ![pr_strand.png](/attachments/cc012483-25f0-491f-a06e-ad3029981d47) | ![pr_strip.png](/attachments/73fa2f5c-5252-4b30-a334-e935ed0fb938) | ![pr_cylinder.png](/attachments/3133b2d4-a6f2-41ee-8e2d-f6fd00db0c8d) |

|      | Strand | Strip | Cylinder |
| ---- | --- | --- | --- |
| Main | ![main_strand_closeup.png](/attachments/730bd79c-6762-446d-819b-3ea47961ff9f) |![main_strip_closeup.png](/attachments/d9ace578-cfeb-4895-9896-3625b6ad7a02) | N/A |
| PR   | ![pr_strand_closeup.png](/attachments/ac8f3b0c-6ef6-4d54-b714-6322f9865036)|![pr_strip_closeup.png](/attachments/8504711a-955b-4ab2-aa3d-c2d114baf9d4)| ![pr_cylinder_closeup.png](/attachments/1e2899a8-0a5c-431f-ac6c-5184d87e9598) |

Cyclic Curve, Mixed curve type, and proper radius support:
![image.png](/attachments/7f0bf05e-62ee-4ae9-aef9-a5599249b8d7)

Test file for attribute lookup: [test_attribute_lookup.blend](/attachments/1d54dd06-379b-4480-a1c5-96adc1953f77)

Follow Up Tasks:
- Correct full tube segments orientation based on tangent and normal attributes
- Correct V resolution property per object
- More attribute type support (currently only color)

TODO:
- [x] Attribute Loading Changes
  - [x] Generic Attributes
  - [x] Length Attribute
  - [x] Intercept Attribute
  - [x] Original Coordinate Attribute
- [x] Cyclic Curves
- [x] Legacy Hair Particle conversion
  - [x] Attribute Loading
  - [x] Additional Subdivision
- [x] Move some function to generic headers (VertBuf, OffsetIndices)
- [x] Fix default UV/Color attribute assignment

Pull Request: https://projects.blender.org/blender/blender/pulls/143180
2025-08-27 09:49:43 +02:00
Miguel Pozo
15da5dbaf8 Fix #145194: EEVEE: World Shader crash
Regression from 7e26323724

Pull Request: https://projects.blender.org/blender/blender/pulls/145196
2025-08-27 09:10:20 +02:00
Hans Goudey
af32b24199 Cleanup: Resolve missing declaration warning 2025-08-26 15:54:35 -04:00
Miguel Pozo
8adb3e758f Draw: Use ResourceHandleRange
Optimize instancing performance by syncing all instances at once.
Part of #130291

At the moment, it only works for certain Object types in Workbench and
Overlay.
Everything else follows a path similar to the previous one.

Performance on instancing heavy scenes can range from 1.5x to 3x faster
depending on hardware and platform.

Pull Request: https://projects.blender.org/blender/blender/pulls/140378
2025-08-26 17:08:47 +02:00
Clément Foucault
7e26323724 EEVEE: Remove GPencil from geometry types
The Grease pencil is taking a different direction
and will not be supported in EEVEE.

See https://devtalk.blender.org/t/2025-08-13-grease-pencil-rendering-meeting/41845
2025-08-26 15:39:25 +02:00
Campbell Barton
0c78410ae1 Cleanup: clarify naming for CharTrans, EditFontSelBox members
Also make arguments const.
2025-08-26 17:44:13 +10:00
Clément Foucault
e0afb37648 Fix #144781: EEVEE: Assert fail in ShadowModule at close zoom
Caused by the `lod_level` turning negative.
Using preventive measure to avoid this faulty value
fixes the issue.
2025-08-25 17:21:37 +02:00
Clément Foucault
cffb5af2ff Fix #142381: EEVEE: Freeze playing back a certain animation
In this instance the texture loading was using another
`threaded_for` loop internally which created conflict with
the top most `threaded_for`.

Using task isolation fixes the issue.

Candidate for backporting to 4.5 LTS.

Pull Request: https://projects.blender.org/blender/blender/pulls/145124
2025-08-25 17:13:35 +02:00
Clément Foucault
5ed307f8aa Fix: EEVEE: Bilateral denoiser has wrong color transform
The transform used for accumulation space was not
reciprocal and could modify the input intensity.

Pull Request: https://projects.blender.org/blender/blender/pulls/144987
2025-08-25 14:06:11 +02:00
Clément Foucault
87fe13fb7b Fix: EEVEE: Avoid Valgrind issues
Running valgrind on a render test exhibit a lot of warnings
about `Conditional jump or move depends on uninitialised value(s)`.

This patch makes sure to initialize the memory to avoid
platform dependent bugs.

Pull Request: https://projects.blender.org/blender/blender/pulls/144995
2025-08-25 14:05:50 +02:00
Campbell Barton
dae9bed968 Refactor: move the evaluated font size into EditFont
Avoids manipulating the Curve when evaluating fonts.
2025-08-25 06:20:10 +00:00
Campbell Barton
1b559b4f78 Cleanup: quiet class-memaccess warning 2025-08-24 19:50:40 +10:00
Sergey Sharybin
1e4764a9a5 Refactor: Simplify subdiv utilities
- Return evaluated points as function return value.
  Used in cases when only limit or final point is requested, without
  partial derivatives.

- Re-order function argument list and use default argument values to
  simplify usage in the simple/typical cases.

No functional changes expected.
2025-08-22 17:15:06 +02:00
Clément Foucault
8ee6bc2c01 EEVEE: Change barriers in the raytracing pipeline
Found when debugging the test regressions on the bot.

Pull Request: https://projects.blender.org/blender/blender/pulls/144985
2025-08-22 15:50:15 +02:00