Commit Graph

1278 Commits

Author SHA1 Message Date
Alaska
8ed69341d0 Shader: Expose light path "is volume scatter ray" in UI
This commit adds the "is volume scatter" output to the light path node
in the shader editor.

All the funcitonal code for this feature already exists in Cycles SVM
and OSL, but the output wasn't exposed on the node.

EEVEE does not support the feature, so it's output will
always be zero.

Pull Request: https://projects.blender.org/blender/blender/pulls/134343
2025-02-12 15:45:04 +01:00
Clément Foucault
623c81c7ec Fix: GPU: Broken gizmo color
Some unrelated change was brought back inside
86b70143d5

Revert the offending change.
2025-02-11 12:54:20 +01:00
Clément Foucault
86b70143d5 Cleanup: GPU: Remove unused Transform Feedback implementation
Most of the cleanup is inside the metal backend.

Pull Request: https://projects.blender.org/blender/blender/pulls/134349
2025-02-10 17:30:42 +01:00
Bastien Montagne
4b996baa76 Merge branch 'blender-v4.4-release' 2025-02-10 14:16:47 +01:00
Clément Foucault
34216a2b7b Fix #134234: GPU: Shader Compile Error on with gpu.types.GPUShader
The removal of the loose uniform made the shader not compile.
This patch adds a new define for these type of shaders and add
back the loose uniform.

Note that these shaders might no longer work on Metal as
the source is not parsed anymore.

Pull Request: https://projects.blender.org/blender/blender/pulls/134341
2025-02-10 14:06:47 +01:00
Campbell Barton
e659e87a67 Cleanup: cmake formatting, sort file lists 2025-02-10 19:40:06 +11:00
Weizhen Huang
d2db9927ed Fix #86648: reduce ray differentials size for bump mapping
Use sub-pixel differentials for bump mapping helps with reducing
artifacts when objects are moving or when textures have high frequency
details.

Currently we scale it by 0.1 because it seems to work good in practice,
we can adjust the value in the future if it turns out to be impractical.

Ref: #122892

Pull Request: https://projects.blender.org/blender/blender/pulls/133991
2025-02-05 13:39:27 +01:00
Campbell Barton
4cd827870d Cleanup: quiet check_spelling_* targets
Also correct outdated references to `ghash`.
2025-02-02 13:58:34 +11:00
Clément Foucault
651ae0e47c Metal: Add OOB coordinate rejection to image atomic functions
These should have been guarded but are not, creating
buffer out of bound access error on Apple devices.
2025-01-31 16:17:58 +01:00
Clément Foucault
067f6767d4 Fix #129571: Metal: Broken texture atomic workaround
The refactor 9c0321ae9b
had the wrong mental model of the backing texture
layout for the atomic workaround.

For 3D textures, the layout is breaking the 3D texture
and reinterpreting the linear location as its 2D
linear location. This breaks the 3D texture Z slices
into non contiguous regions in 2D.

Comments have been added to avoid future confusion.

Pull Request: https://projects.blender.org/blender/blender/pulls/133830
2025-01-31 16:10:59 +01:00
Clément Foucault
10c0b19213 Cleanup: GPUMaterial: Remove leftover EEVEE Legacy code 2025-01-28 17:48:34 +01:00
Brecht Van Lommel
7a0a173d39 Fix: Missed case of OCIO luminance coefficients in EEVEE
Following up on #133368. Thanks Omar for spotting this.

Pull Request: https://projects.blender.org/blender/blender/pulls/133400
2025-01-22 11:19:02 +01:00
Brecht Van Lommel
5e02b4e6f1 EEVEE: Use OpenColorIO for luminance
Color to grayscale conversions should take into account the colorspace,
and these are considered to be in scene linear colorspace.

Note the RBG to BW node implementation is used for implicit conversions,
so that is covered as well.

No change with the default configuration.

Pull Request: https://projects.blender.org/blender/blender/pulls/133368
2025-01-21 18:05:56 +01:00
Miguel Pozo
e3c6c2c6fc Cleanup: CMake: De-duplicate with_shader_cpp_compilation code
Move the common setup and function to `macros.cmake`.

Pull Request: https://projects.blender.org/blender/blender/pulls/131391
2024-12-06 21:03:11 +01:00
Clément Foucault
994c43413a Metal: Remove SSBO Vertex Fetch
This API was used as a workaround to the lack of
geometry shader. It has been rendered redundant
since the introduction of #125782.
2024-12-05 22:58:52 +01:00
Miguel Pozo
bd1f4ec23c Fix: GPU: CPP shader errors in VS2019
Continuation of #131332.

