Commit Graph

6953 Commits

Author SHA1 Message Date
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
Weizhen Huang
a69352824e Cleanup: simplify terms in EEVEE multiscatter GGX
Also update some comments

Pull Request: https://projects.blender.org/blender/blender/pulls/111634
2023-08-29 12:50:53 +02:00
Campbell Barton
d06da5a6ad License headers: add missing header 2023-08-29 16:32:25 +10:00
Campbell Barton
eec449ffe8 Cleanup: correct spelling, comments
Hyphenate words in GLSL code-comments.
2023-08-29 15:55:09 +10:00
Miguel Pozo
ee7e187b7f Fix #111561: Workbench-Next: Overlay in-front compositing
Copy the in-front depth buffer to `DefaultTextureList::depth_in_front` for
correct overlay compositing.

Pull Request: https://projects.blender.org/blender/blender/pulls/111630
2023-08-28 21:01:56 +02:00
Miguel Pozo
0fa8b099a5 EEVEE-Next: Move the transmittance LUT to the Utility Texture
Saves one texture slot for forward materials.

Pull Request: https://projects.blender.org/blender/blender/pulls/111535
2023-08-28 21:01:08 +02:00
Miguel Pozo
3acda70d8c Fix: Workbench-Next: Viewport Image Render 2023-08-28 18:12:39 +02:00
Jeroen Bakker
779bfe2734 Cleanup: Make format 2023-08-28 15:31:20 +02:00
Gilberto Rodrigues
fb6687a790 Viewport: Add toggle for edit mode overlays fresnel
Adds a userpref toggle for the edit mode overlays fresnel.
The edit mode fresnel is only a bit useful in edge cases, like
very dense photogrametry, and the problem is that it causes
more eye strain when modeling for many hours. And it's
benefit on shape readability is small compared to it's negative
impact on selection visibility. It makes the selection color to a
darker less saturated color instead of the theme color, which
leads to worse contrast between the selection and the mesh
or with the background, and also makes the unselected (black)
brighter, also reducing contrast. So it's off by default.

This was split up from https://projects.blender.org/blender/blender/pulls/110097

Pull Request: https://projects.blender.org/blender/blender/pulls/111494
2023-08-28 15:29:25 +02:00
Hans Goudey
3db523ab3e Cleanup: Move BLO headers to C++
Except for BLO_readfile.h, which is still included by C files.

Pull Request: https://projects.blender.org/blender/blender/pulls/111610
2023-08-28 15:01:05 +02:00
Gilberto Rodrigues
1f4c7a36df Wireframe color option for all shading modes
Enables three options of wireframe color for all shading modes: theme color, object color
and random color.  Previously this was exclusive to the wireframe shading mode.

Pull Request: https://projects.blender.org/blender/blender/pulls/111502
2023-08-28 11:04:40 +02:00
Weizhen Huang
8a735d0aa4 Fix: EEVEE: Incorrect GGX BRDF pdf and BTDF evaluation
* Using standard NDF and Smith shadowing-masking terms. The previous
`xxxx_opti()` functions were faster to evaluate, but confusing and
error-prone.
* After correcting the BRDF pdf, the prefiltered environment LOD bias
needs to be adjusted to avoid overblurred reflections.
* Corrected the half-vector computation in BTDF evaluation, added check
for invalid configuration due to total internal reflection or `eta == 1`.
* Use `saturate()` instead of `max()` when no division is needed because
the former is faster.
* Indirectly fixes EEVEE-Next refraction denoising.

Pull Request: https://projects.blender.org/blender/blender/pulls/111591
2023-08-27 20:51:32 +02:00
Weizhen Huang
03071e8c02 Cleanup: remove unused test file
This file was committed by mistake. There is no lightprobe test
2023-08-26 21:09:04 +02:00
Weizhen Huang
67843e188b Fix: EEVEE-Next: incorrect GGX BRDF LUT coordinates 2023-08-26 00:23:00 +02:00
Sergey Sharybin
4151691552 Fix #111504: Regression: Mesh draw corruption in sculpt mode
The commit f10965dcb8 introduced a regression in the way how the VBOs
are filled by assuming the requested VBO attribute type has the same
alignment as the CPU and is the same on different platforms.

Unfortunately, this turned out to not be the case.

Switch the mask attribute to be float on the GPU, which has a downside
of increased bandwidth to be transferred, but a benefit of less compute
power needed to update the VBO.

