Commit Graph

134656 Commits

Author SHA1 Message Date
Omar Emara
fa3e47523e Compositor: Port GLSL SMAA to CPU compositor
This patch ports the GLSL SMAA library to the CPU compositor in order to
unify the anti-aliasing behavior between the CPU and GPU compositor.
Additionally, the SMAA texture generator was removed since it is now
unused.

Previously, we used an external C++ library for SMAA anti-aliasing,
which is itself a port of the GLSL SMAA library. However, the code
structure and results of the library were different, which made it quite
difficult to match results between CPU and GPU, hence the decision to
port the library ourselves.

The port was performed through a complete copy of the library to C++,
retaining the same function and variable names, even if they are
different from Blender's naming conversions. The necessary code changes
were done to make it work in C++, including manually doing swizzling
which changes the code structure a bit.

Even after porting the library, there were still major differences
between CPU and GPU, due to different arithmetic precision. To fix this
some of the bilinear samplers used in branches and selections were
carefully changed to use point samplers to avoid discontinuities around
branches, also resulting in a nice performance improvement. Some slight
differences still exist due to different bilinear interpolation, but
they shall be looked into later once we have a baseline implementation.

The new implementation is slower than the existing implementation, most
likely due to the liberal use of bilinear interpolation, since it is
quite cheap on GPUs and the code even does more work to use bilinear
interpolation to avoid multiple texture fetches, except this causes a
slow down on CPUs. Some of those were alleviated as mentioned in the
previous section, but we can probably look into optimizing it further.

Pull Request: https://projects.blender.org/blender/blender/pulls/119414
2024-03-25 14:21:00 +01:00
Hans Goudey
9d88fa483c Cleanup: Make format 2024-03-25 09:13:33 -04:00
Omar Emara
4971b144a4 Compositor: Unify sRGB to Linear between CPU and GPU
This patch unifies the sRGB to Linear color space conversion between the
CPU and GPU compositors. This is because CPU uses an optimized path that
produces values that are very slightly off. To fix this, for the GPU, we
do the conversion CPU side instead of doing it in a shader. Since images
are cached, the performance implications are not significant.

Another added benefit is that we no longer get differences due to the
order of alpha pre-multiplication and sRGB conversion, demonstrated in
#114305. And we no longer require any preprocessing of the images.

This patch adds some new utilities to the Image Buffer module to assign
float, byte, and compressed buffers along with their color spaces. It
also adds an ownership flag to compressed data. Those were added as a
way to facilitate the implementation.

Pull Request: https://projects.blender.org/blender/blender/pulls/118624
2024-03-25 14:09:54 +01:00
Pratik Borhade
209db414e0 Fix #119860: Undo crash in asset browser poll function
`asset_lib` is null when calling undo in active file browser space.
This causes crash in `asset undo poll`. So exit out of the poll function
when active file space is filebrowser.

Pull Request: https://projects.blender.org/blender/blender/pulls/119870
2024-03-25 14:00:38 +01:00
Pratik Borhade
f6190dcf9f Merge branch 'blender-v4.1-release' 2024-03-25 18:28:23 +05:30
Pratik Borhade
436b9a5aae Fix #119862: poly build crash when adding first vertex in empty geometry
object_index is not found (-1) when all mesh data is deleted hence it
crashes when accessing base from the vector at index -1.
So skip the further execution to prevent crash.

Pull Request: https://projects.blender.org/blender/blender/pulls/119865
2024-03-25 13:55:57 +01:00
Germano Cavalcante
f66cb1e635 UI: rename 'Snap With' and 'Snap To' to 'Snap Base' and 'Snap Target'
Since the `Set Snap Base` feature has been implemented, it would be
convenient to reflect the use of the term `Snap Base` in other areas in
the UI.

