Commit Graph

14165 Commits

Author SHA1 Message Date
Sergey Sharybin
f1e82c99b9 Fix: Division by zero in Cycles render scheduler 2024-08-07 18:24:19 +02:00
Alaska
6b522c5e30 Fix #125307: Precision issues with MetalRT
Reverts a change in 5508b41a40 that
disabled ray offsetting on MetalRT, which lead to rendering artifacts
in scenes far away from the origin.

Pull Request: https://projects.blender.org/blender/blender/pulls/126003
2024-08-07 17:20:09 +02:00
David Murmann
df4df3cd52 Fix #114940: Cycles: GGX roughness has abrupt cutoff
This decreases BSDF_ROUGHNESS_SQ_THRESH so that the microfacet
roughness has a cutoff at much lower values and fixes a precision
issue in the bsdf_sample code that prevented this previously.

Pull Request: https://projects.blender.org/blender/blender/pulls/125919
2024-08-07 16:53:07 +02:00
Lukas Stockner
b119e1a497 Cycles: Fix potential NaN in normal mapping
I ran into this in a test scene - somehow the normalization here can result
in NaN (so presumably a zero vector). I don't think this has a notable
performance impact from some basic tests.

Pull Request: https://projects.blender.org/blender/blender/pulls/125930
2024-08-07 02:07:19 +02:00
Lukas Stockner
9ed7d38aac Cycles: Improve numerical precision of Beckmann distribution at low roughness 2024-08-06 23:04:16 +02:00
Weizhen Huang
d4ceade5ea Fix: Cycles BVH2 and Embree missing some transparent shadow bounces
the code snippet is supposed to compute the maximal `isect.t` in the
array, which is used to determine if subsequent intersections should be
added.

However, the previous implementation includes the old `isect.t` which is
going to be replaced, resulting an overestimation of `tmax_hits` and
thus missing closer intersections.

For BVH2, the issue is fixed by computing the `max_t` after a new entry
is inserted.

For Embree, the issue is fixed by finding the `second_largest_t` as well, and
compare that with the new insertion to find the new `max_t`.

Pull Request: https://projects.blender.org/blender/blender/pulls/125739
2024-08-06 15:37:49 +02:00
Alaska
50ba7a3033 Fix build failure after recent HIP-RT change
Fixes build failure after 6b848a9993

Pull Request: https://projects.blender.org/blender/blender/pulls/125936
2024-08-06 02:41:11 +02:00
Alaska
6b848a9993 Fix: Crash with deforming motion blurred meshes in HIPRT
Fixes a crash that can occur if motion blur was on, there is a
deforming mesh in the scene with deformable motion blur turned on,
with BVH time steps set >0.

Render results in my test scene appear to match CPU Embree.

Pull Request: https://projects.blender.org/blender/blender/pulls/125854
2024-08-05 18:38:28 +02:00
Weizhen Huang
e981389bdd Refactor: Cycles: use reservoir sampling to pick phase function in volume
so that we loop through the volumes only once.

Pull Request: https://projects.blender.org/blender/blender/pulls/125676
2024-08-05 10:55:47 +02:00
Weizhen Huang
7e40d567d4 Fix #125595: Cycles artifacts in overlapping volumes with different phase functions
A phase function is normalized over the sphere, it is therefore
incorrect to sum two phase functions together when evaluating for NEE.
It should be a weighted sum with normalized weights, which, according to
`volume_shader_phase_pick()`, is `sample_weight / sum_sample_weight`.

Also corrects an error in `volume_shader_phase_pick()`.
2024-08-05 10:55:44 +02:00
Campbell Barton
c071030ac3 Cleanup: spelling in comments 2024-08-04 13:45:06 +10:00
Alaska
5b61a01c19 Fix #125750: NaN on Glossy materials with low roughness
Fix a NaN when rendering glossy materials that can appear due to a
division by zero in bsdf_D when rendering materials with low roughness.

Thank you to Weizhen for the fix after my incorrect
first attempt.

Pull Request: https://projects.blender.org/blender/blender/pulls/125756
2024-08-02 16:28:42 +02:00
Alaska
5ce29bedf6 Fix: Cycles Shadow linking with HIP-RT
Fix shadow linking not working on HIP-RT by adding code to correctly
ignore certain shadow ray hits.