The fix is suggested by Clement.

Pull Request: https://projects.blender.org/blender/blender/pulls/111521
2023-08-25 17:58:35 +02:00
Clément Foucault
2eb447b00f EEVEE-Next: Shadow: Fix shader compilation
Some platforms do not support `bool` type as
shared variables, and no component reference
for atomics.
2023-08-25 11:07:00 +02:00
Campbell Barton
3de8900ed6 Cleanup: spelling in comments 2023-08-25 09:40:42 +10:00
Miguel Pozo
f63a0e670a Workbench-Next: Workaround lack of texture views support
Extract a mask from the stencil buffer and use that texture instead
when texture views are not available.
Needed for supporting the Windows ARM software driver.

The workaround is isolated on its own class so it's easy to remove once
it's no longer needed.

Note that while this adds a function to check if texture views are available
(`GPU_texture_view_support`), at the moment this always returns true in
practice, since OpenGL 4.3 is the minimum supported version.
A separate patch will be needed to allow Blender to run using
OpenGL 4.2 + extensions.

Pull Request: https://projects.blender.org/blender/blender/pulls/111402
2023-08-24 15:10:33 +02:00
Campbell Barton
24a8d6425a CMake: include missing files in source files 2023-08-24 11:51:25 +10:00
Campbell Barton
4492742487 License headers: manually integrate existing copyright into SPDX text
Some GLSL files already contained copyright information,
manually merge this into existing SPDX headers.

Ref !111247
2023-08-24 10:57:19 +10:00
Campbell Barton
0148293520 License headers: add SPDX licenses for '*.glsl' files
When GLSL sources were first included in Blender they were treated as
data (like blend files) and had no license header.
Since then GLSL has been used for more sophisticated features
(EEVEE & real-time compositing)
where it makes sense to include licensing information.

Add SPDX copyright headers to *.glsl files, matching headers used for
C/C++, also include GLSL files in the license checking script.

As leading C-comments are now stripped,
added binary size of comments is no longer a concern.

Ref !111247
2023-08-24 10:57:03 +10:00
Campbell Barton
8d1ffe14b2 Cleanup: use a bool for BKE_mesh_orco_verts_transform invert argument 2023-08-24 10:45:34 +10:00
Miguel Pozo
8d8f03be9c Cleanup: Draw: Clarify comment 2023-08-23 16:10:38 +02:00
Miguel Pozo
89dc2e1649 Fix: EEVEE-Next: Object Info > Random 2023-08-23 16:01:31 +02:00
Miguel Pozo
85b02b893a Workbench-Next: Enabled by default
Replace Workbench with Workbench Next.
The old Workbench code is still there for now,
but it should be unreachable.

Pull Request: https://projects.blender.org/blender/blender/pulls/111403
2023-08-23 15:09:37 +02:00
Campbell Barton
24ef5e097a Cleanup: balance doxy sections 2023-08-23 14:54:46 +10:00
Miguel Pozo
f57a8f07c0 Fix: EEVEE-Next: World Volume compilation error
Add missing model matrix.
2023-08-21 15:48:48 +02:00
Campbell Barton
33a05725be Cleanup: spelling in comments 2023-08-21 10:05:45 +10:00
Clément Foucault
65f91bd53a Fix: DRW: Broken debug decimal display
This is a temporary fix. A better fix
that display the non-scientific notation
would be better.
2023-08-20 17:52:48 +02:00
Clément Foucault
b4b5977aed DRW: Guard debug lib using defines
This allows adding debug calls to library
sources and not trigger an error for
all shaders that reference the lib.
The particular shader that need to use
it can set `drw_debug_print_enable` and
`drw_debug_draw_enable` in their main file
and it will trigger the injection of the
debug functions.
2023-08-20 17:52:48 +02:00
Campbell Barton
faa3ef6ad5 Cleanup: format 2023-08-19 23:52:47 +10:00
Campbell Barton
4f72240c1d Cleanup: spelling (correct correction), update dictionary 2023-08-19 20:19:13 +10:00
Campbell Barton
20b4a77872 datatoc: exclude the initial C-style comment from GLSL/MSL/Cuda files
Add optional argument `STRIP_LEADING_C_COMMENTS` to CMake macros:
data_to_c_simple & data_to_c.