Including built-in headers in VS2019 ends up including `corecrt_math.h`
as a side effect, which has many functions that overlap in name with
our stubs.
This puts the conflicting functions inside its own namespace (`glsl`)
and declares macros for them.
(Note this has the side effect of not allowing us to use those as
variable names)

This also removes the `<cassert>` and `<cstdio>` includes.

Pull Request: https://projects.blender.org/blender/blender/pulls/131386
2024-12-04 18:03:42 +01:00
Miguel Pozo
72aaaa0c24 Fix: GPU: Errors and warnings for CPP shaders in MSVC
Pull Request: https://projects.blender.org/blender/blender/pulls/131332
2024-12-04 17:33:12 +01:00
Clément Foucault
e0989d5bd6 Cleanup: GPU: Address unused GLSL variables throughout the codebase 2024-12-02 23:01:12 +01:00
Clément Foucault
01f1e9a2c4 GPU: Silence most GLSL C++ compilation warnings 2024-12-02 23:01:12 +01:00
Clément Foucault
2c3ccdf77a GPU: GLSL compilation as C++ for eevee static shaders
Rel #127983

Pull Request: https://projects.blender.org/blender/blender/pulls/130298
2024-12-02 21:26:15 +01:00
Clément Foucault
e44ae763bc GPU: GLSL C++ Stubs: Add minor missing features 2024-11-30 10:20:37 +01:00
Clément Foucault
bda911bcaa GPU: GLSL C++ Stub: Add packed type and small types 2024-11-29 21:33:06 +01:00
Clément Foucault
6332be9700 GPU: C++ GLSL Stubs: Use unions instead of inheritance for swizzle
This avoid stack overflow on GCC because types were getting too
large (70 bytes for a float4) and created a lot of static
memory for UBOs declarations.
2024-11-29 12:00:01 +01:00
Clément Foucault
95233986cb GPU: C++ GLSL Stubs: Add atomic sampler 2024-11-29 10:19:23 +01:00
Clément Foucault
c1bc1ef3ea GPU: C++ GLSL Stubs: Fix isinf / isnan 2024-11-29 00:37:45 +01:00
Clément Foucault
b39843e7b0 GPU: Use extern for non static expressions and use non zero value for gl_WorkGroupSize
Pull Request: https://projects.blender.org/blender/blender/pulls/131064
2024-11-28 23:23:30 +01:00
Clément Foucault
dd480ab604 GPU: Refactor the GLSL C++ stub swizzle implementation
This removes support for nested swizzling but avoid
warning about static member accesses through class
instance.
2024-11-28 23:23:27 +01:00
Clément Foucault
5954898edf GPU: Add back support for uchar4 color when using widelines
This is still pretty useful as the data savings is not negligeable.

Also supports it for python.
2024-11-28 18:28:08 +01:00
Clément Foucault
00a8d006fe GPU: Move Polyline shader to primitive expansion
This port is not so straightforward.

This shader is used in different configurations and is
available to python bindings. So we need to keep
compatibility with different attributes configurations.

This is why attributes are loaded per component and a
uniform sets the length of the component.

Since this shader can be used from both the imm and batch
API, we need to inject some workarounds to bind the buffers
correctly.

The end result is still less versatile than the previous
metal workaround (i.e.: more attribute fetch mode supported),
but it is also way less code.

### Limitations:
The new shader has some limitation:
- Both `color` and `pos` attributes need to be `F32`.
- Each attribute needs to be 4byte aligned.
- Fetch type needs to be `GPU_FETCH_FLOAT`.
- Primitive type needs to be `GPU_PRIM_LINES`, `GPU_PRIM_LINE_STRIP` or `GPU_PRIM_LINE_LOOP`.
- If drawing using an index buffer, it must contain no primitive restart.

Rel #127493

Co-authored-by: Jeroen Bakker <jeroen@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/129315
2024-11-27 17:37:04 +01:00
Clément Foucault
ebcc3dbc41 Fix: UI: Broken Geometry node socket display on macOS
Fix various warnings (that were errors) referring to
variables used inside their own initialization.
2024-11-26 21:32:27 +01:00
Campbell Barton
0de8ae8046 Cleanup: spelling in comments 2024-11-25 13:24:46 +11:00
Leon Schittek
13e0077c5c Nodes: Add new shader for node sockets
Add a new shader specifically for node sockets rather than using the
keyframe shader.