Ref #125086

Pull Request: https://projects.blender.org/blender/blender/pulls/125803
2024-08-02 12:17:09 +02:00
Alaska
ba5d76e7e2 Fix: Shader: Align vector math node reflect mode with OSL
Align Cycles SVM and EEVEE's rendering of the vector math node
in reflect mode with OSL when the normal vector is 0,0,0.

This is done by using safe_normalize rather than normalize on the
normal vector. Which also fixes a NaN in the reflect mode in this
specific configuration.

Pull Request: https://projects.blender.org/blender/blender/pulls/125688
2024-08-02 11:20:57 +02:00
Hans Goudey
edf298b505 Cleanup: Formatting 2024-07-29 23:10:49 -04:00
Campbell Barton
99af19932e Cleanup: spelling in comments 2024-07-30 12:38:16 +10:00
Campbell Barton
d8c2301ee8 Cleanup: use const arguments 2024-07-30 12:23:09 +10:00
Weizhen Huang
29fdddb0e9 Fix: Cycles camera keeps updating due to NaN in central cylindrical camera
`NaN != NaN` causes the camera to be tagged as needs update. To fix,
initialize radius to 1 and add hard limit.
2024-07-29 17:05:25 +02:00
softyoda
5e9096829c Cycles: Add Central Cylindrical Panoramic camera model
This type of projection is often used e.g. in exhibitions that leverage big
curved screens.

Effectively, the frame is mapped onto a cylinder, with the x axis becoming the
longitude and y axis becoming the height.

Users can configure the min/max longitude, the min/max height and the radius of
the cylinder.

Co-authored-by: Lukas Stockner <lukas.stockner@freenet.de>
Pull Request: https://projects.blender.org/blender/blender/pulls/123046
2024-07-29 15:03:57 +02:00
Bastien Montagne
63016ad965 MEM management: Add data storage only destructed after memleak detection.
Add a new API to store data that is guaranteed to not be freed
before the memleak detector has run.

This will be used in next commit by the readfile code to improve
reporting on leaks from blendfile readingi process.

This is done by a two-layer approach:

A new templated `MEM_construct_leak_detection_data` allows to
create any type of data. Its ownership and lifetime are handled
internally, and guaranteed to not be destroyed before the memleak
detector has run.

Add a new template-based 'allocation string storage' system to
`intern/memutil`. This uses the new `Guardedalloc Persistent Storage`
system to store all 'complex' allocation messages, that cannot be
defined as literals.

Internally, the storage is done through an owning reference (a
`shared_ptr`) of the created data into a mutex-protected static
vector.

`MEM_init_memleak_detection` code ensures that this static storage
is created before the memleak detection data, so that it is destructed
after the memleak detector has ran.

The main container (`AllocStringStorageContainer`) is wrapping a
map of `{string -> AllocStringStorage<key_type, hash_type>}`.
The key is a storage identifier.

Each storage is also a map wrapped into a simple templated API
class (`AllocStringStorage`), where the values are the alloc strings,
and the keys type is defined by the user code.

Pull Request: https://projects.blender.org/blender/blender/pulls/125320
2024-07-29 11:47:04 +02:00
Campbell Barton
111a40239a Cleanup: match argument names for function & declarations
Match function and declaration names, picking names based on
consistency with related code & clarity.

Also changes for old conventions, missed in previous cleanups:

- name -> filepath
- tname -> newname
- maxlen -> maxncpy
2024-07-27 13:32:51 +10:00
Harley Acheson
13795b5df1 UI: Custom VSE Handle Cursors for Mac
Mac Platform-specific PDF cursors for VSE handle types.

Pull Request: https://projects.blender.org/blender/blender/pulls/125471
2024-07-26 17:31:25 +02:00
Alaska
8650068f0c Fix: NaN in vector math node in refract mode
Fix a NaN that can occur in the vector math node when set to
refract mode with a 'normal' input of length zero.