Pull Request: https://projects.blender.org/blender/blender/pulls/119723
2024-03-25 13:35:52 +01:00
Hans Goudey
b1c85fa78c Fix: Python import error for GPUVertBuf
Caused by fe76d8c946e5ce7a76d45acaee0a67407cb3b599
2024-03-25 08:10:48 -04:00
Weizhen Huang
082b68fcb9 Cycles: improve equiangular sampling in volume
By restricting the sample range along the ray to the valid segment.

Supports

**Mesh Light**
- [x] restrict the ray segment to the side with MIS

**Area Light**
- [x] when the spread is zero, find the intersection of the ray and the bounding box/cylinder of the rectangle/ellipse area light beam
- [x] when the spread is non-zero, find the intersection of the ray and the minimal enclosing cone of the area light beam
*note the result is also unbiased when we just consider the cone from the sampled point in volume segment. Far away from the light source it's less noisy than the current solution, but near the light source it's much noisier. We have to restrict the sample region on the area light to the part that lits the ray then, I haven't tried yet to see if it would be less noisy.*

**Point Light**
- [x] the complete ray segment should be valid.

**Spot Light**
- [x] intersect the ray with the spot light cone
- [x] support non-zero radius

Pull Request: https://projects.blender.org/blender/blender/pulls/119438
2024-03-25 13:02:02 +01:00
Campbell Barton
ab93a426a0 Fix assert from recent cleanup
Change from [0] didn't account for edit-meshes without faces.

[0]: 3805974b6fa8e15ae4409f597747bc7beee51fa3
2024-03-25 22:28:53 +11:00
Pratik Borhade
2e8259e4d4 GPv3: Clean loose points in draw mode menu
Include `clean loose` operator in draw mode menu.
And move this operator inside `Cleanup menu` (same as GPv2)

Pull Request: https://projects.blender.org/blender/blender/pulls/119782
2024-03-25 12:17:03 +01:00
Campbell Barton
7371b11bb5 Fix #119871: Window contents invalid on startup under Wayland & GNOME
Resolve a glitch where the window contents didn't fit the window
on startup under GNOME. This also avoids flickering whenever the
window manager changed the window size from the requested size.

See code-comments for details.
2024-03-25 22:08:27 +11:00
Aras Pranckevicius
26337b9fb4 Metal: implement support for compressed textures
Noticed lack of it via #119793. Now DDS images using BC1/BC2/BC3
(aka DXT1/DXT3/DXT5) formats can keep on being GPU compressed
on Metal too, just like e.g. on OpenGL.

Pull Request: https://projects.blender.org/blender/blender/pulls/119835
2024-03-25 11:40:20 +01:00
Sergey Sharybin
bffcb000e8 Fix: Cycles crash on Metal GPU with ASAN builds
Running a very simple files when Blender is built with the
WITH_COMPILER_ASAN=ON and WITH_CYCLES_KERNEL_ASAN=ON CMake options
leads to ASAN reporting an unknown-crash at line where the worker
pool is being filled in.

It is not entirely clear if it is a real issue in the code, since
placing debug prints with `this` address report proper addresses,
however there is no harm on capturing `this` pointer by value and
it does solve the ASAN reporting issues.

It is possible to reproduce the ASAN crash with the following steps:
- Start with --factory-startup
- Enable Metal device in User Preferences
- Switch render device to GPU Compute
- Switch viewport more to Rendered

Pull Request: https://projects.blender.org/blender/blender/pulls/119867
2024-03-25 11:36:15 +01:00
Sergey Sharybin
7e2d54e786 Fix: Assert when exiting Metal rendered viewport
This commit fixes the following assert:
  mtl_command_buffer.mm:165, submit(), at 'MTLBackend::get()->is_inside_render_boundary()'

It happens when toggling rendered state of viewport on macOS, and is
caused by incorrect order of setting active GPU context to null and
calling GPU_render_end.

This change makes the flow of GPU_render_{beign, end} and GPU context
activation closer to what it is in the draw manager's functions
DRW_render_context_{enable, disable}.