Motivation:
1. Allow easier addition of new socket shapes
2. Simplify socket drawing by avoiding special handling of multi-inputs
3. Support multi-inputs for all socket types (diamond, square, etc.)

The new shader is tweaked to look the same to the old ones.

**Comparison**
The biggest difference is that the multi socket is now more consistent
with the other sockets.
For single sockets there can be small size differences depending on zoom
level because the old socket shader always aligned the sockets to the
pixel grid. This could cause a bit of jiggling compared to the rest of
the node when slowly zooming. Therefore I left it out of the new shader
and it now scales strictly linear with the view.

**Multi Socket Types**
While there currently is no need for (.) internally, there are a few
obvious use-cases for multi-input field (diamond) sockets like
generalized math nodes with an arbitrary number of inputs (Add,
Multiply, Minimum etc.).

Co-authored-by: Jacques Lucke <jacques@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/119243
2024-11-23 16:42:38 +01:00
Clément Foucault
94d2a1e6a2 GPU: GLSL CPP stubs: Allow printf in code 2024-11-17 19:17:12 +01:00
Clément Foucault
c0c816f846 GPU: GLSL compilation as C++ for workbench static shaders 2024-11-14 23:15:06 +01:00
Clément Foucault
b76cc897b6 Cleanu: GPU: Address GLSL warnings 2024-11-13 12:38:00 +01:00
Clément Foucault
1aea4fb5c7 GPU: GLSL C++ shaders: Silence unuseful warnings 2024-11-13 12:37:00 +01:00
Clément Foucault
29b3df7504 GPU: GLSL compilation as C++ for draw intern shaders
Allow compilation of shaders using C++ for linting and
IDE support.

Related #127983

Pull Request: https://projects.blender.org/blender/blender/pulls/130193
2024-11-13 12:32:39 +01:00
Clément Foucault
091004f1b8 GPU: GLSL compilation as C++ for gpu static shaders
Allow compilation of shaders using C++ for linting and
IDE support.

Related #127983

Pull Request: https://projects.blender.org/blender/blender/pulls/128724
2024-11-12 18:53:34 +01:00
Clément Foucault
b17af94e2e EEVEE: Use packed type for codegen structs
This reduces register pressure on mac.

Mr Elephant 17.9s > 17.2s (4% speedup)

Extracted from #116728

Pull Request: https://projects.blender.org/blender/blender/pulls/129605
2024-11-12 12:58:58 +01:00
Clément Foucault
85f6350c0f Fix: GPU: Missing include breaking shader tests 2024-11-09 21:50:37 +01:00
Clément Foucault
4416e27b14 GPU: GLSL C++ stubs: Add support for depth and buffer sampler fetch 2024-11-08 00:28:59 +01:00
Clément Foucault
0a3008172b Cleanup: GPU: Silence shader warnings 2024-11-08 00:28:08 +01:00
Clément Foucault
94a5f541c3 GPU: Improve GLSL-C++ compatibility
Add a few missing operator/functions and fix some argument
type deduction problems.
2024-11-05 00:39:10 +01:00
Clément Foucault
d9ff375e7e GPU: GLSL-C++ Stubs: Make compilation possible
- Add `main` workaournd.
- Define out create info class when compiling with stubs.
- Move interfaces and info namespace to global namespace.
2024-11-01 23:38:22 +01:00
Clément Foucault
01236be188 Cleanup: GPU: Remove unused shader files
These shaders have not been used for a long time.
2024-11-01 23:36:45 +01:00
Clément Foucault
d2c378984d Cleanup: GPU: Avoid glsl functions with only one void argument 2024-11-01 18:57:22 +01:00
Clément Foucault
0deec1005c GPU: Remove some warnings and errors in GLSL C++ Stubs 2024-10-31 10:18:32 +01:00
Omar Emara
ba5c6c8682 Compositor: Implement Chroma Matte for new CPU compositor
Reference #125968.
2024-10-25 11:25:55 +03:00
Clément Foucault
3035fd1c36 GPencil: Port geometry shader to primitive expansion API
This removes the need for the geometry shader and the
workaround path for Metal.

Note that creating 2 batches for each stroke might become
a bottleneck in bigger scenes. But currently the bottleneck
is always be the fill algorithm. It can be optimized further
if needed.

Rel #127493

Pull Request: https://projects.blender.org/blender/blender/pulls/129274
2024-10-21 16:25:24 +02:00
Campbell Barton
5a561c6aeb Cleanup: spelling in comments 2024-10-16 21:10:49 +11:00