Pull Request: https://projects.blender.org/blender/blender/pulls/125374
2024-07-26 12:04:58 +02:00
Campbell Barton
b73d8595bb Cleanup: add missing cursor entries for Wayland 2024-07-26 17:09:12 +10:00
Campbell Barton
b4d5c6eea5 Cleanup: remove unused imports 2024-07-26 10:26:11 +10:00
Harley Acheson
459572b15f UI: Custom Windows Cursors for VSE Handles
VSE has three mouse cursors defined, WM_CURSOR_LEFT_HANDLE,
WM_CURSOR_RIGHT_HANDLE, and WM_CURSOR_BOTH_HANDLES that are currently
always using our default cursor format. This format works on all
platforms but does not support multiple sizes or antialiasing. This
PR makes these use custom cursors (created by Pablo Vazquez) on the
Windows platform.

Pull Request: https://projects.blender.org/blender/blender/pulls/125252
2024-07-25 18:21:16 +02:00
Campbell Barton
2edc2393d2 Cleanup: spelling in comments 2024-07-25 10:17:42 +10:00
Campbell Barton
62afbbef9b Cleanup: use const variables & args, pass args by reference 2024-07-25 10:17:40 +10:00
Alaska
e7ce8d33e3 Fix #124642: OSL generates UVs for objects that don't have any
After e3697710d0, if no UV map was found, then Cycles OSL would
generate UV coordinates for users. This was done to add UV coordinates
to lights, however it had the side effect of creating new UV
coordinates for other object types that don't have a UV map.
This lead to a rendering difference between OSL and SVM
when rendering meshes with no UV map, and objects with no
UV map, like curves.

This commit fixes this issue by adding a new "is_light" attribute to
Cycles OSL and using that to figure out if UV coordinates should be
generated for lights.

Pull Request: https://projects.blender.org/blender/blender/pulls/124673
2024-07-24 12:16:44 +02:00
Campbell Barton
cb8c5d77d9 Fix error in NDOF button range check
Correct error in 3da3f678eb
2024-07-24 12:49:46 +10:00
Kamil Galik
3da3f678eb GHOST/NDOF: Extend NDOF devices support on Windows
Commit adds support for new format of RawInput packets used by
3Dconnexion devices: SpaceMouse Enterprise, Keyboard Pro and Numpad Pro
specifically. This required distinguishing processing button data
delivered as a bitmask and as a numbers array.

Basically it allows for using said devices buttons in Blender including
using these buttons in shortcuts.

Changes work only for Windows. MacOS will allow only for older format
that is bitmask.

Details:

- NDOF button event values have been moved into the public GHOST_Types.h
  header and are no longer aligned to the WM event values.
  This was done so the values could be changed to match hardware/drivers
  without breaking key-maps stored in user preferences.
- Keyboard Pro and Numpad Pro buttons are not currently used because
  they don't map to any standard keyboard events.
  These could be supported, see the PR for details.

Ref: !124155
2024-07-24 12:37:08 +10:00
Weizhen Huang
c816649d85 Cleanup: improve comment regarding Cycles spot light scaling
mentioning increase in noise is a bit misleading because it shouldn't be
noticeable at this scale.
2024-07-23 12:42:30 +02:00
Campbell Barton
068bb052b2 Cleanup: use const variables in mallocn reporting 2024-07-23 15:58:21 +10:00
Alaska
90e83175eb Fix #125168: Cycles spot light theata_e can flip with a wide spread
When the spread of a spot light is at it's maximum (180 degrees),
then `atan(tan(theta_e))` could become quite unpredictable due to
a asymtote in the tan function when working with lights with this
spread (because theta_e is `spread * 0.5 = pi/2`).
This lead to issues like theta_e for the spotlight becoming negative,
which lead to rendering errors due to a malformed light tree.

This commit fixes this issue by adding a episilon region around the
troublesome values and sets theta_e to `pi/2` when in that region.

Candidate for backporting to 4.2 and potentially 3.6

Pull Request: https://projects.blender.org/blender/blender/pulls/125172
2024-07-22 17:09:43 +02:00
Lukas Tönne
7c903f9b83 Revert "update"
This reverts commit c4f99bcb6c.
2024-07-22 09:54:02 +02:00
Lukas Tönne
c4f99bcb6c update 2024-07-22 09:52:19 +02:00
Campbell Barton
5794913fb8 Cleanup: CMake file indentation, wrap long lines 2024-07-22 09:58:45 +10:00
Campbell Barton
f85c29dc5c Cleanup: move Wayland's private window member into GWL_Window
Keep private options in one place: GWL_Window.
2024-07-22 09:58:41 +10:00
Campbell Barton
a616799607 Fix window activation on startup with Wayland & libdecor
Libdecor would attempt to activate the window before it was
known to the window manager, causing the GHOST_kEventWindowActivate
event not to be sent.