Strip leading C-style comments that don't bloat binary size.
Comments are replaced with blank lines so line numbers in error messages
match. Reduces Blender's binary size by ~70kb.
2023-08-19 17:57:12 +10:00
Campbell Barton
63c1a26069 Cleanup: move GLSL comments to the file start
This has the benefit that leading comments may be stripped,
reducing the binary size (not yet supported).
2023-08-19 17:56:48 +10:00
Campbell Barton
add2a656da Cleanup: spelling, use C-style in GLSL 2023-08-19 17:13:05 +10:00
Campbell Barton
bc1ffdce5b Cleanup: spelling in comments 2023-08-18 08:56:12 +10:00
Falk David
0bc755face Fix #109403: GP doesn't render selection outline
The issue was that there was a change in the shader that expected
a specific flag to be set. The current grease pencil code did not
set these flags.

This fix separates the old and new shader code so that
the old way of rendering the strokes remains untouched.

Pull Request: https://projects.blender.org/blender/blender/pulls/111227
2023-08-17 18:09:04 +02:00
Clément Foucault
672d25b02d EEVEE-Next: Shadow Rendering Refactor
Split shadow rendering per LOD per tilemap and improve
fragment shader invocation rate by using multi-viewport.

Also changes the layout of the atlas to be 4 x 4 x Layers.
This allow to grow the atlas while keeping the content
and page indirection correct, but this isn't implemented
in this patch.

# First attempt

Shadow rendering using atomic proved to be less than ideal
and performance were not quite to an acceptable level.

The previous method had issue with atomic contention when
a lot of triangle would overlap and too many fragment shader
invocations with quite complex indirection rules and biases
which made the technique costly.

The new implementation leverage multi viewport and
layered rendeing to effectively replace the need for atomic
and render directly to the shadow atlas. Using the well
supported extension these are free on modern hardware and
do not need a geometry shader.

One view per tile is needed since we use the viewport index
and the layer index as a way to index a specific tile in the
array.

# Geometric Complexity Problem

The counterpart of this is that we need to draw one geometry
instance per tile which is 32x32 time more instances (at most)
than with the previous method.

This means that we will have to find a way to mitigate this
geometry cost by either reducing the number of tiles per
tilemaps (in other words, making the system less memory efficient)
or splitting complex objects' geometry into smaller, more
cull friendly chunks (for example, like the sculpt PBVH nodes).
The later seems to be a longer term solution as it requires
way too much engineering time we have right now.

# Update Lag Problem

This also mean we can only update up to 64 tile per redraw
which is not enough even in the most basic cases. This leads
to missing or over shadowing when a light updates until there
is no updates and the shadow rendering can catch up.

One possible solution is to update a lower LODs first waiting
until there is no update to render. This would allow no artifact
during the transforms (unless there is too many light updates
even for lowest LOD, but that was an issue also for the
previous implementation). This could also help with the
geometric complexity.

# Solution

In the end, we decided to have one view per lod. This limits
the complexity of the fragment shader (improve speed),
reduces the number of views per tilemap (fix update lag),
and reduces the number of instances.
This also mean we cannot render directly to the atlas anymore
and reverted to the atomic solution. Using the smallest
possible viewport, we assure that there isn't that much fragment
shader invocations which was one of the bottleneck. And also
reduces the amount of geometry instances that pass the
clipping test.

Pull Request: https://projects.blender.org/blender/blender/pulls/110979
2023-08-17 17:35:19 +02:00
Jeroen Bakker
a80de9ed40 Fix Incorrect Merge GPencil/Overlay shaders
Only Metal shaders where broken
2023-08-17 15:56:58 +02:00
Jeroen Bakker
85c5bb89a0 Vulkan: Convert Eevee(-next) Stage Interfaces
This PR makes all static shaders in Eevee and Eevee-next compatible with Vulkan.
If required, dynamic shaders will be converted later on.

Pull Request: https://projects.blender.org/blender/blender/pulls/111224
2023-08-17 15:49:32 +02:00
Jeroen Bakker
6c9f6eefe9 Vulkan: Convert Workbench Stage Interfaces
Convert workbench stage interfaces to be compatible with Vulkan.

Pull Request: https://projects.blender.org/blender/blender/pulls/111221
2023-08-17 15:48:22 +02:00
Jeroen Bakker
667be8c49d Vulkan: Convert Overlay Stage Interfaces
Convert overlay stage interfaces to be compatible with vulkan.