Pull Request: https://projects.blender.org/blender/blender/pulls/119868
2024-03-25 11:28:28 +01:00
fb6b4fe75c Merge remote-tracking branch 'origin/blender-v4.1-release' 2024-03-25 11:27:43 +01:00
Jun Mizutani
cc580136c6 Fix #119812: 'Add Child Collection' adds a brother bone collection
Change label from "Add Child Collection" to "Add Bone Collection", as the
newly added collection becomes a sibling, not a child, of the active one.

Pull Request: https://projects.blender.org/blender/blender/pulls/119845
2024-03-25 11:26:30 +01:00
8f015d3bfc Modeling: Merge Vertices, correct spelling of report
Fix the "Merge Vertices" report, replacing "vertice(s)" with either
"vertex" or "vertices". The singular "vertice" is not a word in English,
and thus the regular "append (s)" approach is incorrect.

Pull Request: https://projects.blender.org/blender/blender/pulls/119863
2024-03-25 10:18:13 +01:00
Jun Mizutani
378d37ed3d Fix #119812: 'Add Child Collection' adds a brother bone collection
Change label from "Add Child Collection" to "Add Bone Collection", as the
newly added collection becomes a sibling, not a child, of the active one.

Pull Request: https://projects.blender.org/blender/blender/pulls/119845
2024-03-25 09:25:24 +01:00
Jesse Yurkovich
e9eb2d35f8 USD: Add new test files for curves and point instancing 2024-03-24 21:49:55 -07:00
Bastien Montagne
792f4cc1d1 Merge branch 'blender-v4.1-release' 2024-03-25 10:02:07 +09:00
Bastien Montagne
31aec5ae1d I18N: Updated UI translstions from git/weblate repo (5f533cb92100b). 2024-03-25 09:59:29 +09:00
Lukas Stockner
05a9f96446 Fix: Add missing callback reset in RE_InitRenderCB
This caused an ASan abort while looking into #101993.

From what I can tell, the issue is that when you click the render button on
the Render Layer node, RENDER_OT_render sets the callback. Then, when you
hit F12 later, it reuses the Render from before, including the callback,
but the corresponding handle has been freed already.
2024-03-25 01:38:55 +01:00
Lukas Stockner
02a488d0fe Fix #61042: Cycles: Various Toon BSDF issues
The original bug report was that the Glossy Toon BSDF behaves incorrectly
when mixed with other closures.
The underlying issue here was that the eval function didn't check whether
the reflection angle is inside the valid cone and always returned its PDF,
which is very high compared to e.g. the diffuse closure's PDF for small
sizes (since the cone is supposed to be quite tight) and therefore breaks
MIS mixing.

However, while looking into this, I found a number of other issues, and so
this commit also contains several other changes to the Toon BSDFs:
- The angle that was used to compute the intensity wasn't the actual angle
  between the vectors. From what I can see, the formula that was used goes
  back all the way to the initial commit 12 years ago, so this probably was
  something that happened to work with one particular cone sampling method.
  Now, however, it caused weird asymmetric highlights, so replace it with
  the actual angle (which we already compute anyways).
- Setting size to zero caused the BSDF to go black, so clamp to 1e-5.
- The code was overall a bit repetitive, so I've cleaned it up a bit.
2024-03-24 23:52:16 +01:00
Harley Acheson
b545770f5c UI: Adjustments to Minimum Area Sizes
When areas are dragged very small we want the (visual) vertical minimum
to equal header height, and the horizontal minimum to be equal to the
Properties nav area width. This PR just makes these adjust correctly
with changes of resolution scale and line width.

Pull Request: https://projects.blender.org/blender/blender/pulls/119848
2024-03-24 19:40:18 +01:00
Lukas Stockner
d4d5281d45 Fix: Cycles: Metal compilation error 2024-03-24 19:39:25 +01:00
Hans Goudey
b54d9875ba Fix: Another Metal build error after recent refactor
Sorry for the noise, I misread the output from the PR build.
2024-03-24 13:24:03 -04:00
Lukas Stockner
1f44be97e6 Fix #56355: Cycles: Wrong differentials for panoramic camera
The code to compute differentials mixed up the camera-space locations
of the raster coordinate and the camera itself, which caused the dP
differential to be set even when the ray origin is always the same.