Resolve by skipping window manager activation when the window has
not yet been initialized.
2024-07-20 13:55:43 +10:00
Jesse Yurkovich
ec4fc2d34a CMake: Modernize the optional TBB dependency
This continues the cmake modernization effort and introduces support for
allowing our optional dependencies to integrate properly. TBB is added
here as it's proven troublesome to maintain correctly.

Currently the only Blender project which uses the TBB headers directly
is `blenlib`.  However, all downstream projects which require blenlib as
their dependency, and wish to properly make use of its threading
facilities, needed to define various TBB items in their CMake files. Not
only is this unnecessary and arcane, but several projects didn't do this
and ended up not using threading as well as producing ODR violations
along the way[1].

This PR makes TBB a modern dependency and exposes it PUBLIC'ly from
`blenlib`.  All downstream projects which depend on blenlib will now
receive everything they require from TBB automatically. This includes
the `WITH_TBB` define, the headers, and the library itself.

[1] blender/blender@05241f47f5

Pull Request: https://projects.blender.org/blender/blender/pulls/124916
2024-07-19 23:30:56 +02:00
Xavier Hallade
cee4ad4518 Refactor: Cycles: oneAPI: Simplify num_concurrent_states()
Deduplicated code by reusing num_concurrent_busy_states().
2024-07-18 15:46:17 +02:00
Xavier Hallade
c8421a0007 Cycles: set num_sort_partition_elements to 65536 for simd16+ Intel GPUs
Intel(R) Data Center GPU Max greatly benefits from this change since
its bigger simd width leads to a greater execution divergence.
2024-07-18 15:15:00 +02:00
Campbell Barton
c1deaeb57a Cleanup: quiet compiler warning with LIBDECOR disabled 2024-07-18 15:10:45 +10:00
Campbell Barton
80f0c613c0 Fix #123096: Opening & closing a window freezes Blender under Wayland
Skipping window decoration creation apparently resolves the freeze,
although I'm unable to redo this on my system.
2024-07-17 23:59:18 +10:00
Jesse Yurkovich
138e914346 Fix #124745: Wrong stack offset for Voronoi lacunarity parameter
This would cause values plugged into the Smoothness socket to also be
used for Lacunarity.

Pull Request: https://projects.blender.org/blender/blender/pulls/124761
2024-07-16 18:58:25 +02:00
Sergey Sharybin
047568f633 Cycles: Add an assert for DeviceString construction
The motivation is to be able to catch issues like #124705 early on,
by relying on asserts.

The not-so-obvious part of the change is the change in the order of
includes, which is needed for the types.h to have definition of the
kernel_assert().

Pull Request: https://projects.blender.org/blender/blender/pulls/124729
2024-07-16 09:43:28 +02:00
Bastien Montagne
c607ead4b7 Refactor: Makesrna: move generated code further in C++.
This commit moves generated `RNA_blender.h`, `RNA_prototype.h` and
`RNA_blender_cpp.h` headers to become C++ header files.

It also removes the now useless `RNA_EXTERN_C` defines, and just
directly use the `extern` keyword. We do not need anymore `extern "C"`
declarations here.

Pull Request: https://projects.blender.org/blender/blender/pulls/124469
2024-07-15 16:39:45 +02:00
Alaska
cf96136ec6 Fix #124705: Incorrect SSS method used in OptiX OSL
Update the string hashs in SSS OSL closure setup so they match the
strings being used by the SSS node.

This fixes two issues in OptiX OSL:
- SSS Random Walk would render as Random Walk Skin.
- Random Walk Skin wouldn't render at all.

Pull Request: https://projects.blender.org/blender/blender/pulls/124707
2024-07-15 16:23:45 +02:00
Pratik Borhade
5f54c463c0 Fix #124501: Make Cycles camera DOF UI consistent with EEVEE
Fix labels and add DOF eyedropper button in camera properties panel.

Pull Request: https://projects.blender.org/blender/blender/pulls/124506
2024-07-15 15:26:32 +02:00
Campbell Barton
84b0ccdd4b Merge branch 'blender-v4.2-release' 2024-07-15 19:42:57 +10:00