Pull Request: https://projects.blender.org/blender/blender/pulls/111218
2023-08-17 15:47:36 +02:00
Jeroen Bakker
101c9383d7 Vulkan: Convert Grease Pencil Shaders
Converting grease pencil stage interfaces to be compatible with vulkan.

Pull Request: https://projects.blender.org/blender/blender/pulls/111222
2023-08-17 15:25:36 +02:00
Omar Emara
110cb5d0d5 BLI: Add square function
This patch adds the square function for both float and vector math BLI
libraries. It also renames the corresponding GLSL function for
compatibility.

Pull Request: https://projects.blender.org/blender/blender/pulls/111217
2023-08-17 15:05:52 +02:00
Campbell Barton
c713c70781 CMake: quiet uninitialized warnings 2023-08-17 11:53:56 +10:00
Aras Pranckevicius
2f060706a4 Cleanup: fewer BLI_color.hh et al includes
Include counts of some headers while making full blender build:
- BLI_color.hh 1771 -> 1718
- BLI_math_color.h 1828 -> 1783
- BLI_math_vector.hh 496 -> 405
- BLI_index_mask.hh 1341 -> 1267
- BLI_task.hh 958 -> 903
- BLI_generic_virtual_array.hh 509 -> 435
- IMB_colormanagement.h 437 -> 130
- GPU_texture.h 806 -> 780
- FN_multi_function.hh 331 -> 257

Note: DNA_node_tree_interface_types.h needs color include only
for the currently unused (but soon to be used) socket_color function.
Future step is to figure out how to include
DNA_node_tree_interface_types.h less.

Pull Request: #111113
2023-08-16 14:48:53 +03:00
Aras Pranckevicius
acbd952abf Cleanup: fewer iostreams related includes from BLI/BKE headers
Including <iostream> or similar headers is quite expensive, since it
also pulls in things like <locale> and so on. In many BLI headers,
iostreams are only used to implement some sort of "debug print",
or an operator<< for ostream.

Change some of the commonly used places to instead include <iosfwd>,
which is the standard way of forward-declaring iostreams related
classes, and move the actual debug-print / operator<< implementations
into .cc files.

This is not done for templated classes though (it would be possible
to provide explicit operator<< instantiations somewhere in the
source file, but that would lead to hard-to-figure-out linker error
whenever someone would add a different template type). There, where
possible, I changed from full <iostream> include to only the needed
<ostream> part.

For Span<T>, I just removed print_as_lines since it's not used by
anything. It could be moved into a .cc file using a similar approach
as above if needed.

Doing full blender build changes include counts this way:
- <iostream> 1986 -> 978
- <sstream> 2880 -> 925

It does not affect the total build time much though, mostly because
towards the end of it there's just several CPU cores finishing
compiling OpenVDB related source files.

Pull Request: https://projects.blender.org/blender/blender/pulls/111046
2023-08-16 09:51:37 +02:00
Falk David
969de5135a GPv3: Re-evaluate on frame change
This makes it so the `GreasePencil` geometry gets updated on a time
change.
The frame at which the object gets evaluated is stored in runtime as
`eval_frame`. This is for example used to calculate the bounding box
of the geometry as well as invalidating the batch cache for different
frames.

Pull Request: https://projects.blender.org/blender/blender/pulls/111137
2023-08-15 17:31:11 +02:00
Campbell Barton
e955c94ed3 License Headers: Set copyright to "Blender Authors", add AUTHORS
Listing the "Blender Foundation" as copyright holder implied the Blender
Foundation holds copyright to files which may include work from many
developers.

While keeping copyright on headers makes sense for isolated libraries,
Blender's own code may be refactored or moved between files in a way
that makes the per file copyright holders less meaningful.

Copyright references to the "Blender Foundation" have been replaced with
"Blender Authors", with the exception of `./extern/` since these this
contains libraries which are more isolated, any changed to license
headers there can be handled on a case-by-case basis.

Some directories in `./intern/` have also been excluded:

- `./intern/cycles/` it's own `AUTHORS` file is planned.
- `./intern/opensubdiv/`.

An "AUTHORS" file has been added, using the chromium projects authors
file as a template.

Design task: #110784

Ref !110783.
2023-08-16 00:20:26 +10:00