This commit fixes that, reorganizes the code so that the Px/Py are
no longer used for both values to avoid future confusion, and skips
some unnecessary calculations stereo rendering isn't being used.
2024-03-24 17:52:22 +01:00
Hans Goudey
aa87b747c5 Fix: Additional macOS metal build error 2024-03-24 12:37:36 -04:00
Hans Goudey
e201b5e553 Fix: Debug build error after previous commit 2024-03-24 12:17:44 -04:00
Hans Goudey
fe76d8c946 Refactor: Remove unnecessary C wrappers for vertex and index buffers
Now that all relevant code is C++, the indirection from the C struct
`GPUVertBuf` to the C++ `blender::gpu::VertBuf` class just adds
complexity and necessitates a wrapper API, making more cleanups like
use of RAII or other C++ types more difficult.

This commit replaces the C wrapper structs with direct use of the
vertex and index buffer base classes. In C++ we can choose which parts
of a class are private, so we don't risk exposing too many
implementation details here.

Pull Request: https://projects.blender.org/blender/blender/pulls/119825
2024-03-24 16:38:30 +01:00
Hans Goudey
84c6ead74b Refactor: Remove unnecessary curves GPU evaluation caches
Currently we have a cache for all combinations of "strand/strip" and
the four subdivision levels. Recomputing this data should be very fast
and doesn't require re-uploading data from the CPU. Because they are
scene settings, they will be the same for all render engines too, so we
won't have a case where we're constantly requesting different values.

The extra caches just complicate code, so better to remove them. Now
the final evaluated cache remembers the settings it was created with,
and it's cleared if they are changed.

Pull Request: https://projects.blender.org/blender/blender/pulls/119804
2024-03-24 16:33:12 +01:00
Casey Bianco-Davis
cb453a5846 Fix: Debug crash upon entering edit mode.
Any valid object gets added to `object_data` so we should check if it is not empty rather then is empty.

Pull Request: https://projects.blender.org/blender/blender/pulls/119839
2024-03-24 13:11:01 +01:00
Iliya Katueshenock
9123451427 Cleanup: BLI: Redundant dereference
Redundant dereference of array element.
This code is not used currently, but i noticed issue
while using this in my branch.

Pull Request: https://projects.blender.org/blender/blender/pulls/119842
2024-03-24 11:07:00 +01:00
John Swenson
af0c42e266 Fix #118260: VSE scene strip wireframe display
The issue is that a draw call in the sequencer does not have any
knowledge of the viewport's wireframe opacity and threshold settings,
defaulting both to 0.

A similar issue #86956 implemented a quick hack to fix grease pencil
shading in VSE, so I opted to do the same here. In the future, a better
solution could be implemented to preserve the entire v3d.overlay.

I should note that I made `wireframe_threshold = 0.5f` to match the
default value given in `versioning_280.cc` but if this works better
as `1.0f` instead let me know.

Pull Request: https://projects.blender.org/blender/blender/pulls/119811
2024-03-24 08:52:47 +01:00
Hans Goudey
3805974b6f Refactor: Use C++ array for edit mesh looptris
Pull Request: https://projects.blender.org/blender/blender/pulls/119829
2024-03-23 17:43:38 +01:00
Hans Goudey
3ce8c74a57 Cleanup: Fix outdated comments about Mesh data 2024-03-23 11:47:07 -04:00
Hans Goudey
73e7023c71 Fix #119816: New curves draw tool options missing in sidebar 2024-03-23 10:51:48 -04:00
Hans Goudey
374b80b84a Cleanup: Miscellaneous cleanups to newly C++ headers 2024-03-23 10:10:52 -04:00
Hans Goudey
1dc16f909d Cleanup: Move GPU Python headers to C++ 2024-03-23 10:06:45 -04:00
Hans Goudey
a54c9b9e36 Cleanup: Move eevee_private.h to C++ 2024-03-23 09:59:23 -04:00
Hans Goudey
5cd1237594 Cleanup: Miscellaneous cleanups to newly C++ headers
Pull Request: https://projects.blender.org/blender/blender/pulls/119824
2024-03-23 14:52:00 +01:00
Hans Goudey
a099061feb Cleanup: Move remaining draw headers to C++ 2024-03-23 14:51:59 +01:00
Clément Foucault
4d502ab51d EEVEE-Next: Refactor light data packing
This allows to use unions on the C++ side and safe type
casting on the GPU side.

The type casting functions are statically verified at
compile time in C++.

This PR doesn't change the size of the light struct
but removes the need of packing floats in the `object_mat`.
The matrix will be changed to a `float4x3` in another PR
and will reduce the struct by 16 bytes.

This remove the need for the light parameters macros and
reveals the padding members that could be used for future
features for each type.

After this, all accesses to light type dependent data in
the shaders should be done using:
- `LightLocalData light_local_data_get(LightData light)`
- `LightSpotData light_spot_data_get(LightData light)`
- `LightAreaData light_area_data_get(LightData light)`
- `LightSunData light_sun_data_get(LightData light)`

Note that these functions are simple passthrough for Metal
since it supports `union` (but enforce for error checking
if option is enabled).

The error check on GPU is a bit costly so it is disabled
by default.

Pull Request: https://projects.blender.org/blender/blender/pulls/119713
2024-03-23 08:16:12 +01:00
Bastien Montagne
c7afb06ed0 Fix (unreported) some old files having regular IDs flagged as embedded.
It is unknown why/how this can happen, but there are some files out there
that have e.g. Objects flagged as embedded data... See e.g. the
`(Anim) Hero p23 for 2.blend` file from our cloud gallery
(https://cloud.blender.org/p/gallery/5b642e25bf419c1042056fc6).

Not much to be done, but add another checking pass at the end of
readfile process to fix these.
2024-03-23 12:55:57 +09:00
Bastien Montagne
7643bd7d89 Fix (unreported) broken GPv3 conversion code using one node socket for both input and output.
This is explicitely forbidden by an assert since 067daec270 a few days
ago, but somehow this GPv3 usage was missed then.
2024-03-23 12:02:41 +09:00
Bastien Montagne
4d973d3cf3 GPv3: Optional automatic conversion of legacy GP objects on fileload.
This adds a new exprimental option to automatically convert GP legacy
data to GPv3 one.

It supports also linking and appending cases. Conversion also happens
when opening a file linking GP legacy data saved by an older .blendfile.

Pull Request: https://projects.blender.org/blender/blender/pulls/118705
2024-03-23 03:28:57 +01:00
Hans Goudey
8b514bccd1 Cleanup: Move remaining GPU headers to C++
Pull Request: https://projects.blender.org/blender/blender/pulls/119807
2024-03-23 01:24:18 +01:00
Harley Acheson
f235990009 UI: Updated Interface Font to Inter Version 4.0
Upgrade Inter font from 3.019 (0a5106e0b) to 4.000 (a52131595)

Pull Request: https://projects.blender.org/blender/blender/pulls/119720
2024-03-22 21:32:34 +01:00
Harley Acheson
9eb275e6eb UI: Correction to Weight of 3D Viewport Overlay Text
Currently the overlay text, like stats for example, are drawing with
the widget_label font style size but using widget's weight. This is
just because UI_fontstyle_set is not called. Without this call we can
get a jiggling of the overlay text if these two styles differ in
weight. This PR also makes an (unnoticeable) correction to the font id
used in fontstyle_set_ex. uiFontStyle's uifont_id is not always the
same id as regular font ids, but here they are confused.

Pull Request: https://projects.blender.org/blender/blender/pulls/119808
2024-03-22 21:28:55 +01:00