1
1

Compare commits

...

719 Commits

Author SHA1 Message Date
Sebastian Herholz
0925bfac34 Merge branch 'master' into cycles_path_guiding 2023-02-06 16:00:51 +01:00
8adebaeb7c Modifiers: measure execution time and provide Python access
The goal is to give technical artists the ability to optimize modifier usage
and/or geometry node groups for performance. In the long term, it
would be useful if Blender could provide its own UI to display profiling
information to users. However, right now, there are too many open
design questions making it infeasible to tackle this in the short term.

This commit uses a simpler approach: Instead of adding new ui for
profiling data, it exposes the execution-time of modifiers in the Python
API. This allows technical artists to access the information and to build
their own UI to display the relevant information. In the long term this
will hopefully also help us to integrate a native ui for this in Blender
by observing how users use this information.

Note: The execution time of a modifier highly depends on what other
things the CPU is doing at the same time. For example, in many more
complex files, many objects and therefore modifiers are evaluated at
the same time by multiple threads which makes the measurement
much less reliable. For best results, make sure that only one object
is evaluated at a time (e.g. by changing it in isolation) and that no
other process on the system keeps the CPU busy.

As shown below, the execution time has to be accessed on the
evaluated object, not the original object.

```lang=python
import bpy
depsgraph = bpy.context.view_layer.depsgraph
ob = bpy.context.active_object
ob_eval = ob.evaluated_get(depsgraph)
modifier_eval = ob_eval.modifiers[0]
print(modifier_eval.execution_time, "s")
```

Differential Revision: https://developer.blender.org/D17185
2023-02-06 15:40:15 +01:00
773a36d2f8 Fix Cycles OneAPI build error after recent changes 2023-02-06 15:36:49 +01:00
cc623ee7b0 Transform: do not save settings when canceling the operation
If we are canceling, the settings must remain the same as before we
start the operation.
2023-02-06 11:18:52 -03:00
deaddbdcff Fix forced snap status being removed when changing transform mode
The `SNAP_FORCED` setting is set to the operation and not the snap
status.

Therefore, this option should not be cleared along with the other
statuses when resetting snapping.

Move then the location of this setting to `TransInfo::modifiers`.
2023-02-06 11:18:52 -03:00
f2538c7173 Fix T104335: MNEE + OptiX OSL results in illegal address error
The OptiX pipeline created for OSL was missing sufficient continuation
stack to handle the MNEE ray generation program.
2023-02-06 15:06:52 +01:00
4bd3b02984 Python: Suppress BGL deprecation messages after 100 times.
BGL deprecation calls used to be reported on each use. As bgl calls
are typically part of a handler that is triggered at refresh this
could lead to overflow of messages and slowing down systems when
the terminal/console had to be refreshed as well.

This patch only reports the first 100 bgl deprecation calls. This
gives enough feedback to the developer that changes needs to be made
. But still provides good responsiveness to users when they have
such add-on enabled. Only the first frames can have a slowdown.
2023-02-06 13:35:29 +01:00
Sebastian Herholz
e50e5380f9 Merge branch 'master' into cycles_path_guiding 2023-02-06 13:24:12 +01:00
7beb487e9a Fix T104353: Crash on opening sculpting template
`t->region` was `NULL`.

It can happen depending on the context.

Caused by rB19b63b932d2b.
2023-02-06 09:21:04 -03:00
9ad3a85f8b Fix Cycles GPU binaries build error after recent changes for Metal 2023-02-06 13:17:57 +01:00
Sebastian Herholz
309fa3e0f7 Guiding: make format 2023-02-06 12:40:47 +01:00
Sebastian Herholz
7ae7446f4a Guiding: Adding roughness threshold parameter and preparing for Open PGL 0.5 2023-02-06 12:38:15 +01:00
Michael Jones
654e1e901b Cycles: Use local atomics for faster shader sorting (enabled on Metal)
This patch adds two new kernels: SORT_BUCKET_PASS and SORT_WRITE_PASS. These replace PREFIX_SUM and SORTED_PATHS_ARRAY on supported devices (currently implemented on Metal, but will be trivial to enable on the other backends). The new kernels exploit sort partitioning (see D15331) by sorting each partition separately using local atomics. This can give an overall render speedup of 2-3% depending on architecture. As before, we fall back to the original non-partitioned sorting when the shader count is "too high".

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D16909
2023-02-06 11:18:26 +00:00
Michael Jones
46c9f7702a Cycles: Enable MetalRT opt-in for AMD/Navi2 GPUs
Reviewed By: brecht

Differential Revision: https://developer.blender.org/D17043
2023-02-06 11:14:11 +00:00
Michael Jones
be0912a402 Cycles: Prevent use of both AMD and Intel Metal devices at same time
This patch removes the option to select both AMD and Intel GPUs on system that have both. Currently both devices will be selected by default which results in crashes and other poorly understood behaviour. This patch adds precedence for using any discrete AMD GPU over an integrated Intel one. This can be overridden with CYCLES_METAL_FORCE_INTEL.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D17166
2023-02-06 11:13:33 +00:00
Michael Jones
0a3df611e7 Fix T103393: Cycles: Undefine __LIGHT_TREE__ on Metal/AMD to fix perf
This patch fixes T103393 by undefining `__LIGHT_TREE__` on Metal/AMD as it has an unexpected & major impact on performance even when light trees are not in use.

Patch authored by Prakash Kamliya.

Reviewed By: brecht

Maniphest Tasks: T103393

Differential Revision: https://developer.blender.org/D17167
2023-02-06 11:12:34 +00:00
Amelie Fondevilla
6d297c35c8 Fix T104371: GPencil merge down layer duplicates wrong frame
The merge down operator was sometimes copying the wrong frame, which altered the animation.
While merging the layers, it is sometimes needed to duplicate a keyframe,
when the lowest layer does not have a keyframe but the highest layer does.
Instead of duplicating the previous keyframe of the lowest layer, the code
was actually duplicating the active frame of the layer which was the current frame in the timeline.

This patch fixes the issue by setting the previous keyframe of the layer as its active frame before duplication.

Related issue: T104371.

Differential Revision: https://developer.blender.org/D17214
2023-02-06 10:44:17 +01:00
329eeacc66 Cleanup: Cycles: Remove isotropic microfacet closure setup functions
Turns out these are 100% redundant, so get rid of them.
2023-02-06 04:26:36 +01:00
2627635ff3 Cleanup: use nullptr in C++ 2023-02-06 12:50:34 +11:00
d6b6050e5b Cleanup: use function style casts in C++ 2023-02-06 12:35:51 +11:00
731c3efd97 Cleanup: format 2023-02-06 12:32:45 +11:00
9f5c17f4af Cleanup: comments in code 2023-02-06 12:25:04 +11:00
4fcc9f5e7e Cleanup: use back-slash doxygen commands, de-duplicate doc-string 2023-02-06 12:25:04 +11:00
7de1a4d1d8 Fix GHOST/Wayland thread-unsafe timer-manager manipulation
Mutex locks for manipulating GHOST_System::m_timerManager from
GHOST_SystemWayland relied on WAYLAND being the only user of the
timer-manager.

This isn't the case as timers are fired from
`GHOST_System::dispatchEvents`.

Resolve by using a separate timer-manager for wayland key-repeat timers.
2023-02-06 12:25:04 +11:00
d3949a4fdb Fix GHOST/Wayland thread-unsafe key-repeat timer checks
Resolve a thread safety issue reported by valgrind's helgrind checker,
although I wasn't able to redo the error in practice.

NULL check on the key-repeat timer also needs to lock, otherwise it's
possible the timer is set in another thread before the lock is acquired.

Now all key-repeat timer access which may run from a thread
locks the timer mutex before any checks or timer manipulation.
2023-02-06 12:25:04 +11:00
b642dc7bc7 Fix: Incorrect forward-compatible saving of face sets
There were two errors with the function used to convert face sets
to the legacy mesh format for keeping forward compatibility:
- It was moved before `CustomData_blend_write_prepare` so it
  operated on an empty span.
- It modified the mesh when it's only supposed to change the copy
  of the layers written to the file.

Differential Revision: https://developer.blender.org/D17210
2023-02-05 18:09:22 -05:00
501352ef05 Cleanup: Move PBVH files to C++
For continued refactoring of the Mesh data structure. See T103343.
2023-02-05 17:36:47 -05:00
3420c47900 GPU: Fix incorrect implicit datatype conversions in test case shaders. 2023-02-05 22:33:46 +01:00
RiverIntheSky
a094f30a74 Fix T104363: BLI_assert 'attr->comp_len == 3' failed in cage 2d gizmo 2023-02-05 21:21:35 +01:00
3d6ceb737d Geometry Nodes: parallelize part of Duplicate Elements node
This implements two optimizations:
* If the duplication count is constant, the offsets array can be
  filled directly in parallel.
* Otherwise, extracting the counts from the virtual array is parallelized.
  But there is still a serial loop over all elements in the end to compute
  the offsets.
2023-02-05 20:59:39 +01:00
b7034e7280 Cleanup: use boolean instead of int, use const arguments, variable 2023-02-05 21:51:34 +11:00
a97607dcfa Cleanup: use typed enum for the handler flag in wm_event_system 2023-02-05 21:51:34 +11:00
f1314f3d5b Cleanup: make WM_HANDLER_* action flags local to wm_event_system 2023-02-05 21:51:34 +11:00
d6cd7d1138 WM: correct the return flag from wm_handler_fileselect_do
In the unlikely case an area could not be created OPERATOR_CANCELLED
was returned, this has the same value of WM_HANDLER_HANDLED however
break is logical in this situation and both flags work.
2023-02-05 21:51:34 +11:00
b2196ebe28 Win32: Relax Debug Assert in BLI_file_attributes
If GetFileAttributesW returns an error, only debug assert if the reason
is file not found.

See D17204 for more details.

Differential Revision: https://developer.blender.org/D17204

Reviewed by Ray Molenkamp
2023-02-04 13:44:10 -08:00
1a13940ef8 Fix T88617: Wrong annotation cursor in Preview of sequencer editor
Allow preview region to change cursor as per the selected tool

Reviewed by: campbellbarton, ISS

Differential Revision: https://developer.blender.org/D16878
2023-02-04 10:22:50 +05:30
62fc001979 Cleanup: silence warning
```
warning C4457: declaration of 'fac' hides function parameter
message : see declaration of 'fac'
```
2023-02-04 00:16:02 -03:00
Germano Cavalcante
06305e5ca8 Cleanup/refactor: split Edge and Vert Slide code into more specific functions
This makes the code more readable.

In this commit also the `int curr_side_unclamp` member was moved to
`EdgeSlideParams` as it is a common value for all "Containers".
2023-02-03 23:01:26 -03:00
789e549dba Geometry Nodes: Tweak menu location of sample nodes
There was an inconsistency between geometry sample nodes and mesh/curve
sample nodes, where the latter didn't have a special "Sample" category,
and we categorized as "Operations", which they were not. Also put the
sample category between "Read" and "Write" since the verb name is
more consistent and sampling is an advanced form of reading.
2023-02-03 16:26:56 -05:00
ab9c34e7e7 Fix T104316: Width of headerless panels on regions with overlap
In some cases panels without headers were drawn too wide in sidebars
with region overlap.

Instead of always using the maximum width the view allows, headerless
panels now also use the width calculated in
`panel_draw_width_from_max_width_get`. The function already returns the
correct width in all cases and also takes care of insetting the panels,
when their backdrop needs to be drawn, which is necessary for headerless
panels, too, when there is region overlap.

Reviewed By: Hans Goudey

Differential Revision: http://developer.blender.org/D17194
2023-02-03 21:40:38 +01:00
90f36fc50e Fix (unreported): snap to object origin not respecting clipping planes
There was an incorrect conversion for local clip planes although the
coordinates used are in world positions.
2023-02-03 17:16:44 -03:00
73000c792d Cycles: Reorganize Fresnel handling in Microfacet closures
This is both a cleanup and a preparation for the Principled v2 changes.
Notable changes:
- Clearcoat weight is now folded into the closure weight, there's no reason
  to track this separately.
- There's a general-purpose helper for computing a Closure's albedo, which is
  currently used by the denoising albedo and diffuse/gloss/transmission color
  passes.
- The d/g/t color passes didn't account for closure albedo before, this means
  that e.g. metallic shaders with Principled v2 now have their color texture
  included in the glossy color pass. Also fixes T104041 (sheen albedo).
- Instead of precomputing and storing the albedo during shader setup, compute
  it when needed. This is technically redundant since we still need to compute
  it on shader setup to adjust the sample weight, but the operation is cheap
  enough that freeing up the storage seems worth it.
- Future changes (Principled v2) are easier to integrate since the Fresnel
  handling isn't all over the place anymore.
- Fresnel handling in the Multiscattering GGX code is still ugly, but since
  removing that entirely is the next step, putting effort into cleaning it up
  doesn't seem worth it.
- Apart from the d/g/t color passes, no changes to render results are expected.

Differential Revision: https://developer.blender.org/D17101
2023-02-03 21:03:48 +01:00
0220bdc2d5 Cycles: Tests: Add option to increase SPP for manual comparisons
Useful for validating changes when sampling/noise changes:
- First run with BLENDER_TEST_UPDATE=1 and e.g. CYCLESTEST_SPP_MULTIPLIER=32
- Apply your change
- Run with only CYCLESTEST_SPP_MULTIPLIER=32
- Compare
- Reset the SVN repo

Differential Revision: https://developer.blender.org/D17107
2023-02-03 21:00:47 +01:00
b454416927 Cycles: add non-uniform scaling to spot light size
Cycles ignores the size of spot lights, therefore the illuminated area doesn't match the gizmo. This patch resolves this discrepancy.
| Before (Cycles) | After (Cycles) | Eevee
|{F14200605}|{F14200595}|{F14200600}|
This is done by scaling the ray direction by the size of the cone. The implementation of `spot_light_attenuation()` in `spot.h` matches `spot_attenuation()` in `lights_lib.glsl`.
**Test file**:
{F14200728}

Differential Revision: https://developer.blender.org/D17129
2023-02-03 18:51:14 +01:00
6590a288b0 Fix number sliders not working
Own mistake in d204830107.

For some buttons the type is changed after construction, which means the button
has to be reconstructed. For example number buttons can be turned into number
slider buttons this way. New code was unintentionally overriding the button
type after reconstruction with the old type again.
2023-02-03 18:46:12 +01:00
23506622a5 Gizmo: add central point to circular 2D cage 2023-02-03 18:30:57 +01:00
7f958217ad Curves: Use shared caches for evaluated data
Use the `SharedCache` concept introduced in D16204 to share lazily
calculated evaluated data between original and multiple evaluated
curves data-blocks. Combined with D14139, this should basically remove
most costs associated with copying large curves data-blocks (though
they add slightly higher constant overhead). The caches should
interact well with undo steps, limiting recalculations on undo/redo.

Options for avoiding the new overhead associated with the shared
caches are described in T104327 and can be addressed separately.

Simple situations affected by this change are using any of the following data
on an evaluated curves data-block without first invalidating it:
- Evaluated offsets (size of evaluated curves)
- Evaluated positions
- Evaluated tangents
- Evaluated normals
- Evaluated lengths (spline parameter node)
- Internal Bezier and NURBS caches

In a test with 4m points and 170k curves, using curve normals in a
procedural setup that didn't change positions procedurally gave 5x
faster playback speeds. Avoiding recalculating the offsets on every
update saved about 3 ms for every sculpt update for brushes that don't
change topology.

Differential Revision: https://developer.blender.org/D17134
2023-02-03 12:19:40 -05:00
dc79281223 Nodes: Add modal keymap for Node link drag
This will add a proper modal keymap for the node link drag operator.
It allows the user to customize the keys used to start drag and so on.
Also it gets rid of the custom status bar message.

Differential Revision: https://developer.blender.org/D17190
2023-02-03 17:41:12 +01:00
1195933ada Fix: Compile error after BMesh conversion commit 2023-02-03 11:09:19 -05:00
a1c01e0c06 Attempt to fix build errors with NDOF enabled 2023-02-03 17:03:29 +01:00
fcc1166821 GPU: Disable verbose GLSL variable names in debug builds
GpuInput::node can be deallocated in some cases. (See T104265)
This is a temp workaround until a proper solution is implemented.
2023-02-03 17:00:35 +01:00
d204830107 UI: Make uiBut safe for non-trivial construction
No user-visible changes expected.

Essentially, this makes it possible to use C++ types like `std::function`
inside `uiBut`. This has plenty of benefits, for example this should help
significantly reducing unsafe `void *` use (since a `std::function` can hold
arbitrary data while preserving types).

----

I wanted to use a non-trivially-constructible C++ type (`std::function`) inside
`uiBut`. But this would mean we can't use `MEM_cnew()` like allocation anymore.

Rather than writing worse code, allow non-trivial construction for `uiBut`.
Member-initializing all members is annoying since there are so many, but rather
safe than sorry. As we use more C++ types (e.g. convert callbacks to use
`std::function`), this should become less since they initialize properly on
default construction.

Also use proper C++ inheritance for `uiBut` subtypes, the old way to allocate
based on size isn't working anymore.

Differential Revision: https://developer.blender.org/D17164

Reviewed by: Hans Goudey
2023-02-03 16:35:51 +01:00
ebe8f8ce71 BMesh: Parallelize BMesh to evaluated Mesh conversion
Currently this conversion (which happens when using modifiers in edit
mode, for example) is completely single threaded. It's harder than some
other areas to multithread because BMesh elements don't always know
their indices (and vise versa), and because the dynamic AoS format
used by BMesh makes some typical solutions not helpful.

This patch proposes to split the operation into two steps. The first
updates the indices of BMesh elements and builds tables for easy
iteration later. It also checks if some optional mesh attributes
should be added. The second uses parallel loops over all elements,
copying attribute values and building the Mesh topology.

Both steps process different domains in separate threads (though the
first has to combine faces and loops). Though this isn't proper data
parallelism, it's quite helpful because each domain doesn't affect the
others.

**Timings**
I tested this on a Ryzen 7950x with a 1 million face grid, with no
extra attributes and then with several color attributes and vertex
groups.

| File | Before | After |
| Simple | 101.6 ms | 59.6 ms |
| More Attributes | 149.2 ms | 65.6 ms |

The optimization scales better with more attributes on the BMesh. The
speedup isn't as linear as multithreading other operations, indicating
added overhead. I think this is worth it though, because the user is
usually actively interacting with a mesh in edit mode.

See the differential revision for more timing information.

Differential Revision: https://developer.blender.org/D16249
2023-02-03 10:20:19 -05:00
Germano Cavalcante
19b63b932d Fix transform gizmo not updating according to state
Whenever a transform operation is activated by gizmo, the gizmo
modal is maintained, but its drawing remains the same even if the
transform mode or constrain is changed.

So update the gizmo according to the mode or constrain set.

NOTE: Currently only 3D view gizmo is affected
2023-02-03 11:07:43 -03:00
af0d378177 Cleanup: Move multires reshape header to C++
For continued refactoring of the Mesh data structure. See T103343.
2023-02-03 08:48:00 -05:00
96e37affe5 Cleanup: Remove unused image paint function 2023-02-03 08:18:41 -05:00
5a9d2b872e Cleanup: incorrect naming of storage_buf parameters.
They were named vert.
2023-02-03 14:11:07 +01:00
0f51b5b599 Animation: Add Operator for adding FCurve modifiers to more menus
The operator has the option to add to selected FCurves instead
of only the active, but it was only exposed in the redo panel.
This patch adds the operator to the right-click menu on FCurve channels,
and to the channel menu in the Graph editor.
Both times with configured to add to selected
instead of only the active FCurve

Revied by Reviewed by: Sybren A. Stüvel
Differential Revision: https://developer.blender.org/D17066
Ref: D17066
2023-02-03 13:06:15 +01:00
cc23b6abd6 Cleanup: rename cage2d draw style (RECTANGLE -> BOX_TRANSFORM) 2023-02-03 12:01:45 +01:00
3c8c0f1094 Gizmo: add gizmo for adjusting spot light blend
Ref T104280

Differential Revision: https://developer.blender.org/D17171
2023-02-03 11:32:10 +01:00
d335db09e0 Fix T90893: Restoring a key in the keymap editor doesn't work if the key is only disabled
Reset `KMI_INACTIVE` flag when restore-item  button is called

Reviewed By: campbellbarton

Differential Revision: https://developer.blender.org/D16773
2023-02-03 15:45:59 +05:30
ab3e1809b6 Vulkan: Select graphics queue with compute capabilities.
There might be cases that the graphics queue and compute
queue are separated, but that would be something that we
will solve in the future.
2023-02-03 10:16:01 +01:00
a45a881534 Spelling: familly -> family.
Fix spelling mistake originated from tmp-vulkan branch.
2023-02-03 10:16:01 +01:00
9565ea0724 IO: Harmonize UI for selection of axes in OBJ and Collada
Implements T103858: in OBJ importer and exporter, and in Collada
exporter, present axis choices as a dropdown instead of inline button
row.

Reviewed By: Bastien Montagne
Differential Revision: https://developer.blender.org/D17186
2023-02-03 11:14:53 +02:00
2fb0c20f53 Cleanup: remove unreachable return values 2023-02-03 20:02:25 +11:00
307113d744 GPU: Fix incorrect datatype conversions in test case shaders. 2023-02-03 08:23:55 +01:00
11d8965da1 Cleanup: quiet undeclared variable warning 2023-02-03 15:10:58 +11:00
c468aeefb5 PyAPI: updates to bl_ui.generic_ui_list which didn't follow conventions
- Replace type annotations with doc-strings, the current conventions is
  not to use type annotations in startup scripts.
- Replace abbreviation "idx" with "index" in public arguments/properties.
- Replace `len(..) > 0` with boolean checks.
- Add `__all__` to list public members.
- Use `arg` instead of `param` for doc-strings.
- Locate the doc-string so it shows as `__doc__`.
2023-02-03 15:07:14 +11:00
266d8de687 Cleanup: spelling in comments 2023-02-03 12:41:01 +11:00
27e2b32a06 Cleanup: Remove redundant calls to init grids
`BKE_volume_init_grids` gets called in `volume_init_data` that is run
on creating new datablocks so it's unnecessary to run it separately.
2023-02-03 00:14:19 +01:00
023277359f Fix T104053: Limit pbvh recursion
The recursion depth was checked for equality with a maximum depth,
allowing leaves with more primitives if a certain depth was reached.

However, a single leaf must always use the same material (including
set_smooth), so if a leaf contained multiple materials it was split
anyway. This meant that in the next recursion step the depth was
larger than the cutoff value and it would go back to recursing until
the number of primitives was small enough, ignoring the recursion
depth for the rest of the process.

In certain edge cases this could lead to a stack overflow.

Even with the check changed from 'equality' to 'larger or equal'
this could still fail in the pathological case where every primitive
has another material. But that can't be helped, and it wouldn't
realistically happen either.

Differential Revsision: https://developer.blender.org/D17188
2023-02-03 00:09:26 +01:00
b5e00a1482 Revert "BLI: Use BLI_math_matrix_type.hh instead of BLI_math_float4x4.hh"
This reverts commit 52de84b0db.

had some build issues on windows i can't quickly resolve, revert for
now while we fix the problems
2023-02-02 11:46:23 -07:00
f31ad5d98b Cleanup: refactoring BKE_nlastrips_add_strip method to Null check. Adding Unit tests for method
Reviewed By: Sybren

Differential Revision: https://developer.blender.org/D17155
2023-02-02 13:20:25 -05:00
52de84b0db BLI: Use BLI_math_matrix_type.hh instead of BLI_math_float4x4.hh
Straightforward port. I took the oportunity to remove some C vector
functions (ex: `copy_v2_v2`).

This makes some changes to DRWView to accomodate the alignement
requirements of the float4x4 type.
2023-02-02 18:11:35 +01:00
ca99a59605 Fix T104261: crash when trying to draw viewer overlay for empty curve
`BKE_displist_make_curveTypes` only sets `curve_eval` if the final geometry
of the object actually contains curve data, otherwise it's null.
2023-02-02 17:20:57 +01:00
Iliya Katueshenock
fdc81be213 Fix T104223: attribute not propagated to Set Curve Radius node
This declaration change tells the evaluation system that the radius
field is evaluated on the input geometry. Which in turn means that
attributes referenced by the radius field should be propagated to
the geometry.
2023-02-02 17:04:29 +01:00
fc2a64e21a Win32: Better Error Handling in BLI_file_attributes
After Win32 API call GetFileAttributesW, check for
INVALID_FILE_ATTRIBUTES, which is returned on error,
usually if file not found.

See D17176 for more details.

Differential Revision: https://developer.blender.org/D17176

Reviewed by Ray Molenkamp
2023-02-02 08:01:43 -08:00
7208938707 Fix T104278: incorrect handling of unavailable linked node groups
The declaration of group nodes using unavailable linked groups contains
a `skip_updating_sockets` tag, which indicates that the node shouldn't
change. This information was not used properly further down the line.
2023-02-02 16:38:53 +01:00
2a19810f97 Fix T104296: crash caused by incorrectly initialized group nodes
Versioning code in `do_versions_after_linking_260` inserted new group input
and output nodes. And (reasonably?) expected sockets to exist on those nodes.
However, `nodeAddStaticNode` did not initialize sockets on nodes with that use
`declare_dynamic` yet. This patch changes it so that `declare_dynamic` is used
in more places, which caused issues during file loading when node groups are
updated in somewhat arbitrary order (not in an order that is based on which
groups use which).

Differential Revision: https://developer.blender.org/D17183
2023-02-02 16:38:53 +01:00
04aab7d516 Animation: Add "Select Linked Vertices" to Weight Paint Mode
Adds two operators to select linked  vertices in weight paint mode.
Similar to how it works in edit mode.
Press "L" to select vertices under the cursor,
or CTRL + "L" to select anything linked to the current selection.

Reviewed by: Sybren A. Stüvel, Hans Goudey, Marion Stalke
Differential Revision: https://developer.blender.org/D16848
Ref: D16848
2023-02-02 16:17:17 +01:00
fe5d54d3d0 Gizmo: add new cage2d draw style for circular shapes
`ED_GIZMO_CAGE2D_STYLE_CIRCLE` now draw circles. The previous `ED_GIZMO_CAGE2D_STYLE_CIRCLE`, which drew rectangles, is renamed to `ED_GIZMO_CAGE2D_STYLE_RECTANGLE`. The meaning of `ED_GIZMO_CAGE2D_STYLE_BOX` is now unclear and probably needs to be renamed too.
Ref T104280

Maniphest Tasks: T104280

Differential Revision: https://developer.blender.org/D17174
2023-02-02 16:15:23 +01:00
c2c6707919 Fix T102690: Object can be animated with a single keyframe
Remove some assumptions that an FCurve with a single keyframe always is
extrapolated in constant fashion. There's no reason for the Beziér handles
to be ignored in such a case.

FCurve evaluation already worked properly, it was just the drawing in the
graph editor and the selectability of the handles that needed adjustments.
2023-02-02 16:01:03 +01:00
c1b85103fe GPU: Added testcase for SSBO/Compute.
Test case is a smaller step towards supporting Vulkan. Other
test cases rely on SSBOs as well so it is better to first satisfy
this step before handling the others.
2023-02-02 14:11:43 +01:00
49ad91b5ab Animation: Enable Pin Icon in the Dope Sheet
Even though the dope sheet respects the pinned channels, it did not show the icon to interact with the pinned state.

This adds the icon to the dope sheet as well.

{F14178715}

Reviewed by: Sybren A. Stüvel
Differential Revision: https://developer.blender.org/D17061
Ref: D17061
2023-02-02 13:58:13 +01:00
bbc18673f3 Cleanup: make format 2023-02-02 13:16:39 +01:00
d77b87eb93 Fix invalid versioning code for meshes
The issue was introduced in d92edca862: one shall not use
polygon index to index polygon custom data layer.
2023-02-02 13:10:45 +01:00
644d54a193 GPU: Fix memory leak in VkShader.
std::string makes a copy, without taking ownership.
2023-02-02 13:06:10 +01:00
6c66f3e2b3 GPU: Remove prototype without implementation.
`GPUShaderInterface(const ShaderCreateInfo&)` is defined but its
implementation has been removed.
2023-02-02 11:46:29 +01:00
d92edca862 Fix: CustomData layers become unsorted in versioning
n versioning, when converting CD_SCULPT_FACE_SETS to CD_PROP_INT32
the layers were not kept properly ordered by type.

This was discovered while investigating T104053

Differential Revision: D17165
2023-02-02 09:49:25 +01:00
Stephen Seo
e1ee86b63c Change default AV1 encoder for "slowest"
Previously, having the "Encoding speed" set to "slowest" would choose
libaom-av1 first and librav1e second. This change makes Blender choose
librav1e first (and has a fallback to whatever other AV1 codec is
available if librav1e is not installed).

Addresses /T103849 on systems where librav1e codec available.

Reviewed By: sergey, ISS

Maniphest Tasks: T103849

Differential Revision: https://developer.blender.org/D17002
2023-02-02 09:33:25 +01:00
199233eee1 Cleanup: Change VMA from CRLF to LF.
To match the rest of our repository.
2023-02-02 08:23:54 +01:00
5d9971bc63 Vulkan: Fix compilation warning in VMA. 2023-02-02 08:19:17 +01:00
99520a79b6 Viewport Compositor: Platform support message.
In the previous situation the message was shown for Apple devices.
But this is not correct and confusing.

- Apple with Metal backend are supported, OpenGL on Apple isn't
- Legacy devices on Windows or Linux are also not supported.

This change will check that the capabilities of the GPU match the
requirements to use Viewport compositor. Based on those capabilities
a message is shown and the panel is activated.
2023-02-02 07:43:18 +01:00
e2c3bff78b Spelling: 'GPU Back end' -> 'GPU Backend'. 2023-02-02 07:35:32 +01:00
96ea0dd458 Cleanup: spelling in comments 2023-02-02 14:00:32 +11:00
31a6400279 Fix error referencing transition context which doesn't exist
Regression in [0] added reference to constraint which doesn't exist.

[0]: db87e2a638
2023-02-02 13:33:08 +11:00
d82ffb9787 Fix T103530: Allow Recursive File Lists
In File Browser, correct full path creation so that it works correctly
in recursive listings.

See D17175 for more details.

Differential Revision: https://developer.blender.org/D17175

Reviewed by Julian Eisel
2023-02-01 14:06:38 -08:00
a4868f2058 Fix T104136: Crash with Mesh to Volume & Simplify
Blender crashes when Simplify is enabled and set to 0.
This is because mesh_to_volume_grid returns nullptr at voxel size 0.
A simple null-check fixes this problem.

Differential Revision: https://developer.blender.org/D17122
2023-02-01 20:50:39 +01:00
9b86741ae7 FIx possible return of string without null character
`WM_modalkeymap_items_to_string` is expected to always return a string.

But in the special case of zero length, the returned string was not
terminated with `'\0'`.

This can cause problems with the header of the knife tool for example.
It always uses the returned string.

(This issue was observed when investigating T103804).
2023-02-01 15:29:21 -03:00
c105c49407 Cleanup: rename places where 3D cage gizmo uses 2D cage enums 2023-02-01 17:28:35 +01:00
19fe5caf87 Geometry Nodes: add support for eye dropper for object input in modifier
Differential Revision: https://developer.blender.org/D17108
2023-02-01 12:53:57 +01:00
5a97b282e9 Fix (unreported) crash when importing data with custom normals.
The usage of `index` was inverted between destination array of vectors
and source vector in rB3a3d9488a1633.
2023-02-01 10:53:53 +01:00
e515f81318 Cleanup: move swapping objects in a collection to a utility function
Including this logic inline complicated D17016 & was noted as a TODO.
2023-02-01 14:41:40 +11:00
345dded146 Revert "Geometry Nodes: hide group inputs with "Hide Value" enabled in modifier"
This reverts commit 11a9578a19.

Reverting this because there was a miscommunication between Simon and me. Shortly
before I committed the change, Simon noticed that there are cases when "Hide Value"
is checked to hide the value in a group node, but we still want to show the value
in the modifier.
2023-01-31 19:28:22 +01:00
3750e7ef0b Sculpt: Don't invert in geodesic mask expand keymap 2023-01-31 10:23:07 -08:00
0a9520ce84 Sculpt: Un-invert expand normal falloff
Normals falloff mask is created inverted compared
to how other falloffs work.  It's now un-inverted
in a final step at the end.

Also exposed the normals falloff smooth steps as
an RNA property.
2023-01-31 10:23:07 -08:00
11a9578a19 Geometry Nodes: hide group inputs with "Hide Value" enabled in modifier
When the "Hide Value" option of a group input is enabled, only its name
is displayed in group nodes. Modifiers should have the same behavior.
However, for modifiers, only showing the name does not make sense
when the user can't edit the value. Therefore the value is not shown at all.
2023-01-31 18:55:06 +01:00
2995165148 Cleanup: simplify wrapping CurvesGeometry in C++ 2023-01-31 18:45:55 +01:00
fa9fc59b56 Fix T104240: OptiX OSL texture loading broken with displacement
The image manager used to handle OSL textures on the GPU by
default loads images after displacement is evaluated. This is a
problem when the displacement shader uses any textures, hence
why the geometry manager already makes the image manager
load any images used in the displacement shader graph early
(`GeometryManager::device_update_displacement_images`).
This only handled Cycles image nodes however, not OSL nodes, so
if any `texture` calls were made in OSL those would be missed and
therefore crash when accessed on the GPU. Unfortunately it is not
simple to determine which textures referenced by OSL are needed
for displacement, so the solution for now is to simply load all of
them early if true displacement is used.
This patch also fixes the result of the displacement shader not
being used properly in OptiX.

Maniphest Tasks: T104240

Differential Revision: https://developer.blender.org/D17162
2023-01-31 16:41:00 +01:00
ce42906b89 Fix wrong spot light blend circle radius in viewport
Was using squared cosine instead of cosine. The problem is obvious for large spread angles.
|before|after
|{F14220946}|{F14220948}
The images are generating by returning `floor(spotmask)` in function `spot_attenuation()` in `lights_lib.glsl`.
2023-01-31 16:26:51 +01:00
1cb04af1df BLI: Fix missing const correctness
This fix incorrect rBa837604d44a0 commit
2023-01-31 15:36:24 +01:00
6de43f6f04 BLI: Fix invalid swizzle commit
This fix incorrect rBa837604d44a0 commit
2023-01-31 14:53:54 +01:00
a837604d44 BLI: Math: Add xy() and xyz() swizzle functions
Thoses are added for better component masking syntax.
This avoids the harder to read `float2(my_vec4)`.

This is not meant to be fully usable swizzling support but could be
extended in the future.
2023-01-31 14:48:19 +01:00
59b7aec9a2 VSE: Add missing NULL check in poll
Commit 90e9406866 forgot to add a NULL check for `ed`
2023-01-31 14:43:17 +01:00
5021f10e65 GPencil: Group similar UI parameters in Offset modifier 2023-01-31 13:13:00 +01:00
c1e5359eba GPencil: Use BLI_math_matrix_type.hh instead of BLI_math_float4x4.hh
Straightforward port. I took the oportunity to remove some C vector
functions (ex: `copy_v2_v2()`).

Reviewed By: antoniov

Differential Revision: https://developer.blender.org/D17160
2023-01-31 12:53:44 +01:00
a71ae981c7 Fix T104243: GPencil Cutter flattening caps on both sides 2023-01-31 11:18:13 +01:00
Jason Fielder
a504058dee Metal: Optimize GLSL to MSL translation. Improve cached compilation
Reduces the GLSL to MSL translation stage of shader compilation from 120 ms to 5 ms for complex EEVEE materials. This manifests in faster overall compilations, and faster cache hits for secondary compilations, as the MSL variant is needed as a key.

Startup time is also improved for both first-run and second-run. Note that this change does not affect shader compilation times within the Metal API.

Also disables shader output to disk

Authored by Apple: Michael Parkin-White

Ref T96261
Depends on D16990

Reviewed By: fclem

Maniphest Tasks: T96261

Differential Revision: https://developer.blender.org/D17033
2023-01-31 11:06:31 +01:00
Jason Fielder
f3bd5458a3 Metal: Optimise shader texture cache usage and branch reduction via point sampling.
Replace texelFetch calls with a texture point-sample rather than a textureRead call. This increases texture cache utilisation when mixing between sampled calls and reads. Bounds checking can also be removed from these functions, reducing instruction count and branch divergence, as the sampler routine handles range clamping.

Authored by Apple: Michael Parkin-White
Ref T96261

Depends on D16923

Reviewed By: fclem

Maniphest Tasks: T96261

Differential Revision: https://developer.blender.org/D17021
2023-01-31 10:56:25 +01:00
9f866a92dc Fix T104176: Smooth modifier with vergex group not work for negative factors.
Regression from rBabc8d6b12ce9, over three years ago!

Should be backported to the active LTS releases too.
2023-01-31 09:55:45 +01:00
3d765f6527 GPU: Fix gpu_math_test.glsl test case.
Test results were generated from incorrect code.
Code was fixed, but test results weren't updated.
This patch updates the test results to match the implementation.
- `projection_perspective.w.w == 0.0`
2023-01-31 09:51:08 +01:00
59aefaf3d0 Vulkan: Fix assert when compiling transform feedback shaders.
Transform feedback shaders don't have a fragment shader and should not
fail when it is not given.
2023-01-31 09:50:50 +01:00
d44d165e8a Vulkan: Fix compilation on Linux.
ShaderC was missing and is required for compilation.
2023-01-31 09:23:21 +01:00
d8cd8a0852 Cleanup: remove compilation warning
Unused parameter in vk_backend.
2023-01-31 09:10:18 +01:00
b7e178cb7d GPU: Cross test OpenGL tests to Vulkan.
Enhanced the GPU_TEST macro to also handle Vulkan backend
when WITH_VULKAN_BACKEND compilation option has been
enabled.
2023-01-31 08:48:52 +01:00
6b8fa899ca Metal: Fix compilation of GLSL used in test cases.
Added imageStore for 1d textures.
2023-01-31 08:42:33 +01:00
57efef2635 Fix generating geometry icons for meshes without vertex colors 2023-01-31 16:46:40 +11:00
91263a8b8b Sculpt: Fix T104040: Always update eevee shadows in sculpt modes 2023-01-30 21:29:11 -08:00
79c82fc1c5 Cleanup: trailing space 2023-01-31 15:49:04 +11:00
b18b53eae0 CMake: add missing headers 2023-01-31 14:22:26 +11:00
4f1800d70a Docs: note that delimiting by winding could be supported
Some users requested this behavior since it was removed,
so note that it could be supported again.
2023-01-31 14:22:25 +11:00
6c8c8c20c7 Cleanup: quiet mypy type checking warnings 2023-01-31 14:22:24 +11:00
27b4916b1a Cleanup: spelling in comments
Also minor changes in comments:
- Reference BLENDER_HISTORY_FILE instead of the literal file-name
  (simplifies looking up usage).
- Use usernames in tags, as noted in code-style.
2023-01-31 14:22:23 +11:00
ea8fd343eb Gitea: add merge message templates
To add the pull request # at the end of the commit.
2023-01-30 23:48:41 +01:00
f359a39d11 Fix T100028: Convert USD camera properties to mm from USD units.
Authored by Sonny Campbell.

Currently when importing a USD file, some of the camera properties are
ignored, or the units are not converted correctly from USD world units.
On import we currently set the focal length, but not the camera sensor
size (horizontal and vertical aperture), so the camera field of view
is wrong. The sensor size information is in the USD file, but is ignored
for perspective cameras.

USD uses "tenth of a world unit" scale for some physical camera properties
like focal length and aperture.
https://graphics.pixar.com/usd/release/api/class_usd_geom_camera.html#UsdGeom_CameraUnits

I have added the UsdStage's metersPerUnit parameter to the ImportSettings
so the camera can do the required conversion on import. This will convert from
the USD file's world units to millimeters for Blender's camera settings.

Reviewed by: Sybren and makowalski.

Differential Revision: https://developer.blender.org/D16019
2023-01-30 17:22:26 -05:00
129093fbce Cycles: Fix crash when rendering with OSL on multiple GPUs
The `MultiDevice` implementation of `get_cpu_osl_memory` returns a
nullptr when there is no CPU device in the mix. As such access to that
crashed in `update_osl_globals`. But that only updates maps that are not
currently used on the GPU anyway, so can just skip that when the CPU
is not used for rendering.

Maniphest Tasks: T104216
2023-01-30 19:40:22 +01:00
87a923fdb6 GPU: Add SSBO binding test to new structure.
This test was added to test the shader info structure binding
information for SSBOs. It still used the legacy GLSL structure.
2023-01-30 19:07:33 +01:00
f4deed288b USD export: style fixes to previous commit.
Changed to C-style comments and added braces.
2023-01-30 11:57:28 -05:00
c79b55fc05 USD export: add scale and bias for normal maps.
Changes authored by Michael B Johnson (drwave).

This addresses the issue in T102911.

Add scale and bias inputs to ensure the normals are
in tangent space [(-1,-1,-1), (1,1,1)].

This is following the convention as set in the USD Spec
(https://graphics.pixar.com/usd/dev/spec_usdpreviewsurface.html).

Differential Revision: https://developer.blender.org/D17072
2023-01-30 11:32:03 -05:00
ad083f925c GPencil: Rename init_time to time_start 2023-01-30 16:27:00 +01:00
ce13d0d326 GPU: Only compile test shaders when test cases option is enabled.
The glsl files + create infos of shaders that are only used
during development where still being compiled into blender.

This isn't needed and shouldn't be included. This change will
only include them when WITH_GTEST and WITH_OPENGL_DRAW_TESTS are
enabled. All other cases those files will be skipped.
2023-01-30 15:46:12 +01:00
1a50f814e6 Cleanup: Remove unused variable, use switch, and C++ casting. 2023-01-30 15:41:01 +01:00
Jason Fielder
aca9c131fc Metal: Fix issue with premature safe buffer list flush and optimize memory manager overhead.
Resolve an issue where released buffers were returned to the reusable memory pool before GPU work associated with these buffers had been encoded. Usually release of memory pools is dependent on successful completion of GPU work via command buffer callbacks. However, if the pool refresh operation occurs between encoding of work and submission, buffer ref-count is prematurely decremented.

Patch also ensures safe buffer free lists are only flushed once a set number of buffers have been used. This reduces overhead of small and frequent flushes, without raising the memory ceiling significantly.

Authored by Apple: Michael Parkin-White

Ref T96261

Reviewed By: fclem

Maniphest Tasks: T96261

Differential Revision: https://developer.blender.org/D17118
2023-01-30 14:54:39 +01:00
d4d4efd3d3 GPU: Use create info for compute test cases.
Compute test case still used legacy API to construct
GLSL shaders. This change will migrate it to use the
GPUShaderCreateInfo's.

In preparation to run test-cases against non-opengl
back-ends.
2023-01-30 14:45:07 +01:00
62dd0855a9 Cleanup: Remove special handling of 3DCursor in undo code.
Such preserve-across-undo data handling is now done through the IDType
callbacks, see e.g. `scene_undo_preserve` for the 3DCursor case.
2023-01-30 14:40:59 +01:00
Jason Fielder
596ee79a9f Metal: Optimize shader local memory usage.
Due to shader global scope emulation via class interface, global constant arrays in shaders are allocated in per-thread shader local memory. To reduce memory pressure, placing these constant arrays inside function scope will ensure they only reside within device constant memory. This results in a tangible 1.5-2x performance uplift for the specific shaders affected.

Authored by Apple: Michael Parkin-White

Ref T96261

Reviewed By: fclem

Maniphest Tasks: T96261

Differential Revision: https://developer.blender.org/D17089
2023-01-30 13:53:00 +01:00
dea924a91f GPU: Fix incorrectly commited test compilation of all shaders 2023-01-30 12:30:21 +01:00
0da74d3ee9 GPU: Fix GLSL compilation on OpenGL backend.
Regression in {d0f55aa671f7}
2023-01-30 12:23:02 +01:00
411345757c Cleanup: Remove unused variable.
Introduced in recent commit.
2023-01-30 12:04:44 +01:00
a36c1cabce Vulkan: Changes to CMake config.
Paths to vulkan libraries, paths and related components were
hardcoded in the platform cmake file. This patch separates
this by using adding CMake modules for Vulkan and ShaderC.

This change has only been applied to the macOs configuration as
that is currently our main platform for development. Other platforms
will be added during the development of the Vulkan back-end.
2023-01-30 12:04:44 +01:00
084dd110c9 Build: Remove unused BLENDER_GL_LIBRARIES.
This CMAKE variable isn't used.
2023-01-30 12:04:44 +01:00
Jason Fielder
6dde185dc4 Metal: Fix edge-case with point primitive restart index removal where all indices are restarts.
Metal backend does not support primtiive restart for point primtiives. Hence strip_restart_indices removes restart indices by swapping them to the end of the index buffer and reducing the length.
An edge-case existed where all indices within the index buffer were restarts and no valid swap-index would be found, resulting in a buffer underflow.

Authored by Apple: Michael Parkin-White

Ref T96261

Reviewed By: fclem

Maniphest Tasks: T96261

Differential Revision: https://developer.blender.org/D17088
2023-01-30 11:26:38 +01:00
Jason Fielder
57552f52b2 Metal: Realtime compositor enablement with addition of GPU Compute.
This patch adds support for compilation and execution of GLSL compute shaders. This, along with a few systematic changes and fixes, enable realtime compositor functionality with the Metal backend on macOS. A number of GLSL source modifications have been made to add the required level of type explicitness, allowing all compilations to succeed.

GLSL Compute shader compilation follows a similar path to Vertex/Fragment translation, with added support for shader atomics, shared memory blocks and barriers.

Texture flags have also been updated to ensure correct read/write specification for textures used within the compositor pipeline. GPU command submission changes have also been made in the high level path, when Metal is used, to address command buffer time-outs caused by certain expensive compute shaders.

Authored by Apple: Michael Parkin-White

Ref T96261
Ref T99210

Reviewed By: fclem

Maniphest Tasks: T99210, T96261

Differential Revision: https://developer.blender.org/D16990
2023-01-30 11:06:56 +01:00
d0f55aa671 Vulkan: Fix GLSL compilation errors.
Recent changes in our GLSL libraries didn't compile on Vulkan. This
change reverts a compile directive that was removed, but required
in order to compile using the Vulkan backend.
2023-01-30 10:55:14 +01:00
2ff08d6d9c Cleanup: Pass explicit type to MEM_cnew.
Better avoid fancy implicit typing in this template, and be clear about
what type is actually being allocated.
2023-01-30 10:41:42 +01:00
be8778355a Cleanup: Unused parameters and variables. 2023-01-30 09:45:42 +01:00
3649c05f57 Cleanup: Run make format on codebase. 2023-01-30 09:40:17 +01:00
Damien Picard
db87e2a638 I18n: extract and disambiguate a few messages
Extract:
- EEVEE: Compiling Shaders (the same message exists in EEVEE Next, but
  it uses string concatenation and I don't know yet how to deal with
  those--see T92758)

Disambiguate:
- Pan (audio, camera)
- Box (TextSequence)
- Mix (noun in constraints, GP materials)
- Volume (object type, file system)
- Floor (math integer part, 3D viewport horizontal plane)
  - Impossible to disambiguate the constraint name because
    bConstraintTypeInfo doesn't have a context field.
- Show Overlay (in the sequence editor, use the same message as other
  editors to avoid a confusion with the Frame Overlay feature, also
  called "Show Overlay")

Additionally, fix a few issues reported by Joan Pujolar (@jpujolar)
in T101830.

Reviewed By: mont29

Differential Revision: https://developer.blender.org/D17114
2023-01-30 09:38:57 +01:00
Damien Picard
75c772391d I18n: construct report verbosely when moving objects to collection
When moving or linking an object to a collection, the report was not
properly translatable. In French for instance, it would give
nonsensical half-translated sentences such as "<Object> moved vers
<collection>", instead of "<Object> déplacé vers <collection>".

Instead, separate the report into the four possible translations (one
or multiple objects, linking or moving). This is very verbose and less
legible, but it ensure the sentences can be properly translated,
including plurals in languages which use grammatical agreement.

In addition, use BKE_collection_ui_name_get() to get the collection
name, because the Scene Collection's name is hardcoded, but it can be
localized.

Reviewed By: mont29

Differential Revision: https://developer.blender.org/D17112
2023-01-30 09:31:38 +01:00
90e9406866 VSE: Add Update scene frame range operator
This operator updates scene strip internal length to reflect target
scene length. Previously scene strip had to be deleted and added from
scratch. Scene strip length in timeline will not be changed.
2023-01-30 07:56:53 +01:00
ad146bd17a Fix T103852: Muting timeline channel does not update image
Add RNA update function to invalidate cache for all strips in channel.
2023-01-30 06:48:01 +01:00
11de4aa0ce Update RNA to User manual mappings 2023-01-29 19:00:47 -05:00
042775ad48 Sculpt: Fix T104068, depth calculation error in trim tools
Also made the coplanar padding factor relative.
2023-01-28 16:10:02 -08:00
e497da5fda Fix: off by one error in previous commit
Fixes rB90253ad2e753acde161b38d82bd650d54d3f6581.
2023-01-29 00:13:37 +01:00
52ed8bcb27 Gitea: fix pull request template so commit body can be set as description 2023-01-28 18:11:51 +01:00
90253ad2e7 Geometry Nodes: avoid creating a lazy function many times
It's better to use some statically allocated functions instead
of dynamically allocating them all the time.
2023-01-28 15:28:55 +01:00
b2534fb866 Fix: anonymous attribute output requested even though it's not used
The code removed here was intended to be an optimization that
avoids creating an additional node to join multiple attribute sets.
However, that optimization did not work, because it did not take
into account whether the single attribute set is required or not.
2023-01-28 14:55:39 +01:00
904357d67a Fix: assert when converting between incompatible field types
This results in a compile time error now which hopefully prevents
this specific kind of mistake in the future.
2023-01-28 14:52:15 +01:00
89aae4ac82 Node Editor: Controlled node link swapping
Allow to explicitly swap node links by pressing the alt-key while
reconnecting node links. This replaces the old auto-swapping based on
matching prefixes in socket names.

The new behavior works as follows:

* By default plugging links into already occupied (single input)
  sockets will connect the dragged link and remove the existing one.
* Pressing the alt-key while dragging an existing node link from one
  socket to another socket that is already connected will swap the
  links' destinations.
* Pressing the alt-key while dragging a new node link into an already
  linked socket will try to reconnect the existing links into another
  socket of the same type and remove the links, if no matching socket
  is found on the node. This is similar to the old auto-swapping.

Swapping links from or to multi input sockets is not supported.

This commit also makes the link drag tooltip better visible, when using
light themes by using the text theme color.

Reviewed By: Hans Goudey, Simon Thommes

Differential Revision: https://developer.blender.org/D16244
2023-01-28 10:07:29 +01:00
fe5c3a0ab3 GNUmakefile: add convenience target 'check_wiki_file_structure'
This target ensures https://wiki.blender.org/wiki/Source/File_Structure
follows Blender's source tree.
2023-01-28 16:41:12 +11:00
4e9c6929c1 VSE: Handle drivers when duplicating strips
Most operations where strips are duplicated use `SEQ_animation` API,
which handles keyframe animation. Now drivers are handled as well.

When group of strips is duplicated and driver references other strip,
it will still reference original strip. However, this is much better,
than previous behavior, when strip duplication results in "transfer" of
driver from original strip to duplicated one.

Fixes T104141
2023-01-28 03:24:44 +01:00
3a9e589142 Fix (Unreported): VSE side panel flickering when tweaking offset value
Panel was split by factor calculated from property value string length.
Since these properties have float type now, calculated length was
incorrect.
2023-01-28 00:25:56 +01:00
d7e914270f Fix (unreported): Pasted strip is not active
Broken by renaming strip before comparing name to reference.
2023-01-28 00:08:07 +01:00
cef03c867b UV: cleanup winding
Simplify `BM_uv_element_map_create` by using `BM_face_calc_area_uv_signed`.

Remove unused UV winding code in `BM_uv_vert_map_create`.

Fixes unlikely memory leak in `BKE_mesh_uv_vert_map_create`.

No functional changes.

Differential Revision: https://developer.blender.org/D17137
2023-01-28 11:03:45 +13:00
8336de03a6 Cleanup: VSE: use context->for_render instead of G.is_rendering 2023-01-27 22:50:38 +01:00
9facc5067a Cleanup: Simplify mesh and point cloud conversion
Since mesh positions are stored as a generic attribute,
the attribute doesn't need special handling here.
2023-01-27 14:34:10 -06:00
Colin Basnett
328772f2d9 Mesh: Add operator to flip quad tessellation
This adds a new operator: bpy.ops.mesh.flip_quad_tessellation()

This operator rotates the internal loops of the selected quads, allowing
the user to control tessellation without destructively altering the
mesh.

{F14201995}

This operator can be found in the "Face" menu (Ctrl+F) under "Face
Data".

{F14201997}

Reviewed By: campbellbarton, dbystedt

Differential Revision: https://developer.blender.org/D17056
2023-01-27 11:02:55 -08:00
f5e76aa39e Cleanup: Array types, const, math API in workbench code
Some miscellaneous cleanups left over from a fix/cleanup combo:
- Use const variables
- Use the C++ `math` namespace functions
- Use `std::array` for arrays with size known at compile time
- Use `MutableSpan` instead of reference to array

Differential Revision: https://developer.blender.org/D17094
2023-01-27 11:35:08 -06:00
0050d6d399 Cleanup: move function to file where it is used
`drawLine` is only used for constraint, so it should be in
`transform_constraints.c`
2023-01-27 14:10:43 -03:00
8343e841fd Cleanup: Quiet unused variable warning in non-debug builds 2023-01-27 09:59:59 -06:00
179605bd2d Fix T104168: No active UV when reading auto-save files
Similar to 6d12d43a05, we should skip the
legacy to generic conversion if there's nothing to convert.
2023-01-27 09:59:59 -06:00
000e722c7d Geometry Nodes: Optimize start point case of Points of Curve node
In the node groups for T103730, the "Points of Curve" node is often used to
retrieve the root point of every curve. Since the curve point offsets array
already contains that data directly, we can detect this as a special case and
avoid all the other work.

Differential Revision: https://developer.blender.org/D17128
2023-01-27 09:59:59 -06:00
e99ae0a75d Vulkan: Tweaks to CMake configuration.
MoltenVK wasn't found as it was previous part of lib/vulkan.
as lib/vulkan now doesn't contain
the full sdk, we will use a moltenvk folder.

At this moment the moltenvk folder isn't filled, but will eventually be.
2023-01-27 16:58:14 +01:00
b67b84bd5d Fix T103984: USD exports pass usdchecker
These changes were authored by Michael B Johnson (drwave).

The default Blender USD export currently produces files that trigger
errors in the usdchecker that ships with USD 22.11.

The changes are:

- Set the defaultPrim if no defaultPrim is set. This sets it to the
first prim in the hierarchy which matches the behaviour of Pixar's
referencing (where referencing a USD layer without a defaultPrim will
pick the first prim) as well as matches the logic in Pixar's Maya USD
exporter code.

- Applies the MaterialBindingAPI to prims with material binding
attributes. This is a relatively new requirement for USD as it will
help for efficiency with upcoming changes to Hydra.

- Removes the preview scope in the USD shader hierarchy, because it
is no longer valid for shaders to have any non-container ancestors in
their hierarchy up until the enclosing Material prim.

Reviewed by: Michael Kowalski

Differential Revision: https://developer.blender.org/D17041
2023-01-27 10:29:58 -05:00
4635dd6aed Fix T104157: Deleting an active OSL node causes issues
Removing all OSL script nodes from the shader graph would cause that
graph to no longer report it using `KERNEL_FEATURE_SHADER_RAYTRACE`
via `ShaderManager::get_graph_kernel_features`, but the shader object
itself still would have the `has_surface_raytrace` field set.
This caused kernels to be reloaded without shader raytracing support, but
later the `DEVICE_KERNEL_INTEGRATOR_SHADE_SURFACE_RAYTRACE`
kernel would still be invoked since the shader continued to report it
requiring that through the `SD_HAS_RAYTRACE` flag set because of
`has_surface_raytrace`.
Fix that by ensuring `has_surface_raytrace` is reset on every shader update,
so that when all OSL script nodes are deleted it is set to false, and only
stays true when there are still OSL script nodes (or other nodes using it).

Maniphest Tasks: T104157

Differential Revision: https://developer.blender.org/D17140
2023-01-27 16:14:25 +01:00
2590de913d Cleanup: Silence compilation warning (unused parameter). 2023-01-27 15:50:52 +01:00
46c68c46a5 3D Texturing: Adding more cases where seams can be fixed.
Case added where a corner in uv space share the same edge in 3d space.
This used to work, but was lost when implementing
the new approach.
2023-01-27 15:49:10 +01:00
3d7697b325 Tweak to previous commit: move checks on DNA deprecated data at the end of readfile code.
BKE blendfile should not be allowed to deal with DNA deprectaed data, so
move recent check in rB138b3815e528 into BLO readfile, in a new
`blo_read_file_checks` util that is being called at the very end of main
readfile code (`blo_read_file_internal` and `library_link_end`).
2023-01-27 15:32:44 +01:00
138b3815e5 Fix (unreported) missing clear of deprecated Window data on fileread.
rB7f564d74f9ed (6 years ago!) forgot to clear the deprecated
`Window->screen` pointer on file read for recent-enough .blend files.

This is required since a valid value is always written in .blend files
for that pointer, to ensure backward compatibility.

The issue was never detected so far because that pointer is explicitely
reset to NULL after filewrite, which includes any memfile undostep
write, and usually existing UI data is re-used instead of loading the
one from the .blend file, so thedden  assert in `blo_lib_link_restore`
would never be triggered.

Now moved the assert at the end of `setup_app_data` to ensure it always
get checked.
2023-01-27 15:14:55 +01:00
1fd1d24265 Revert accidental changes to sub-modules
When committing via VSCode's Git UI,
my commit 073cf46b2e
seems to have affected sub-modules.
Gotta be more careful!
2023-01-27 15:05:44 +01:00
073cf46b2e Fix Generic List move ops clickable with 1 element
Meant to include this piece of feedback from Sybren in D14119.
2023-01-27 14:56:53 +01:00
75d6228583 PyAPI: Generic UIList for CollectionProperties
This patch adds a draw_ui_list() function, which is a wrapper around
layout.template_list(). It implements generic add/remove/move buttons,
passing the correct "row" integer to template_list(), as well as a
drop-down menu, if provided, making it a complete solution for
consistent UILists for addons.

Differential Revision: https://developer.blender.org/D14119
2023-01-27 14:51:13 +01:00
Iliya Katueshenock
454057f9df Fix T104175: adding Blur Attribute node with link drag search fails
The node does not support blurring booleans, but that was not handled
property in link drag search.

Differential Revision: https://developer.blender.org/D17139
2023-01-27 14:48:29 +01:00
79f70e48eb Fix: crash in mesh topology nodes
This was broken in rBd6c9cd445cb41480b40.
2023-01-27 12:40:08 +01:00
d5b026a16c Fix incorrect RNA path for GPencil brush settings, and add it for Curves brush settings.
RNA paths should be relative to their owner ID, not to some other ID!
2023-01-27 11:11:18 +01:00
0cce653892 Cleanup: Pass double2 by reference.
Just to be sure if compilers aren't inlining the function that at
least the parameter isn't copied.
2023-01-27 10:25:39 +01:00
71d7c919c0 ImBuf: Limit transform region to pixels that are affected by the transformation.
Only the area where the source buffer will be drawn on the destination buffer
will be evaluated. This will improve performance in sequencer and image editors as
less calcuations needs to happen.
2023-01-27 09:56:19 +01:00
b3fd169259 ImBuf: Precalc subsamples to reduce branching.
Micro improvement to store delta uv per subsample. This reduces
branching that might happen on the CPU, but also makes it possible
to add other sub-sampling filters as well.

No changes for the end-user.
2023-01-27 08:39:26 +01:00
2b4bafeac6 UV: add "similar object" and "similar winding" to uv "select similar"
Adds new options to UV Face selection in the UV Editor, with UV > Select > Select Similar

In multi object edit mode, "Similar Object" selects faces which have the same object.

"Similar Winding" will select faces which have the same winding, i.e. are they
facing upwards or downwards.

Resolves: T103975
Differential Revision: https://developer.blender.org/D17125
2023-01-27 17:58:07 +13:00
6c8db7c22b Fix T103868: render uv transform gizmo even if it has zero area
Change the 2D Gizmo drawing function to provide a usable transform matrix,
if it would otherwise be degenerate.

Differential Revision: https://developer.blender.org/D17113
2023-01-27 17:06:14 +13:00
34a6591a07 Fix T98594: missing uv editor redraw with geometry nodes modifier
If an object has a geometry nodes modifier, the UVs on that object might change
in response to any change on any other object.

Now we will redraw the UV editor on any object change, not just the active object.

Differential Revision: https://developer.blender.org/D17124
2023-01-27 16:53:14 +13:00
d76004f48f Sculpt: Fix sculpt expand not switching falloff types properly 2023-01-26 17:54:10 -08:00
742c2e46bb Cleanup: format 2023-01-27 14:45:37 +13:00
e735bf02cb Fix linux/mac compiler warning. 2023-01-26 20:16:07 -05:00
647cffc001 Sculpt: Add numpad aliases for number keymap entries in expand modal map 2023-01-26 16:57:28 -08:00
Aaron Carlisle
3e90390918 Sculpt: Resolve Shift R shortcut conflicts
Based on T99607:
- Existing Angle Control shortcuts are removed
- Voxel, Dyntopo and Hair resolution shortcuts are remapped to `R`

Since voxel remeshing is not compatible with dyntopo, each can use the shortcut `R` for the remeshing resolution without causing a conflict.
The shortcut `R` is not currently used for anything important.
The angle control menu is commonly not used.
And sculpt mode is only coincidentally inheriting the rotate operator shortcut on `R` because nothing else is mapped to the key.

Reviewed By: Julien Kaspar and Hans Goudey and Joseph Eagar
Differential Revision: https://developer.blender.org/D16511
Ref D16511
2023-01-26 16:55:03 -08:00
cdef135f6f USD import: Support importing USDZ.
This addressed feature request T99811.

Added the following features to fully support importing USDZ archives:

- Added .usdz to the list of supported extensions.
- Added new USD import options to copy textures from USDZ archives. The
textures may be imported as packed data (the default) or to a directory
on disk.
- Extended the USD material import logic to handle package-relative texture
assets paths by invoking the USD asset resolver to copy the textures from
the USDZ archive to a directory on disk. When importing in Packed mode,
the textures are first saved to Blender's temporary session directory
prior to packing.

The new USD import options are

- Import Textures: Behavior when importing textures from a USDZ archive
- Textures Directory: Path to the directory where imported textures will
be copied
- File Name Collision: Behavior when the name of an imported texture file
conflicts with an existing file

Import Textures menu options:

- None: Don't import textures
- Packed: Import textures as packed data (the default)
- Copy: Copy files to Textures Directory

File Name Collision menu options:

- Use Existing: If a file with the same name already exists, use that
instead of copying (the default)
- Overwrite: Overwrite existing files

Reviewed by: Bastien

Differential Revision: https://developer.blender.org/D17074
2023-01-26 18:08:45 -05:00
Sebastian Herholz
77b2ceaa1f BSDF: init all eval and samples with zeros 2023-01-26 20:14:08 +01:00
Sebastian Herholz
f55d6816ec Guiding: Added roughness-based MIS guiding type and fixed sss bug with RIS 2023-01-26 20:02:47 +01:00
Sebastian Herholz
1a27728dc8 Guiding: fixing RIS sampling 2023-01-26 20:02:47 +01:00
Sebastian Herholz
2fe4e80648 Guiding: Adding first implementation of RIS directional guiding 2023-01-26 20:02:47 +01:00
Sebastian Herholz
a71930fa42 Guiding: Adding ui switches to select the directional sampling type for guiding 2023-01-26 20:02:46 +01:00
Sebastian Herholz
05b342c0a3 Fix T103977: Cycles handling ray visibility inconsistent for forward and nee 2023-01-26 20:02:46 +01:00
Sebastian Herholz
69d3e7d95f Merge branch 'master' into cycles_path_guiding 2023-01-26 20:02:18 +01:00
Iliya Katueshenock
9a4c54e8b0 Fix: Curve to Points node has wrong field interface status
In 7536abbe16 changes make possible to input field as Count field.
But changes of declaration probably was forgotten. So now this input
can take field and node will be work. But input link was red. This
patch resolves this issue.

Differential Revision: https://developer.blender.org/D17131
2023-01-26 13:01:03 -06:00
d6c9cd445c Geometry Nodes: Skip sorting in topology nodes if possible
When the sort weights are a single value, they have no effect,
so sorting the relevant indices for the element will be wasted work.
The sorting is expensive compared to the rest of the node. In my
simple test of the points of curve node, it became 6 times faster
when the weights are a single value.
2023-01-26 12:34:28 -06:00
Germano Cavalcante
3b4486424a Fix repeated transform constraint orientations
On some occasions, as in cases where transform operations are triggered
via gizmos, the constrain orientations that can be toggled with
multiple clicks of X, Y or Z were repeated.

There is no use in maintaining repeated orientations.
2023-01-26 14:54:48 -03:00
f19f50d288 USD export test format fixes. 2023-01-26 10:35:14 -05:00
1fd54204b0 Enable commented out code.
Code was disabled for debugging purposes.
2023-01-26 15:17:37 +01:00
c412c38f0d Fix missing code-paths in previous sequence/imbuf commits. 2023-01-26 15:15:21 +01:00
3b17d6c619 Sequencer: Made subsampling a transform option.
There are cases where automatic selection of subsampling doesn't work
This patch move adds a filtering option that
can enable this.
2023-01-26 15:03:19 +01:00
f210842a72 Sequencer: Improve Image Transform Quality When Exporting.
Image Transform use linear or nearest sampling during editing and exporting.
This gets sampling is fine for images that aren't scaled. When sequencing
however you mostly want use some sort of scaling, that leads to poorer
quality.

This change will use sub-sampling to improve the quality. This is only
enabled when rendering. During editing the subsampling is disabled to
keep the user interface reacting as expected.

Another improvement is that image transform is stopped at the moment
it hadn't sampled at least 4 samples for a scan line. In that case we
expect that there are no further samples that would change to result.

In a future patch this could be replaced by a ray/bounding bo intersection
as that would remove some unneeded loops in both the single sampled and
sub sampled approach.
2023-01-26 14:25:49 +01:00
6d79bc0073 ImBuf: Use vector types in transform.cc.
Replace array types with the vector types. No functional changes.
2023-01-26 14:25:49 +01:00
f7dd7d5454 Python API: add a method for reordering modifiers.
Add an `object.modifiers.move()` method, similar to the one
for constraints and some other collections. Currently reordering
modifiers requires using operators, which depend on context.

The implementation is straightforward, except for the need to
make the severity of errors reported by the underlying editor
code into a parameter, so that the new Python API function
reports any problems as Python exceptions, and refactoring
the code to allow aborting a blocked move before making any
changes. I also turn the negative index condition from an assert
into an error.

Differential Revision: https://developer.blender.org/D16966
2023-01-26 14:56:58 +02:00
4a768a7857 Cleanup: remove unused variable 2023-01-26 13:31:41 +01:00
a42f307915 Shader Nodes: Use layers from evaluated mesh
The list was populated from the base (unevaluated) object, but now that
Geometry nodes can generate various layers this is impractical..

Differential Revision: https://developer.blender.org/D17093
2023-01-26 10:31:13 +01:00
ef39d85d7c Fix T104121: Grease pencil clear function in python not updated in viewport
The clear functions for grease pencil data/frame/layer
was not followed by immediate update in the viewport.
Some notifiers were missing in the rna definition of these functions,
which are added in by this patch.

Reviewed By: Antonio Vazquez

Differential Revision: https://developer.blender.org/D17120
2023-01-26 09:02:45 +01:00
564673b8ea Fix T71137: curve minimum twist producing wrong geometry
Only one point should be used to create a reference rotation for other
points to follow. Using two caused the resulting twist to be
asymmetric, especially noticeable on symmetrical, cyclic curves.

An update to [0] which broke curve_to_mesh & deform_modifiers tests,
now this change only applies to cyclic curves as the final result was
much greater for non-cyclic curves because of a difference between how
end-point directions are calculated (see code-comments for details).

Alternate fix to D11886 which caused T101843.

[0]: 36a82314a0.
2023-01-26 17:38:20 +11:00
c1beaea80f Fix T103587: Redo panel doesn't appear for spin operator
Regression in [0] which cleared the redo-panel if an operator added
its own undo step. This worked for sculpt to fix T101743, but caused
the redo-panel to be cleared for actions who's undo steps where created
by nested operators (which is the case for the spin operator).

Fix by checking an undo-step is added without registering an operator.

[0]: f68e50a263
2023-01-26 11:06:38 +11:00
f5d94f97e4 Fix T104132: Vertex colors no longer displaying in Workbench 2023-01-25 23:01:00 +01:00
fa57c691f6 USD IO CI Tests
Various new CI tests for USD Import / Export functionalty:

Import:
 - Added mesh import tests for topology types and multiple UV sets. (Python)

Export:
 - Added a verification tests for mesh topology. (C++)
 - Added a test to make sure UsdPreviewSurface export conversion of materials
is correct. (C++)

Reviewed by: Sybren and Hans.

Differential Revision: https://developer.blender.org/D16274
2023-01-25 14:51:39 -05:00
feae1c7d05 Gitea: update issue template with new scoped labels and other tweaks 2023-01-25 20:39:27 +01:00
6e0d58a68a Cleanup: Edit Mesh: Decrease variable scope, use bool instead of int 2023-01-25 12:56:26 -06:00
9ad051140c Revert "Fix T71137: curve minimum twist producing wrong geometry"
This reverts commit 36a82314a0.
as it has broken tests for the last day and a half, it likely just
needs a test file update, but we can't keep this failing longer
than it already has.
2023-01-25 11:00:08 -07:00
Sibo Van Gool
2f9346bc0a Fix T104071: Mix up in Realize Instances tooltip text
A mistake in the node type descriptions gave the node a description for
the reverse curve node.

Differential Revision: https://developer.blender.org/D17111
2023-01-25 11:42:10 -06:00
f954029e97 Curves Sculpt: Add report about missing surface for puff brush
This is done in the other sculpt brushes that require a surface object.
2023-01-25 11:38:12 -06:00
405b08e00d Fix: Workbench Next: Ensure matcaps textures are loaded 2023-01-25 17:12:25 +01:00
e744673268 Draw: Improve Texture assignment operator
Differential Revision: https://developer.blender.org/D17119
2023-01-25 17:12:25 +01:00
ffe45ad87a USD import unused materials.
Added a new Import All Materials USD import option.  When this
option is enabled, USD materials not used by any geometry will
be included in the import.  Imported materials with no users
will have a fake user assigned.

Maniphest Tasks: T97195

Differential Revision: https://developer.blender.org/D16172
2023-01-25 10:46:07 -05:00
Faheim Arslan M
69288daa74 Fix T100674: Use plural for axes option in object properties
This commit fixes T100674, Renamed the "axis" label under viewport display
panel to "axes" in object properties.

Differential Revision: https://developer.blender.org/D16650
2023-01-25 16:25:17 +01:00
12ca26afc2 Fix T104089: Removing greasepencil vertex group can leave no active
We should always have an active vertexgroup (making sure this is the
case was just not happening on the greasepencil side).

Now do this (similar to what is done for other object types in
`object_defgroup_remove_common`).

Maniphest Tasks: T104089

Differential Revision: https://developer.blender.org/D17091
2023-01-25 13:52:35 +01:00
ef3225b9da Cleanup: Workbench Next: Remove UNUSED_VARS 2023-01-25 13:16:53 +01:00
e27d1d9bb6 Fix broken listdir code.
Error in `bli_builddir` cahnges in B4815d0706fb5 commit.
2023-01-25 12:31:00 +01:00
b898e00edc Cleanup: remove unused KernelGlobals in microfacet BSDF 2023-01-25 11:26:51 +01:00
72c012ab4a Python: enable user site-packages without --python-use-system-env
User site-packages were disabled unless `--python-use-system-env`
argument was given. This was done to prevent Blender's Python
unintentionally using modules that happened to be installed locally,
however it meant so pip installing modules from Blender would fail to
load those modules (for some users).

Enable user site-packages since it's needed for installing additional
packages via pip, see code-comments for details.

Resolves T104000.
2023-01-25 12:52:30 +11:00
7416021bf7 Command Line Arguments: all errors now print to the stderr
This was done by some callbacks but not all.
Only use the stdout for status & information.
2023-01-25 12:20:48 +11:00
6c310acccc help now includes a GPU section & improve --gpu-backend error
- Include available GPU backends in the GPU backend error.
- Use stderr for the error message.
2023-01-25 12:20:00 +11:00
821dee6de4 CMake: de-duplicate option(..) for platform specific defaults
Use a variable for the default instead, avoid duplicate descriptions.
2023-01-25 12:18:41 +11:00
adcb0edca0 Cleanup: clang-tidy, replace defines with enum, redundant parenthesis 2023-01-25 11:53:06 +11:00
9c71f5807f Cleanup: remove unused argument, warnings 2023-01-25 11:18:33 +11:00
0c2b2cdb78 BLI_filelist: minor changes to bli_builddir behavior
- Don't call exit() when memory allocation fails, while unlikely
  internal failures should not be exiting the application.
- Don't print a message when the directory is empty as it's
  unnecessarily noisy.
- Print errors the the stderr & include the reason for opendir failing.
2023-01-25 10:48:59 +11:00
d3967ce27c Cleanup: use early return in bli_builddir, reduce right shift 2023-01-25 10:48:56 +11:00
b51034b9ca Asset system: use native slash for AssetLibraryIndex.indices_base_path
When constructing run-time paths native slashes are preferred as WIN32
doesn't have full support for forward slashes in paths.
It can also cause problems when performing exact matches on paths
which are normalized, where normalizing one of the paths makes
comparisons fail.

Using the system native slash would have avoided T103385.
2023-01-25 09:59:43 +11:00
b8cb962fb2 Cleanup: perform string join & allocation in a single step 2023-01-25 09:59:33 +11:00
d446809f96 Cleanup: remove unused argument 2023-01-25 09:53:35 +11:00
c5d9938adc Fix T104073: Unable to add more than two strips in one channel
Originally, function `sequencer_generic_invoke_xy_guess_channel`
looked in what channel the last strip of the same type is and the
channel used for new strip placement. This was changed as a workaround
when sound strips were added below movie strips
(58bea005c5).
Now these workarounds aren't necessary, but the function was left
unchanged.

Current logic is for adding movie strip to channel 1 is:
- Sound is added to channel 1
- Video is added to channel 2
- If there is only video, it is added to channel 1

Since movie may, or may not contain sound, it is not possible to align
added strips in a way that was done before, unless timeline is analyzed
more in detail, but this would be quite inefficient.
Also, note, that the code did not work, if strip is added next to
previous one, so it mostly did not work as intended.

This commit changes:
- Fix alignment not working when strip is added right next to previous
  strip
- Assume that movie strips have sound strip underneath it, so channel
  below last movie strip is picked
- For other strip types, pick channel of the last strip of same type

Ultimately, the code is still rather weak, and better system, like using
channel where strip was manually moved, or concept of "typed channels"
would improve this feature.
2023-01-24 23:28:16 +01:00
1ad11355a3 Transform: fix use of "snap_point" property
There is not much documentation on the "snap_point" property, but by
code it is possible to note that it serves to set a target snap point
and is of internal use as it is hidden from the Redo panel.

However, this property was still very dependent on Tools settings and
if set to an operator's call, it changes the scene configurations
inadequately.

Therefore,
- remove this dependency from UI for rotation and resize operators,
- do not change the state of the snap in the scene and
- cleanup the code.
2023-01-24 17:10:21 -03:00
0f52aa0954 Transform: Initialize 'transform_matrix' accordingly
Some transform modes are changeable, so callbacks should be reset
together.

Currently the unchanged `transform_matrix` callback is not a major
issue as it is only used for gizmos and gizmos stop updating when
changing the operator type.
2023-01-24 17:10:21 -03:00
5cc9f07d5c Draw: Workbench Next: Fix shaders memory leaks
Ensure all shaders are deleted
2023-01-24 20:52:35 +01:00
361ebe98d5 Draw: Workbench Next: Fix shadow culling after recent cleanup commit
79ba1a1ac8 changed virtual function signatures so they didn't match their parents.
2023-01-24 20:52:35 +01:00
789ab9b92a Sculpt: Fix T104090: Automask topology not constrained by brush radius 2023-01-24 11:04:39 -08:00
a73a2d345f Fix T104044: keep order of UVMaps on load
Use a Vector<std::string> , instead of a Set<std::string> as a Set does
not keep the same order when iterating over it.

Differential Revision: https://developer.blender.org/D17103
2023-01-24 18:26:02 +01:00
e56f284843 readfile: Fix 'virtual' issue in memfile case.
In many cases when reading undo memfile, n the 'restore id from old
main' part of the process, the 'id_old' is not set, which means that
the call to `BKE_main_idmap_insert_id` would try to dereference a `nullptr`.

In practice this is likely not an issue (see comment in code for details),
but at least explicitely check for a nullptr `id_old` pointer.

Would deffer actual cleanup of this area for after 3.5 is branched out.
2023-01-24 18:15:06 +01:00
30b34735e3 Cleanup/refactor: Add a new flag for IDTypes that are not read in memfile undo.
Currently only affects 'UI' IDs (WindowManager, Screen, etc.), but in
the future other types may be affected as well.

NOTE: this is only used in readfile code itself, not in the
post-processing performed by `setup_app_data`, as this code is too
specific for such generic handling.
2023-01-24 18:15:06 +01:00
e308b891c8 Cycles: Use faster and exact GGX VNDF sampling algorithm
Based on "Sampling the GGX Distribution of Visible Normals" by Eric Heitz
(https://jcgt.org/published/0007/04/01/).

Also, this removes the lambdaI computation from the Beckmann sampling code and
just recomputes it below. We already need to recompute for two other cases
(GGX and clearcoat), so this makes the code more consistent.

In terms of performance, I don't expect a notable impact since the earlier
computation also was non-trivial, and while it probably was slightly more
accurate, I'd argue that being consistent between evaluation and sampling is
more important than absolute numerical accuracy anyways.

Differential Revision: https://developer.blender.org/D17100
2023-01-24 17:59:29 +01:00
fdcb55b285 Cycles: Switch microfacet code to non-separable shadowing-masking term
This gives closer results to what I've seen in papers and other renderers when
using the code to precompute albedo later (to replace MultiGGX).

It's usually a tiny difference, the only case where I've seen it matter is
in the `shader/node_group_float.blend` test - but that's a (single-scatter) GGX
closure with 0.9 roughness, so it's not too surprising. In any case, the new
result looks closer to Eevee, so that's good I guess.

Differential Revision: https://developer.blender.org/D17099
2023-01-24 17:59:29 +01:00
ce25e3e581 Cycles: Cleanup: Add general-purpose conversion between sin and cos 2023-01-24 17:59:29 +01:00
b1c8889396 Cleanup: format 2023-01-24 17:59:29 +01:00
ae80a6696f Geometry Nodes: don't show warning in modifier with multiple geometry inputs
Simon mentioned that this gets in the way more than it helps. No geometry
sockets currently show up in the modifier panel. People may build node groups
that have multiple geometry inputs that can be used when the group is used
as node instead of as modifier.

In the future we could also allow e.g. choosing an object to pass into a geometry
socket. That has the problem that we'd also have to duplicate other functionality
of the Object Info node (original vs. relative space).
2023-01-24 17:45:47 +01:00
6899474615 Fix: crash when adding curves in curves sculpt mode with interpolation
There were two issues:
* The `new_point_counts_per_curve` was one too large, resulting in
  `interpolate_from_neighbors` reading invalid memory.
* Writing the counts into the existing offsets array didn't quite work
  because there can be a collision at the offset right between the
  last old curve and the first new point. There was a race condition
  where this value could be read and written at the same time.
2023-01-24 17:36:53 +01:00
62743dde11 Gpencil: More UI tweaks in Offset modifier
Remove more duplicate words
2023-01-24 16:53:28 +01:00
0931d91ab6 GPenciil: Small UI tweak
Remove duplicate `Layer` word
2023-01-24 16:47:22 +01:00
3956c4738f GPencil: Change range for Length value in Simplify modifier
In some cases a smaller value is required. Anyways, the UI value
soft limit is 0.005
2023-01-24 16:44:37 +01:00
813425877b Geometry Nodes: propagate material from guides in Interpolate Curves node
This was missing from the original implementation.
2023-01-24 16:24:00 +01:00
6e4e5f6484 UI: Allow spawning file browser dialog from regular file browser editor
When some path property was displayed in the File Browser, clicking the
icon to open a file browser dialog to choose a file/directory would
show an error. While this makes sense when you are already in a file
browser dialog (we don't support such nested file browser dialogs),
allow it when the file browser is opened as a normal editor, not as a
dialog.
2023-01-24 15:33:44 +01:00
10a06dfd11 Code-style: Rename internal parts of pbvh_uv_islands.
- InnerEdge -> FanSegment
- full -> is_manifold
2023-01-24 15:12:21 +01:00
21eff2c0ac 3DTexturing: Improve fix seam bleeding for manifold parts of mesh.
Current implementation had some faulty assumtions and had some work
arounds for crashes that were actually limitation of the implementation.

The main reason for this was that the implementation didn't add new
primitives in the same direction it was already adding. Some when
incorrect behavior was detected it was assumed that the part wasn't
manifold (anymore) and didn't fix that part of the mesh.

The new implementation will extract a solution and use this solution
also as the order to generate primitives in uv space.

This patch fixes several crashes and improves the overall quality
when fixing seam bleeding. It also adds additional debug tools
(print_debug) implementation in order to find issues faster in the
future.
2023-01-24 15:03:21 +01:00
4815d0706f Fix T103385: Asset Browser Thumbnails take long time to load
Regression in [0] caused by a change where path joining would
replace a forward slash with a back-slash when joining paths WIN32.
Now the directory is always used as a prefix for the paths returned
by BLI_filelist_dir_contents which resolves the regression.

[0]: 9f6a045e23
2023-01-25 00:21:13 +11:00
246485b213 BLI_path: make BLI_path_slash_is_native_compat into a public function 2023-01-25 00:21:11 +11:00
33edef15ed Fix T104095: missing crazy space data while sculpting curves
`remember_deformed_curve_positions_if_necessary` has to be called before
topology changing operations on curves. Otherwise the crazy-space data
is invalid.
2023-01-24 14:07:01 +01:00
cf332e896f GPencil: Fix unreported double rotation in Fill circles
The help circles to fill areas were rotated with the object rotation,
but as the stroke is part of the object, apply the rot matrix again
produced a double rotation, so it can be removed.
2023-01-24 13:19:22 +01:00
c16bd34316 Fix: memory allocation before guarded allocator is initialized
Use the construct-on-first-use idiom to fix this.
2023-01-24 13:07:54 +01:00
a36e2a9b64 Gpencil: Expose stroke and point time properties to API
Two properties are now exposed in python API :
time of each point, and inittime of each stroke.

Reviewed by: Antonio Vazquez

Differential Revision: https://developer.blender.org/D17104
2023-01-24 12:39:48 +01:00
74aa960398 Cleanup: add newline in Collada error message 2023-01-24 10:53:52 +01:00
1c90f8209d Cycles: fix rendering with Nishita Sky Texture on Intel Arc GPUs
Speckles and missing lights were experienced in scenes with Nishita Sky
Texture and a Sun Size smaller than 1.5°, such as in Lone Monk and Attic
scenes.
Increasing the precision of cosf fixes it.
2023-01-24 09:58:22 +01:00
6279042d21 Cleanup: use const, doc-string for BevList.poly & rename args
It wasn't clear that BevList.poly was used to check cyclic BevList's.
2023-01-24 16:42:38 +11:00
36a82314a0 Fix T71137: curve minimum twist producing wrong geometry
Only one point should be used to create a reference rotation for other
points to follow. Using two caused the resulting twist to be
asymmetric, especially noticeable on symmetrical, cyclic curves.

Alternate fix to D11886 which caused T101843.
2023-01-24 16:40:58 +11:00
67c48314ba Revert "Fix T71137: curve minimum twist producing wrong geometry"
This reverts commit cf72194214.
2023-01-24 15:33:47 +11:00
0ad4d07f10 Fix: Debug build compile error after recent cleanup commit
79ba1a1ac8 missed that this variable was used in an assert.
2023-01-23 15:57:33 -06:00
f72969f377 Fix T103888: Regression: Side-by-side stereo renders ignore color management
Looks like rB42937493d8253a295a97092315288f961e8c6dba accidentally dropped the
colorspace copy.
2023-01-23 22:12:16 +01:00
42f8f98ee1 Fix T104088: Geometry nodes modifier boolean lost on undo
After object-mode undo (memfile undo), the value wan't lost, but the
property would be temporarily converted back to integer type in order
to be forward compatible. Now only use the forward compatible
writing when writing undo steps. Auto-saves and similar files are
currently not forward compatible anyway.
2023-01-23 15:06:55 -06:00
79ba1a1ac8 Cleanup: Compiler warnings in new sculpt & workbench
Set but unused variables, unused arguments, unnecessary/incorrect type
casting, missing static qualifier. Unused arguments are removed.
2023-01-23 14:57:26 -06:00
f24b9a7943 Cleanup: Rename pbvh.cc to pbvh_colors.cc
In preparation for moving pbvh.c to C++, give this file a different name
so git will recognize that future commit as a rename.
2023-01-23 14:47:08 -06:00
7fc395354c Cleanup: Use offset indices arguments for curves utilities
Make the functions more flexible and more generic by changing the curves
arguments to the curve offsets. This way, theoretically they could become
normal utility functions in the future. Also do a consistency pass over
the algorithms that generate new curves geometry for naming and
code ordering, and use of utility functions. The functions are really
quite similar, and it's much easier to tell this way.
2023-01-23 14:43:04 -06:00
15575b953d Merge By Distance: Optimize algorithm to find duplicate polygons
The most time-consuming operation in merge by distance is to find
duplicate faces (faces that are different but have the same vertices).

Therefore, some strategies were planned to optimize this algorithm:
- Store the corner indices in an array thus avoiding multiple calls of `weld_iter_loop_of_poly_next`;
- Create a map of polygons linked to edges instead of linked to vertices - this decreases the number of connections and reduces the calculation of the intersection of polygon indices.

There are other fields to optimize, like reusing the `wpolys` array
instead of creating a new array of corner offsets. And join some arrays
as members of the same struct to be used in the same buffer.
But for now, it is already a nice optimization. And the new
`poly_find_doubles` function can be reused in the future to create a
generic utility.

The result of the optimization varies greatly depending on the number
of polygons, the size of each polygon and the number of duplicates.
On average it was something around 2 times faster.

Worst case tested (old vs new): 0.1ms vs 0.3ms
Best case tested (old vs new): 10.0ms vs 3.2ms

Differential Revision: https://developer.blender.org/D17071
2023-01-23 17:21:52 -03:00
b6b6e47e1d Sculpt: PBVH node splitting for texture paint
`PBVH_Leaf` nodes are now split into a new `PBVH_TexLeaf`
node type when using the paint brush.  These nodes are
split by image pixels, not triangles.  This greatly
increases performance when working with large
textures on low-poly meshes.

Reviewed By: Jeroen Bakker
Differential Revision: https://developer.blender.org/D14900
Ref: D14900
2023-01-23 10:44:50 -08:00
8afcecdf1f Cycles: update Intel Graphics compiler to 101.4032 on Windows
A noticeable (>5%) performance regression in oneAPI backend came with
a501a2dbff. Updating to latest graphics
compiler from driver 101.4032 fixes it.

I've tested it with current min-supported drivers and it runs well but
since compatibility of graphics compiler with older drivers isn't
guaranteed, I'm also bumping the min-supported driver versions.

If end-users consider latest drivers too fresh to switch to (version
isn't released as stable on Linux as of today but should be before
Blender 3.5 release), CYCLES_ONEAPI_ALL_DEVICES=1 env variable can be
used.

Intel Graphics Compiler on Linux will be updated in a later commit
so we can then close D16984.

Reviewed By: sergey, LazyDodo
2023-01-23 19:36:34 +01:00
fe8bf5e0c7 Fix T104039: GPencil Fill crash in multiframe
The problem was that the stroke array was not reset for 
each iteration of the loop, so the second time around, 
the array was not initialized correctly and 
was left with a NaN value.
2023-01-23 18:44:53 +01:00
e49e5f6f08 Enable USD Preview Surface import by default
The USD Preview Surface material import feature is now considered
stable, so this patch removes this option from the Experimental
category in the UI.

The Import USD Preview option is now enabled by default.

The Experimental box has been removed.

A new Materials box has been added to group the Import
USD Preview Surface, Set Material Blend and Material
Collision Mode options.

Reviewed by: Sybren

Differential Revision: https://developer.blender.org/D17053
2023-01-23 12:02:38 -05:00
ba982119cd Workbench Next
Rewrite of the Workbench engine using C++ and the new Draw Manager API.

The new engine can be enabled in Blender `Preferences > Experimental > Workbench Next`.
After that, the engine can be selected in `Properties > Scene > Render Engine`.
When `Workbench Next` is the active engine, it also handles the `Solid` viewport mode rendering.

The rewrite aims to be functionally equivalent to the current Workbench engine, but it also includes some small fixes/tweaks:
- `In Front` rendered objects now work correctly with DoF and Shadows.
- The `Sampling > Viewport` setting is actually used when the viewport is in `Render Mode`.
- In `Texture` mode, textured materials also use the material properties. (Previously, only non textured materials would)

To do:
- Sculpt PBVH.
- Volume rendering.
- Hair rendering.
- Use the "no_geom" shader versions for shadow rendering.
- Decide the final API for custom visibility culling (Needed for shadows).
- Profile/optimize.

Known Issues:
- Matcaps are not loaded until they’re shown elsewhere. (e.g. when opening the `Viewort Shading` UI)
- Outlines are drawn between different materials of the same object. (Each material submesh has its own object handle)

Reviewed By: fclem

Maniphest Tasks: T101619

Differential Revision: https://developer.blender.org/D16826
2023-01-23 17:59:07 +01:00
Jason Fielder
84c25fdcaa Metal: Improve command buffer handling and workload scheduling.
Improve handling for cases where maximum in-flight command buffer count is exceeded. This can occur during light-baking operations. Ensures the application handles this gracefully and also improves workload pipelining by situationally stalling until GPU work has completed, if too much work is queued up.

This may have a tangible benefit for T103742 by ensuring Blender does not queue up too much GPU work.

Authored by Apple: Michael Parkin-White

Ref T96261
Ref T103742
Depends on D17018

Reviewed By: fclem

Maniphest Tasks: T103742, T96261

Differential Revision: https://developer.blender.org/D17019
2023-01-23 17:47:21 +01:00
Jason Fielder
139fb38d4f DRW: Add texture usage host read to Lightcache texture.
Required by Metal backend to have correct usage flags for textures which are read by host.

Authored by Apple: Michael Parkin-White

Ref T96261

Reviewed By: fclem

Maniphest Tasks: T96261

Differential Revision: https://developer.blender.org/D17020
2023-01-23 17:46:46 +01:00
Jason Fielder
1c672f3d1d Fix T103433: Ensure Metal memory allocator is safe for multi-threaded allocation. Resolves crash when baking indirect lighting.
Also applies correct texture usage flag to light bake texture.

Authored by Apple: Michael Parkin-White

Ref T96261

Reviewed By: fclem, jbakker

Maniphest Tasks: T96261, T103433

Differential Revision: https://developer.blender.org/D17018
2023-01-23 17:45:39 +01:00
Jason Fielder
0ba5954bb2 Fix T103635: Fix failing EEVEE and OCIO shader compilations in Metal.
Affecting render output preview when tone mapping is used, and EEVEE scenes such as Mr Elephant rendering in pink due to missing shaders.

Authored by Apple: Michael Parkin-White

Ref T103635
Ref T96261

Reviewed By: fclem

Maniphest Tasks: T103635, T96261

Differential Revision: https://developer.blender.org/D16923
2023-01-23 17:40:10 +01:00
8e56ded86d Cycles: temporarily disable AMD Vega GPU rendering due to compiler bug
To make daily builds pass while we figure this out.

Ref T104097
2023-01-23 17:30:12 +01:00
Jason Fielder
cd2926fb05 Fix T103412: Resolve selection outline rendering with Metal backend on AMD.
AMD GPUs do not appear to produce consistent results with other GPUs when using textureGather in the Metal backend. Disabling for now to ensure correct function of outline rendering.

This may require an additional sub-pixel offset in the texture sampling calls, to achieve correct behaviour.

Authored by Apple: Michael Parkin-White

Ref T103412
Ref T96261

Reviewed By: fclem

Maniphest Tasks: T103412, T96261

Differential Revision: https://developer.blender.org/D16934
2023-01-23 17:24:30 +01:00
Tomoaki Nakano
48b82a6ea3 Fix Metal GPU backend shader compile errors in certain language environments
This patch fixes an issue where Blender 3.5 alpha with the Metal GPU backend enabled on Japanese macOS fails to compile shaders and crashes on startup.

In a Japanese environment, `defaultCStringEncoding` is the legacy MacJapanese encoding, and it erroneously converts backslashes (0x5c) to Yen symbols (¥).
Therefore, Metal shader compile fails with the following log and Blender crashes.
```
2022-12-29 13:50:10.200 Blender[13404:246707] Compile Error - Metal Shader Library (Stage: 0), error Error Domain=MTLLibraryErrorDomain Code=3 "program_source:225:74: error: non-ASCII characters are not allowed outside of literals and identifiers
    template<typename T, access A = access::sample> struct STRUCT_NAME { ¥
                                                                         ^
program_source:226:14: error: no template named 'TEX_TYPE'
      thread TEX_TYPE<T, A> *texture; ¥
             ^
program_source:226:39: error: non-ASCII characters are not allowed outside of literals and identifiers
      thread TEX_TYPE<T, A> *texture; ¥
                                      ^
program_source:227:29: error: non-ASCII characters are not allowed outside of literals and identifiers
      thread sampler *samp; ¥
                            ^
...
```
We can use `stringWithUTF8String` instead.

Reviewed By: fclem, MichaelPW

Differential Revision: https://developer.blender.org/D16881
2023-01-23 16:56:06 +01:00
b44a8f6749 Fix: Draw: Negative scaled objects cause wrong resource indexing
In the new Draw Manager, when the same DrawGroup has both front and back facing instances, the front facing instances don't offset their indices accordingly.

Differential Revision: https://developer.blender.org/D17069
2023-01-23 16:42:37 +01:00
6043ed9e62 Build: checkout assets directory automatically
This changes `make update` to download the assets repository automatically
if it does not exist already. If it does exist, it is updated. Precompiled libraries
have the same behavior. This is required for T103620.

`pipeline_config.yaml` is updated as well for the builtbot.

Differential Revision: https://developer.blender.org/D17090
2023-01-23 13:52:21 +01:00
59ee5add12 Usual UI messages fixes & tweaks. 2023-01-23 12:31:43 +01:00
607b814096 DRW: Debug Print: Fix print of vec3 2023-01-23 11:05:04 +01:00
e0c8fa4ab9 DRW: Fix Texture.ensure() function always recreating the texture
This was caused by recent change of the `size()` method which now return
1 for missing dimensions.
2023-01-23 11:05:04 +01:00
f5c081dafc Fix T104033: UV edges not selecting when selecting faces
Regression in [0] replaced edge with vertex selection.

[0]: 6c774feba2
2023-01-23 20:23:55 +11:00
64dbfe714b Fix T99963: Fallback actions are used in RCS on left click
The right mouse-select action no longer changes the dragging behavior
of the left mouse button.
2023-01-23 17:31:56 +11:00
eca4b991d8 Cleanup: use function style casts 2023-01-23 17:31:46 +11:00
ab0be6ec24 Cleanup: quiet clang warnings 2023-01-23 17:31:44 +11:00
c68d4bf839 Cleanup: fix msvc compilation issue 2023-01-23 02:16:35 +01:00
93a840360a Cleanup: quiet clang warnings 2023-01-23 00:55:15 +01:00
4bef5f3df7 Cleanup: move some undo related files to C++
For continued testing in D14139. Also see T103343.
2023-01-23 00:33:55 +01:00
e2006f15a9 Fix T103618: GN Transform modifies source VDB grid
The call to BKE_volume_grid_openvdb_for_write() was accidentally removed
in D15806. This adds it to BKE_volume_grid_transform_matrix_set() to
avoid that it happens again when that function is used.

Differential Revision: D16949
2023-01-22 23:32:19 +01:00
3a2899cc31 Fix T103942 ASAN crash in math_boolean function.
The code in questions comes from Shewchuk's triangle code, which
hasn't been updated to fix the out-of-buffer access problem
that ASAN finds in the delaunay unit test. The problem is benign:
the code would exit the loop before using the value fetched from
beyond the end of the buffer, but to make ASAN happy, I put in
a couple extra tests to not fetch values that aren't going to be used.
2023-01-22 12:48:45 -05:00
b544199c56 Fix T102532: bevel spikes with loop slide.
There's a compromise of a code parameter called BEVEL_GOOD_ANGLE,
and bugs T44961, T86768, T95335, and this one, are all about problems
with various values of that parameter. If an angle of an adjacent
non-beveled edge is too close to that of the beveled edge, then you
get spikes. The BEVEL_GOOD_ANGLE says that if you are within that
angle difference, then no bevel happens. If the value is too small
then one gets spikes for certain models people build; if the value
is too large, then other people are annoyed that no bevel happens.
Hopefully this compromise in this commit is the final one I will do
before switching to Bevel v2, where none of this should be an issue.
2023-01-22 10:34:28 -05:00
537db96fb7 GHOST/NDOF: don't send button events when there is no active window
NDOF events without an active window were ignored and printed
warnings in the console.
2023-01-22 21:06:10 +11:00
00ac2ddca2 Fix T103722: Stuck modifiers for wheel events over unfocused windows
Regression in [0] caused mouse wheel events over windows without focus
to use the modifier state at the point the window was de-activated.

Now un-focused windows have all events release, when focused again
modifier press events are set again.

[0]: 8bc76bf4b9
2023-01-22 20:50:09 +11:00
4fcbfcfc96 Cleanup: GCC compiler warning 2023-01-22 20:49:00 +11:00
c2a28f9f6c Cleanup: quiet compiler warnings 2023-01-22 02:03:44 +01:00
96dfa68e5f Cleanup: extract function that slices parameters for multi-function call 2023-01-22 00:13:47 +01:00
3f1886d0b7 Functions: align chunk sizes in multi-function evaluation
This can improve performance in some circumstances when there are
vectorized and/or unrolled loops. I especially noticed that this helps
a lot while working on D16970 (got a 10-20% speedup there by avoiding
running into the non-vectorized fallback loop too often).
2023-01-22 00:03:25 +01:00
8d98d5c402 Cleanup: fix compiling in debug mode 2023-01-21 23:56:11 +01:00
f2bb044fdb Cleanup: Move six mesh-related files to C++
For continued refactoring of the Mesh data structure. See T103343.
2023-01-21 15:44:58 -06:00
3d6fd2906b Cleanup: Move versioning_290.c to C++
Ref T103343
2023-01-21 15:30:38 -06:00
50387964b6 Curves: Add initial transform support
This adds basic support for the transform operators for curves.

Differential Revision: https://developer.blender.org/D17063
2023-01-21 20:38:36 +01:00
0b17d171d7 Cleanup: Move three modifier related files to C++
For continued refactoring of the Mesh data structure. See T103343.
2023-01-21 12:15:41 -06:00
cbd15d387f GHOST/Wayland: don't send activate/deactivate on pointer enter/leave
This isn't correct as window activation is handled separately
from the cursor entering/leaving a window.

This would call de-activate when the cursor moved outside the window
even though the window remained focused.

Rely on focus changes which already handle activate/deactivate events.
2023-01-21 23:09:22 +11:00
65f68ee023 Cleanup: compiler warnings 2023-01-21 23:09:20 +11:00
6aa29549e8 Fix T103887: Line Art Vertex Weight Transfer to target group broken
Caused by {rB841df831e89d} and {rB3558bb8eae75}.

These commits moved flags from `eLineArtGPencilModifierFlags` to
`eLineartMainFlags`, but later on in code, these were still evaluated
from the modifiers `flags` (instead of `calculation_flags`).
This resulted in a false condition (`match_output` was assumed true but
it wasnt), leading to a wrong codepath taken.

This is now corrected (`calculation_flags` need to be passed around for
this as well).

Maniphest Tasks: T103887

Differential Revision: https://developer.blender.org/D17062
2023-01-21 08:27:44 +01:00
b5bb38400f Python API: Set defaults for Denoise Node
Fixes T103898
2023-01-20 21:42:24 -05:00
25864d3dfc Cleanup: Use ampersand instead of "and" for labels
UI guideline is use '&' for labels, use "and" for descriptions.
2023-01-20 20:27:25 -05:00
Leon Schittek
68625431d5 Geometry Nodes: Adjust modifier UI to put field toggles on the right
This also fixes the layout of boolean properties with the field toggle
visible. This was discussed in the most recent geometry nodes submodule
meeting.
2023-01-20 17:41:34 -06:00
2ea47e0def Geometry Nodes: Use checkbox for exposed boolean sockets
This uses the changes from ef68a37e5d to create IDProperties
for exposed boolean sockets with a boolean type instead of an integer
with a [0,1] range. Existing properties and values are converted
automatically.

For forward compatibility, the properties are switched to the integer
type for saving. Otherwise older versions crash immediately when opening
a newer file. The "Use Attribute" IDProperties aren't changed here,
since that wouldn't have a visible benefit.

Differential Revision: https://developer.blender.org/D12816
2023-01-20 17:36:47 -06:00
6a22230db4 Fix : accidentally committed typo, roo many closing brackets.
Ooops
2023-01-21 00:22:25 +01:00
a82c12ae32 Add collection properties to MeshUVLoopLayer to access UV and the associated bool attributes (Python API).
This adds 4 collection properties to MeshUVLoopLayer to eventually replace the (MeshUVLoop) .data property.
The added properties are:

.uv
.vertex_selection
.edge_selection
.pin

The direct access to the separate arrays is much more efficient than the access via MeshUVLoop.

Differential Revision: https://developer.blender.org/D16998
2023-01-21 00:03:42 +01:00
453724894e Fix T103704: Particle hair doesn't fall back to active UV
Caused by 05952aa94d, which removed the use of the
active tessface UV pointer on meshes but didn't replace it properly with
the equivalend custom data API function.
2023-01-20 15:34:24 -06:00
244c87dd68 Geometry Nodes: avoid geometry copy if nothing is selected in Set Position node
This improves performance in cases where the Set Position node is "turned off"
by passing `false` into the selection input.

It's possible that the node still takes some time in this case currently, because
it is destructing the input fields which may reference geometries that need
to be destructed as well. We could potentially change this node (and others)
so that the field inputs are only requested when the selection is not a
constant `false`.
2023-01-20 21:27:57 +01:00
37dfce550f Fix Cycles CUDA compiler warning with if constexpr
This is a C++17 feature, compiler should be able to figure this out
without the hint.
2023-01-20 20:31:40 +01:00
60ea01aa30 Cleanup: Move four sculpt/paint files to C++
For continued refactoring of the Mesh data structure. See T103343.
2023-01-20 11:55:43 -06:00
f31f7e3ef0 Cleanup: Remove unused light_sample_is_light() function.
This also fixes compile warnings on MSVC.
2023-01-20 17:36:48 +01:00
70ca15670d Curves: Edit mode selection operators
This adds the following operators to edit mode:
 - `select_all`
 - `select_random`
 - `select_end`

Differential Revision: https://developer.blender.org/D17047
2023-01-20 16:40:51 +01:00
d650162ecd Curves: Add initial undo system
This adds an `UndoType` for the `Curves` object, for edit mode.
For now, this will only store the `CurvesGeometry` at every step.
Other properties such as the `selection_domain` or the `surface` object
will have to be dealt with in subsequent commits.

Differential Revision: https://developer.blender.org/D16979
2023-01-20 16:32:36 +01:00
c07fdad03d Cleanup: Move multires files to C++
For continued refactoring of the Mesh data structure. See T103343.
2023-01-20 09:20:56 -06:00
c8a10c43b1 Geometry Nodes: show number of curve points in socket inspection tooltip
This was not done originally, because one had to iterate over all curves
to get the number of points which had some overhead. Now the number
of points is stored all the time anyway.
2023-01-20 14:44:37 +01:00
c006ba83e0 Fix: execution graph for geometry nodes contained cycles leading to crash
The `fix_link_cycles` function added in rB2ffd08e95249df2a068dd did not
handle the case correctly when there are multiple cycles going through
the same socket.
2023-01-20 14:38:09 +01:00
d79abb5d4f Fix: missing clamping in single mode in Sample Index node 2023-01-20 14:33:06 +01:00
b6278c5a96 Fix: crash when subdividing curves
This was an error in rB38a45e46bc910c68ae3.
2023-01-20 14:15:22 +01:00
31a505d1a5 Functions: add debug utility for lazy function graphs
This makes it easier to print information about a socket. Just the
socket name is sometimes not enough information to know where
it is in the graph.
2023-01-20 13:39:29 +01:00
Sebastian Herholz
1cbdadb722 Merge branch 'master' into cycles-path-guiding-main 2023-01-20 13:28:57 +01:00
453e47eb42 Cleanup: suppress clang-tidy warning 2023-01-20 22:32:31 +11:00
5218391701 Fix assertion in UV path select
Existing path selection & new path picking included without UV's.
Now limit objects to those with UV's.

Also remove use of CTX_wm_view3d(C) in the UV editor it would be NULL,
but it doesn't makes sense to use the 3D viewport for UV operations
even if it was available.
2023-01-20 22:31:27 +11:00
127eb2e328 Fix: wrong identifier int for interpolate curves node
This does not break existing files, because the idname is the ground truth.
2023-01-20 12:16:49 +01:00
85908e9edf Geometry Nodes: new Interpolate Curves node
This adds a new `Interpolate Curves` node. It allows generating new curves
between a set of existing guide curves. This is essential for procedural hair.

Usage:
- One has to provide a set of guide curves and a set of root positions for
  the generated curves. New curves are created starting from these root
  positions. The N closest guide curves are used for the interpolation.
- An additional up vector can be provided for every guide curve and
  root position. This is typically a surface normal or nothing. This allows
  generating child curves that are properly oriented based on the
  surface orientation.
- Sometimes a point should only be interpolated using a subset of the
  guides. This can be achieved using the `Guide Group ID` and
  `Point Group ID` inputs. The curve generated at a specific point will
  only take the guides with the same id into account. This allows e.g.
  for hair parting.
- The `Max Neighbors` input limits how many guide curves are taken
  into account for every interpolated curve.

Differential Revision: https://developer.blender.org/D16642
2023-01-20 12:09:38 +01:00
d072764809 Add RNA path functions to AssetMetaData and AssetTag structures. 2023-01-20 11:56:42 +01:00
244522d6cb 3D Texturing: Remove actual invocation of print_debug.
Was a mistake as only the function should have landed in master.
2023-01-20 11:15:37 +01:00
884e14ac93 3D Texturing: Adding print_debug for visually inspecting the generated geometry.
During 3D texturing the uv islands are extended in order to fix seam bleeding
for manifold parts of the input mesh. This patch adds a `print_debug` method
on UVIsland that generates a python script. This script can be copy-past
into the Python Console to show the generated geometry.

This script can be extended to show the extracted border and use face colors
for showing internal decisions.
2023-01-20 10:28:58 +01:00
721bd5e6cf Fix invalid swapBuffer calls & outdated window decorations on Wayland
Swap-buffers was being deferred (to prevent it being called
from the event handling thread) however when it was called the
OpenGL context might not be active (especially with multiple windows).

Moving the cursor between windows made eglSwapBuffers report:
EGL Error (0x300D): EGL_BAD_SURFACE.

Resolve this by removing swapBuffer calls and instead add a
GHOST_kEventWindowUpdateDecor event intended for redrawing
client-side-decoration.

Besides the warning, this results an error with LIBDECOR window frames
not redrawing when a window became inactive.
2023-01-20 18:05:52 +11:00
bbc35fef25 Cleanup: Remove remaining subdiv/subsurf files to C++
For continued refactoring of the Mesh data structure. See T103343.
2023-01-19 22:25:04 -06:00
1e8cc72f85 Cleanup: corrections, clarification to do comments 2023-01-20 15:20:02 +11:00
844cca9984 Cleanup: spelling in comments 2023-01-20 15:19:32 +11:00
06c836c911 WM: rename safe areas preset add operator
The name SAFE_AREAS_OT_preset_add lead to "Safe Areas" having it's own
section in the operator API docs. Name CAMERA_OT_safe_areas_preset_add
instead. Keep "safe_areas" as the preset directory for users with
existing presets.
2023-01-20 14:47:15 +11:00
6672b5373f Fix T103971: uv packing wasn't ignoring uv islands on hidden faces
Fixes the packing operators that use ED_uvedit_pack_islands_multi

Also fixes UV Select Similar with hidden UV islands.

Packing operators using GEO_uv_parametrizer should remain unchanged.

Add a check to BM_elem_flag_test(efa, BM_ELEM_HIDDEN).
Note that BM_mesh_calc_face_groups doesn't easily support XOR of flags,
requiring logic to be moved to a preprocess step on BM_ELEM_TAG.

Regression in rBe3075f3cf7ce.

Differential Revision: https://developer.blender.org/D17055
2023-01-20 16:29:33 +13:00
92734d868b PyDoc: resolve bpy.types & bpy.ops expanding sub-modules inline
The bpy.types page was unreasonably long (over 17k lines).
Resolve by setting the `maxdepth` for this and the `bpy.ops` page too.

This problem showed up in v3.4 release and may be caused by changes
to Sphinx's default behavior as there doesn't seem to be any change
that would cause this in the generated docs.
2023-01-20 14:04:34 +11:00
b73814c65c Cleanup: use function style casts for C++ 2023-01-20 14:04:34 +11:00
d0010d48c7 Cleanup: add ED_uvedit_get_aspect_y utility function
This avoids having to perform the aspect division inline.
2023-01-20 14:04:34 +11:00
a0706d6cf0 Fix T102680: UV Pick shortest Path wrong for multi-object editing
Path selection support from [0] didn't account for multiple objects in
edit-mode. Now picking the UV also picks the object to operate on.

[0]: ea5fe7abc1
2023-01-20 14:04:34 +11:00
ebb519652c Object: add functionality to access the object as an index for operators
Add:
- ED_object_in_mode_to_index
- ED_object_in_mode_from_index

Useful for operators that act on a non-active object in multi-edit mode,
so the index can be stored for the operators exec function to read back
the value when redoing an action. Needed to resolve T102680.
2023-01-20 14:04:34 +11:00
1184501d5c Sculpt: Fix T103948: Automasking stroke id not being updated 2023-01-19 18:32:40 -08:00
fcb0425f64 Sculpt: Remove old connected component API in favor of new island API 2023-01-19 18:22:59 -08:00
da21e035d3 Sculpt: Fix T103923: Expand face sets now taking visibility into account
The code was never ported from the old system of encoding visibility
as negative face set values.
2023-01-19 18:04:34 -08:00
4fa6ce0973 Sculpt: Expand NORMALS and TOPOLOGY_DIAGNAL falloff now check islands
Prevents disconnect parts of the mesh from having their masks
filled.
2023-01-19 17:55:25 -08:00
0e35d5c095 Sculpt: Expand now waits for click before invoking when called from menu 2023-01-19 17:49:53 -08:00
8a6c6a5dc5 Cleanup: Remove unused functions in sculpt automasking code 2023-01-19 17:30:17 -08:00
8b5c2d9ef1 Sculpt: Restrict expand to active mesh islands for geodesic and topology
Fixes bug where other islands sometimes get their masks cleared (or
filled) in strange circumstances.  Still need to figure out the
correct behavior for spherical falloff.
2023-01-19 17:27:40 -08:00
9889918fd4 Sculpt: New API for keeping track of topology islands
Mesh islands (shells) are now calculated on an as-needed
basis and cached inside of a temp attribute,
`sculpt_topology_island_key`.  This attribute is updated
as needed when geometry changes (e.g. the trim brush)
or when mesh visibility changes.

This replaces the old behavior where the "topology" automasking
mode would walk the entire mesh on every stroke.
2023-01-19 16:58:30 -08:00
05bdef7ce6 Fix T103094: Cycles ignores small suns in Nishita sky
The background evaluation samples the sky discretely, so if the sun is
too small, it can be missed in the evaluation. To solve this, the sun is
ignored during the background evaluation and its contribution is
computed separately.
2023-01-19 18:31:54 -06:00
241d87e9f4 Curves: Add RNA access to evaluated normals per control point
Add an RNA API function that gives an array of the normals for every control point.
The normals depend on the `normal_mode` attribute, which can currently be
minumum twist or Z-up, though more options are planned. Normals are currently
evaluated on the evaluated points and then sampled back to the control points.
Because that can be expensive, a normal mode that only does a first evaluation
on control points may be important

The function is intended to be used by Cycles, so it doesn't have to implement
the calculation of normals itself. They can be interpolated between control points
and normalized.

For best performance, the function should only be called once, since it does the
full calculation for every control point every time it is called.

Differential Revision: https://developer.blender.org/D17024
2023-01-19 17:43:55 -06:00
203ab983ce Geometry Nodes: Rename node and socket for "Group ID" convention
Based on discussion about T102962, rename the "Face Set Boundaries" node
to "Face Group Boundaries" and the Accumulate Field node's "Group Index"
socket to "Group ID". This convention of "__ Group" and "Group ID" will
be used more in other nodes in the future.

This commit doesn't affect forwards or backwards compatibility.
2023-01-19 16:56:06 -06:00
bbeb37696d Cleanup: format 2023-01-20 11:43:28 +13:00
79053a6ff7 Cleanup: Move several modifiers files to C++
For continued refactoring of the Mesh data structure. See T103343.
2023-01-19 15:54:47 -06:00
2ab72f6db8 Fix T103964: Assert on mouse hover of empty node editor
The reverse iteration added in e091291b5b didn't handle
the case where there are no nodes properly. Thanks to Iliya Katueshenock
for investigating this.
2023-01-19 15:50:07 -06:00
fe552bf236 Cleanup: make format 2023-01-19 22:48:05 +01:00
670b3c5013 Cleanup: compiler warnings 2023-01-19 22:48:05 +01:00
190d66b51e Cleanup: Remove unused attribute API function
While we do need higher level utilities for copying attributes
between geometries, this currently isn't used and it's not clear
that it will be the right abstraction in the end.
2023-01-19 15:37:36 -06:00
baf69b064b Geometry Nodes: Avoid creating cyclic attribute when redundant
The default when there is no cyclic attribute is that none of the curves
are cyclic. In the mesh to curve node, avoid creating the attribute with
just false to save time and memory usage. Also avoid looking up the
attribute twice in the trim node.
2023-01-19 15:35:58 -06:00
7db00d4ef7 Cleanup: Rename curves utility function
"Fill" usually refers to setting a single value. This copies the
sizes from curves offsets to a separate array.
2023-01-19 15:31:26 -06:00
8d63293c46 Curves: Avoid building evaluated point offsets for poly curves
When all the curves are poly curves, skip the work of building a
separate array of offsets for the evaluated points (which are the
same as the control points). This saves 1-4ms on every reevaluation
in test files with many curves.
2023-01-19 15:22:54 -06:00
9233b609eb Cleanup: Use utility function for copying curve domain data
Standardizing the process of creating a new CurvesGeometry with
different curve sizes based on an existing curves is helpful, since
there are a few methods to simplify the process that aren't obvious
at first, like filling the offsets with sizes directly and accumulating
them to become sizes.

Also, in the trim curves node, avoid creating the curve types attribute
all the time. Use the special API functions for the types which do
some optimizations automatically. Also use a more consistent
method to copy the curve domain data, and correct some comments.
2023-01-19 15:08:58 -06:00
dfd63bf1e4 Curves: Avoid reallocations when evaluating NURBS curves
I didn't detect a noticeable performance difference in a basic test,
but this is better in principle anyway.
2023-01-19 14:29:14 -06:00
e12498e44e Cleanup: Avoid reallocations when evaluating curve in trim node
Use the same method as the resample node to use a single vector for
each thread. This avoids an allocation for each attribute of each curve.
2023-01-19 14:16:31 -06:00
4cfa4f7551 Geometry Nodes: Parallelize flip faces node
I observed a 2x performance improvement for a large mesh.
2023-01-19 14:14:12 -06:00
76673e5fcf Cleanup: Use OffsetIndices abstraction in duplicate elements node 2023-01-19 13:48:54 -06:00
38a45e46bc Cleanup: Use OffsetIndices class in more cases
The same logic from D17025 is used in other places in the curve code.
This patch uses the class for the evaluated point offsets and the Bezier
control point offsets. This helps to standardize the behavior and make
it easier to read.

Previously the Bezier control point offsets used a slightly different standard
where the first point was the first offset, just so they could have the same
size as the number of points. However two nodes used a helper function
to use the same `OffsetIndices` system, so switch to that there too.
That requires removing the subtraction by one to find the actual offset.

Also add const when accessing data arrays from curves, for consistency.

Differential Revision: https://developer.blender.org/D17038
2023-01-19 13:48:20 -06:00
d3ea931647 Fix: Compile error from designated initializers in C++ 2023-01-19 13:37:49 -06:00
f71bfe4655 Fix anisotropic Beckmann regression test failing on Metal
The lookup table method on CPU and the numerical root finding method on
GPU give quite different results. This commit deletes the Beckmann lookup
table and uses numerical root finding on all devices. For the numerical
root finding, a combined bisection-Newton method with precision control
is used.

Differential Revision: https://developer.blender.org/D17050
2023-01-19 20:12:05 +01:00
Nate Rupsis
fa67b84c34 NLA: Udating Blend-in and Blend-out values to clamp on NLA strip Transform
Previously, transforming a clip (scaling, repeat, etc) wouldn't re-calculate the blend-in and blend-out values, leading to over / undershoot, and a visual clip artifact

Old:

{F14045003}

This patch adds re-calculation logic (new `BKE_nlastrip_recalculate_blend()`  method) to the blend-in/out on transformations to clamp values, and avoid over/under shoot.

The `BKE_nlastrip_recalculate_blend()`  encapsulates the existing logic for both the `rna_NlaStrip_blend_in_set()` and `rna_NlaStrip_blend_out_set()` methods into a single BKE method that we an execute as needed. The fact that blend-in is first decreased, is strictly on the order of calculation. My suspicion is that //if// the blend-in / blend-our values were working as intended, the RNA set methods would update in order, and we'd experience the same thing. In short, the choice here was to linearly combine the logic, without making any assumptions of my own.

while talking things over with @sybren  and @RiggingDojo, they are fine with how this currently works, but there a desire to update how the two values interact with each (ratio scale, etc) in the future.

New:
{F14045024}

{F14045025}

Reviewed By: sybren

Maniphest Tasks: T101369

Differential Revision: https://developer.blender.org/D16720
2023-01-19 13:47:16 -05:00
9066f2e043 Cycles: Add support for OSL texture intrinsic on the GPU
This makes it possible to use `texture` and `texture3d` in custom
OSL shaders with a constant image file name as argument on the
GPU, where previously texturing was only possible through Cycles
nodes.
For constant file name arguments, OSL calls
`OSL::RendererServices::get_texture_handle()` with the file name
string to convert it into an opaque handle for use on the GPU.
That is now used to load the respective image file using the Cycles
image manager and generate a SVM handle that can be used on
the GPU. Some care is necessary as the renderer services class is
shared across multiple Cycles instances, whereas the Cycles image
manager is local to each.

Maniphest Tasks: T101222

Differential Revision: https://developer.blender.org/D17032
2023-01-19 19:14:48 +01:00
Michael Jones
e270a198a5 Cycles: Markup to disable specialisation of kernel data fields (Metal)
This patch adds markup to specify that certain kernel data constants should not be specialised. Currently it is used for `tabulated_sobol_sequence_size` and `sobol_index_mask` which change frequently based on the aa sample count, trash the shader cache, and have little bearing on performance.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D16968
2023-01-19 17:57:42 +00:00
Michael Jones
08b3426df9 Cycles: Occupancy tuning for new higher end M2 machines
This patch adds occupancy tuning for the newly announced high-end M2 machines, giving 10-15% render speedup over a pre-tuned build.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D17037
2023-01-19 17:56:40 +00:00
e7af2503c5 Cleanup: Fix unused variable warning in merge by distance 2023-01-19 11:53:32 -06:00
2a41e0822a Fix T103911: Custom property edit gets wrong existing default
The array length was wrong for all types after 0e89d24318, and
a typo meant that the boolean defaults were assigned to the int defaults.
2023-01-19 11:15:19 -06:00
12a3de96bb Fix T103972: crash with cloth simulation rest shape key and subdivision surface 2023-01-19 17:33:12 +01:00
Germano Cavalcante
25ce705617 Merge by Distance: split code into more specialized functions
Split the algorithms that find duplicates.

This improves readability and helps us find areas for optimization.

It may also facilitate the implementation of generic utilities.

No functional changes.

Differential Revision: https://developer.blender.org/D16918
2023-01-19 13:29:19 -03:00
90c6674f28 Fix T102615: crash on USD export for scenes with point clouds or hair
Code authored by Michael B Johnson (drwave).

Reviewed by Sybren and makowalski.

This patch addresses a crash that occurs when exporting a
scene to a USD file, when that scene includes a point cloud
object or hair.

Added OB_POINTCLOUD and OB_CURVES enums and a default case
statement in the switch statement in
USDHierarchyIterator::create_data_writer, to avoid dereferencing
a NULL pointer.

Differential Revision: https://developer.blender.org/D16776
2023-01-19 10:57:22 -05:00
9b7c2cca3d Refactor: replace bool beckmann with enum MicrofacetType for readability
Differential Revision: https://developer.blender.org/D17044
2023-01-19 15:55:07 +01:00
Jeroen Bakker
7f81d18ffe Metal: Fix crash when using batch_for_shader.
`batch_for_shader` is an utility function that creates the correct
vertex buffer based on the given shader. In the shader interface
the `attr_types_` contains the GPUType for each location in the
vertex buffer.

When using Metal, the `attr_types_` was never updated, resulting
in using incorrect or non-existing data types. This patch fixes
this by updating the `attr_types_` when building the shader
interface.

Reviewed By: fclem

Differential Revision: https://developer.blender.org/D17042
2023-01-19 15:11:06 +01:00
203bacbe4a Fix T103809: Using Preview Range Breaks Normalized FCurve Display
When using the "normalized" display of FCurves in the
Graph Editor, and also turning on the preview range,
the normalized display would break.

The preview frame range was assumed to be bezt indices,
which is only true when every frame has a key.

Reviewed by: Colin Basnett
Differential Revision: https://developer.blender.org/D16987
Ref: D16987
2023-01-19 14:38:49 +01:00
320757bc61 Refactor microfacet BSDF to reduce repetition 2023-01-19 12:07:53 +01:00
a3c38667f0 Fix T103881: Unlink operation crash in Blender File view
Similar to rBe97443478e32 and rBe772087ed664, exit early when
texture, collection and world ID has no parent to unlink from.

Reviewed by: Severin, lichtwerk

Differential Revision: https://developer.blender.org/D17017
2023-01-19 16:04:15 +05:30
eb657633ed Fix anisotropic Beckmann using isotropic sampling 2023-01-19 11:22:16 +01:00
2907227db2 Fix T103880: Crash with Line Art Grease-Pencil modifier
The line art modifier added a wmNotifier in it's
GpencilModifierTypeInfo.generateStrokes callback which isn't thread-safe
when called from the depsgraph. This was from the original inclusion
of the feature [0] however a more recent optimization to notifier
lookups [1] made the crash occur more frequently.

Remove the notifier as modifiers should not be adding WM level events
and it works without it.

[0]: 3e87d8a431
[1]: 0aaff9a07d
2023-01-19 20:41:45 +11:00
71b5799852 Code-style: Remove double semicolons at end of statement. 2023-01-19 09:46:45 +01:00
93d84e87b2 Fix T103400: Transfer Mesh Data Layout broken for color attributes
This was the case when using the operator outside of the modifiers panel.

Caused by {rBeae36be372a6}.

In above commit, `DT_layer_items` shared both `DT_TYPE_MPROPCOL_LOOP` |
`DT_TYPE_MLOOPCOL_LOOP` in a single EnumPropertyItem value "Colors".
This is a bit unusual, but probably allowed.
As a consequence, checks for specific datatypes would fail when selecting
such EnumPropertyItem:
- `DT_DATATYPE_IS_MULTILAYERS` (uses `ELEM` to check distinct entries --
would return false)
- `BKE_object_data_transfer_dttype_to_srcdst_index` (would return
`DT_MULTILAYER_INDEX_INVALID`)

These places have now been corrected to take these "special" values into
account.

Another issue was that multiple EnumPropertyItems with the same value
could be created in dt_add_vcol_layers() if attributes of the same
domain, but different color types are in play (could lead to crashes)
and that has also been corrected.

Also: above commit did not give the choice of transfering color
attributes from the vertex domain (only face corner attributes could be
chosen), this has now been added. DT_layer_vert_items (used from the
modifier) already had this included so this was only an issue when using
the operator outside of the modifiers panel.

Since we now feature two domains, the single "VCOL" in the enum has been
split into "COLOR_VERTEX" and "COLOR_CORNER". This will break existing
scripts calling bpy.ops.object.datalayout_transfer and will be marked as
a breaking change in the release notes.

NOTE: there is another bug here when attributes of the same domain, but
different color types are in play and you want to transfer just a single
specific layer (but that is for a separate commit)

Maniphest Tasks: T103400

Differential Revision: https://developer.blender.org/D16935
2023-01-19 09:24:52 +01:00
3f627c38a2 Fix test cases by reducing the severity of the bgl error message to warning. 2023-01-19 08:25:28 +01:00
41b33f8968 Fix spelling mistake in previous commit. 2023-01-19 08:23:05 +01:00
Jeroen Bakker
cac6b6f388 BGL_Wrap: disable calls on non-opengl backends.
Goal of this patch is to stop the invocation of OpenGL calls via the bgl module
on a none OpenGL GPU backend, report this as a python deprecation warning
and report this to the user.

## Deprecation warning to developers

```
>>> import bgl
>>> bgl.glUseProgram(0)
<blender_console>:1: DeprecationWarning: 'bgl.glUseProgram' is deprecated and will be removed in Blender 3.7. Report or update your script to use 'gpu' module.
```

## Deprecation message to users

The message to the user is shown as part of the Info Space and as a message box.
{F14159203 width=100%}
{F14158674 width=100%}

During implementation we tried several ideas:

# Use python warning as errors: This isn't fine grained enough and can show incorrect information to the user.
# Throw deprecation as error and use sys.excepthook to report the user message.
   This required a custom exception class to identify the bgl deprecation and a CPython handler function to
   be set during python initialization. Although this is the most flexible there was a disconnect between the
   exception class, exception function and the excepthook registration.
# A variant how we handle autoexec failures. A flag is stored in Global and when set the user message is reported.
   Not that flexible, but code is more connected to the boolean stored in the Global struct.

Although using Global struct isn't nice I chose this solution due to its traceability. It is clear to developers
reading the code how the mechanism works by using search all functionality of your IDE.

Reviewed By: MichaelPW, campbellbarton

Maniphest Tasks: T103863

Differential Revision: https://developer.blender.org/D16996
2023-01-19 08:18:37 +01:00
66595e29e2 Cleanup: remove/comment unused code, simplify casts
Remove simple counters where they aren't used, comment in some cases.
Also add missing include.
2023-01-19 17:10:42 +11:00
bc502f3b19 CMake: add WITH_LIBS_PRECOMPILED option (UNIX only)
This makes it convenient to build blender without referencing
pre-compiled libraries which don't always work on newer Linux systems.

Previously I had to rename ../lib while creating the CMakeCache.txt
to ensure my systems libraries would be used.

This change ensures LIBDIR is undefined when WITH_LIBS_PRECOMPILED is
disabled, so any accidental use warns with CMake's `--warn-unused-vars`
argument is given.
2023-01-19 17:10:42 +11:00
66dee44088 CMake: quiet references to undeclared variable warnings
These warnings can reveal errors in logic, so quiet them by checking
if the features are enabled before using variables or by assigning
empty strings in some cases.

- Check CMAKE_THREAD_LIBS_INIT is set before use as CMake docs
  note that this may be left unset if it's not needed.
- Remove BOOST/OPENVDB/VULKAN references when disable.
- Define INC_SYS even when empty.
- Remove PNG_INC from freetype (not defined anywhere).
2023-01-19 17:10:42 +11:00
8b7d2d8eb2 CMake: use BULLET_LIBRARIES for both extern_bullet and system libraries
There was no need to differentiate between these and it made
the CMake files more verbose.
2023-01-19 17:10:42 +11:00
978a7459f1 CMake: support multi-line strings for the help_features target 2023-01-19 17:10:42 +11:00
c2120b8c4f CMake: suppress missing-variable-declarations warnings with Clang
Code generated by wayland-scanner contained missing declarations.
2023-01-19 17:10:42 +11:00
9676dce317 Cleanup: CMake indentation 2023-01-19 17:10:42 +11:00
163d4aa094 Fix T103707: Use beauty fill for the UV select overlap operator
The original code used `BLI_polyfill_calc` which can create degenerate
triangles during triangulation per T103913. This causes the subsequent
overlap test to produce incorrect results in certain cases. Change to
using a "beauty" fill instead.

Differential Revision: https://developer.blender.org/D17015
2023-01-18 21:25:55 -08:00
83f9218801 Cleanup: Remove unused/redundant includes from curves/pointcloud draw 2023-01-18 18:14:44 -06:00
6c4e3a9e51 Curves: Deduplicate and parallelize point to curve map creation
There is a utility method on `CurvesGeometry` to build a map of the
curve for each point. Use that in two more places and make sure its
implementation is multithreaded, which gives a slight speedup
in a simple test file.
2023-01-18 16:41:10 -06:00
d3aaa7d523 Fix: Build issue with VS2019
fix by @JacquesLucke I just sprinkled it to all places
it needed to be.
2023-01-18 12:41:09 -07:00
e4e91bf830 Fix crash when listing assets repeatedly in node search menus
When doing partial reloads of asset libraries (only reload assets from
the current file, e.g. after undo re-allocated ID pointers), we'd end up
with assets that don't have their asset data read correctly. It would
execute a branch that didn't set the asset library object necessary to
create and store asset representations.

Steps to reproduce were:
* Open .blend file with geometry node assets in there
* In a geometry node editor, press Shift+A to open the add menu
* Cancel
* Move a node
* Undo
* Press Shift+A again
2023-01-18 18:27:25 +01:00
8707cab70b Gitea: don't reference branch in issues by default 2023-01-18 16:58:09 +01:00
9ccec5715e Gitea: layout and wording tweaks to issue and pull request templates 2023-01-18 16:43:55 +01:00
e8d1d1486e Fix T103960: build issue with GCC 13 in Cycles thread code 2023-01-18 16:43:47 +01:00
6f206f713e BLI: Math: Fix matrix tests failling
Regression introduced in rB17768b3df19a
2023-01-18 15:36:46 +01:00
c412d2dcfe DRW: View: Allow disabling view test by setting bound sphere radius to -1 2023-01-18 15:36:46 +01:00
534214e65c DRW: Make intersect lib not dependent on common_view_lib.glsl
This declares view intersection functions only if the view lib if
required.
2023-01-18 15:36:46 +01:00
9e5ada315f DRW: Protect common_math_lib.glsl from duplicated declaration
This avoid most issues when including this header along with some of the
newer `gpu_shader_math_*_lib.glsl`.
2023-01-18 15:36:46 +01:00
df74a9b624 DRW: Tests: Add test for PassSimple::Sub 2023-01-18 15:36:46 +01:00
e6be3f96d8 DRW: Fix DRW_VIEW_FROM_RESOURCE_ID 2023-01-18 15:36:46 +01:00
9c54f2655d DRW: Add double buffering of objects matrices, bounds, and infos
This allows easy delta calculation and access to last known position of
deleted objects.
2023-01-18 15:36:46 +01:00
efe51f0220 DRW: View: Allow for GPU side specification of view bounds
This allows an engine to perform GPU side view specification and let the
draw manager extract the culling informations (bounds).

To this end, the matrices ubo gets exposed to be able to write to it.

`compute_procedural_bounds()` need to be explicitely called before any
main pass using the culling result.
2023-01-18 15:36:46 +01:00
493e3230b4 DRW: Fix display print
Wrong uniform for viewport size.
2023-01-18 15:36:46 +01:00
21b3689fb9 DRW: GPU Wrappers: Add swap to storage buffers, empty framebuffer and fixes
Also add an assert to mip_view to avoid incorrect usage.
2023-01-18 15:36:46 +01:00
cf50a3eabc Cleanup: remove is_same method for virtual arrays
This abstraction is rarely used. It could be replaced by some more
general "query" API in the future. For now it's easier to just compare
pointers in the Set Position node where this was used.

This is possible now, because mesh positions are stored as flat `float3`
arrays (previously, they were stored as `MVert` with some other data
interleaved).
2023-01-18 13:24:19 +01:00
6e6ae17335 Fix reversed cosNI and cosNO in Cycles anisotropic beckmann G1 2023-01-18 13:10:45 +01:00
973db6b5c1 Gitea: make bug report template more compact
And split text before and after description field to reduce long distance
between title and description.
2023-01-18 12:50:13 +01:00
2c2178549b Curves: add OffsetIndices abstraction
This changes how we access the points that correspond to each curve in a `CurvesGeometry`.
Previously, `CurvesGeometry::points_for_curve(int curve_index) -> IndexRange`
was called for every curve in many loops. Now one has to call
`CurvesGeometry::points_by_curve() -> OffsetIndices` before the
loop and use the returned value inside the loop.

While this is a little bit more verbose in general, it has some benefits:
* Better standardization of how "offset indices" are used. The new data
  structure can be used independent of curves.
* Allows for better data oriented design. Generally, we want to retrieve
  all the arrays we need for a loop first and then do the processing.
  Accessing the old `CurvesGeometry::points_for_curve(...)` did not follow
  that design because it hid the underlying offset array.
* Makes it easier to pass the offsets to a function without having to
  pass the entire `CurvesGeometry`.
* Can improve performance in theory due to one less memory access
  because `this` does not have to be dereferenced every time.
  This likely doesn't have a noticable impact in practice.

Differential Revision: https://developer.blender.org/D17025
2023-01-18 11:52:37 +01:00
c1d360f7fb Fix urls in LTS script.
The urls were missing /release/, leading to 404 links on the LTS download page.
2023-01-18 10:39:50 +01:00
60d9de767d Cleanup: remove redundant forward declarations for structs 2023-01-18 18:41:13 +11:00
ca3e19f4c5 Fixes for 'make check_pep8' target
- Skip files in dirs starting with '.' (`.git` was being searched).
- Update --disable list for pylint.
2023-01-18 18:27:49 +11:00
9e5e2aa775 Cleanup: rename Mesh/Curve/MetaBall loc/size/texflag
Struct members loc/size were misleading as they read as if the object
data stored object level transform channels. Rename these to match RNA
with a `texspace_*` prefix to make it clear these struct members only
apply to texture-space transform.

Also rename ME_AUTOSPACE & ME_AUTOSPACE_EVALUATED to
ME_TEXSPACE_FLAG_AUTO & ME_TEXSPACE_FLAG_AUTO_EVALUATED.
2023-01-18 17:20:10 +11:00
07af7e2266 Cleanup: remove unused MetaBalle.disp & rot 2023-01-18 17:17:31 +11:00
988bc3dddf Cleanup: keep dna_rename_defs sorted 2023-01-18 17:17:29 +11:00
1c470dbd72 Cleanup: replace BLI_findptr with BKE_collection_has_object
Also swap the order of checks in collection_object_add to perform
the comparison before calling collection_find_child_recursive.
2023-01-18 15:43:20 +11:00
b380d25053 Cleanup: define COLLECTION_FLAG_ALL_RUNTIME, use in file read/write 2023-01-18 14:18:58 +11:00
fd2bf32dc7 Cleanup: use memset instead of clearing individual runtime members 2023-01-18 14:10:29 +11:00
44dd3308a5 DNA: move Collection members into their own Runtime struct
Also add static assert that COLLECTION_COLOR_TOT has the correct number
of items in the enum.
2023-01-18 14:00:09 +11:00
9179362e7b Geometry Nodes: Prefer evaluate at index value input in search
Give the "Value" input a higher search weight than the "Index"
input, since it's more likely that users will want to connect to
that. Based on feedback from Simon Thommes.
2023-01-17 19:43:59 -06:00
Iliya Katueshenock
d45ad0acd3 Geometry Nodes: Show supported geometry types tooltip without computing
Socket declarations exist all the time and it would be useful to use
them for tooltips at all times, not just when there is a computed log.

Differential Revision: https://developer.blender.org/D16846
2023-01-17 19:43:59 -06:00
bdb34c9804 Gitea: add more complete pull request template 2023-01-18 01:40:25 +01:00
737e7a63b1 Fix: incorrect curve type counts after adding curves of same type 2023-01-18 00:05:54 +01:00
301119619c Curves: Remove attribute retrieval, deduplicate evaluation logic
Avoid calling `interpolate_to_evaluate` while evaluating normals,
which has to look up attributes by name for every curve. Also avoid
duplicating the curve type switch in a few functions. I didn't observe
a performance difference, but theoretically this could reduce
overhead for many small curves.
2023-01-17 14:58:54 -06:00
dcb37959d4 Fix roation snap failing with zero angle
Due to precision issues, the cosine value calculated with
`dot_v3v3(start, end)` can be outside the -1, 1 range causing `acosf`
to return `nan(ind)`.

Use `angle_signed_on_axis_v3v3_v3` instead. It returns more accurate
values, deduplicates code, and avoids these `nan` issues.
2023-01-17 17:21:39 -03:00
17768b3df1 BLI: Math: Fix perspective matrix function
The port missed this one component that should have been left to 0.0.
2023-01-17 21:02:57 +01:00
d42d4e339f Cleanup: Remove unnecessary includes in geometry set header 2023-01-17 12:50:06 -06:00
85ea74ad77 Cleanup: Remove unnecessary curves RNA verification disabling
There is no SDNA data for `position_data` anymore after
e9f82d3dc7.
2023-01-17 12:50:06 -06:00
df54561233 Cleanup: Fix incorrect comments in mesh extrude node 2023-01-17 12:50:06 -06:00
d76a0e98ba Fix: Avoid node reevaluations for selection and parenting
Since 90ea1b7643, node trees have been reevaluated
after many selection operations because nodes are sorted based on
the selection status and an update tag was added for that. However,
for years the node order was allowed to be different between the
original and evaluated copy of node trees.

Though it is a bit sketchy to have that difference in the evaluated
node tree, reevaluations for just selection are very bad, so use a
"smaller" update tag and add a comment for justification.

Differential Revision: https://developer.blender.org/D17023
2023-01-17 12:50:06 -06:00
665732115e Gitea: add separate issue templates for bug, design and todo 2023-01-17 19:44:21 +01:00
1d253b6652 Fix T103945: incorrect anonymous attribute references
The case where the same field group input is evaluated on
more than one geometry inputs was not handled correctly.
2023-01-17 18:40:28 +01:00
34326fec02 Fix: sample index node outputs default value
Error in rBb5105085139227a713f154446ff6a3255cb8be99.
2023-01-17 18:29:25 +01:00
543bf28fb1 Refactor: renamed I -> wi, omega_in -> wo in Cycles
wi is the viewing direction, and wo is the illumination direction. Under this notation, BSDF sampling always samples from wi and outputs wo, which is consistent with most of the papers and mitsuba. This order is reversed compared with PBRT, although PBRT also traces from the camera.
2023-01-17 18:07:13 +01:00
400f022989 Geometry Nodes: Add warning to set material node with no faces
The node can't do anything in this case, which isn't always obvious.

Resolves T103133
2023-01-17 10:31:07 -06:00
873794b196 Fix T103937: Applying modifier resets shape keys
The order of arguments to memcpy was reversed, which is sadly possible
because the constness `KeyBlock` of keyblock doesn't propagate to
pointers it contains.
2023-01-17 10:22:29 -06:00
d411de96f7 Fix T103936: Regression: Track To constraint broken
Caused by 6769acbbba.

Some of the matrix variants are rather obscure from the
semantic: they don't really fully initialize the output:
as in, they only write to an upper-left 3x3 block.

A quick solution to fix the very commonly used constraint.
It feels that it is possible to minimize about of copy
operations.
2023-01-17 17:10:41 +01:00
0e89d24318 Cleanup: Use elif in custom property edit operator, reduce whitespace 2023-01-17 09:51:43 -06:00
50105b2952 Fix T103911: Editing boolean custom property UI data resets value
The old value wasn't retrieved for boolean array properties.
2023-01-17 09:51:43 -06:00
f8b11528b2 USD export: ensure edit mode changes are exported
Code authored by Charles Wardlaw.

Reviewed by Bastien, Sybren and makowalski.

Differential Revision: https://developer.blender.org/D15916
2023-01-17 10:24:43 -05:00
7df5d7c7a7 Cleanup: Curves selection boolean to float comparison
The conversion from float to boolean is now handled by
the attribute API.
2023-01-17 09:15:33 -06:00
Kevin C. Burke
e144af1f7c GPencil: Provide Option for Fill in Material Popover
The Grease Pencil Material Popover currently has a color picker 
for the Stroke of a Material using Solid style, but not one for
 a Fill using Solid style. 

With the default Grease Pencil Materials, the current 
popover only shows the Stroke color for the grey "Solid Fill" 
material (which doesn't have its Stroke enabled) instead of 
the more useful Fill color.

This patch shows a Stroke color picker when the Material 
has Stroke enabled and the style is Solid. 
This is the same for the Fill.

Reviewed By: antoniov, mendio

Differential Revision: https://developer.blender.org/D17004
2023-01-17 15:44:38 +01:00
f8328ec172 Fix: Draw: Freeze Culling
Bind the frozen culling data as well.

Reviewed By: fclem

Differential Revision: https://developer.blender.org/D17010
2023-01-17 15:10:36 +01:00
8b660e1cbf Cleanup: use defaulted constructor 2023-01-17 13:43:38 +01:00
b510508513 Geometry Nodes: optimize Sample Index node with constant index
Previously, the node would always evaluate the input field on the
entire geometry domain. This is good when most indices will be
accessed afterwards. However, it is quite a bad when only a single
index is used. Now the field is only evaluated for that one index.
2023-01-17 13:29:55 +01:00
03fab057f1 Cleanup: correct asserts 2023-01-17 13:13:43 +01:00
2c6ed49c03 Cleanup: Rename confusing region variable
`scaleare` reads like "scale area", but should read "scale region".
2023-01-17 13:08:06 +01:00
Damien Picard
8082b96a75 Tracking: fix inverted pie menu items for pattern match of track
The two items had their effects inverted.

Reviewed By: sebastian_k

Differential Revision: https://developer.blender.org/D16438
2023-01-17 09:40:08 +01:00
962c3cf6b1 Cleanup: remove unused IDProperty members
Remove:

- IDPropertyTemplate.matrix_or_vector
  Matrix & vector types have been deprecated, this wasn't used.

- IDProperty.saved
  This was added preemptively but never used, replace with a pad so as
  not to hint at a feature that doesn't exist.
2023-01-17 12:05:21 +11:00
9789835db8 Docs: improve ID property doc-strings
Add some clarifications and reference enum types from DNA.
2023-01-17 11:59:05 +11:00
7241ab6ede Revert "Fix: don't set default value for unused socket in geometry nodes"
This reverts commit 154d3e95f8.

This caused crashes in the mouse house and flower shop benchmark files.
A proper solution will be investigated soon.
2023-01-16 16:58:24 -06:00
647a7da17d Curves: Avoid adding curve type attribute when setting default
The default curve type when there is no "curve_type" attribute is
Catmull ROM. In order to avoid allocating an entire array of values
just to set this default type, remove the attribute instead. This will
be less important when we can store attributes as single values.

Also fix a curve utility API comment.
2023-01-16 16:51:32 -06:00
6769acbbba BLI_math: simplify matrix multiply logic
Improve safety and correctness of matrix multiplication by using
temporary storage if one of the inputs is also the output.

No functional changes.

Differential Revision: https://developer.blender.org/D16876
Reviewed By: Campbell Barton, Sergey Sharybin
2023-01-17 11:18:33 +13:00
7026096099 Nodes: Use dynamic declarations for group nodes
Since a year and a half ago we've been switching to a new way to
represent what sockets a node should have called "declarations"
that's easier to use, clearer, and more flexible for upcoming
features like dynamic socket counts or generic type sockets.

All builtin nodes with a static set of sockets have switched, but one
missing area has been group nodes and group input/output nodes. These
nodes have **dynamic** declarations which change based on their
properties or the group they're inside of. This patch addresses that,
in preparation for using the same dynamic declaration feature for
simulation nodes.

Generally there shouldn't be user-visible differences, but one benefit
is that user-created socket descriptions are now visible directly in
the node editor for group nodes and group input/output nodes.

The commit contains a few changes:
- Add a node type callback for building dynamic declarations with
  different arguments
- Add an `Extend` socket declaration for the "virtual" sockets used
  for connecting new links
- A similar `Custom` socket declaration is used for addon-defined socket
- Simplify the node update loop to use the declaration to build update
  sockets
- Replace the "group update" functions with the declaration building
- Move the node group input/output link creation to link drag operator
- Make the field status part of group node declarations
  (not for group input/output nodes though)
- Some fixes for declarations to make them update and build properly

Differential Revision: https://developer.blender.org/D16850
2023-01-16 15:47:25 -06:00
6d12d43a05 Mesh: Skip conversion from legacy data if reading new format
Under some circumstances (loading autosaves), we end up reading from
files that were saved with the new mesh format (after T95965). When
that happens we should skip the conversion from the old format to
avoid data-loss. This will also give forward compatibility when we
stop saving in the old format completely in 4.0.

Here I mostly just check if the attributes in the new format already
exist. Along with checking for the null status of `Mesh::mvert`, that
should cover the majority of cases.

Fixes T103878

Differential Revision: https://developer.blender.org/D17011
2023-01-16 15:47:25 -06:00
39c6953462 UI: Fix alignment of custom properties edit & remove buttons
This fixes the UI alignment issues that were introduced by {D12815} with the addition of the boolean custom properties.

Reviewed By: HooglyBoogly

Differential Revision: https://developer.blender.org/D17012
2023-01-16 12:54:25 -08:00
6f6cc269a4 Cleanup: Move sculpt_dyntopo.c to C++
See T103343
2023-01-16 14:41:28 -06:00
e0e6afb766 Geometry Nodes: Parallelize mesh and curve edit hint transformation
Previously transforming and translating meshes (used by the object info
and transform geometry nodes) was single threaded. Now use the same
code path as other geometry types which already includes multithreading.

I observed a 5x performance improvement for a 4 million vert mesh on a
Ryzen 7950x.
2023-01-16 13:16:44 -06:00
93ca4eeec1 Cleanup: remove unused functions 2023-01-16 19:40:25 +01:00
Mattias Fredriksson
c55767b32e Fix T103632: Single point trim samples curve end point incorrectly
Trim erronously samples the next to last control point when it should
sample the last control point on the curve. This only happens when
reducing the curve to a single point. These changes should correct
the behavior.

Differential Revision: https://developer.blender.org/D17003
2023-01-16 12:22:20 -06:00
a219507d57 Cleanup: Add documentation to curve legacy conversion functions 2023-01-16 12:06:36 -06:00
b82f7814c4 Fix: Draw: Incorrect culling in the new Draw Manager
ViewCullingData::corners (vec4) was casted to a BoundingBox (vec3),  so the frustum corners were uploaded in the wrong format to the GPU.

Now the ViewCullingData::corners are used directly without casting, since the BoundBox API is not really needed.

Reviewed By: fclem

Differential Revision: https://developer.blender.org/D17008
2023-01-16 18:41:06 +01:00
c66da0b267 Docs: change readme.rst to README.md, as Gitea can't render rst 2023-01-16 17:54:11 +01:00
a84a8a528d Cycles: remove SSE3 and AVX kernel optimization levels
While keeping SSE2, SSE4.1 and AVX2. This does not affect hardware support, it
only slightly reduces performance for some older CPUs.

To reduce maintenance cost and improve compile times.

Differential Revision: https://developer.blender.org/D16978
2023-01-16 17:53:36 +01:00
debd912bef Fix T103906: Crash when canceling transform operation with the mirror options set
Caused by rB3b761901b6d6.

Some mirror transdata values were not being initialized.
2023-01-16 12:14:27 -03:00
8cc558814d Cleanup: make format 2023-01-16 14:39:17 +01:00
Iliya Katueshenock
154d3e95f8 Fix: don't set default value for unused socket in geometry nodes
Setting the default value resulted in an incorrect tooltip.

Differential Revision: https://developer.blender.org/D16957
2023-01-16 12:41:07 +01:00
5320372c34 User Inteface: Missing separator in Geometry Nodes > Add Node > Geometry menu
This separator was missing in the original change in the menus (d4e638baac).
2023-01-16 12:23:52 +01:00
Marc Chéhab
9a1f0443cb Fix Unreported: GPencil Separating strokes creates negative times
Separating strokes using "selected points" didn't take into account 
that points->time can be 0 and thus created points with negative 
values in points->time, which should be an impossibility. 
This patch fixes this in BKE_gpencil_stroke_delete_tagged_points.

Also, it makes the build modifier's new drawspeed immune 
to (erroneous) negative time values, should they arise in other situations.

Reviewed By: antoniov


Differential Revision: https://developer.blender.org/D17006
2023-01-16 12:07:15 +01:00
ff814ec5f6 Metal: Fix read from uninitialized memory.
Implementation didn't count the string terminator when allocating
memory to store `msl_patch_default`. The string terminator could
be overwritted by other memory adding some undefined behavior.
2023-01-16 11:12:14 +01:00
5cbc8ce3b1 Fix ASAN error when Wayland fell back to X11
An alternative fix to [0] which caused an error with ASAN
(freeing an GHOST_ISystem instead of a GHOST_System).
Reported by @Baardaap in chat, I'm unable to reproduce the issue.

Instead of calling the destructor directly, add a private method that
deletes data before raising an exception.

[0]: fd36221930
2023-01-16 15:29:22 +11:00
a294c35370 Docs: expand on doc-string for seam_connected_recursive
Also use const UVs where possible.
2023-01-16 14:51:12 +11:00
6a7ecec6e1 Cleanup: avoid returning large structs from functions
Return BezTriple as a const pointer from utility functions
instead of by a value since it's a large struct.
2023-01-16 14:23:23 +11:00
cc5fefffe6 Cleanup: quiet array-bounds warning in GCC 12.2 2023-01-16 14:06:41 +11:00
2467becade Cleanup: spelling in comments 2023-01-16 13:57:10 +11:00
eeb6a3dc05 Clenaup: comments places awkwardly before code 2023-01-16 13:27:51 +11:00
33c30af742 Cleanup: comments in struct declarations
Use a consistent style for declaring the names of struct members
in their declarations. Note that this convention was already used in
many places but not everywhere.

Remove spaces around the text (matching commented arguments) with
the advantage that the the spell checking utility skips these terms.
Making it possible to extract & validate these comments automatically.

Also use struct names for `bAnimChannelType` & `bConstraintTypeInfo`
which were using brief descriptions.
2023-01-16 13:27:35 +11:00
Sibo Van Gool
b038662887 Fix T103559: Check for no-face object for particle baking
Meshes spawning particles from faces with with UV's/Vertex-colors but no
faces would crash de-referencing a NULL pointer.

Resolve by adding a check for this case and an assertion if CD_MFACE is
NULL when the mesh has polygons.

Ref D16947
2023-01-16 11:15:40 +11:00
28db19433e GPU: Math: Add floatBitsToOrderedInt and orderedIntBitsToFloat
These allow the usage of `atomicMin` and `atomicMax` function with float
values as there is no overload for these types in GLSL.

This also allows signed 0 preservation.
2023-01-16 00:39:57 +01:00
945d108ab8 GPU: Fix uninitialized variable which created asan warning / errors
This wasn't really a problem since these are set on first bind or creation.
The test `if (enabled_srgb && srgb_) {` was depending on that variable that
in certain case, might not have been initialized (because of lazy init).
2023-01-16 00:39:57 +01:00
6da7436cce DRW: Add debug print for matrix type 2023-01-16 00:39:57 +01:00
6d07b459f2 Cleanup: compare to GPU_SHADER_CFG_CLIPPED when checking configurations
Don't assume a non-zero eGPUShaderConfig is clipped, as this would cause
unexpected behavior if other configurations are added.
2023-01-16 10:21:32 +11:00
e1aef2e87e Cleanup: suppress '-Warray-bounds' warnings
Changes to overlay_shader.cc workaround a bug in GCC-12.2
(likely a duplicate of [0]). As the workaround involved removing
a local variable which most functions already didn't assign,
remove it for all functions.

An alternative is to add (otherwise redundant) parenthesis, e.g.
`&(e_data.sh_data[sh_cfg])`, but this would need to be noted in
code-comments, so opt for removing the intermediate variable.

[0]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106247
2023-01-16 10:12:21 +11:00
87bb14ab5f Fix T103256 Viewport: Regression: Clipping Region is not working
This was caused by a change in UBO name that wasn't propagated through
all usage, leading to missing UBO bind.
2023-01-15 14:24:06 +01:00
8b5d5cbf06 BLI: Math: Add sign() function
This implement the sign function as simple as possible while giving the
the same result as `signum`.
2023-01-15 14:15:39 +01:00
0a7c485b66 Cleanup: remove redundant memset on calloc'ed array 2023-01-15 23:55:06 +11:00
bec86c5d15 Cleanup: remove unused arguments 2023-01-15 23:52:50 +11:00
8c7df5fa72 Fix invalid arguments to memcpy in IMB_rectfill_area_replace
Passing the pointer to the array doesn't make sense in this case.
2023-01-15 23:45:56 +11:00
82bd020a30 CMake: suppress GCC warnings stringop-overread & stringop-overflow
As noted in comments, there are a lot of false positives which can't
be conveniently suppressed. Many of these warnings were caused by
`float x, y, z` being passed as `float[3]` using a pointer to `x`.
2023-01-15 23:31:44 +11:00
fc9c818531 Fix missing view layer sync in recent change to ED_view3d_datamask
Call BKE_view_layer_synced_ensure before getting the active object [0]
caused an assertion for tests in debug mode.

[0]: c158dd560e
2023-01-15 23:28:12 +11:00
cc332264ae Audaspace: porting changes from upstream. 2023-01-14 22:18:39 +01:00
1a79bdfbf1 BLI: inline index mask slice methods
Those are simple enough to be inlined.
2023-01-14 19:40:22 +01:00
ff15edc6ab Cleanup: unify method parameters for virtual arrays
This makes `GVArrayImpl` and `VArrayImpl` more similar.
Only passing the pointer instead of the span also increases
efficiency a little bit. The downside is that a few asserts had
to be removed as well. However, in practice the same asserts
are in place at a higher level as well (in `VArrayCommon`).
2023-01-14 19:13:51 +01:00
72cc68e299 Functions: only allocate resource scope when it is actually used
In most cases it is currently not used, so always having it there
causes unnecessary overhead. In my test file that causes
a 2 % performance improvement.
2023-01-14 15:56:43 +01:00
50980981e3 Cleanup: remove MF prefix from some classes in multi-function namespace
This was missing in rBeedcf1876a6651c38d8f4daa2e65d1fb81f77c5d.
2023-01-14 15:42:52 +01:00
8625495b1c Functions: improve handling of unused multi-function outputs
Previously, `ParamsBuilder` lazily allocated an array for an
output when it was unused, but the called multi-function
wanted to access it. Now, whether the multi-function supports
an output to be unused is part of the signature. This way, the
allocation can happen earlier when the parameters are build.
The benefit is that this makes all methods of `MFParams`
thread-safe again, removing the need for a mutex.
2023-01-14 15:35:44 +01:00
aea26830dc Cleanup: use std::get instead of std::get_if
`std::get` could not be used due to restrictions on macos.
However, the minimum requirement has been lifted in
{rB597aecc01644f0063fa4545dabadc5f73387e3d3}.
2023-01-14 14:16:51 +01:00
8126d92073 Cleanup: fix compile error in debug build 2023-01-14 14:15:21 +01:00
92773761d3 Sculpt: Change expand hotkey to not auto-create mask 2023-01-13 20:17:03 -08:00
325105ee6f Sculpt: add support for curves sculpt to paint_init_pivot
Uses BKE_object_boundbox_get.
2023-01-13 19:58:42 -08:00
3a3d9488a1 Refactor: Const correct Custom Data API, prepare for CoW
Currently you can retrieve a mutable array from a const CustomData.
That makes code unsafe since the compiler can't check for correctness
itself. Fix that by introducing a separate function to retrieve mutable
arrays from CustomData. The new functions have the `_for_write`
suffix that make the code's intention clearer.

Because it makes retrieving write access an explicit step, this change
also makes proper copy-on-write possible for attributes.

Notes:
- The previous "duplicate referenced layer" functions are redundant
  with retrieving layers with write access
- The custom data functions that give a specific index only have
  `for_write` to simplify the API

Differential Revision: https://developer.blender.org/D14140
2023-01-13 17:22:07 -06:00
4160da187c Fix T103670: correct seam calculation when finding unique uvs
Fixes bugs where UV islands with `mark seam` would tear at boundaries.

Modify seam_connected to search both it's edges instead of only one,
as this could fail if the edge was a seam or did not fan to the other loop.

Also fixes bug in `seam_connected_recursive`:
- `loop->prev == needle` changed to `loop == needle`

Maniphest Tasks: T103787
Reviewed By: Campbell Barton
Differential Revision: https://developer.blender.org/D16992
Test File: F14145477, F14137755, T79304
2023-01-14 11:47:59 +13:00
326e1eeb56 UV: cleanup
Cleanup ahead of D16992

Changes in `seam_connected_recursive`:

- Remove redundant `anchor` parameter.
- Improve const correctness

No functional changes.
2023-01-14 11:47:59 +13:00
Iliya Katueshenock
e35053d369 Fix T103850: Convex hull node crash with empty geometry components
Avoid using components that can contain null pointer.
Getting attibute should avoid trying to do it for a null mesh.
This fix bypasses working with components.

Differential Revision: https://developer.blender.org/D16997
2023-01-13 15:46:39 -06:00
b55b671955 Cleanup: format 2023-01-14 10:38:53 +13:00
0a21a554d5 Fix T103304: Incorrect handling of edge crease in subdivision node
The crease custom data layer was added to a mutable version of the mesh,
but that wasn't used in the rest of the operation. Also the layer wasn't
retrieved properly with write access from the custom data API (fixed
separately as part of D14140). Also clean up a bit by retrieving
attributes from the mesh directly and by tweaking naming a bit.
2023-01-13 15:34:01 -06:00
dc99c09daa Cleanup: Use const when accessing custom data layers 2023-01-13 14:52:04 -06:00
a5c3f5b0bc Fix T103818: Freeze frames in movie strips when timecodes are used
Timecodes were generated from read packets, but applied to decoded
frames. This works as long as delay between packet read and decoded
frame is less than GOP size or if packet does not produce multiple
frames. In this case it did not work.

Use `pkt_pos`, `pkt_dts` and `pts` from `AVFrame` instead of `AVPacket`.
This way delay can be eliminated and timecode files are more reliable.
2023-01-13 21:32:42 +01:00
2c910cb70a Modifiers: Only allow geometry nodes for curves and point cloud
Effectively this disables two volume modifiers for the new curves
object and the point cloud object types. The aim is to simplify the
process of using these object types to prove out a node-group-based
workflow integrated with the asset browser. We're making the assumption
that these two modifiers were used very rarely on the new curves type
since that wasn't its purpose, so this breaks backwards compatibility.
2023-01-13 14:20:08 -06:00
cb92ff7b2d Geometry Nodes: Only set soft range for modifier properties
Similar to the corresponding properties on node sockets, only adjust
the soft range. Because group nodes only have soft limits, groups
should generally be able to accept these inputs anyway. The benefit
of only using a soft range is that it allows choosing a more user-
friendly default range while keeping flexibility.
2023-01-13 12:50:19 -06:00
ef68a37e5d Custom Properties: Add boolean type
A proper boolean custom property type is commonly requested. This
commit simply adds a new `IDP_BOOLEAN` type that can be used for
boolean and boolean array custom properties. This can also be used
for exposing boolean node sockets in the geometry nodes modifier.

I've just extended the places existing IDProperty types are used, and
tested with the custom property edit operator and the python console.
Adding another IDProperty type is a straightforward extension of the
existing design.

Differential Revision: https://developer.blender.org/D12815
2023-01-13 12:31:27 -06:00
4961e5f91d Geometry Nodes: Rename Interpolate Domain and Field at Index nodes
- `Interpolate Domain` -> `Evaluate on Domain`
- `Field at Index` -> `Evaluate at Index`

These names, discussed in recent geometry nodes submodule meetings,
describe actions rather than nouns, which is generally how nodes are
supposed to be named. The names are consistent, which is helpful
because they're similar conceptually. They also don't require knowledge
of the field concept, which we generally try to keep out of the UI in
favor of more beginner-friendly concepts.

We hope to add the ability to search for nodes with multiple
names for 3.5, so the old names can still have search items.
2023-01-13 11:49:50 -06:00
ba71419891 Cleanup: improve const correctness of bvh tree 2023-01-13 18:09:27 +01:00
046d1a414b Fix: Curves select all operator name
The operator is used for edit mode and sculpt mode, so it
shouldn't have the sculpt prefix.
2023-01-13 10:47:33 -06:00
761e6b1b78 Fix: crash when opening node add menu
Differential Revision: https://developer.blender.org/D16995
2023-01-13 17:25:20 +01:00
d4e638baac User Interface: Re-organization of Geometry Nodes Add Node Menu
The menus are growing too large. This patches move some categories under
sub-menus, and shuffle some entries around.

We already had sub-categories split by separators. This change now
goes a step further and embrace 3-level menus.

Inspired by the "Simpler Add Menu" add-on by Quackers (waiting to hear
back to know Quackers real name).

Inspired by the "Simpler Add Menu" add-on by Alfonso Martinez II.

Differential Revision: https://developer.blender.org/D16993
2023-01-13 16:31:27 +01:00
2fb829a2de Fix T103837: crash opening a specific file
Caused by {rBd397ecae325}.

Above commit added a new socket, so
`version_geometry_nodes_primitive_uv_maps` was getting the wrong sockect
with `->next`.

Now get the right one with yet another `->next` (might not be ideal, but
searching the right socket with other methods might be overhead?)

Maniphest Tasks: T103837

Differential Revision: https://developer.blender.org/D16994
2023-01-13 14:58:57 +01:00
bc3da3ad41 Sculpt: fix T103454: SCULPT_vertex_is_occluded is not compatible with
filters
2023-01-13 00:10:46 -08:00
daedf19315 Sculpt: Fix T103724: missing mask attr existance check for PBVH_GRIDS 2023-01-12 23:58:00 -08:00
c158dd560e WM: reduce CPU use while idle in ED_view3d_datamask
When idle, each 3D view made two calls CTX_data_mode_enum(C) from the
WM_main loop. While not causing problems it complicated troubleshooting
high CPU use while idle in other areas.

Access the object via the view layer, giving approx 40x speedup.
2023-01-13 17:56:05 +11:00
0c2a3054ba Fix high CPU use when idle under Wayland
Recently the event handling thread for Wayland sometimes used 100% of a
CPU core while idle.

Resolve by waiting for changes to the Wayland file-handle when
there are no events to read.
2023-01-13 17:48:52 +11:00
bbe7183cd3 GHOST/Wayland: fix threaded event handling
The previous fix from T100855 [0] no longer works on my system
(3.4.1 release also fails for GNOME/KDE/WLROOTS compositors).

Resolve by removing the loop from the wait-on-file handle check.
Also reduce locking/unlocking calls.

[0]: 37b256e26f
2023-01-13 17:48:50 +11:00
b599820418 OBJ: add split by objects/groups import options (T103839)
The new C++ OBJ importer was missing "split by objects" / "split by
groups" import settings of the older Python importer.
Implements T103839.

Added test coverage for all 4 possible combinations of these two
options.
2023-01-12 22:47:39 +02:00
b2746876f2 EEVEE: Avoid glitchy displacement on curve geometry
This is caused by the partial derivatives not being precise enough to
take the tube shape into account. For now we just disable displacement
bump for this type of geometry to match cycles.

Fixes T101175 Eevee displacement behavior changed
2023-01-12 16:19:03 +01:00
Marc Chéhab
063caae72e GPencil: Fix unreported error in Build modifier
In patch D16759 cleanup a  else was removed by error which
 deals with situations where current gpf was copied, 
so that previous gpf may have MORE strokes than current gpf.

Reviewed By: antoniov

Differential Revision: https://developer.blender.org/D16986
2023-01-12 15:37:35 +01:00
Germano Cavalcante
589d1be147 Cleanup: rename variables to distinguish between target and source
From --> To

**Struct Members:**
|snapTarget|snap_source
|snapPoint|snap_target
|snapTargetGrid|snap_target_grid
|calcSnap|snap_target_fn
|targetSnap|snap_source_fn
|applySnap|snap_mode_apply_fn
|distance|snap_mode_distance_fn
|source_select|source_operation
|target_select|target_operation

**Functions:**
|snap_calc_view3d_fn|snap_target_view3d_fn
|snap_calc_uv_fn|snap_target_uv_fn
|snap_calc_node_fn|snap_target_node_fn
|snap_calc_sequencer_fn|snap_target_sequencer_fn
|TargetSnapMedian|snap_source_median_fn
|TargetSnapCenter|snap_source_center_fn
|TargetSnapClosest|snap_source_closest_fn
|TargetSnapActive|snap_source_active_fn

**Enums:**
|TARGET_INIT|SNAP_SOURCE_FOUND
|TARGET_GRID_INIT|SNAP_TARGET_GRID_FOUND
|POINT_INIT|SNAP_TARGET_FOUND
|MULTI_POINTS|SNAP_MULTI_POINTS

**Types:**
|eSnapSourceSelect|eSnapSourceOP
|eSnapTargetSelect|eSnapTargetOP

Also rename Select to Operation.

Reviewed By: campbellbarton

Differential Revision: https://developer.blender.org/D16967
2023-01-12 10:30:47 -03:00
16fc928068 Fix: uninitialized UVs when painting in sculpt mode
Because of a mistake in commit 6c774feba2 the uv vbo was not
initialized in the pbvh.
2023-01-12 14:25:37 +01:00
c5f9bf95cd Cleanup: Remove unused function pose_propagate_fcurve
Remove the unused function `pose_propagate_fcurve`
It was missed in D16771

Reviewed By: Jacques Lucke
Differential Revision: https://developer.blender.org/D16937
Ref: D16937
2023-01-12 13:03:55 +01:00
ed178f5ff5 Fix: Potential divide by 0 using GRAPH_OT_ease
In case there is only 1 key on the FCurve,
the operator can run into a situation where it divides by 0.
It now skips the curve in that case

Reviewed by: Sybren A. Stüvel
Differential Revision: https://developer.blender.org/D16982
Ref: D16982
2023-01-12 12:54:27 +01:00
ea1c31a244 Fix T103074: flipped vertex group meaning in Multi-Modifier Armature.
For some reason the Armature modifier in the Multi-Modifier mode
interpreted the vertex group in a way essentially opposite to the
regular mode. Moreover, this depended not on the Multi-Modifier
checkbox, but on whether the mode was actually active.

This fixes the flip and adds versioning code to patch old files.
One difficulty is that whether the Multi-Modifier flag is valid
can be different between the viewport and render. The versioning
code assumes any modifier enabled in either to be active.

This change is not forward compatible, so min version is also bumped.

Differential Revision: https://developer.blender.org/D16787
2023-01-12 12:46:22 +02:00
09a26f26e8 Cleanup: missing-declarations warnings
Also remove duplicate doc-string.
2023-01-12 20:22:46 +11:00
eeff49a3b1 macOS: Replace PboardTypes with PasteboardTypes.
Related to {T103758}.

- NSStringPboardType is replaced by NSPasteboardTypeString
- NSTIFFPboardType is replaced by NSPasteboardTypeTIFF
2023-01-12 08:48:48 +01:00
Jeroen Bakker
3590e263e0 macOS: Remove user notifications.
User notifications in Blender were always annoying and therefore by default turned off.
- When tweaking compositor/material tree a notification was shown.
- When rendering an animation for each frame a notification was shown.

The reason for this was that it was automatically shown when a background job was
finished and Blender wasn't the top most application.

In stead of migrating user notification to UserNotification.framework it was decided
to remove it for now. If in the future notifications should be added back we should
start with a design to figure out where notifications makes sense.

Reviewed By: sergey, brecht

Maniphest Tasks: T103757

Differential Revision: https://developer.blender.org/D16955
2023-01-12 08:39:56 +01:00
Jeroen Bakker
b9177014b6 3D Texturing: Replace pointers with indexes in pbvh_uv_islands
Replace the pointers in the MeshEdge with indexes, removing MeshPrimitive and MeshVertex.

Code cleanup proposed by the geometry nodes to make the data structures more reusable by
other areas of Blender as well. Old implementation was to focused to the texture painting.

Initial the idea was to do the same with the data structures in UVIslands, but there some
concerns were raised that requires a different design than expected from a clean-up patch.

Concerns raised about converting UVIslands:
* Maps between UVPrimitive, UVEdge and UVVertex will be stored inside the UVIsland.
   During UVIsland extraction detected islands can be merged. When they are merged all
   Indexes should be updated.
* It is not possible to pre-allocate all buffers as they grow, what will lead to more re-allocations. The current
   implementation uses a VectorList to ensure that re-allocations don't require the data to be
   moved to the newly allocated memory. We could store some information about last used
   sizes in runtime data to reduce the re-allocation overhead.
* Solution would require index based access inside a VectorList, which might increase the
   complexity.
* UVIslands during 3d texturing is used as intermediate data, the final data is stored as PackedPixelRows.
   We could proceed converting UVIslands as well, but that would lower the performance noticeably.
   3D texturing has performance requirements, so when doing so we should make sure that
   it matches that as well.

Reviewed By: HooglyBoogly

Maniphest Tasks: T101740

Differential Revision: https://developer.blender.org/D16752
2023-01-12 08:35:38 +01:00
0349a6e6e0 Fix disappearing snap indication in Measure tool
Snap cursor disappeared while dragging.

Regression in 2b32a2c3b
2023-01-11 23:03:25 -03:00
2b4bf586ad Fix T102920: Cycles doesn't support multiple outputs on muted nodes
Cycles converts internal links to converter nodes which don't do anything and
later on get collapsed by the graph optimization. However, the previous code
assumed that one Blender input socket maps to one Cycles input socket.

When a node is muted, there might be internal links from one input to multiple
outputs. In Cycles, this meant that one Blender input socket now mapped to
multiple input sockets on all the converter nodes, so only the last one survived.

THe fix is simple, just make the mapping a MultiMap.
2023-01-12 00:53:05 +01:00
2b32a2c3b2 Snap Gizmo: hide snap cursor if another gizmo is highlighted 2023-01-11 18:52:30 -03:00
442b08aac0 Snap Gizmo: support the WM_GIZMO_HIDDEN flag
Support snap cursor removal in poll callback, this makes it possible to
delay cursor removal if the gizmo is hidden.
2023-01-11 18:27:16 -03:00
ff86573d72 Fix T102313: Enabling shadow catcher in viewport render shows self-shadowing
The problem here is that whether an object is a shadow catcher or not affects the
visibility flags, but changes to the shadow catcher property did not trigger a
visibility flag update.
2023-01-11 21:36:46 +01:00
88e9826529 Sculpt: Fix T102889: Sculpt trim tool extrudes in perspective
Added an extrude mode enum to the trim operators to
control extrusion: "project" and "fixed."  "Fixed" just
extrudes along a fixed normal and is the new default.
2023-01-11 09:57:58 -08:00
4d1f12212b Transform: deduplicate code
Edge Bevel Weight and Edge Crease operations have the same code.

Only the name displayed in the header changes.
2023-01-11 13:08:42 -03:00
5029f3e483 Fix crease and bevel weight unaffected when transforming
Regression in 3b761901b
2023-01-11 12:49:19 -03:00
ad01cdd7fc Transform: improve safety when restoring data 2023-01-11 12:08:04 -03:00
3b761901b6 Fix T103783: crash when canceling vertex crease having vertex groups
`transdata_restore_basic` uses `copy_v3_v3` to restore a pointer that is 1D.
2023-01-11 11:52:41 -03:00
a6b6f5db10 Fix issue with recent refactor in liboverride diffing.
New code from rBd05909a70c36 last week did not take into account
liboverride templates and `NOOP` operations. So we cannot assume that
there is no valid override property for these which need to be restored.

While we may get rid of templates at some point now, for now they are
still exposed in PY API, and have some basic unittests, so keep them
working as best as possible.

Issue reported on IRC by Martijn Versteegh (@Baardaap), thanks!
2023-01-11 15:32:06 +01:00
5d07b0e6da Cleanup: delegate to string_view equality for StringRef
This also fixes an issue introduced in rBd3e8d63a8c455d0,
where the function relied on the `StringRef` being null-terminated.
2023-01-11 13:19:11 +01:00
8f7bb812c4 Gitea: Add Issue and Pull Request templates
It is a part of the Phabricator to Gitea migration.

The issue template is based on the bug submission instructions which
are shown in the Phabricator's bug submission form. Some further tweaks
are likely needed, but the current version of the template simplifies
re-iteration while working on the migration.

The pull request template is needed to override the template in the
.github folder which is otherwise picked up by Gitea.
2023-01-11 11:46:53 +01:00
866b24ac88 Cleanup: use continue in loop to reduce right-shift 2023-01-11 21:08:15 +11:00
cff2807aff Fix T103719: missing shortcuts info for some tool-settings
Tool settings can be accessed from both `tool_settings` &
`scene.tool_settings`.

As of [0] `scene.tool_settings` was used instead of `tool_settings`
causing the snap shortcut not to display.

Resolve by supporting variations of data-paths so both are detected.

[0]: 9a76dd2454
2023-01-11 21:02:21 +11:00
d3e8d63a8c Fix error in StringRef equality
Regression in [0] wasn't correct as it's important for empty strings
to be equal to nullptr.

[0]: 9f283bee7e
2023-01-11 20:04:00 +11:00
68c6fc6d38 Fix T103267: No shortcuts shown in the Pose Assets context menu
Support displaying shortcuts for uiListDyn.custom_drag_* &
custom_activate_* operators.
2023-01-11 19:25:12 +11:00
f88e788569 Pose Slide: set the value of "release_confirm" from the event when unset
Needed to fix T103267, so the properties for the menu item and the
drag action will match & show the shortcut in the menu.
2023-01-11 19:25:06 +11:00
d8d20e0e59 UI: include 'drag-' prefix in the short-cut text for menu items
This was already done for double-click events but not drag events.
2023-01-11 17:54:12 +11:00
86464cfcef Fix error converting UV's to MLoopUV
Logic to skip UV layers that are part of the MLoopUV treated all
loop-layers as UV's, causing duplicate and invalid names to be added
to be added to 'uv_sublayers_to_skip', this asserted in debug mode
when saving the `ellie_animation.blend` demo blend file.
2023-01-11 14:03:57 +11:00
28d38e876f Cleanup: rename face_corners to loop for internal layer operations
Follows naming used elsewhere.
2023-01-11 14:00:20 +11:00
bd7a1d5de6 Docs: improve doc-string for UI_BUT_HAS_SEP_CHAR & UI_SEP_CHAR 2023-01-11 13:41:14 +11:00
32812c2cc2 Cleanup: Remove redundant mesh data mask handling
Byte colors are generic attributes and are therefore included in
CD_MASK_PROP_ALL. Also clarify the use of vertex groups.
They always have to be propagated since they're displayed in
the spreadsheet, etc.
2023-01-10 21:14:03 -05:00
8367f2bffc Cleanup: function style casts for C++ 2023-01-11 13:04:23 +11:00
494c3ba063 Cleanup: quiet warning mixing enum/int & replace NULL with nullptr 2023-01-11 13:04:23 +11:00
12a26b8fe3 Cleanup: format 2023-01-11 13:04:23 +11:00
9f283bee7e BLI_string_ref: avoid passing null to strncmp (quiet ASAN warning)
The existing logic to avoid passing null only worked when both
strings were null.
2023-01-11 13:04:23 +11:00
bd9602036a Fix pose-slide failing with array custom properties
Pose slide would attempt to use non-array functions to get/set RNA
array properties. Asserting in debug mode.
2023-01-11 13:04:17 +11:00
50d6af1e0e Fix invalid string comparison
Error from recent addition: 250eda36b8.
Compare the enum value instead.
2023-01-11 13:03:44 +11:00
dd9e1eded0 Mesh: Move sharp edge flag to generic attribute
Move the `ME_SHARP` flag for mesh edges to a generic boolean
attribute. This will help allow changing mesh edges to just a pair
of integers, giving performance improvements. In the future it could
also give benefits for normal calculation, which could more easily
check if all or no edges are marked sharp, which is helpful considering
the plans in T93551.

The attribute is generally only allocated when it's necessary. When
leaving edit mode, it will only be created if an edge is marked sharp.
The data can be edited with geometry nodes just like a regular edge
domain boolean attribute.

The attribute is named `sharp_edge`, aiming to reflect the similar
`select_edge` naming and to allow a future `sharp_face` name in
a separate commit.

Ref T95966

Differential Revision: https://developer.blender.org/D16921
2023-01-10 16:12:14 -05:00
Damien Picard
30c90f0ad0 Cleanup: Replace "UV's" with "UVs"
An apostrophe should not be used because it is not a mark of plural,
even for initialisms. This involves mostly comments, but a few UI
messages are affected as well.

Differential Revision: https://developer.blender.org/D16749
2023-01-10 14:50:13 -05:00
5bc71f22a2 Snap Gizmo: remove unused "snap_elements"
This property was intended to keep the snap elements synchronized with the scene.

But another solution exists.

And this property is not even working correctly.
2023-01-10 15:56:17 -03:00
d397ecae32 Geometry Nodes: Add a selection input to the store named attribute node
This patch is a response to T101313.

Adds a selection to the Store Named Attribute node.

If the attribute does not exist unselected parts
are filled with zero values. Otherwise, only the
selected parts are filled.

Differential Revision: https://developer.blender.org/D16237
2023-01-10 18:16:08 +00:00
8a3a1a0c14 Fix T103781: assert when connecting viewer node on mesh without faces
`Span.data()` does not have to be `nullptr` when the size is zero.
This happens e.g. when slicing a span to a size of zero.
2023-01-10 17:14:28 +01:00
db688b62f9 Fix T103764: Grease Pencil modes other than Draw use a wrong radial
It was introduced in commit https://developer.blender.org/rB0fb12a9c2ebc

The problem was that the tool uses the same values for all modes,
but the new calculation must be only for Draw mode.

Now the mode is checked.
2023-01-10 17:00:58 +01:00
9b8c2f91f6 Cleanup: Compile filesel.c in C++
This is a mere "get this to compile in C++", didn't do changes like
using `MEM_cnew()` instead of `MEM_calloc()`.

Needed for the blender-project-basics branch, so I don't have to write C
wrappers for a single call from this file.
2023-01-10 16:36:56 +01:00
df5ebd348b Fix T103556: Cycles viewport unexpected pixel changes when hovering over UI
With the GPU API the sampler can not be set after texture binding, which caused
a delay of the actual change. Now do both in a single call for correctness and
performance.
2023-01-10 16:35:19 +01:00
3a98dc6812 Fix crash when dragging video into VSE timeline
Caused by NULL dereference in strip overlap handling (expand to fit),
because `time_dependent_strips` strip collection is not created.

Check if strip collection is provided in `query_right_side_strips()`.
2023-01-10 16:19:10 +01:00
09a5443f20 GPencil: Fix unreported wrong fill vertex color in Outline
The Fill vertex color was assigned to the wrong stroke. It needs to be
set in the perimeter stroke, not in the original one.
2023-01-10 16:13:51 +01:00
66af16571d Refactor: Use new "All" asset library to extend node menus with assets
Updates the add and search menu of the node editor to use the new "All"
asset library introduced in the previous commit. This simplifies code by
removing redundant logic to merge contents of multiple asset libraries.
2023-01-10 15:41:58 +01:00
35e54b52e6 Assets: "All" asset library
Adds a new built-in asset library that contains all other asset
libraries visible in the asset library selector menu. This also means
all their asset catalogs will be displayed as a single merged tree. The
asset catalogs are not editable, since this would require support for
writing multiple catalog definition files, which isn't there yet.

Often it's not relevant where an asset comes from. Users just want to be
able to get an asset quickly, comparable to how people use a search
engine to browse images or the web itself, instead of first going to a
dedicated platform. They don't want to bother with first choosing where
they want the result to come from.
This especially is needed for the Asset Shelf (T102879) that is being
developed for the brush assets project (T101895). With this, users will
have access to all their brushes efficiently from the 3D view, without
much browsing.

Did an informal review of the asset system bits with Sybren.
2023-01-10 15:41:58 +01:00
250eda36b8 GPencil: Build modifier add "natural drawing" time
This patch uses the recorded drawing speed to rebuild the strokes. This results in a way more
natural feel of the animation.

Here's a short summary of existing data used:

- gps->points->time: This is a timestamp in seconds of when the point was created
  since the creation of the stroke. It's quite often 0 (I added a sanitization routine).
- gpf->inittime: This is a timestamp in seconds when a stroke was drawn measured
  since some unknown point in time. I only ever use the difference between two strokes,
  so the absolute value is not relevant.

Reviewed By: frogstomp, antoniov, mendio

Differential Revision: https://developer.blender.org/D16759
2023-01-10 15:38:46 +01:00
fddb76e9af Fix: new Grease Pencil layer not selected when added from the viewport
When adding a new layer from the viewport, the newly created layer
is set as active, which is visible in the properties panel,
but the selection in the dopesheet was not updated accordingly,
due to a missing notifier which is added in this patch.
2023-01-10 15:20:35 +01:00
Jeroen Bakker
597aecc016 MacOS: Update Min Requirement to 10.15.
A few weeks ago we enabled the Metal back-end for the viewport.
Due to metal, master is only able to build on MacOS 10.15 and above.
The previous minimum requirement is MacOS 10.13.

It was already planned to bump to a higher version for Blender 3.6. After
a short discussion via bf-committers it was decided that it is fine to bump it for
3.5 release.

This patch cleans up the CMake files and update the minimum requirement.

With this patch the next deprecations will be listsed.
- `NSOpenGLView`, `NSOpenGLContext` is deprecated. (replaced by metal)
- `NSStringPboardType` is replaced by `NSPasteboardTypeString`
- `NSTIFFPboardType` is replaced by `NSPasteboardTypeTIFF`
- `NSFilenamesPboardType` should be replaved by multiple pasteboard items with `NSPasteboardTypeFileURL` instead.
- `NSUserNotification` should be replaced with UserNotifications.frameworks API

Deprecations will be handled in separate tasks and commits. OpenGL won't be
fixed at this moment, as it will be phased out in the future. NSStringPboardType, NSTiffPboardType & NSFilenamesPboardType
 will be provided in a single patch. NSUserNotification will also be provided in
its own patch.

Reviewed By: brecht, sergey

Differential Revision: https://developer.blender.org/D16953
2023-01-10 15:01:16 +01:00
387fc9b40b MacOS: Silence OpenGL deprecation warnings.
OpenGL is deprecated by Apple and triggers a warning when used. The goal
is that OpenGL is replaced by Metal backend, but we are not there yet.

To improve tracability of new warnings we hide deprecation warnings
when the GHOST_ContextCGL.h file is included.

NOTE: This change silences other deprecation warnings as well.
2023-01-10 14:57:23 +01:00
c6b4bd407e Cleanup: deduplicate conditions in transform code
The `t->spacetype` check is already done in `setSnappingCallback`.
2023-01-10 09:35:59 -03:00
6f38ce5a40 Fix T103679: Add missing operators in object context menu for point cloud and curves
Set origin and convert operator now accepts point cloud and new curve
object. But these operators were not added in context menu.
Support for set origin and convert operator was added in
rBadb4dd911b91, rB933d56d9e98d and rB2752a88478a8

Reviewed by: HooglyBoogly

Differential Revision: https://developer.blender.org/D16939
2023-01-10 15:27:57 +05:30
b7f5e4b1b6 Fix building on MSVC
Empty struct introduced in dad9f45561.
2023-01-10 19:04:07 +11:00
ed66321996 GHOST/Wayland: simplify logic for disconnecting monitors under Wayland
The T103586 fix effectively ran the wl_surface_listener.leave callback
to as WLROOTS based compositors doesn't run them. Remove the workaround
since it's an error in WLROOTS to be fixed upstream.

Temporarily using the wrong window scale when disconnecting a monitor
on configurations that use different DPI per monitor is a minor enough
issue that I don't think it makes sense to workaround in GHOST.
2023-01-10 17:50:29 +11:00
dad9f45561 Cleanup: move run-time members of SurfaceModifierData into a struct
Using run-time members in the surface modifier complicated code-review
and caused an unnecessary renaming in `dna_rename_defs.h`.

Also rename:
- `x` -> `vert_positions_prev`.
- `v` -> `vert_velocities`.
- `cfra` -> `cfra_prev`.
2023-01-10 17:19:30 +11:00
Sebastian Herholz
3696dff676 Merge branch 'master' into cycles_path_guiding 2022-12-09 13:17:22 +01:00
Sebastian Herholz
98398f5a5d Merge branch 'master' into cycles_path_guiding 2022-11-09 09:13:08 +01:00
Sebastian Herholz
3e3ec87846 Merge branch 'master' into cycles_path_guiding 2022-10-14 21:12:04 +02:00
Sebastian Herholz
15bfc836a0 Deps: Switching to new version of OpenPGL 0.4.0 2022-10-14 21:02:29 +02:00
Sebastian Herholz
6629f6ccc5 Deps: Switching to bugfix version of OpenPGL 0.4.0 2022-10-14 13:34:16 +02:00
Sebastian Herholz
209dc4c695 Merge branch 'master' into cycles_path_guiding 2022-10-14 12:32:03 +02:00
Sebastian Herholz
b047a003f6 Cycles: Reset path segment during shadow path init (when path guiding) 2022-10-10 11:35:07 +02:00
Sebastian Herholz
4e460bc5b3 Cycles: Limiting spatial resolution of the guiding caches 2022-10-10 11:31:36 +02:00
Sebastian Herholz
7a88402cc9 Merge branch 'master' into cycles_path_guiding 2022-10-10 10:19:52 +02:00
Sebastian Herholz
82056b26b0 Merge branch 'master' into cycles_path_guiding 2022-10-06 14:40:37 +02:00
Sebastian Herholz
65c248af72 Cycles: Explicitly reset all guiding related state variables at path initialization 2022-10-06 10:42:55 +02:00
Sebastian Herholz
896a333867 Cycles: Do not use path guiding in (almost) delta volumes 2022-10-06 10:41:05 +02:00
Sebastian Herholz
5ce446f90c Cycles: enable the use of external Open PGL builds 2022-10-06 10:37:22 +02:00
Sebastian Herholz
f93823e9d4 Merge branch 'master' into cycles_path_guiding
# Conflicts:
#	build_files/build_environment/cmake/harvest.cmake
#	intern/cycles/cmake/external_libs.cmake
#	intern/cycles/integrator/path_trace.cpp
#	intern/cycles/integrator/path_trace_work_cpu.h
#	intern/cycles/kernel/integrator/guiding.h
#	intern/cycles/kernel/integrator/state_template.h
#	intern/cycles/kernel/integrator/volume_shader.h
2022-10-06 10:27:42 +02:00
4bb41ed439 Fix Metal build errors 2022-09-24 05:41:26 +02:00
4eda313942 Merge branch 'master' into cycles_path_guiding 2022-09-24 03:58:20 +02:00
bc2275ebda Merge branch 'master' into cycles_path_guiding 2022-09-23 21:35:30 +02:00
5bf003db05 Fix principled hair test failure 2022-09-23 21:35:03 +02:00
1aeb742c85 Disable guiding tests until new deterministic OpenPGL version. 2022-09-23 21:07:09 +02:00
a6396b143d Workaround HIP compiler bug
Cause is unclear, just changing around code enough to sidestep it.
2022-09-23 21:06:49 +02:00
5f10d9990a Fix CUDA build error 2022-09-23 21:06:15 +02:00
8482dbf7b0 Fix build error for Metal 2022-09-23 16:06:23 +02:00
7b5c506088 Merge branch 'master' into cycles_path_guiding 2022-09-22 20:53:48 +02:00
148c4d4289 Cycles: BSDF eval refactor to remove separate reflection/refraction methods
Simplifies code overall to do it inside the eval function, most of the BSDFs
already compute the dot product.
2022-09-22 20:52:47 +02:00
2338f3a490 Fix subtle difference in volume shadow path termination
Volume shadow integration should get the full throughput to make a decision
when opacity falls is above the threshold.
2022-09-21 21:39:57 +02:00
9c3f1e01e7 Simplify/optimize code for initializing integrator state
* Don't duplicate some openpgl pointers from kernel globals in state, only
  adds overhead.
* Reserve path segment storage only once in kernel globals.
* Reduce PATH_GUIDING_LEVEL checks, in a way that should not affect performance.
2022-09-21 21:38:12 +02:00
bdbb73b172 Minor renaming and cleanup 2022-09-21 21:11:47 +02:00
581f0b2ce7 Fix crash with directly visible volume emission 2022-09-21 21:11:47 +02:00
2019385b10 Merge branch 'master' into cycles_path_guiding
Different solution for negative BSDF weights was implemented in master.
2022-09-20 21:09:29 +02:00
59979c3d8f Simplify volume guiding and add TODO comments about seemingly wrong code 2022-09-20 20:45:08 +02:00
e85f04c15d Simplify BSSRDF bounce recording. 2022-09-20 20:44:36 +02:00
d0cce099e5 Build: don't add PATH_GUIDING_DEBUG defines
This is a bit excessive, prefer to check WITH_CYCLES_DEBUG directly.
2022-09-20 20:44:36 +02:00
eb997a9d7f Cleanup: code style 2022-09-20 20:44:36 +02:00
8ec9800ef6 UI and defaults changes:
* Renaming Training Iterations to Samples, make 0 infinite samples matching
  the viewport samples behavior.
* Enable deterministic path guiding by default, make it debug option. Not
  yet ready to give on deterministic rendering even if it comes at a
  performance cost.
* Disable guiding by default internaly (was already done in Blender).
* Improve tooltips.
* Move Path Guiding panel above Advanced.
2022-09-20 20:44:36 +02:00
6689a6a848 Kernel implementation refactoring
* Isolate OpenPGL types and functions in kernel to guiding.h.
* Follow code style guidelines.
* Don't use VLOG in the kernel.
* Various renaming and code reshuffling.
2022-09-20 20:44:33 +02:00
68347715d8 Disable AVX2 guiding device until new OpenPGL version, minor code refactor. 2022-09-20 20:26:15 +02:00
013d758cb7 Fix broken training, train_guiding was not propagated to CPU threads 2022-09-20 20:26:15 +02:00
b0c4590130 Cleanup: tweak limit samples per update code, remove outdated TODO 2022-09-20 20:26:15 +02:00
4ae67097f4 Merge branch 'master' into cycles_path_guiding 2022-09-20 20:26:07 +02:00
a34cdb0814 Build: auto disable path guiding if OpenPGL not found 2022-09-20 20:22:13 +02:00
Sebastian Herhoz
a89e1c439e Guiding: Added support for guiding in overlapping volumes 2022-09-19 11:06:09 +02:00
Sebastian Herhoz
00f984f9ae Guiding: Code cleanup as well as adding functions to validate bsdf_label and bsdf_roughness_eta 2022-09-18 11:52:16 +02:00
Sebastian Herholz
059dae0f1a Guiding: commented out print outs 2022-09-17 22:22:44 +02:00
047ebfc383 Fix Arm build error 2022-09-15 19:42:48 +02:00
Sebastian Herholz
a8188b1388 Guiding: Added documentation to the guiding helper functions used to record paths 2022-09-09 13:16:26 +02:00
Sebastian Herholz
ee2fc1eb77 Guiding: Added option to enable deterministic path guiding
This commits enables to run the training of the guiding caches in a deterministic way.
As a result two individual renderings should result in exactly the same image.
Note: this option can increase the training time by 5-10%.
2022-09-08 14:25:26 +02:00
Sebastian Herholz
e262e4f289 Guiding: Added support to handle different Open PGL versions 2022-09-07 13:54:01 +02:00
Sebastian Herholz
b455a14252 Guiding: Added an option to set the number of training iterations
After a specific number of training iterations is reached no new training
samples are generated during rendering and the guiding structures
are not updated anymore. From now own the guiding structures are only queried
for sampling, which remove the overhead of collecting the training samples and
updating the structures.
2022-09-07 13:20:52 +02:00
Sebastian Herholz
6d137fd489 Guiding: Adding functionality to automatically check if at least SIMD4 support is available to activate guiding 2022-09-06 20:07:37 +02:00
Sebastian Herholz
364100b30a Guiding: changed naming of surface_shader_is_transmission
Change the naming of surface_shader_is_transmission to
surface_shader_is_transmission_sd and
surface_shader_is_transmission_sc to be able to better differentiate them.
2022-09-06 19:47:32 +02:00
Sebastian Herholz
52b7b219af Guiding: Some code cleanup 2022-09-06 19:44:28 +02:00
Sebastian Herholz
b3638c05e3 Guiding: Disabling guiding on translucent BSDFs 2022-09-06 12:13:28 +02:00
Sebastian Herholz
f4767bcd3c Guiding: Adding support for emissive volumes 2022-09-06 10:26:52 +02:00
Sebastian Herholz
edb873364d Guiding: Cleanup: Removed some unnecessary code/TODOs/snippets and added some comments 2022-09-05 20:14:15 +02:00
sherholz-intel
f510d96b0a Guiding: removed bssrdf_weight from the state 2022-09-05 10:43:01 +02:00
9098fab439 Merge branch 'master' into cycles_path_guiding 2022-09-02 18:49:36 +02:00
4b51c9da58 Merge branch 'master' into cycles_path_guiding 2022-09-01 18:27:57 +02:00
9ae8cec47a Fix potential correlation issues with PRNG_GUIDING 2022-08-25 21:51:02 +02:00
1c76982030 Cleanup: add utility functions for converting to pgl vectors 2022-08-25 21:29:30 +02:00
6362f2d8d1 Replace rr_throughput with factor to multiply with throughput
This seems simpler and more efficient overall.

It also removes a division by albedo of rr_throughput in random walk SSS,
which seems wrong.
2022-08-25 21:29:30 +02:00
fe2ec0ae13 Cleanup: rename/tweak film accumulation functions for consistency with guiding 2022-08-25 21:29:30 +02:00
54a6ae709f Refactor functions to record paths for path guiding:
* Use guiding_record_ prefix for all, and rename to better match Cycles
  terminology.
* Move #ifdefs into guiding.h where possible to simplify code calling these.
* Fix missing call to guiding_new_virtual_light_segment with volumes in front
  of lights, by moving this into the shade_light kernel.
* Fix missing call to guiding_add_background for distant lights.
2022-08-25 21:29:30 +02:00
72c90a2dc4 Add initial guiding regression tests 2022-08-25 21:16:50 +02:00
cca72b4d2e Merge branch 'master' into cycles_path_guiding 2022-08-25 15:32:31 +02:00
a99e1c1a03 Merge branch 'master' into cycles_path_guiding 2022-08-15 14:13:22 +02:00
5bab2098ae Guiding: use Cycles debug preference, instead of experimental
Enabled through Preferences > Interface > Show Developer UI, Experimental > Cycles Debug.
2022-08-11 17:10:41 +02:00
0f8df1b350 Guiding: create device on demand, store in unique_ptr, simplify device API 2022-08-11 16:37:32 +02:00
3c9a3ea992 Guiding: don't allocate integrator state for GPU
Using new KERNEL_FEATURE_PATH_GUIDING. Also ensure guiding gets disabled
in the integrator if the device does not support it.
2022-08-11 16:37:32 +02:00
6bf7e2868f Guiding: various changes to debug passes
* Remove OpenPGL from the name, use just Guiding instead
* Enable using WITH_CYCLES_DEBUG option instead of separate define
* Fix wrong PASS_CATEGORY_DATA_END (is blocks of 32 passes for bitflags)
2022-08-11 16:37:32 +02:00
bc5b47d41b Cleanup: changes to path guiding params
* Rename identifiers to be long, fix typo in label
* Remove redundant guiding params update in session
* Use unique_ptr for storage in Path Trace
* Various other tweaks.
2022-08-11 16:37:32 +02:00
0fee5d3fd4 Cleanup path: guiding #ifdefs
* Only use __PATH_GUIDING__ in the kernel, use WITH_PATH_GUIDING on the host side
* Reduce number of #ifdefs, should mainly be used for code that uses OpenPGL.
2022-08-11 16:37:32 +02:00
9a30e4b21c Cleanup: change assert to kernel_assert 2022-08-11 14:08:58 +02:00
ab69f9a758 Cleanup: move guiding utilities from state_util.h to new guiding.h 2022-08-11 14:02:43 +02:00
66c3f40da4 Merge branch 'master' into cycles_path_guiding
Adapting to the new Spectrum type.
2022-08-11 13:56:02 +02:00
Sebastian Herholz
7111f74bc4 Merge branch 'master' into cycles_path_guiding 2022-08-01 18:55:09 +02:00
Sebastian Herholz
cf6d4d5757 Cycles-X: Path Guiding: Moving ui settings to the Sampling section and renamed Guiding to Path Guiding 2022-07-25 12:35:00 +02:00
Sebastian Herholz
5fea147d46 Cycles-X: Path Guiding: (Internal) Renaming of the ui parameters (adding use_ prefix) 2022-07-25 11:58:46 +02:00
Sebastian Herholz
8c04bf54bf Cycles-X: Path Guiding: Cleaned up CMake scripts 2022-07-25 11:55:30 +02:00
Sebastian Herholz
e781b8482b Cycles-X: Path Guiding: setting WITH_CYCLES_PATH_GUIDING CMake option in the blender_full and blender_release cmake scripts 2022-07-25 11:04:13 +02:00
Sebastian Herholz
51340e21c5 Cycles-X: Path Guiding: turning on path guiding by default 2022-06-28 17:11:22 +02:00
Sebastian Herholz
28a98a7eec Cycles-X: Path Guiding: Fixing regression for random walk SSS and RR 2022-06-28 14:07:16 +02:00
Sebastian Herholz
681fa53dcc Cycles-X: Path Guiding: Fixing crash when turning guiding on/off during rendering. 2022-06-28 14:06:34 +02:00
Sebastian Herholz
ab2c1271ed Cycles-X: Path Guiding: UI: updating ui behavior
`Guiding` is now disabled by default.

The `Guiding` menu is now disabled when blender is compiled without path guiding support

The `Guiding` tap is now not visible anymore when using the GPU device.

Some of the guiding parameters are now only shown if the `Experimental` features are active.
2022-06-28 14:05:14 +02:00
591c7e79b7 deps: better fix for static embree
Problem is actually caused by

7619ec5c01

that removed the static define in rtcore_config.h
leading openpgl and blender both to assume we
were dealing with a dynamic embree which made
things rather unhappy at link time.

this adds a patch embree to generate a proper
rtcore_config.h header file again.
2022-06-24 21:11:28 -06:00
4cdff68309 deps: fix openpgl assuming dynamic embree
openpgl's build uses the embree config files which are
aware it is a static version of embree, but never
actually pass -DEMBREE_STATIC_LIB to openpgl's CXX flags,
resulting in the assumption that embree is dynamic,
which causes linker errors when we link it against
static embree in the final blender binary.
2022-06-24 13:21:43 -06:00
Sebastian Herholz
f4641a35e5 Cycles-X: Integration of path guiding using Intel's Open Path Guidign Library (Open PGL)
This patch adds path guiding features into Cycles
by integrating Intel®'s Open path guiding library
(Open PGL: https://github.com/OpenPathGuidingLibrary/openpgl).

The current implementation supports guiding directional sampling
decisions on surfaces, when the material contains a least one diffuse component,
and in volumes, with isotropic and anisotropic Henyey-Greenstein phase functions.

On surfaces, the guided sampling decision is proportional to the product of
the incident radiance and the normal-oriented cosine lobe and in volumes it
is proportional to the product of the incident radiance and the phase function.

The incident radiance field of a scene is learned and updated during rendering
after each per-frame rendering iteration/progression.

At the moment, path guiding is only supported by Cycles
CPU backend. Support for GPU backends will be added in
future versions of Open PGL.

To build Blender/Cycles with path guiding support, one only needs to enable
the CMake option `WITH_PATH_GUIDING`.
2022-06-24 13:07:23 +02:00
Sebastian Herholz
3235b657cd Cycles-X: clamping bsdf weights to be >= 0 and changing default value of eta to 1.0 2022-06-23 20:24:15 +02:00
Sebastian Herholz
0ef4d5bf1b Cycles-X: Path Guiding: Adding OpenPGL cmake flags and use OpenPGLs cmake config from Blender's dependency 2022-06-23 16:01:12 +02:00
Sebastian Herholz
0831b5ce86 Build: OpenPGL removed version number form the destination folder of the cmake configs 2022-06-23 16:00:23 +02:00
f7a57a5304 deps: openpgl updates for windows.
- tell the compiler to generate the _d postfix for debug
  libs, rather than renaming the openpgl.lib to openpgl_d.lib
  manually.
- enable the post install phase for windows.
- Small white space clean-up.
2022-06-22 13:07:48 -06:00
Sebastian Herholz
71a5a0f412 Build: OpenPGL: Adding Open PGL
Adding Intel's Open Path Guiding Library (v0.3.1) to the build scripts
2022-06-22 18:48:08 +02:00
Sebastian Herholz
d650b30c0a Build: Embree: updating to new version 3.13.4 and cleaning up embree.cmake script
The new version of Embree supports to set the name of the TBB component (i.e., tbb_static) and fixes the dllexport/dllimport for the static builds under Windows.
As a result we do not need to patch the Embree cmake scripts and can use them as-is.
2022-06-22 18:47:55 +02:00
1446 changed files with 64099 additions and 45553 deletions

View File

@@ -0,0 +1,5 @@
${CommitTitle}
${CommitBody}
Pull Request #${PullRequestIndex}

View File

@@ -0,0 +1,3 @@
${PullRequestTitle}
Pull Request #${PullRequestIndex}

View File

@@ -0,0 +1,44 @@
name: Bug Report
about: File a bug report
labels:
- "type::Report"
- "status::Needs Triage"
- "priority::Normal"
body:
- type: markdown
attributes:
value: |
### Instructions
First time reporting? See [tips](https://wiki.blender.org/wiki/Process/Bug_Reports).
* Use **Help > Report a Bug** in Blender to fill system information and exact Blender version.
* Test [daily builds](https://builder.blender.org/) to verify if the issue is already fixed.
* Test [previous versions](https://download.blender.org/release/) to find an older working version.
* For feature requests, feedback, questions or build issues, see [communication channels](https://wiki.blender.org/wiki/Communication/Contact#User_Feedback_and_Requests).
* If there are multiple bugs, make multiple bug reports.
- type: textarea
id: body
attributes:
label: "Description"
hide_label: true
value: |
**System Information**
Operating system:
Graphics card:
**Blender Version**
Broken: (example: 2.80, edbf15d3c044, master, 2018-11-28, as found on the splash screen)
Worked: (newest version of Blender that worked as expected)
**Short description of error**
**Exact steps for others to reproduce the error**
Based on the default startup or an attached .blend file (as simple as possible).
- type: markdown
attributes:
value: |
### Help the developers
Bug fixing is important, the developers will handle reports swiftly. For that reason, carefully provide exact steps and a **small and simple .blend file** to reproduce the problem. You do your half of the work, then we do our half!

View File

@@ -0,0 +1 @@
blank_issues_enabled: false

View File

@@ -0,0 +1,10 @@
name: Design
about: Create a design task (for developers only)
labels:
- "type::Design"
body:
- type: textarea
id: body
attributes:
label: "Description"
hide_label: true

View File

@@ -0,0 +1,10 @@
name: To Do
about: Create a to do task (for developers only)
labels:
- "type::To Do"
body:
- type: textarea
id: body
attributes:
label: "Description"
hide_label: true

View File

@@ -0,0 +1,17 @@
name: Pull Request
about: Contribute code to Blender
body:
- type: markdown
attributes:
value: |
### Instructions
Guides to [contributing code](https://wiki.blender.org/index.php/Dev:Doc/Process/Contributing_Code) and effective [code review](https://wiki.blender.org/index.php/Dev:Doc/Tools/Code_Review).
By submitting code here, you agree that the code is (compatible with) GNU GPL v2 or later.
- type: textarea
id: body
attributes:
label: "Description"
hide_label: true

View File

@@ -167,14 +167,26 @@ get_blender_version()
option(WITH_BLENDER "Build blender (disable to build only the blender player)" ON)
mark_as_advanced(WITH_BLENDER)
if(APPLE)
# In future, can be used with `quicklookthumbnailing/qlthumbnailreply` to create file
# thumbnails for say Finder. Turn it off for now.
option(WITH_BLENDER_THUMBNAILER "Build \"blender-thumbnailer\" thumbnail extraction utility" OFF)
elseif(WIN32)
option(WITH_BLENDER_THUMBNAILER "Build \"BlendThumb.dll\" helper for Windows explorer integration" ON)
if(WIN32)
option(WITH_BLENDER_THUMBNAILER "\
Build \"BlendThumb.dll\" helper for Windows explorer integration to support extracting \
thumbnails from `.blend` files."
ON
)
else()
option(WITH_BLENDER_THUMBNAILER "Build \"blender-thumbnailer\" thumbnail extraction utility" ON)
set(_option_default ON)
if(APPLE)
# In future, can be used with `quicklookthumbnailing/qlthumbnailreply`
# to create file thumbnails for say Finder.
# Turn it off for now, even though it can build on APPLE, it's not likely to be useful.
set(_option_default OFF)
endif()
option(WITH_BLENDER_THUMBNAILER "\
Build stand-alone \"blender-thumbnailer\" command-line thumbnail extraction utility, \
intended for use by file-managers to extract PNG images from `.blend` files."
${_option_default}
)
unset(_option_default)
endif()
option(WITH_INTERNATIONAL "Enable I18N (International fonts and text)" ON)
@@ -214,14 +226,19 @@ option(WITH_BULLET "Enable Bullet (Physics Engine)" ON)
option(WITH_SYSTEM_BULLET "Use the systems bullet library (currently unsupported due to missing features in upstream!)" )
mark_as_advanced(WITH_SYSTEM_BULLET)
option(WITH_OPENCOLORIO "Enable OpenColorIO color management" ON)
set(_option_default ON)
if(APPLE)
# There's no OpenXR runtime in sight for macOS, neither is code well
# tested there -> disable it by default.
option(WITH_XR_OPENXR "Enable VR features through the OpenXR specification" OFF)
mark_as_advanced(WITH_XR_OPENXR)
else()
option(WITH_XR_OPENXR "Enable VR features through the OpenXR specification" ON)
set(_option_default OFF)
endif()
option(WITH_XR_OPENXR "Enable VR features through the OpenXR specification" ${_option_default})
if(APPLE)
mark_as_advanced(WITH_XR_OPENXR)
endif()
unset(_option_default)
option(WITH_GMP "Enable features depending on GMP (Exact Boolean)" ON)
# Compositor
@@ -353,12 +370,13 @@ else()
set(WITH_COREAUDIO OFF)
endif()
if(NOT WIN32)
set(_option_default ON)
if(APPLE)
option(WITH_JACK "Enable JACK Support (http://www.jackaudio.org)" OFF)
else()
option(WITH_JACK "Enable JACK Support (http://www.jackaudio.org)" ON)
set(_option_default OFF)
endif()
option(WITH_JACK_DYNLOAD "Enable runtime dynamic JACK libraries loading" OFF)
option(WITH_JACK "Enable JACK Support (http://www.jackaudio.org)" ${_option_default})
unset(_option_default)
option(WITH_JACK_DYNLOAD "Enable runtime dynamic JACK libraries loading" OFF)
else()
set(WITH_JACK OFF)
endif()
@@ -399,6 +417,26 @@ mark_as_advanced(WITH_SYSTEM_GLOG)
# Freestyle
option(WITH_FREESTYLE "Enable Freestyle (advanced edges rendering)" ON)
# Libraries.
if(UNIX AND NOT APPLE)
# Optionally build without pre-compiled libraries.
# NOTE: this could be supported on all platforms however in practice UNIX is the only platform
# that has good support for detecting installed libraries.
option(WITH_LIBS_PRECOMPILED "\
Detect and link against pre-compiled libraries (typically found under \"../lib/\"). \
Disabling this option will use the system libraries although cached paths \
that point to pre-compiled libraries will be left as-is."
ON
)
mark_as_advanced(WITH_LIBS_PRECOMPILED)
option(WITH_STATIC_LIBS "Try to link with static libraries, as much as possible, to make blender more portable across distributions" OFF)
if(WITH_STATIC_LIBS)
option(WITH_BOOST_ICU "Boost uses ICU library (required for linking with static Boost built with libicu)." OFF)
mark_as_advanced(WITH_BOOST_ICU)
endif()
endif()
# Misc
if(WIN32 OR APPLE)
option(WITH_INPUT_IME "Enable Input Method Editor (IME) for complex Asian character input" ON)
@@ -406,11 +444,6 @@ endif()
option(WITH_INPUT_NDOF "Enable NDOF input devices (SpaceNavigator and friends)" ON)
if(UNIX AND NOT APPLE)
option(WITH_INSTALL_PORTABLE "Install redistributable runtime, otherwise install into CMAKE_INSTALL_PREFIX" ON)
option(WITH_STATIC_LIBS "Try to link with static libraries, as much as possible, to make blender more portable across distributions" OFF)
if(WITH_STATIC_LIBS)
option(WITH_BOOST_ICU "Boost uses ICU library (required for linking with static Boost built with libicu)." OFF)
mark_as_advanced(WITH_BOOST_ICU)
endif()
endif()
option(WITH_PYTHON_INSTALL "Copy system python into the blender install folder" ON)
@@ -491,7 +524,7 @@ endif()
if(NOT APPLE)
option(WITH_CYCLES_DEVICE_HIP "Enable Cycles AMD HIP support" ON)
option(WITH_CYCLES_HIP_BINARIES "Build Cycles AMD HIP binaries" OFF)
set(CYCLES_HIP_BINARIES_ARCH gfx900 gfx906 gfx90c gfx902 gfx1010 gfx1011 gfx1012 gfx1030 gfx1031 gfx1032 gfx1034 gfx1035 gfx1100 gfx1101 gfx1102 CACHE STRING "AMD HIP architectures to build binaries for")
set(CYCLES_HIP_BINARIES_ARCH gfx1010 gfx1011 gfx1012 gfx1030 gfx1031 gfx1032 gfx1034 gfx1035 gfx1100 gfx1101 gfx1102 CACHE STRING "AMD HIP architectures to build binaries for")
mark_as_advanced(WITH_CYCLES_DEVICE_HIP)
mark_as_advanced(CYCLES_HIP_BINARIES_ARCH)
endif()
@@ -605,10 +638,6 @@ else()
set(WITH_METAL_BACKEND OFF)
endif()
if(WITH_METAL_BACKEND)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum OS X deployment version" FORCE)
endif()
if(WIN32)
getDefaultWindowsPrefixBase(CMAKE_GENERIC_PROGRAM_FILES)
set(CPACK_INSTALL_PREFIX ${CMAKE_GENERIC_PROGRAM_FILES}/${})
@@ -997,6 +1026,8 @@ set(PLATFORM_LINKLIBS "")
# - CMAKE_EXE_LINKER_FLAGS_DEBUG
set(PLATFORM_LINKFLAGS "")
set(PLATFORM_LINKFLAGS_DEBUG "")
set(PLATFORM_LINKFLAGS_RELEASE "")
set(PLATFORM_LINKFLAGS_EXECUTABLE "")
if(NOT CMAKE_BUILD_TYPE MATCHES "Release")
if(WITH_COMPILER_ASAN)
@@ -1210,13 +1241,6 @@ if(WITH_OPENGL)
add_definitions(-DWITH_OPENGL)
endif()
#-----------------------------------------------------------------------------
# Configure Vulkan.
if(WITH_VULKAN_BACKEND)
list(APPEND BLENDER_GL_LIBRARIES ${VULKAN_LIBRARIES})
endif()
# -----------------------------------------------------------------------------
# Configure Metal
@@ -1266,12 +1290,14 @@ endif()
# -----------------------------------------------------------------------------
# Configure Bullet
if(WITH_BULLET AND WITH_SYSTEM_BULLET)
find_package(Bullet)
set_and_warn_library_found("Bullet" BULLET_FOUND WITH_BULLET)
else()
set(BULLET_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/extern/bullet2/src")
# set(BULLET_LIBRARIES "")
if(WITH_BULLET)
if(WITH_SYSTEM_BULLET)
find_package(Bullet)
set_and_warn_library_found("Bullet" BULLET_FOUND WITH_BULLET)
else()
set(BULLET_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/extern/bullet2/src")
set(BULLET_LIBRARIES "extern_bullet")
endif()
endif()
@@ -1431,6 +1457,9 @@ if(CMAKE_COMPILER_IS_GNUCC)
add_check_c_compiler_flag(C_WARNINGS C_WARN_TYPE_LIMITS -Wtype-limits)
add_check_c_compiler_flag(C_WARNINGS C_WARN_FORMAT_SIGN -Wformat-signedness)
add_check_c_compiler_flag(C_WARNINGS C_WARN_RESTRICT -Wrestrict)
# Useful but too many false positives and inconvenient to suppress each occurrence.
add_check_c_compiler_flag(C_WARNINGS C_WARN_NO_STRINGOP_OVERREAD -Wno-stringop-overread)
add_check_c_compiler_flag(C_WARNINGS C_WARN_NO_STRINGOP_OVERFLOW -Wno-stringop-overflow)
# C-only.
add_check_c_compiler_flag(C_WARNINGS C_WARN_NO_NULL -Wnonnull)
@@ -1470,6 +1499,9 @@ if(CMAKE_COMPILER_IS_GNUCC)
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_RESTRICT -Wrestrict)
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_NO_SUGGEST_OVERRIDE -Wno-suggest-override)
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_UNINITIALIZED -Wuninitialized)
# Useful but too many false positives and inconvenient to suppress each occurrence.
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_NO_STRINGOP_OVERREAD -Wno-stringop-overread)
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_NO_STRINGOP_OVERFLOW -Wno-stringop-overflow)
# causes too many warnings
if(NOT APPLE)

View File

@@ -71,6 +71,13 @@ Static Source Code Checking
* check_mypy: Checks all Python scripts using mypy,
see: source/tools/check_source/check_mypy_config.py scripts which are included.
Documentation Checking
* check_wiki_file_structure:
Check the WIKI documentation for the source-tree's file structure
matches Blender's source-code.
See: https://wiki.blender.org/wiki/Source/File_Structure
Spell Checkers
This runs the spell checker from the developer tools repositor.
@@ -481,6 +488,10 @@ check_smatch: .FORCE
check_mypy: .FORCE
@$(PYTHON) "$(BLENDER_DIR)/source/tools/check_source/check_mypy.py"
check_wiki_file_structure: .FORCE
@PYTHONIOENCODING=utf_8 $(PYTHON) \
"$(BLENDER_DIR)/source/tools/check_wiki/check_wiki_file_structure.py"
check_spelling_py: .FORCE
@cd "$(BUILD_DIR)" ; \
PYTHONIOENCODING=utf_8 $(PYTHON) \

38
README.md Normal file
View File

@@ -0,0 +1,38 @@
<!--
Keep this document short & concise,
linking to external resources instead of including content in-line.
See 'release/text/readme.html' for the end user read-me.
-->
Blender
=======
Blender is the free and open source 3D creation suite.
It supports the entirety of the 3D pipeline-modeling, rigging, animation, simulation, rendering, compositing,
motion tracking and video editing.
![Blender screenshot](https://code.blender.org/wp-content/uploads/2018/12/springrg.jpg "Blender screenshot")
Project Pages
-------------
- [Main Website](http://www.blender.org)
- [Reference Manual](https://docs.blender.org/manual/en/latest/index.html)
- [User Community](https://www.blender.org/community/)
Development
-----------
- [Build Instructions](https://wiki.blender.org/wiki/Building_Blender)
- [Code Review & Bug Tracker](https://developer.blender.org)
- [Developer Forum](https://devtalk.blender.org)
- [Developer Documentation](https://wiki.blender.org)
License
-------
Blender as a whole is licensed under the GNU General Public License, Version 3.
Individual files may have a different, but compatible license.
See [blender.org/about/license](https://www.blender.org/about/license) for details.

View File

@@ -2,7 +2,7 @@
# LLVM does not switch over to cpp17 until llvm 16 and building ealier versions with
# MSVC is leading to some crashes in ISPC. Switch back to their default on all platforms
# for now.
# for now.
string(REPLACE "-DCMAKE_CXX_STANDARD=17" " " DPCPP_CMAKE_FLAGS "${DEFAULT_CMAKE_FLAGS}")
if(WIN32)

View File

@@ -42,7 +42,7 @@ endif()
# LLVM does not switch over to cpp17 until llvm 16 and building ealier versions with
# MSVC is leading to some crashes in ISPC. Switch back to their default on all platforms
# for now.
# for now.
string(REPLACE "-DCMAKE_CXX_STANDARD=17" " " LLVM_CMAKE_FLAGS "${DEFAULT_CMAKE_FLAGS}")
# short project name due to long filename issues on windows

View File

@@ -10,9 +10,9 @@ if(WIN32)
DOWNLOAD_DIR ${DOWNLOAD_DIR}
URL_HASH ${SSL_HASH_TYPE}=${SSL_HASH}
PREFIX ${BUILD_DIR}/ssl
CONFIGURE_COMMAND echo "."
BUILD_COMMAND echo "."
INSTALL_COMMAND echo "."
CONFIGURE_COMMAND echo "."
BUILD_COMMAND echo "."
INSTALL_COMMAND echo "."
INSTALL_DIR ${LIBDIR}/ssl
)
else()
@@ -46,4 +46,4 @@ else()
INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/ssl/src/external_ssl/ && make install
INSTALL_DIR ${LIBDIR}/ssl
)
endif()
endif()

View File

@@ -29,7 +29,7 @@ elseif(UNIX)
set(USD_PLATFORM_FLAGS
-DPYTHON_INCLUDE_DIR=${LIBDIR}/python/include/python${PYTHON_SHORT_VERSION}/
-DPYTHON_LIBRARY=${LIBDIR}/tbb/lib/${LIBPREFIX}${TBB_LIBRARY}${SHAREDLIBEXT}
)
)
if(APPLE)
set(USD_SHARED_LINKER_FLAGS "-Xlinker -undefined -Xlinker dynamic_lookup")

View File

@@ -1,7 +1,7 @@
# SPDX-License-Identifier: GPL-2.0-or-later
if(WIN32)
set(XML2_EXTRA_ARGS
set(XML2_EXTRA_ARGS
-DLIBXML2_WITH_ZLIB=OFF
-DLIBXML2_WITH_LZMA=OFF
-DLIBXML2_WITH_PYTHON=OFF

View File

@@ -19,9 +19,13 @@ ENDIF()
SET(_moltenvk_SEARCH_DIRS
${MOLTENVK_ROOT_DIR}
${LIBDIR}/vulkan/MoltenVK
)
# FIXME: These finder modules typically don't use LIBDIR,
# this should be set by `./build_files/cmake/platform/` instead.
IF(DEFINED LIBDIR)
SET(_moltenvk_SEARCH_DIRS ${_moltenvk_SEARCH_DIRS} ${LIBDIR}/moltenvk)
ENDIF()
FIND_PATH(MOLTENVK_INCLUDE_DIR
NAMES

View File

@@ -17,9 +17,13 @@ ENDIF()
SET(_optix_SEARCH_DIRS
${OPTIX_ROOT_DIR}
"$ENV{PROGRAMDATA}/NVIDIA Corporation/OptiX SDK 7.3.0"
)
# TODO: Which environment uses this?
if(DEFINED ENV{PROGRAMDATA})
list(APPEND _optix_SEARCH_DIRS "$ENV{PROGRAMDATA}/NVIDIA Corporation/OptiX SDK 7.3.0")
endif()
FIND_PATH(OPTIX_INCLUDE_DIR
NAMES
optix.h

View File

@@ -67,6 +67,8 @@ ENDIF()
STRING(REPLACE "." "" PYTHON_VERSION_NO_DOTS ${PYTHON_VERSION})
SET(_PYTHON_ABI_FLAGS "")
SET(_python_SEARCH_DIRS
${PYTHON_ROOT_DIR}
"$ENV{HOME}/py${PYTHON_VERSION_NO_DOTS}"

View File

@@ -0,0 +1,63 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2023 Blender Foundation.
# - Find ShaderC libraries
# Find the ShaderC includes and libraries
# This module defines
# SHADERC_INCLUDE_DIRS, where to find MoltenVK headers, Set when
# SHADERC_INCLUDE_DIR is found.
# SHADERC_LIBRARIES, libraries to link against to use ShaderC.
# SHADERC_ROOT_DIR, The base directory to search for ShaderC.
# This can also be an environment variable.
# SHADERC_FOUND, If false, do not try to use ShaderC.
#
# If SHADERC_ROOT_DIR was defined in the environment, use it.
IF(NOT SHADERC_ROOT_DIR AND NOT $ENV{SHADERC_ROOT_DIR} STREQUAL "")
SET(SHADERC_ROOT_DIR $ENV{SHADERC_ROOT_DIR})
ENDIF()
SET(_shaderc_SEARCH_DIRS
${SHADERC_ROOT_DIR}
)
# FIXME: These finder modules typically don't use LIBDIR,
# this should be set by `./build_files/cmake/platform/` instead.
IF(DEFINED LIBDIR)
SET(_shaderc_SEARCH_DIRS ${_shaderc_SEARCH_DIRS} ${LIBDIR}/shaderc)
ENDIF()
FIND_PATH(SHADERC_INCLUDE_DIR
NAMES
shaderc/shaderc.h
HINTS
${_shaderc_SEARCH_DIRS}
PATH_SUFFIXES
include
)
FIND_LIBRARY(SHADERC_LIBRARY
NAMES
shaderc_combined
HINTS
${_shaderc_SEARCH_DIRS}
PATH_SUFFIXES
lib
)
# handle the QUIETLY and REQUIRED arguments and set SHADERC_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(ShaderC DEFAULT_MSG SHADERC_LIBRARY SHADERC_INCLUDE_DIR)
IF(SHADERC_FOUND)
SET(SHADERC_LIBRARIES ${SHADERC_LIBRARY})
SET(SHADERC_INCLUDE_DIRS ${SHADERC_INCLUDE_DIR})
ENDIF()
MARK_AS_ADVANCED(
SHADERC_INCLUDE_DIR
SHADERC_LIBRARY
)
UNSET(_shaderc_SEARCH_DIRS)

View File

@@ -0,0 +1,63 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2023 Blender Foundation.
# - Find Vulkan libraries
# Find the Vulkan includes and libraries
# This module defines
# VULKAN_INCLUDE_DIRS, where to find Vulkan headers, Set when
# VULKAN_INCLUDE_DIR is found.
# VULKAN_LIBRARIES, libraries to link against to use Vulkan.
# VULKAN_ROOT_DIR, The base directory to search for Vulkan.
# This can also be an environment variable.
# VULKAN_FOUND, If false, do not try to use Vulkan.
#
# If VULKAN_ROOT_DIR was defined in the environment, use it.
IF(NOT VULKAN_ROOT_DIR AND NOT $ENV{VULKAN_ROOT_DIR} STREQUAL "")
SET(VULKAN_ROOT_DIR $ENV{VULKAN_ROOT_DIR})
ENDIF()
SET(_vulkan_SEARCH_DIRS
${VULKAN_ROOT_DIR}
)
# FIXME: These finder modules typically don't use LIBDIR,
# this should be set by `./build_files/cmake/platform/` instead.
IF(DEFINED LIBDIR)
SET(_vulkan_SEARCH_DIRS ${_vulkan_SEARCH_DIRS} ${LIBDIR}/vulkan)
ENDIF()
FIND_PATH(VULKAN_INCLUDE_DIR
NAMES
vulkan/vulkan.h
HINTS
${_vulkan_SEARCH_DIRS}
PATH_SUFFIXES
include
)
FIND_LIBRARY(VULKAN_LIBRARY
NAMES
vulkan
HINTS
${_vulkan_SEARCH_DIRS}
PATH_SUFFIXES
lib
)
# handle the QUIETLY and REQUIRED arguments and set VULKAN_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Vulkan DEFAULT_MSG VULKAN_LIBRARY VULKAN_INCLUDE_DIR)
IF(VULKAN_FOUND)
SET(VULKAN_LIBRARIES ${VULKAN_LIBRARY})
SET(VULKAN_INCLUDE_DIRS ${VULKAN_INCLUDE_DIR})
ENDIF()
MARK_AS_ADVANCED(
VULKAN_INCLUDE_DIR
VULKAN_LIBRARY
)
UNSET(_vulkan_SEARCH_DIRS)

View File

@@ -6,18 +6,80 @@
import re
import sys
from typing import Optional
cmakelists_file = sys.argv[-1]
def main():
def count_backslashes_before_pos(file_data: str, pos: int) -> int:
slash_count = 0
pos -= 1
while pos >= 0:
if file_data[pos] != '\\':
break
pos -= 1
slash_count += 1
return slash_count
def extract_cmake_string_at_pos(file_data: str, pos_beg: int) -> Optional[str]:
assert file_data[pos_beg - 1] == '"'
pos = pos_beg
# Dummy assignment.
pos_end = pos_beg
while True:
pos_next = file_data.find('"', pos)
if pos_next == -1:
raise Exception("Un-terminated string (parse error?)")
count_slashes = count_backslashes_before_pos(file_data, pos_next)
if (count_slashes % 2) == 0:
pos_end = pos_next
# Found the closing quote.
break
# The quote was back-slash escaped, step over it.
pos = pos_next + 1
file_data[pos_next]
assert file_data[pos_end] == '"'
if pos_beg == pos_end:
return None
# See: https://cmake.org/cmake/help/latest/manual/cmake-language.7.html#escape-sequences
text = file_data[pos_beg: pos_end].replace(
# Handle back-slash literals.
"\\\\", "\\",
).replace(
# Handle tabs.
"\\t", "\t",
).replace(
# Handle escaped quotes.
"\\\"", "\"",
).replace(
# Handle tabs.
"\\;", ";",
).replace(
# Handle trailing newlines.
"\\\n", "",
)
return text
def main() -> None:
options = []
for l in open(cmakelists_file, 'r').readlines():
if not l.lstrip().startswith('#'):
l_option = re.sub(r'.*\boption\s*\(\s*(WITH_[a-zA-Z0-9_]+)\s+\"(.*)\"\s*.*', r'\g<1> - \g<2>', l)
if l_option != l:
l_option = l_option.strip()
if l_option.startswith('WITH_'):
options.append(l_option)
with open(cmakelists_file, 'r', encoding="utf-8") as fh:
file_data = fh.read()
for m in re.finditer(r"^\s*option\s*\(\s*(WITH_[a-zA-Z0-9_]+)\s+(\")", file_data, re.MULTILINE):
option_name = m.group(1)
option_descr = extract_cmake_string_at_pos(file_data, m.span(2)[1])
if option_descr is None:
# Possibly a parsing error, at least show something.
option_descr = "(UNDOCUMENTED)"
options.append("{:s}: {:s}".format(option_name, option_descr))
print('\n'.join(options))

View File

@@ -550,7 +550,9 @@ function(setup_platform_linker_libs
endif()
if(WIN32 AND NOT UNIX)
target_link_libraries(${target} ${PTHREADS_LIBRARIES})
if(DEFINED PTHREADS_LIBRARIES)
target_link_libraries(${target} ${PTHREADS_LIBRARIES})
endif()
endif()
# target_link_libraries(${target} ${PLATFORM_LINKLIBS} ${CMAKE_DL_LIBS})
@@ -1115,7 +1117,7 @@ function(find_python_package
# endif()
# Not set, so initialize.
else()
string(REPLACE "." ";" _PY_VER_SPLIT "${PYTHON_VERSION}")
string(REPLACE "." ";" _PY_VER_SPLIT "${PYTHON_VERSION}")
list(GET _PY_VER_SPLIT 0 _PY_VER_MAJOR)
# re-cache
@@ -1262,7 +1264,7 @@ endmacro()
# Utility to gather and install precompiled shared libraries.
macro(add_bundled_libraries library_dir)
if(EXISTS ${LIBDIR})
if(DEFINED LIBDIR)
set(_library_dir ${LIBDIR}/${library_dir})
if(WIN32)
file(GLOB _all_library_versions ${_library_dir}/*\.dll)
@@ -1275,7 +1277,7 @@ macro(add_bundled_libraries library_dir)
list(APPEND PLATFORM_BUNDLED_LIBRARY_DIRS ${_library_dir})
unset(_all_library_versions)
unset(_library_dir)
endif()
endif()
endmacro()
macro(windows_install_shared_manifest)

View File

@@ -97,20 +97,8 @@ add_bundled_libraries(materialx/lib)
if(WITH_VULKAN_BACKEND)
find_package(MoltenVK REQUIRED)
if(EXISTS ${LIBDIR}/vulkan)
set(VULKAN_FOUND On)
set(VULKAN_ROOT_DIR ${LIBDIR}/vulkan/macOS)
set(VULKAN_INCLUDE_DIR ${VULKAN_ROOT_DIR}/include)
set(VULKAN_LIBRARY ${VULKAN_ROOT_DIR}/lib/libvulkan.1.dylib)
set(SHADERC_LIBRARY ${VULKAN_ROOT_DIR}/lib/libshaderc_combined.a)
set(VULKAN_INCLUDE_DIRS ${VULKAN_INCLUDE_DIR} ${MOLTENVK_INCLUDE_DIRS})
set(VULKAN_LIBRARIES ${VULKAN_LIBRARY} ${SHADERC_LIBRARY} ${MOLTENVK_LIBRARIES})
else()
message(WARNING "Vulkan SDK was not found, disabling WITH_VULKAN_BACKEND")
set(WITH_VULKAN_BACKEND OFF)
endif()
find_package(ShaderC REQUIRED)
find_package(Vulkan REQUIRED)
endif()
if(WITH_OPENSUBDIV)

View File

@@ -155,8 +155,8 @@ if("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "arm64")
# M1 chips run Big Sur onwards.
set(OSX_MIN_DEPLOYMENT_TARGET 11.00)
else()
# 10.13 is our min. target, if you use higher sdk, weak linking happens
set(OSX_MIN_DEPLOYMENT_TARGET 10.13)
# 10.15 is our min. target, if you use higher sdk, weak linking happens
set(OSX_MIN_DEPLOYMENT_TARGET 10.15)
endif()
set(CMAKE_OSX_DEPLOYMENT_TARGET "${OSX_MIN_DEPLOYMENT_TARGET}" CACHE STRING "" FORCE)

View File

@@ -1,7 +1,12 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright 2022 Blender Foundation. All rights reserved.
# Auto update existing CMake caches for new libraries
# Auto update existing CMake caches for new libraries.
# Assert that `LIBDIR` is defined.
if(NOT (DEFINED LIBDIR))
message(FATAL_ERROR "Logical error, expected 'LIBDIR' to be defined!")
endif()
# Clear cached variables whose name matches `pattern`.
function(unset_cache_variables pattern)

View File

@@ -4,38 +4,52 @@
# Libraries configuration for any *nix system including Linux and Unix (excluding APPLE).
# Detect precompiled library directory
if(NOT DEFINED LIBDIR)
# Path to a locally compiled libraries.
set(LIBDIR_NAME ${CMAKE_SYSTEM_NAME}_${CMAKE_SYSTEM_PROCESSOR})
string(TOLOWER ${LIBDIR_NAME} LIBDIR_NAME)
set(LIBDIR_NATIVE_ABI ${CMAKE_SOURCE_DIR}/../lib/${LIBDIR_NAME})
# Path to precompiled libraries with known glibc 2.28 ABI.
set(LIBDIR_GLIBC228_ABI ${CMAKE_SOURCE_DIR}/../lib/linux_x86_64_glibc_228)
if(NOT WITH_LIBS_PRECOMPILED)
unset(LIBDIR)
else()
if(NOT DEFINED LIBDIR)
# Path to a locally compiled libraries.
set(LIBDIR_NAME ${CMAKE_SYSTEM_NAME}_${CMAKE_SYSTEM_PROCESSOR})
string(TOLOWER ${LIBDIR_NAME} LIBDIR_NAME)
set(LIBDIR_NATIVE_ABI ${CMAKE_SOURCE_DIR}/../lib/${LIBDIR_NAME})
# Choose the best suitable libraries.
if(EXISTS ${LIBDIR_NATIVE_ABI})
set(LIBDIR ${LIBDIR_NATIVE_ABI})
set(WITH_LIBC_MALLOC_HOOK_WORKAROUND True)
elseif(EXISTS ${LIBDIR_GLIBC228_ABI})
set(LIBDIR ${LIBDIR_GLIBC228_ABI})
if(WITH_MEM_JEMALLOC)
# jemalloc provides malloc hooks.
set(WITH_LIBC_MALLOC_HOOK_WORKAROUND False)
else()
# Path to precompiled libraries with known glibc 2.28 ABI.
set(LIBDIR_GLIBC228_ABI ${CMAKE_SOURCE_DIR}/../lib/linux_x86_64_glibc_228)
# Choose the best suitable libraries.
if(EXISTS ${LIBDIR_NATIVE_ABI})
set(LIBDIR ${LIBDIR_NATIVE_ABI})
set(WITH_LIBC_MALLOC_HOOK_WORKAROUND True)
elseif(EXISTS ${LIBDIR_GLIBC228_ABI})
set(LIBDIR ${LIBDIR_GLIBC228_ABI})
if(WITH_MEM_JEMALLOC)
# jemalloc provides malloc hooks.
set(WITH_LIBC_MALLOC_HOOK_WORKAROUND False)
else()
set(WITH_LIBC_MALLOC_HOOK_WORKAROUND True)
endif()
endif()
# Avoid namespace pollustion.
unset(LIBDIR_NATIVE_ABI)
unset(LIBDIR_GLIBC228_ABI)
endif()
# Avoid namespace pollustion.
unset(LIBDIR_NATIVE_ABI)
unset(LIBDIR_GLIBC228_ABI)
if(NOT (EXISTS ${LIBDIR}))
message(STATUS
"Unable to find LIBDIR: ${LIBDIR}, system libraries may be used "
"(disable WITH_LIBS_PRECOMPILED to suppress this message)."
)
unset(LIBDIR)
endif()
endif()
# Support restoring this value once pre-compiled libraries have been handled.
set(WITH_STATIC_LIBS_INIT ${WITH_STATIC_LIBS})
if(EXISTS ${LIBDIR})
if(DEFINED LIBDIR)
message(STATUS "Using pre-compiled LIBDIR: ${LIBDIR}")
file(GLOB LIB_SUBDIRS ${LIBDIR}/*)
@@ -85,7 +99,7 @@ endmacro()
# These are libraries that may be precompiled. For this we disable searching in
# the system directories so that we don't accidentally use them instead.
if(EXISTS ${LIBDIR})
if(DEFINED LIBDIR)
without_system_libs_begin()
endif()
@@ -97,6 +111,7 @@ find_package_wrapper(Epoxy REQUIRED)
if(WITH_VULKAN_BACKEND)
find_package_wrapper(Vulkan REQUIRED)
find_package_wrapper(ShaderC REQUIRED)
endif()
function(check_freetype_for_brotli)
@@ -114,7 +129,7 @@ endfunction()
if(NOT WITH_SYSTEM_FREETYPE)
# FreeType compiled with Brotli compression for woff2.
find_package_wrapper(Freetype REQUIRED)
if(EXISTS ${LIBDIR})
if(DEFINED LIBDIR)
find_package_wrapper(Brotli REQUIRED)
# NOTE: This is done on WIN32 & APPLE but fails on some Linux systems.
@@ -141,7 +156,7 @@ if(WITH_PYTHON)
if(WITH_PYTHON_MODULE AND NOT WITH_INSTALL_PORTABLE)
# Installing into `site-packages`, warn when installing into `./../lib/`
# which script authors almost certainly don't want.
if(EXISTS ${LIBDIR})
if(DEFINED LIBDIR)
path_is_prefix(LIBDIR PYTHON_SITE_PACKAGES _is_prefix)
if(_is_prefix)
message(WARNING "
@@ -217,7 +232,7 @@ if(WITH_CODEC_SNDFILE)
endif()
if(WITH_CODEC_FFMPEG)
if(EXISTS ${LIBDIR})
if(DEFINED LIBDIR)
set(FFMPEG_ROOT_DIR ${LIBDIR}/ffmpeg)
# Override FFMPEG components to also include static library dependencies
# included with precompiled libraries, and to ensure correct link order.
@@ -232,7 +247,7 @@ if(WITH_CODEC_FFMPEG)
vpx
x264
xvidcore)
if(EXISTS ${LIBDIR}/ffmpeg/lib/libaom.a)
if((DEFINED LIBDIR) AND (EXISTS ${LIBDIR}/ffmpeg/lib/libaom.a))
list(APPEND FFMPEG_FIND_COMPONENTS aom)
endif()
elseif(FFMPEG)
@@ -430,10 +445,13 @@ if(WITH_OPENIMAGEIO)
${PNG_LIBRARIES}
${JPEG_LIBRARIES}
${ZLIB_LIBRARIES}
${BOOST_LIBRARIES}
)
set(OPENIMAGEIO_DEFINITIONS "")
if(WITH_BOOST)
list(APPEND OPENIMAGEIO_LIBRARIES "${BOOST_LIBRARIES}")
endif()
if(WITH_IMAGE_TIFF)
list(APPEND OPENIMAGEIO_LIBRARIES "${TIFF_LIBRARY}")
endif()
@@ -451,7 +469,7 @@ add_bundled_libraries(openimageio/lib)
if(WITH_OPENCOLORIO)
find_package_wrapper(OpenColorIO 2.0.0)
set(OPENCOLORIO_DEFINITIONS)
set(OPENCOLORIO_DEFINITIONS "")
set_and_warn_library_found("OpenColorIO" OPENCOLORIO_FOUND WITH_OPENCOLORIO)
endif()
add_bundled_libraries(opencolorio/lib)
@@ -466,7 +484,7 @@ if(WITH_OPENIMAGEDENOISE)
endif()
if(WITH_LLVM)
if(EXISTS ${LIBDIR})
if(DEFINED LIBDIR)
set(LLVM_STATIC ON)
endif()
@@ -480,7 +498,7 @@ if(WITH_LLVM)
endif()
# Symbol conflicts with same UTF library used by OpenCollada
if(EXISTS ${LIBDIR})
if(DEFINED LIBDIR)
if(WITH_OPENCOLLADA AND (${LLVM_VERSION} VERSION_LESS "4.0.0"))
list(REMOVE_ITEM OPENCOLLADA_LIBRARIES ${OPENCOLLADA_UTF_LIBRARY})
endif()
@@ -536,7 +554,7 @@ if(WITH_CYCLES AND WITH_CYCLES_PATH_GUIDING)
endif()
endif()
if(EXISTS ${LIBDIR})
if(DEFINED LIBDIR)
without_system_libs_end()
endif()
@@ -551,9 +569,14 @@ else()
endif()
find_package(Threads REQUIRED)
list(APPEND PLATFORM_LINKLIBS ${CMAKE_THREAD_LIBS_INIT})
# used by other platforms
set(PTHREADS_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
# `FindThreads` documentation notes that this may be empty
# with the system libraries provide threading functionality.
if(CMAKE_THREAD_LIBS_INIT)
list(APPEND PLATFORM_LINKLIBS ${CMAKE_THREAD_LIBS_INIT})
# used by other platforms
set(PTHREADS_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
endif()
if(CMAKE_DL_LIBS)
list(APPEND PLATFORM_LINKLIBS ${CMAKE_DL_LIBS})
@@ -575,7 +598,7 @@ add_definitions(-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE
#
# Keep last, so indirectly linked libraries don't override our own pre-compiled libs.
if(EXISTS ${LIBDIR})
if(DEFINED LIBDIR)
# Clear the prefix path as it causes the `LIBDIR` to override system locations.
unset(CMAKE_PREFIX_PATH)
@@ -631,7 +654,7 @@ if(WITH_GHOST_WAYLAND)
# When dynamically linked WAYLAND is used and `${LIBDIR}/wayland` is present,
# there is no need to search for the libraries as they are not needed for building.
# Only the headers are needed which can reference the known paths.
if(EXISTS "${LIBDIR}/wayland" AND WITH_GHOST_WAYLAND_DYNLOAD)
if((DEFINED LIBDIR) AND (EXISTS "${LIBDIR}/wayland" AND WITH_GHOST_WAYLAND_DYNLOAD))
set(_use_system_wayland OFF)
else()
set(_use_system_wayland ON)
@@ -695,7 +718,7 @@ if(WITH_GHOST_WAYLAND)
add_definitions(-DWITH_GHOST_WAYLAND_LIBDECOR)
endif()
if(EXISTS "${LIBDIR}/wayland/bin/wayland-scanner")
if((DEFINED LIBDIR) AND (EXISTS "${LIBDIR}/wayland/bin/wayland-scanner"))
set(WAYLAND_SCANNER "${LIBDIR}/wayland/bin/wayland-scanner")
else()
pkg_get_variable(WAYLAND_SCANNER wayland-scanner wayland_scanner)

View File

@@ -43,6 +43,10 @@ update-code:
branch: trunk
commit_id: HEAD
path: lib/benchmarks
assets:
branch: trunk
commit_id: HEAD
path: lib/assets
#
# Buildbot only configs
@@ -59,7 +63,7 @@ buildbot:
optix:
version: '7.3.0'
ocloc:
version: '101.3430'
version: '101.4032'
cmake:
default:
version: any

View File

@@ -24,7 +24,7 @@ import os
import re
import platform
import string
import setuptools # type: ignore
import setuptools
import sys
from typing import (
@@ -208,7 +208,7 @@ def main() -> None:
return paths
# Ensure this wheel is marked platform specific.
class BinaryDistribution(setuptools.dist.Distribution): # type: ignore
class BinaryDistribution(setuptools.dist.Distribution):
def has_ext_modules(self) -> bool:
return True

View File

@@ -13,10 +13,10 @@ import sys
import make_utils
from make_utils import call
# Parse arguments
# Parse arguments.
def parse_arguments():
def parse_arguments() -> argparse.Namespace:
parser = argparse.ArgumentParser()
parser.add_argument("--ctest-command", default="ctest")
parser.add_argument("--cmake-command", default="cmake")

View File

@@ -104,17 +104,30 @@ def svn_update(args: argparse.Namespace, release_version: Optional[str]) -> None
svn_url_tests = svn_url + lib_tests
call(svn_non_interactive + ["checkout", svn_url_tests, lib_tests_dirpath])
# Update precompiled libraries and tests
lib_assets = "assets"
lib_assets_dirpath = os.path.join(lib_dirpath, lib_assets)
if not os.path.exists(lib_assets_dirpath):
print_stage("Checking out Assets")
if make_utils.command_missing(args.svn_command):
sys.stderr.write("svn not found, can't checkout assets\n")
sys.exit(1)
svn_url_assets = svn_url + lib_assets
call(svn_non_interactive + ["checkout", svn_url_assets, lib_assets_dirpath])
# Update precompiled libraries, assets and tests
if not os.path.isdir(lib_dirpath):
print("Library path: %r, not found, skipping" % lib_dirpath)
else:
paths_local_and_remote = []
if os.path.exists(os.path.join(lib_dirpath, ".svn")):
print_stage("Updating Precompiled Libraries and Tests (one repository)")
print_stage("Updating Precompiled Libraries, Assets and Tests (one repository)")
paths_local_and_remote.append((lib_dirpath, svn_url))
else:
print_stage("Updating Precompiled Libraries and Tests (multiple repositories)")
print_stage("Updating Precompiled Libraries, Assets and Tests (multiple repositories)")
# Separate paths checked out.
for dirname in os.listdir(lib_dirpath):
if dirname.startswith("."):

View File

@@ -13,16 +13,16 @@ Blender stores 4 main arrays to define mesh geometry.
- :class:`Mesh.polygons`: (reference a range of loops)
Each polygon reference a slice in the loop array, this way, polygons do not store vertices or corner data such as UV's directly,
Each polygon references a slice in the loop array, this way, polygons do not store vertices or corner data such as UVs directly,
only a reference to loops that the polygon uses.
:class:`Mesh.loops`, :class:`Mesh.uv_layers` :class:`Mesh.vertex_colors` are all aligned so the same polygon loop
indices can be used to find the UV's and vertex colors as with as the vertices.
indices can be used to find the UVs and vertex colors as with as the vertices.
To compare mesh API options see: :ref:`NGons and Tessellation Faces <info_gotcha_mesh_faces>`
This example script prints the vertices and UV's for each polygon, assumes the active object is a mesh with UVs.
This example script prints the vertices and UVs for each polygon, assumes the active object is a mesh with UVs.
"""
import bpy

View File

@@ -2098,6 +2098,8 @@ def write_rst_types_index(basepath):
fw(title_string("Types (bpy.types)", "="))
fw(".. module:: bpy.types\n\n")
fw(".. toctree::\n")
# Only show top-level entries (avoids unreasonably large pages).
fw(" :maxdepth: 1\n")
fw(" :glob:\n\n")
fw(" bpy.types.*\n\n")
@@ -2124,6 +2126,8 @@ def write_rst_ops_index(basepath):
write_example_ref("", fw, "bpy.ops")
fw(".. toctree::\n")
fw(" :caption: Submodules\n")
# Only show top-level entries (avoids unreasonably large pages).
fw(" :maxdepth: 1\n")
fw(" :glob:\n\n")
fw(" bpy.ops.*\n\n")
file.close()

View File

@@ -513,17 +513,19 @@ if(WITH_FFTW)
src/fx/Convolver.cpp
src/fx/ConvolverReader.cpp
src/fx/ConvolverSound.cpp
src/fx/Equalizer.cpp
src/fx/FFTConvolver.cpp
src/fx/HRTF.cpp
src/fx/ImpulseResponse.cpp
src/util/FFTPlan.cpp
)
set(FFTW_HDR
include/fx/BinauralSound.h
include/fx/BinauralSound.h
include/fx/BinauralReader.h
include/fx/Convolver.h
include/fx/ConvolverReader.h
include/fx/ConvolverSound.h
include/fx/Equalizer.h
include/fx/FFTConvolver.h
include/fx/HRTF.h
include/fx/HRTFLoader.h

View File

@@ -54,6 +54,7 @@
#ifdef WITH_CONVOLUTION
#include "fx/BinauralSound.h"
#include "fx/ConvolverSound.h"
#include "fx/Equalizer.h"
#endif
#include <cassert>
@@ -768,4 +769,14 @@ AUD_API AUD_Sound* AUD_Sound_Binaural(AUD_Sound* sound, AUD_HRTF* hrtfs, AUD_Sou
}
}
AUD_API AUD_Sound* AUD_Sound_equalize(AUD_Sound* sound, float *definition, int size, float maxFreqEq, int sizeConversion)
{
assert(sound);
std::shared_ptr<Buffer> buf = std::shared_ptr<Buffer>(new Buffer(sizeof(float)*size));
std::memcpy(buf->getBuffer(), definition, sizeof(float)*size);
AUD_Sound *equalizer=new AUD_Sound(new Equalizer(*sound, buf, size, maxFreqEq, sizeConversion));
return equalizer;
}
#endif

View File

@@ -397,6 +397,16 @@ extern AUD_API AUD_Sound* AUD_Sound_mutable(AUD_Sound* sound);
#ifdef WITH_CONVOLUTION
extern AUD_API AUD_Sound* AUD_Sound_Convolver(AUD_Sound* sound, AUD_ImpulseResponse* filter, AUD_ThreadPool* threadPool);
extern AUD_API AUD_Sound* AUD_Sound_Binaural(AUD_Sound* sound, AUD_HRTF* hrtfs, AUD_Source* source, AUD_ThreadPool* threadPool);
/**
* Creates an Equalizer for the sound
* \param sound The handle of the sound
* \param definition buffer of size*sizeof(float) with the array of equalization values
* \param maxFreqEq Maximum frequency refered by the array
* \param sizeConversion Size of the transformation. Must be 2^number (for example 1024, 2048,...)
* \return A handle to the Equalizer refered to that sound
*/
extern AUD_API AUD_Sound* AUD_Sound_equalize(AUD_Sound* sound, float *definition, int size, float maxFreqEq, int sizeConversion);
#endif
#ifdef __cplusplus

View File

@@ -53,6 +53,7 @@ extern AUD_API AUD_Handle* AUD_pauseAfter(AUD_Handle* handle, double seconds);
* \param buffer The buffer to write to. Must have a size of 3*4*length.
* \param length How many samples to read from the sound.
* \param samples_per_second How many samples to read per second of the sound.
* \param interrupt Must point to a short that equals 0. If it is set to a non-zero value, the method will be interrupted and return 0.
* \return How many samples really have been read. Always <= length.
*/
extern AUD_API int AUD_readSound(AUD_Sound* sound, float* buffer, int length, int samples_per_second, short* interrupt);

View File

@@ -5,12 +5,12 @@ import os
import codecs
import numpy
from distutils.core import setup, Extension
from setuptools import setup, Extension
if len(sys.argv) > 2 and sys.argv[1] == '--build-docs':
import subprocess
from distutils.core import Distribution
from distutils.command.build import build
from setuptools import Distribution
from setuptools.command.build import build
dist = Distribution()
cmd = build(dist)

106
extern/audaspace/include/fx/Equalizer.h vendored Normal file
View File

@@ -0,0 +1,106 @@
/*******************************************************************************
* Copyright 2022 Marcos Perez Gonzalez
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
#pragma once
/**
* @file Equalizer.h
* @ingroup fx
* The Equalizer class.
*/
#include <memory>
#include <vector>
#include "ISound.h"
#include "ImpulseResponse.h"
AUD_NAMESPACE_BEGIN
class Buffer;
class ImpulseResponse;
/**
* This class represents a sound that can be modified depending on a given impulse response.
*/
class AUD_API Equalizer : public ISound
{
private:
/**
* A pointer to the imput sound.
*/
std::shared_ptr<ISound> m_sound;
/**
* Local definition of Equalizer
*/
std::shared_ptr<Buffer> m_bufEQ;
/**
* A pointer to the impulse response.
*/
std::shared_ptr<ImpulseResponse> m_impulseResponse;
/**
* delete copy constructor and operator=
*/
Equalizer(const Equalizer&) = delete;
Equalizer& operator=(const Equalizer&) = delete;
/**
* Create ImpulseResponse from the definition in the Buffer,
* using at the end a minimum phase change
*/
std::shared_ptr<ImpulseResponse> createImpulseResponse();
/**
* Create an Impulse Response with minimum phase distortion using Homomorphic
* The input is an Impulse Response
*/
std::shared_ptr<Buffer> minimumPhaseFilterHomomorphic(std::shared_ptr<Buffer> original, int lOriginal, int lWork);
/**
* Create an Impulse Response with minimum phase distortion using Hilbert
* The input is an Impulse Response
*/
std::shared_ptr<Buffer> minimumPhaseFilterHilbert(std::shared_ptr<Buffer> original, int lOriginal, int lWork);
public:
/**
* Creates a new Equalizer.
* \param sound The sound that will be equalized
*/
Equalizer(std::shared_ptr<ISound> sound, std::shared_ptr<Buffer> bufEQ, int externalSizeEq, float maxFreqEq, int sizeConversion);
virtual ~Equalizer();
virtual std::shared_ptr<IReader> createReader();
/*
* Length of the external equalizer definition. It must be the number of "float" positions of the Buffer
*/
int external_size_eq;
/*
* Length of the internal equalizer definition
*/
int filter_length;
/*
* Maximum frequency used in the equalizer definition
*/
float maxFreqEq;
};
AUD_NAMESPACE_END

View File

@@ -27,7 +27,7 @@
AUD_NAMESPACE_BEGIN
BinauralReader::BinauralReader(std::shared_ptr<IReader> reader, std::shared_ptr<HRTF> hrtfs, std::shared_ptr<Source> source, std::shared_ptr<ThreadPool> threadPool, std::shared_ptr<FFTPlan> plan) :
m_reader(reader), m_hrtfs(hrtfs), m_source(source), m_N(plan->getSize()), m_threadPool(threadPool), m_position(0), m_eosReader(false), m_eosTail(false), m_transition(false), m_transPos(CROSSFADE_SAMPLES*NUM_OUTCHANNELS)
m_position(0), m_reader(reader), m_hrtfs(hrtfs), m_source(source), m_N(plan->getSize()), m_transition(false), m_transPos(CROSSFADE_SAMPLES*NUM_OUTCHANNELS), m_eosReader(false), m_eosTail(false), m_threadPool(threadPool)
{
if(m_hrtfs->isEmpty())
AUD_THROW(StateException, "The provided HRTF object is empty");

View File

@@ -23,7 +23,7 @@
AUD_NAMESPACE_BEGIN
Convolver::Convolver(std::shared_ptr<std::vector<std::shared_ptr<std::vector<std::complex<sample_t>>>>> ir, int irLength, std::shared_ptr<ThreadPool> threadPool, std::shared_ptr<FFTPlan> plan) :
m_N(plan->getSize()), m_M(plan->getSize()/2), m_L(plan->getSize()/2), m_irBuffers(ir), m_irLength(irLength), m_threadPool(threadPool), m_numThreads(std::min(threadPool->getNumOfThreads(), static_cast<unsigned int>(m_irBuffers->size() - 1))), m_tailCounter(0), m_eos(false)
m_N(plan->getSize()), m_M(plan->getSize()/2), m_L(plan->getSize()/2), m_irBuffers(ir), m_numThreads(std::min(threadPool->getNumOfThreads(), static_cast<unsigned int>(m_irBuffers->size() - 1))), m_threadPool(threadPool), m_irLength(irLength), m_tailCounter(0), m_eos(false)
{
m_resetFlag = false;

View File

@@ -24,7 +24,7 @@
AUD_NAMESPACE_BEGIN
ConvolverReader::ConvolverReader(std::shared_ptr<IReader> reader, std::shared_ptr<ImpulseResponse> ir, std::shared_ptr<ThreadPool> threadPool, std::shared_ptr<FFTPlan> plan) :
m_reader(reader), m_ir(ir), m_N(plan->getSize()), m_eosReader(false), m_eosTail(false), m_inChannels(reader->getSpecs().channels), m_irChannels(ir->getSpecs().channels), m_threadPool(threadPool), m_position(0)
m_position(0), m_reader(reader), m_ir(ir), m_N(plan->getSize()), m_eosReader(false), m_eosTail(false), m_inChannels(reader->getSpecs().channels), m_irChannels(ir->getSpecs().channels), m_threadPool(threadPool)
{
m_nChannelThreads = std::min((int)threadPool->getNumOfThreads(), m_inChannels);
m_futures.resize(m_nChannelThreads);

367
extern/audaspace/src/fx/Equalizer.cpp vendored Normal file
View File

@@ -0,0 +1,367 @@
/*******************************************************************************
* Copyright 2022 Marcos Perez Gonzalez
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
#include "fx/Equalizer.h"
#include <chrono>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <memory>
#include <string>
#include "Exception.h"
#include "fx/ConvolverReader.h"
#include "fx/ImpulseResponse.h"
#include "util/Buffer.h"
#include "util/FFTPlan.h"
#include "util/ThreadPool.h"
AUD_NAMESPACE_BEGIN
Equalizer::Equalizer(std::shared_ptr<ISound> sound, std::shared_ptr<Buffer> bufEQ, int externalSizeEq, float maxFreqEq, int sizeConversion) : m_sound(sound), m_bufEQ(bufEQ)
{
this->maxFreqEq = maxFreqEq;
this->external_size_eq = externalSizeEq;
filter_length = sizeConversion;
}
Equalizer::~Equalizer()
{
}
std::shared_ptr<IReader> Equalizer::createReader()
{
std::shared_ptr<FFTPlan> fp = std::shared_ptr<FFTPlan>(new FFTPlan(filter_length));
// 2 threads to start with
return std::shared_ptr<ConvolverReader>(new ConvolverReader(m_sound->createReader(), createImpulseResponse(), std::shared_ptr<ThreadPool>(new ThreadPool(2)), fp));
}
float calculateValueArray(float* data, float minX, float maxX, int length, float posX)
{
if(posX < minX)
return 1.0;
if(posX > maxX)
return data[length - 1];
float interval = (maxX - minX) / (float) length;
int idx = (int) ((posX - minX) / interval);
return data[idx];
}
void complex_prod(float a, float b, float c, float d, float* r, float* imag)
{
float prod1 = a * c;
float prod2 = b * d;
float prod3 = (a + b) * (c + d);
// Real Part
*r = prod1 - prod2;
// Imaginary Part
*imag = prod3 - (prod1 + prod2);
}
/**
* The creation of the ImpuseResponse which will be convoluted with the sound
*
* The implementation is based on scikit-signal
*/
std::shared_ptr<ImpulseResponse> Equalizer::createImpulseResponse()
{
std::shared_ptr<FFTPlan> fp = std::shared_ptr<FFTPlan>(new FFTPlan(filter_length));
fftwf_complex* buffer = (fftwf_complex*) fp->getBuffer();
std::memset(buffer, 0, filter_length * sizeof(fftwf_complex));
std::shared_ptr<IReader> soundReader = m_sound.get()->createReader();
Specs specsSound = soundReader.get()->getSpecs();
int sampleRate = specsSound.rate;
for(unsigned i = 0; i < filter_length / 2; i++)
{
double freq = (((float) i) / (float) filter_length) * (float) sampleRate;
double dbGain = calculateValueArray(m_bufEQ->getBuffer(), 0.0, maxFreqEq, external_size_eq, freq);
// gain = 10^(decibels / 20.0)
// 0 db = 1
// 20 db = 10
// 40 db = 100
float gain = (float) pow(10.0, dbGain / 20.0);
if(i == filter_length / 2 - 1)
{
gain = 0;
}
// IMPORTANT!!!! It is needed for the minimum phase step.
// Without this, the amplitude would be square rooted
//
gain *= gain;
// Calculation of exponential with std.. or "by hand"
/*
std::complex<float> preShift= std::complex<float>(0.0, -(filter_length - 1)
/ 2. * M_PI * freq / ( sampleRate/2)); std::complex<float> shift =
std::exp(preShift);
std::complex<float> cGain = gain * shift;
*/
float imaginary_shift = -(filter_length - 1) / 2. * M_PI * freq / (sampleRate / 2);
float cGain_real = gain * cos(imaginary_shift);
float cGain_imag = gain * sin(imaginary_shift);
int i2 = filter_length - i - 1;
buffer[i][0] = cGain_real; // Real
buffer[i][1] = cGain_imag; // Imag
if(i > 0 && i2 < filter_length)
{
buffer[i2][0] = cGain_real; // Real
buffer[i2][1] = cGain_imag; // Imag
}
}
// In place. From Complex to sample_t
fp->IFFT(buffer);
// Window Hamming
sample_t* pt_sample_t = (sample_t*) buffer;
float half_filter = ((float) filter_length) / 2.0;
for(int i = 0; i < filter_length; i++)
{
// Centered in filter_length/2
float window = 0.54 - 0.46 * cos((2 * M_PI * (float) i) / (float) (filter_length - 1));
pt_sample_t[i] *= window;
}
std::shared_ptr<Buffer> b2 = std::shared_ptr<Buffer>(new Buffer(filter_length * sizeof(sample_t)));
sample_t* buffer_real = (sample_t*) buffer;
sample_t* buffer2 = b2->getBuffer();
float normaliziter = (float) filter_length;
for(int i = 0; i < filter_length; i++)
{
buffer2[i] = (buffer_real[i] / normaliziter);
}
fp->freeBuffer(buffer);
//
// Here b2 is the buffer with a "valid" FIR (remember the squared amplitude
//
std::shared_ptr<Buffer> ir_minimum = minimumPhaseFilterHomomorphic(b2, filter_length, -1);
Specs specsIR;
specsIR.rate = sampleRate;
specsIR.channels = CHANNELS_MONO;
return std::shared_ptr<ImpulseResponse>(new ImpulseResponse(std::shared_ptr<StreamBuffer>(new StreamBuffer(ir_minimum, specsIR)), fp));
}
std::shared_ptr<Buffer> Equalizer::minimumPhaseFilterHomomorphic(std::shared_ptr<Buffer> original, int lOriginal, int lWork)
{
void* b_orig = original->getBuffer();
if(lWork < lOriginal || lWork < 0)
{
lWork = (int) pow(2, ceil(log2((float) (2 * (lOriginal - 1) / 0.01))));
}
std::shared_ptr<FFTPlan> fp = std::shared_ptr<FFTPlan>(new FFTPlan(lWork, 0.1));
fftwf_complex* buffer = (fftwf_complex*) fp->getBuffer();
sample_t* b_work = (sample_t*) buffer;
// Padding with 0
std::memset(b_work, 0, lWork * sizeof(sample_t));
std::memcpy(b_work, b_orig, lOriginal * sizeof(sample_t));
fp->FFT(b_work);
for(int i = 0; i < lWork / 2; i++)
{
buffer[i][0] = fabs(sqrt(buffer[i][0] * buffer[i][0] + buffer[i][1] * buffer[i][1]));
buffer[i][1] = 0.0;
int conjugate = lWork - i - 1;
buffer[conjugate][0] = buffer[i][0];
buffer[conjugate][1] = 0.0;
}
double threshold = pow(10.0, -7);
float logThreshold = (float) log(threshold);
// take 0.25*log(|H|**2) = 0.5*log(|H|)
for(int i = 0; i < lWork; i++)
{
if(buffer[i][0] < threshold)
{
buffer[i][0] = 0.5 * logThreshold;
}
else
{
buffer[i][0] = 0.5 * log(buffer[i][0]);
}
}
fp->IFFT(buffer);
// homomorphic filter
int stop = (lOriginal + 1) / 2;
b_work[0] = b_work[0] / (float) lWork;
for(int i = 1; i < stop; i++)
{
b_work[i] = b_work[i] / (float) lWork * 2.0;
}
for(int i = stop; i < lWork; i++)
{
b_work[i] = 0;
}
fp->FFT(buffer);
// EXP
// e^x = e^ (a+bi)= e^a * e^bi = e^a * (cos b + i sin b)
for(int i = 0; i < lWork / 2; i++)
{
float new_real;
float new_imag;
new_real = exp(buffer[i][0]) * cos(buffer[i][1]);
new_imag = exp(buffer[i][0]) * sin(buffer[i][1]);
buffer[i][0] = new_real;
buffer[i][1] = new_imag;
int conjugate = lWork - i - 1;
buffer[conjugate][0] = new_real;
buffer[conjugate][1] = new_imag;
}
// IFFT
fp->IFFT(buffer);
// Create new clean Buffer with only the result and normalization
int lOut = (lOriginal / 2) + lOriginal % 2;
std::shared_ptr<Buffer> bOut = std::shared_ptr<Buffer>(new Buffer(sizeof(float) * lOut));
float* bbOut = (float*) bOut->getBuffer();
// Copy and normalize
for(int i = 0; i < lOut; i++)
{
bbOut[i] = b_work[i] / (float) lWork;
}
fp->freeBuffer(buffer);
return bOut;
}
std::shared_ptr<Buffer> Equalizer::minimumPhaseFilterHilbert(std::shared_ptr<Buffer> original, int lOriginal, int lWork)
{
void* b_orig = original->getBuffer();
if(lWork < lOriginal || lWork < 0)
{
lWork = (int) pow(2, ceil(log2((float) (2 * (lOriginal - 1) / 0.01))));
}
std::shared_ptr<FFTPlan> fp = std::shared_ptr<FFTPlan>(new FFTPlan(lWork, 0.1));
fftwf_complex* buffer = (fftwf_complex*) fp->getBuffer();
sample_t* b_work = (sample_t*) buffer;
// Padding with 0
std::memset(b_work, 0, lWork * sizeof(sample_t));
std::memcpy(b_work, b_orig, lOriginal * sizeof(sample_t));
fp->FFT(b_work);
float mymax, mymin;
float n_half = (float) (lOriginal >> 1);
for(int i = 0; i < lWork; i++)
{
float w = ((float) i) * 2.0 * M_PI / (float) lWork * n_half;
float f1 = cos(w);
float f2 = sin(w);
float f3, f4;
complex_prod(buffer[i][0], buffer[i][1], f1, f2, &f3, &f4);
buffer[i][0] = f3;
buffer[i][1] = 0.0;
if(i == 0)
{
mymax = f3;
mymin = f3;
}
else
{
if(f3 < mymin)
mymin = f3;
if(f3 > mymax)
mymax = f3;
}
}
float dp = mymax - 1;
float ds = 0 - mymin;
float S = 4.0 / pow(2, (sqrt(1 + dp + ds) + sqrt(1 - dp + ds)));
for(int i = 0; i < lWork; i++)
{
buffer[i][0] = sqrt((buffer[i][0] + ds) * S) + 1.0E-10;
}
fftwf_complex* buffer_tmp = (fftwf_complex*) std::malloc(lWork * sizeof(fftwf_complex));
std::memcpy(buffer_tmp, buffer, lWork * sizeof(fftwf_complex));
//
// Hilbert transform
//
int midpt = lWork >> 1;
for(int i = 0; i < lWork; i++)
buffer[i][0] = log(buffer[i][0]);
fp->IFFT(buffer);
b_work[0] = 0.0;
for(int i = 1; i < midpt; i++)
{
b_work[i] /= (float) lWork;
}
b_work[midpt] = 0.0;
for(int i = midpt + 1; i < lWork; i++)
{
b_work[i] /= (-1.0 * lWork);
}
fp->FFT(b_work);
// Exp
for(int i = 0; i < lWork; i++)
{
float base = exp(buffer[i][0]);
buffer[i][0] = base * cos(buffer[i][1]);
buffer[i][1] = base * sin(buffer[i][1]);
complex_prod(buffer_tmp[i][0], buffer_tmp[i][1], buffer[i][0], buffer[i][1], &(buffer[i][0]), &(buffer[i][1]));
}
std::free(buffer_tmp);
fp->IFFT(buffer);
//
// Copy and normalization
//
int n_out = n_half + lOriginal % 2;
std::shared_ptr<Buffer> b_minimum = std::shared_ptr<Buffer>(new Buffer(n_out * sizeof(sample_t)));
std::memcpy(b_minimum->getBuffer(), buffer, n_out * sizeof(sample_t));
sample_t* b_final = (sample_t*) b_minimum->getBuffer();
for(int i = 0; i < n_out; i++)
{
b_final[i] /= (float) lWork;
}
return b_minimum;
}
AUD_NAMESPACE_END

View File

@@ -22,7 +22,7 @@
AUD_NAMESPACE_BEGIN
FFTConvolver::FFTConvolver(std::shared_ptr<std::vector<std::complex<sample_t>>> ir, std::shared_ptr<FFTPlan> plan) :
m_plan(plan), m_N(plan->getSize()), m_M(plan->getSize()/2), m_L(plan->getSize()/2), m_tailPos(0), m_irBuffer(ir)
m_plan(plan), m_N(plan->getSize()), m_M(plan->getSize()/2), m_L(plan->getSize()/2), m_irBuffer(ir), m_tailPos(0)
{
m_tail = (float*)calloc(m_M - 1, sizeof(float));
m_realBufLen = ((m_N / 2) + 1) * 2;

View File

@@ -75,7 +75,7 @@ void HRTFLoader::loadHRTFs(std::shared_ptr<HRTF> hrtfs, char ear, const std::str
if(ear == 'L')
azim = 360 - azim;
}
catch(std::exception& e)
catch(...)
{
AUD_THROW(FileException, "The HRTF name doesn't follow the naming scheme: " + filename);
}
@@ -86,4 +86,4 @@ void HRTFLoader::loadHRTFs(std::shared_ptr<HRTF> hrtfs, char ear, const std::str
return;
}
AUD_NAMESPACE_END
AUD_NAMESPACE_END

View File

@@ -78,7 +78,7 @@ void HRTFLoader::loadHRTFs(std::shared_ptr<HRTF> hrtfs, char ear, const std::str
if(ear == 'L')
azim = 360 - azim;
}
catch(std::exception& e)
catch(...)
{
AUD_THROW(FileException, "The HRTF name doesn't follow the naming scheme: " + filename);
}
@@ -90,4 +90,4 @@ void HRTFLoader::loadHRTFs(std::shared_ptr<HRTF> hrtfs, char ear, const std::str
return;
}
AUD_NAMESPACE_END
AUD_NAMESPACE_END

View File

@@ -13,10 +13,12 @@ endif()
# Exporting functions from the blender binary gives linker warnings on Apple arm64 systems.
# Silence them here.
if(APPLE AND ("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "arm64"))
if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
string(APPEND CMAKE_C_FLAGS " -fvisibility=hidden")
string(APPEND CMAKE_CXX_FLAGS " -fvisibility=hidden")
if(APPLE)
if("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "arm64")
if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
string(APPEND CMAKE_C_FLAGS " -fvisibility=hidden")
string(APPEND CMAKE_CXX_FLAGS " -fvisibility=hidden")
endif()
endif()
endif()
@@ -261,9 +263,11 @@ set(LIB
blender_add_lib(extern_mantaflow "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
# The VDB libs above are only added to as INTERFACE libs by blender_add_lib,
# meaning extern_mantaflow itself actually does not have a dependency on the
# openvdb libraries, and CMAKE is free to link the vdb libs before
# extern_mantaflow causing linker errors on linux. By explicitly declaring
# a dependency here, cmake will do the right thing.
target_link_libraries(extern_mantaflow PRIVATE ${OPENVDB_LIBRARIES})
if(WITH_OPENVDB)
# The VDB libs above are only added to as INTERFACE libs by blender_add_lib,
# meaning extern_mantaflow itself actually does not have a dependency on the
# openvdb libraries, and CMAKE is free to link the vdb libs before
# extern_mantaflow causing linker errors on linux. By explicitly declaring
# a dependency here, cmake will do the right thing.
target_link_libraries(extern_mantaflow PRIVATE ${OPENVDB_LIBRARIES})
endif()

View File

@@ -7,6 +7,7 @@ set(INC
set(INC_SYS
${VULKAN_INCLUDE_DIRS}
${MOLTENVK_INCLUDE_DIRS}
)
set(SRC

View File

@@ -0,0 +1,15 @@
diff --git a/extern/vulkan_memory_allocator/vk_mem_alloc.h b/extern/vulkan_memory_allocator/vk_mem_alloc.h
index 60f572038c0..63a9994ba46 100644
--- a/extern/vulkan_memory_allocator/vk_mem_alloc.h
+++ b/extern/vulkan_memory_allocator/vk_mem_alloc.h
@@ -13371,8 +13371,8 @@ bool VmaDefragmentationContext_T::IncrementCounters(VkDeviceSize bytes)
// Early return when max found
if (++m_PassStats.allocationsMoved >= m_MaxPassAllocations || m_PassStats.bytesMoved >= m_MaxPassBytes)
{
- VMA_ASSERT(m_PassStats.allocationsMoved == m_MaxPassAllocations ||
- m_PassStats.bytesMoved == m_MaxPassBytes && "Exceeded maximal pass threshold!");
+ VMA_ASSERT((m_PassStats.allocationsMoved == m_MaxPassAllocations ||
+ m_PassStats.bytesMoved == m_MaxPassBytes) && "Exceeded maximal pass threshold!");
return true;
}
return false;

File diff suppressed because it is too large Load Diff

View File

@@ -85,15 +85,11 @@ elseif(WIN32 AND MSVC AND NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# there is no /arch:SSE3, but intrinsics are available anyway
if(CMAKE_CL_64)
set(CYCLES_SSE2_KERNEL_FLAGS "${CYCLES_KERNEL_FLAGS}")
set(CYCLES_SSE3_KERNEL_FLAGS "${CYCLES_KERNEL_FLAGS}")
set(CYCLES_SSE41_KERNEL_FLAGS "${CYCLES_KERNEL_FLAGS}")
set(CYCLES_AVX_KERNEL_FLAGS "${CYCLES_AVX_ARCH_FLAGS} ${CYCLES_KERNEL_FLAGS}")
set(CYCLES_AVX2_KERNEL_FLAGS "${CYCLES_AVX2_ARCH_FLAGS} ${CYCLES_KERNEL_FLAGS}")
else()
set(CYCLES_SSE2_KERNEL_FLAGS "/arch:SSE2 ${CYCLES_KERNEL_FLAGS}")
set(CYCLES_SSE3_KERNEL_FLAGS "/arch:SSE2 ${CYCLES_KERNEL_FLAGS}")
set(CYCLES_SSE41_KERNEL_FLAGS "/arch:SSE2 ${CYCLES_KERNEL_FLAGS}")
set(CYCLES_AVX_KERNEL_FLAGS "${CYCLES_AVX_ARCH_FLAGS} ${CYCLES_KERNEL_FLAGS}")
set(CYCLES_AVX2_KERNEL_FLAGS "${CYCLES_AVX2_ARCH_FLAGS} ${CYCLES_KERNEL_FLAGS}")
endif()
@@ -126,11 +122,7 @@ elseif(CMAKE_COMPILER_IS_GNUCC OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
endif()
set(CYCLES_SSE2_KERNEL_FLAGS "${CYCLES_KERNEL_FLAGS} -msse -msse2")
set(CYCLES_SSE3_KERNEL_FLAGS "${CYCLES_SSE2_KERNEL_FLAGS} -msse3 -mssse3")
set(CYCLES_SSE41_KERNEL_FLAGS "${CYCLES_SSE3_KERNEL_FLAGS} -msse4.1")
if(CXX_HAS_AVX)
set(CYCLES_AVX_KERNEL_FLAGS "${CYCLES_SSE41_KERNEL_FLAGS} -mavx")
endif()
set(CYCLES_SSE41_KERNEL_FLAGS "${CYCLES_SSE2_KERNEL_FLAGS} -msse3 -mssse3 -msse4.1")
if(CXX_HAS_AVX2)
set(CYCLES_AVX2_KERNEL_FLAGS "${CYCLES_SSE41_KERNEL_FLAGS} -mavx -mavx2 -mfma -mlzcnt -mbmi -mbmi2 -mf16c")
endif()
@@ -144,13 +136,8 @@ elseif(WIN32 AND CMAKE_CXX_COMPILER_ID MATCHES "Intel")
if(CXX_HAS_SSE)
set(CYCLES_SSE2_KERNEL_FLAGS "/QxSSE2")
set(CYCLES_SSE3_KERNEL_FLAGS "/QxSSSE3")
set(CYCLES_SSE41_KERNEL_FLAGS "/QxSSE4.1")
if(CXX_HAS_AVX)
set(CYCLES_AVX_KERNEL_FLAGS "/arch:AVX")
endif()
if(CXX_HAS_AVX2)
set(CYCLES_AVX2_KERNEL_FLAGS "/QxCORE-AVX2")
endif()
@@ -174,13 +161,8 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "Intel")
set(CYCLES_SSE2_KERNEL_FLAGS "-xsse2")
endif()
set(CYCLES_SSE3_KERNEL_FLAGS "-xssse3")
set(CYCLES_SSE41_KERNEL_FLAGS "-xsse4.1")
if(CXX_HAS_AVX)
set(CYCLES_AVX_KERNEL_FLAGS "-xavx")
endif()
if(CXX_HAS_AVX2)
set(CYCLES_AVX2_KERNEL_FLAGS "-xcore-avx2")
endif()
@@ -190,15 +172,10 @@ endif()
if(CXX_HAS_SSE)
add_definitions(
-DWITH_KERNEL_SSE2
-DWITH_KERNEL_SSE3
-DWITH_KERNEL_SSE41
)
endif()
if(CXX_HAS_AVX)
add_definitions(-DWITH_KERNEL_AVX)
endif()
if(CXX_HAS_AVX2)
add_definitions(-DWITH_KERNEL_AVX2)
endif()

View File

@@ -208,6 +208,21 @@ enum_guiding_distribution = (
('VMM', "VMM", "Use von Mises-Fisher models as directional distribution", 2),
)
enum_guiding_directional_sampling_types = (
('PRODUCT',
"Diffuse Product",
"Guided diffuse BSDF component based on the incoming light distribution and the cosine product (closed form product)",
0),
('RIS',
"Re-sampled Importance Sampling",
"Perform RIS sampling to guided based on the product of the incoming light distribution and the BSDF",
1),
('ROUGHNESS',
"Roughness-based",
"Adjust the guiding probability based on the roughness of the material components",
2),
)
def enum_openimagedenoise_denoiser(self, context):
import _cycles
@@ -567,6 +582,13 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
default='PARALLAX_AWARE_VMM',
)
guiding_directional_sampling_type: EnumProperty(
name="Directional Sampling Type",
description="Type of the directional sampling used for guiding",
items=enum_guiding_directional_sampling_types,
default='PRODUCT',
)
use_surface_guiding: BoolProperty(
name="Surface Guiding",
description="Use guiding when sampling directions on a surface",
@@ -616,6 +638,13 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
default=True,
)
guiding_roughness_threshold: FloatProperty(
name="Guiding Roughness Threshold",
description="The minimal roughness value of a material to apply guiding",
min=0.0, max=1.0,
default=0.05,
)
max_bounces: IntProperty(
name="Max Bounces",
description="Total maximum number of bounces",
@@ -951,9 +980,7 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
return _cycles.debug_flags_update(scene)
debug_use_cpu_avx2: BoolProperty(name="AVX2", default=True)
debug_use_cpu_avx: BoolProperty(name="AVX", default=True)
debug_use_cpu_sse41: BoolProperty(name="SSE41", default=True)
debug_use_cpu_sse3: BoolProperty(name="SSE3", default=True)
debug_use_cpu_sse2: BoolProperty(name="SSE2", default=True)
debug_bvh_layout: EnumProperty(
name="BVH Layout",
@@ -1673,19 +1700,19 @@ class CyclesPreferences(bpy.types.AddonPreferences):
elif device_type == 'HIP':
import sys
if sys.platform[:3] == "win":
col.label(text="Requires AMD GPU with Vega or RDNA architecture", icon='BLANK1')
col.label(text="Requires AMD GPU with RDNA architecture", icon='BLANK1')
col.label(text="and AMD Radeon Pro 21.Q4 driver or newer", icon='BLANK1')
elif sys.platform.startswith("linux"):
col.label(text="Requires AMD GPU with Vega or RDNA architecture", icon='BLANK1')
col.label(text="Requires AMD GPU with RDNA architecture", icon='BLANK1')
col.label(text="and AMD driver version 22.10 or newer", icon='BLANK1')
elif device_type == 'ONEAPI':
import sys
if sys.platform.startswith("win"):
col.label(text="Requires Intel GPU with Xe-HPG architecture", icon='BLANK1')
col.label(text="and Windows driver version 101.3430 or newer", icon='BLANK1')
col.label(text="and Windows driver version 101.4032 or newer", icon='BLANK1')
elif sys.platform.startswith("linux"):
col.label(text="Requires Intel GPU with Xe-HPG architecture and", icon='BLANK1')
col.label(text=" - intel-level-zero-gpu version 1.3.23904 or newer", icon='BLANK1')
col.label(text=" - intel-level-zero-gpu version 1.3.24931 or newer", icon='BLANK1')
col.label(text=" - oneAPI Level-Zero Loader", icon='BLANK1')
elif device_type == 'METAL':
col.label(text="Requires Apple Silicon with macOS 12.2 or newer", icon='BLANK1')
@@ -1724,13 +1751,20 @@ class CyclesPreferences(bpy.types.AddonPreferences):
row.prop(self, "peer_memory")
if compute_device_type == 'METAL':
import platform
# MetalRT only works on Apple Silicon at present, pending argument encoding fixes on AMD
# Kernel specialization is only viable on Apple Silicon at present due to relative compilation speed
if platform.machine() == 'arm64':
import platform, re
isNavi2 = False
for device in devices:
obj = re.search("((RX)|(Pro)|(PRO))\s+W?6\d00X",device.name)
if obj:
isNavi2 = True
# MetalRT only works on Apple Silicon and Navi2
if platform.machine() == 'arm64' or isNavi2:
col = layout.column()
col.use_property_split = True
col.prop(self, "kernel_optimization_level")
# Kernel specialization is only supported on Apple Silicon
if platform.machine() == 'arm64':
col.prop(self, "kernel_optimization_level")
col.prop(self, "use_metalrt")
def draw(self, context):

View File

@@ -316,6 +316,8 @@ class CYCLES_RENDER_PT_sampling_path_guiding(CyclesButtonsPanel, Panel):
layout.prop(cscene, "guiding_training_samples")
layout.prop(cscene, "guiding_directional_sampling_type", text="Directional Sampling Type")
col = layout.column(align=True)
col.prop(cscene, "use_surface_guiding", text="Surface")
col.prop(cscene, "use_volume_guiding", text="Volume")
@@ -336,6 +338,7 @@ class CYCLES_RENDER_PT_sampling_path_guiding_debug(CyclesDebugButtonsPanel, Pane
layout.active = cscene.use_guiding
layout.prop(cscene, "guiding_distribution_type", text="Distribution Type")
layout.prop(cscene, "guiding_roughness_threshold")
col = layout.column(align=True)
col.prop(cscene, "surface_guiding_probability")
@@ -2112,9 +2115,7 @@ class CYCLES_RENDER_PT_debug(CyclesDebugButtonsPanel, Panel):
row = col.row(align=True)
row.prop(cscene, "debug_use_cpu_sse2", toggle=True)
row.prop(cscene, "debug_use_cpu_sse3", toggle=True)
row.prop(cscene, "debug_use_cpu_sse41", toggle=True)
row.prop(cscene, "debug_use_cpu_avx", toggle=True)
row.prop(cscene, "debug_use_cpu_avx2", toggle=True)
col.prop(cscene, "debug_bvh_layout", text="BVH")

View File

@@ -721,8 +721,6 @@ static void draw_tile(const float2 &zoom,
return;
}
GPU_texture_bind(texture.gpu_texture, 0);
/* Trick to keep sharp rendering without jagged edges on all GPUs.
*
* The idea here is to enforce driver to use linear interpolation when the image is not zoomed
@@ -735,14 +733,14 @@ static void draw_tile(const float2 &zoom,
const float zoomed_height = draw_tile.params.size.y * zoom.y;
if (texture.width != draw_tile.params.size.x || texture.height != draw_tile.params.size.y) {
/* Resolution divider is different from 1, force nearest interpolation. */
GPU_texture_filter_mode(texture.gpu_texture, false);
GPU_texture_bind_ex(texture.gpu_texture, GPU_SAMPLER_DEFAULT, 0, false);
}
else if (zoomed_width - draw_tile.params.size.x > 0.5f ||
zoomed_height - draw_tile.params.size.y > 0.5f) {
GPU_texture_filter_mode(texture.gpu_texture, false);
GPU_texture_bind_ex(texture.gpu_texture, GPU_SAMPLER_DEFAULT, 0, false);
}
else {
GPU_texture_filter_mode(texture.gpu_texture, true);
GPU_texture_bind_ex(texture.gpu_texture, GPU_SAMPLER_FILTER, 0, false);
}
/* Draw at the parameters for which the texture has been updated for. This allows to always draw

View File

@@ -48,6 +48,8 @@ void BlenderSync::sync_light(BL::Object &b_parent,
case BL::Light::type_SPOT: {
BL::SpotLight b_spot_light(b_light);
light->set_size(b_spot_light.shadow_soft_size());
light->set_axisu(transform_get_column(&tfm, 0));
light->set_axisv(transform_get_column(&tfm, 1));
light->set_light_type(LIGHT_SPOT);
light->set_spot_angle(b_spot_light.spot_size());
light->set_spot_smooth(b_spot_light.spot_blend());

View File

@@ -63,9 +63,7 @@ static void debug_flags_sync_from_scene(BL::Scene b_scene)
PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
/* Synchronize CPU flags. */
flags.cpu.avx2 = get_boolean(cscene, "debug_use_cpu_avx2");
flags.cpu.avx = get_boolean(cscene, "debug_use_cpu_avx");
flags.cpu.sse41 = get_boolean(cscene, "debug_use_cpu_sse41");
flags.cpu.sse3 = get_boolean(cscene, "debug_use_cpu_sse3");
flags.cpu.sse2 = get_boolean(cscene, "debug_use_cpu_sse2");
flags.cpu.bvh_layout = (BVHLayout)get_enum(cscene, "debug_bvh_layout");
/* Synchronize CUDA flags. */

View File

@@ -26,7 +26,7 @@
CCL_NAMESPACE_BEGIN
typedef map<void *, ShaderInput *> PtrInputMap;
typedef unordered_multimap<void *, ShaderInput *> PtrInputMap;
typedef map<void *, ShaderOutput *> PtrOutputMap;
typedef map<string, ConvertNode *> ProxyMap;
@@ -1251,7 +1251,9 @@ static void add_nodes(Scene *scene,
ConvertNode *proxy = graph->create_node<ConvertNode>(to_socket_type, to_socket_type, true);
input_map[b_link.from_socket().ptr.data] = proxy->inputs[0];
/* Muted nodes can result in multiple Cycles input sockets mapping to the same Blender
* input socket, so this needs to be a multimap. */
input_map.emplace(b_link.from_socket().ptr.data, proxy->inputs[0]);
output_map[b_link.to_socket().ptr.data] = proxy->outputs[0];
graph->add(proxy);
@@ -1286,7 +1288,7 @@ static void add_nodes(Scene *scene,
/* register the proxy node for internal binding */
group_proxy_input_map[b_input.identifier()] = proxy;
input_map[b_input.ptr.data] = proxy->inputs[0];
input_map.emplace(b_input.ptr.data, proxy->inputs[0]);
set_default_value(proxy->inputs[0], b_input, b_data, b_ntree);
}
@@ -1338,7 +1340,7 @@ static void add_nodes(Scene *scene,
if (proxy_it != proxy_output_map.end()) {
ConvertNode *proxy = proxy_it->second;
input_map[b_input.ptr.data] = proxy->inputs[0];
input_map.emplace(b_input.ptr.data, proxy->inputs[0]);
set_default_value(proxy->inputs[0], b_input, b_data, b_ntree);
}
@@ -1369,7 +1371,7 @@ static void add_nodes(Scene *scene,
/* XXX should not happen, report error? */
continue;
}
input_map[b_input.ptr.data] = input;
input_map.emplace(b_input.ptr.data, input);
set_default_value(input, b_input, b_data, b_ntree);
}
@@ -1401,20 +1403,23 @@ static void add_nodes(Scene *scene,
BL::NodeSocket b_from_sock = b_link.from_socket();
BL::NodeSocket b_to_sock = b_link.to_socket();
ShaderOutput *output = 0;
ShaderInput *input = 0;
ShaderOutput *output = nullptr;
PtrOutputMap::iterator output_it = output_map.find(b_from_sock.ptr.data);
if (output_it != output_map.end())
output = output_it->second;
PtrInputMap::iterator input_it = input_map.find(b_to_sock.ptr.data);
if (input_it != input_map.end())
input = input_it->second;
/* either node may be NULL when the node was not exported, typically
/* either socket may be NULL when the node was not exported, typically
* because the node type is not supported */
if (output && input)
graph->connect(output, input);
if (output != nullptr) {
ShaderOutput *output = output_it->second;
auto inputs = input_map.equal_range(b_to_sock.ptr.data);
for (PtrInputMap::iterator input_it = inputs.first; input_it != inputs.second; ++input_it) {
ShaderInput *input = input_it->second;
if (input != nullptr) {
graph->connect(output, input);
}
}
}
}
}

View File

@@ -441,6 +441,13 @@ void BlenderSync::sync_integrator(BL::ViewLayer &b_view_layer, bool background)
GuidingDistributionType guiding_distribution_type = (GuidingDistributionType)get_enum(
cscene, "guiding_distribution_type", GUIDING_NUM_TYPES, GUIDING_TYPE_PARALLAX_AWARE_VMM);
integrator->set_guiding_distribution_type(guiding_distribution_type);
GuidingDirectionalSamplingType guiding_directional_sampling_type =
(GuidingDirectionalSamplingType)get_enum(cscene,
"guiding_directional_sampling_type",
GUIDING_DIRECTIONAL_SAMPLING_NUM_TYPES,
GUIDING_DIRECTIONAL_SAMPLING_TYPE_PRODUCT);
integrator->set_guiding_directional_sampling_type(guiding_directional_sampling_type);
integrator->set_guiding_roughness_threshold(get_float(cscene, "guiding_roughness_threshold"));
}
DenoiseParams denoise_params = get_denoise_params(b_scene, b_view_layer, background);

View File

@@ -111,8 +111,10 @@ macro(cycles_external_libraries_append libraries)
endif()
if(WITH_OPENIMAGEDENOISE)
list(APPEND ${libraries} ${OPENIMAGEDENOISE_LIBRARIES})
if(APPLE AND "${CMAKE_OSX_ARCHITECTURES}" STREQUAL "arm64")
list(APPEND ${libraries} "-framework Accelerate")
if(APPLE)
if("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "arm64")
list(APPEND ${libraries} "-framework Accelerate")
endif()
endif()
endif()
if(WITH_ALEMBIC)
@@ -136,7 +138,15 @@ macro(cycles_external_libraries_append libraries)
${PYTHON_LIBRARIES}
${ZLIB_LIBRARIES}
${CMAKE_DL_LIBS}
${PTHREADS_LIBRARIES}
)
if(DEFINED PTHREADS_LIBRARIES)
list(APPEND ${libraries}
${PTHREADS_LIBRARIES}
)
endif()
list(APPEND ${libraries}
${PLATFORM_LINKLIBS}
)

View File

@@ -45,9 +45,7 @@ string device_cpu_capabilities()
{
string capabilities = "";
capabilities += system_cpu_support_sse2() ? "SSE2 " : "";
capabilities += system_cpu_support_sse3() ? "SSE3 " : "";
capabilities += system_cpu_support_sse41() ? "SSE41 " : "";
capabilities += system_cpu_support_avx() ? "AVX " : "";
capabilities += system_cpu_support_avx2() ? "AVX2" : "";
if (capabilities[capabilities.size() - 1] == ' ')
capabilities.resize(capabilities.size() - 1);

View File

@@ -9,8 +9,7 @@ CCL_NAMESPACE_BEGIN
#define KERNEL_FUNCTIONS(name) \
KERNEL_NAME_EVAL(cpu, name), KERNEL_NAME_EVAL(cpu_sse2, name), \
KERNEL_NAME_EVAL(cpu_sse3, name), KERNEL_NAME_EVAL(cpu_sse41, name), \
KERNEL_NAME_EVAL(cpu_avx, name), KERNEL_NAME_EVAL(cpu_avx2, name)
KERNEL_NAME_EVAL(cpu_sse41, name), KERNEL_NAME_EVAL(cpu_avx2, name)
#define REGISTER_KERNEL(name) name(KERNEL_FUNCTIONS(name))
#define REGISTER_KERNEL_FILM_CONVERT(name) \

View File

@@ -17,13 +17,10 @@ template<typename FunctionType> class CPUKernelFunction {
public:
CPUKernelFunction(FunctionType kernel_default,
FunctionType kernel_sse2,
FunctionType kernel_sse3,
FunctionType kernel_sse41,
FunctionType kernel_avx,
FunctionType kernel_avx2)
{
kernel_info_ = get_best_kernel_info(
kernel_default, kernel_sse2, kernel_sse3, kernel_sse41, kernel_avx, kernel_avx2);
kernel_info_ = get_best_kernel_info(kernel_default, kernel_sse2, kernel_sse41, kernel_avx2);
}
template<typename... Args> inline auto operator()(Args... args) const
@@ -60,16 +57,12 @@ template<typename FunctionType> class CPUKernelFunction {
KernelInfo get_best_kernel_info(FunctionType kernel_default,
FunctionType kernel_sse2,
FunctionType kernel_sse3,
FunctionType kernel_sse41,
FunctionType kernel_avx,
FunctionType kernel_avx2)
{
/* Silence warnings about unused variables when compiling without some architectures. */
(void)kernel_sse2;
(void)kernel_sse3;
(void)kernel_sse41;
(void)kernel_avx;
(void)kernel_avx2;
#ifdef WITH_CYCLES_OPTIMIZED_KERNEL_AVX2
@@ -78,24 +71,12 @@ template<typename FunctionType> class CPUKernelFunction {
}
#endif
#ifdef WITH_CYCLES_OPTIMIZED_KERNEL_AVX
if (DebugFlags().cpu.has_avx() && system_cpu_support_avx()) {
return KernelInfo("AVX", kernel_avx);
}
#endif
#ifdef WITH_CYCLES_OPTIMIZED_KERNEL_SSE41
if (DebugFlags().cpu.has_sse41() && system_cpu_support_sse41()) {
return KernelInfo("SSE4.1", kernel_sse41);
}
#endif
#ifdef WITH_CYCLES_OPTIMIZED_KERNEL_SSE3
if (DebugFlags().cpu.has_sse3() && system_cpu_support_sse3()) {
return KernelInfo("SSE3", kernel_sse3);
}
#endif
#ifdef WITH_CYCLES_OPTIMIZED_KERNEL_SSE2
if (DebugFlags().cpu.has_sse2() && system_cpu_support_sse2()) {
return KernelInfo("SSE2", kernel_sse2);

View File

@@ -51,7 +51,7 @@ static inline bool hipSupportsDevice(const int hipDevId)
hipDeviceGetAttribute(&major, hipDeviceAttributeComputeCapabilityMajor, hipDevId);
hipDeviceGetAttribute(&minor, hipDeviceAttributeComputeCapabilityMinor, hipDevId);
return (major >= 9);
return (major >= 10);
}
CCL_NAMESPACE_END

View File

@@ -73,6 +73,10 @@ const char *device_kernel_as_string(DeviceKernel kernel)
return "integrator_terminated_paths_array";
case DEVICE_KERNEL_INTEGRATOR_SORTED_PATHS_ARRAY:
return "integrator_sorted_paths_array";
case DEVICE_KERNEL_INTEGRATOR_SORT_BUCKET_PASS:
return "integrator_sort_bucket_pass";
case DEVICE_KERNEL_INTEGRATOR_SORT_WRITE_PASS:
return "integrator_sort_write_pass";
case DEVICE_KERNEL_INTEGRATOR_COMPACT_PATHS_ARRAY:
return "integrator_compact_paths_array";
case DEVICE_KERNEL_INTEGRATOR_COMPACT_STATES:

View File

@@ -55,6 +55,10 @@ void device_metal_info(vector<DeviceInfo> &devices)
info.denoisers = DENOISER_NONE;
info.id = id;
if (MetalInfo::get_device_vendor(device) == METAL_GPU_AMD) {
info.has_light_tree = false;
}
devices.push_back(info);
device_index++;
}

View File

@@ -105,6 +105,8 @@ class MetalDevice : public Device {
bool use_adaptive_compilation();
bool use_local_atomic_sort() const;
bool make_source_and_check_if_compile_needed(MetalPipelineType pso_type);
void make_source(MetalPipelineType pso_type, const uint kernel_features);

View File

@@ -271,6 +271,11 @@ bool MetalDevice::use_adaptive_compilation()
return DebugFlags().metal.adaptive_compile;
}
bool MetalDevice::use_local_atomic_sort() const
{
return DebugFlags().metal.use_local_atomic_sort;
}
void MetalDevice::make_source(MetalPipelineType pso_type, const uint kernel_features)
{
string global_defines;
@@ -278,6 +283,10 @@ void MetalDevice::make_source(MetalPipelineType pso_type, const uint kernel_feat
global_defines += "#define __KERNEL_FEATURES__ " + to_string(kernel_features) + "\n";
}
if (use_local_atomic_sort()) {
global_defines += "#define __KERNEL_LOCAL_ATOMIC_SORT__\n";
}
if (use_metalrt) {
global_defines += "#define __METALRT__\n";
if (motion_blur) {
@@ -327,10 +336,21 @@ void MetalDevice::make_source(MetalPipelineType pso_type, const uint kernel_feat
# define KERNEL_STRUCT_BEGIN(name, parent) \
string_replace_same_length(source, "kernel_data." #parent ".", "kernel_data_" #parent "_");
bool next_member_is_specialized = true;
# define KERNEL_STRUCT_MEMBER_DONT_SPECIALIZE next_member_is_specialized = false;
/* Add constants to md5 so that 'get_best_pipeline' is able to return a suitable match. */
# define KERNEL_STRUCT_MEMBER(parent, _type, name) \
baked_constants += string(#parent "." #name "=") + \
to_string(_type(launch_params.data.parent.name)) + "\n";
if (next_member_is_specialized) { \
baked_constants += string(#parent "." #name "=") + \
to_string(_type(launch_params.data.parent.name)) + "\n"; \
} \
else { \
string_replace( \
source, "kernel_data_" #parent "_" #name, "kernel_data." #parent ".__unused_" #name); \
next_member_is_specialized = true; \
}
# include "kernel/data_template.h"

View File

@@ -49,6 +49,18 @@ struct ShaderCache {
if (MetalInfo::get_device_vendor(mtlDevice) == METAL_GPU_APPLE) {
switch (MetalInfo::get_apple_gpu_architecture(mtlDevice)) {
default:
case APPLE_M2_BIG:
occupancy_tuning[DEVICE_KERNEL_INTEGRATOR_COMPACT_SHADOW_STATES] = {384, 128};
occupancy_tuning[DEVICE_KERNEL_INTEGRATOR_INIT_FROM_CAMERA] = {640, 128};
occupancy_tuning[DEVICE_KERNEL_INTEGRATOR_INTERSECT_CLOSEST] = {1024, 64};
occupancy_tuning[DEVICE_KERNEL_INTEGRATOR_INTERSECT_SHADOW] = {704, 704};
occupancy_tuning[DEVICE_KERNEL_INTEGRATOR_INTERSECT_SUBSURFACE] = {640, 32};
occupancy_tuning[DEVICE_KERNEL_INTEGRATOR_QUEUED_PATHS_ARRAY] = {896, 768};
occupancy_tuning[DEVICE_KERNEL_INTEGRATOR_SHADE_BACKGROUND] = {512, 128};
occupancy_tuning[DEVICE_KERNEL_INTEGRATOR_SHADE_SHADOW] = {32, 32};
occupancy_tuning[DEVICE_KERNEL_INTEGRATOR_SHADE_SURFACE] = {768, 576};
occupancy_tuning[DEVICE_KERNEL_INTEGRATOR_SORTED_PATHS_ARRAY] = {896, 768};
break;
case APPLE_M2:
occupancy_tuning[DEVICE_KERNEL_INTEGRATOR_COMPACT_SHADOW_STATES] = {32, 32};
occupancy_tuning[DEVICE_KERNEL_INTEGRATOR_INIT_FROM_CAMERA] = {832, 32};
@@ -75,6 +87,9 @@ struct ShaderCache {
break;
}
}
occupancy_tuning[DEVICE_KERNEL_INTEGRATOR_SORT_BUCKET_PASS] = {1024, 1024};
occupancy_tuning[DEVICE_KERNEL_INTEGRATOR_SORT_WRITE_PASS] = {1024, 1024};
}
~ShaderCache();
@@ -448,13 +463,18 @@ static MTLFunctionConstantValues *GetConstantValues(KernelData const *data = nul
if (!data) {
data = &zero_data;
}
int zero_int = 0;
[constant_values setConstantValue:&zero_int type:MTLDataType_int atIndex:Kernel_DummyConstant];
[constant_values setConstantValue:&zero_data type:MTLDataType_int atIndex:Kernel_DummyConstant];
bool next_member_is_specialized = true;
# define KERNEL_STRUCT_MEMBER_DONT_SPECIALIZE next_member_is_specialized = false;
# define KERNEL_STRUCT_MEMBER(parent, _type, name) \
[constant_values setConstantValue:&data->parent.name \
[constant_values setConstantValue:next_member_is_specialized ? (void *)&data->parent.name : \
(void *)&zero_data \
type:MTLDataType_##_type \
atIndex:KernelData_##parent##_##name];
atIndex:KernelData_##parent##_##name]; \
next_member_is_specialized = true;
# include "kernel/data_template.h"

View File

@@ -25,6 +25,7 @@ class MetalDeviceQueue : public DeviceQueue {
virtual int num_concurrent_states(const size_t) const override;
virtual int num_concurrent_busy_states(const size_t) const override;
virtual int num_sort_partition_elements() const override;
virtual bool supports_local_atomic_sort() const override;
virtual void init_execution() override;

View File

@@ -278,7 +278,8 @@ int MetalDeviceQueue::num_concurrent_states(const size_t state_size) const
if (metal_device_->device_vendor == METAL_GPU_APPLE) {
result *= 4;
if (MetalInfo::get_apple_gpu_architecture(metal_device_->mtlDevice) == APPLE_M2) {
/* Increasing the state count doesn't notably benefit M1-family systems. */
if (MetalInfo::get_apple_gpu_architecture(metal_device_->mtlDevice) != APPLE_M1) {
size_t system_ram = system_physical_ram();
size_t allocated_so_far = [metal_device_->mtlDevice currentAllocatedSize];
size_t max_recommended_working_set = [metal_device_->mtlDevice recommendedMaxWorkingSetSize];
@@ -314,6 +315,11 @@ int MetalDeviceQueue::num_sort_partition_elements() const
return MetalInfo::optimal_sort_partition_elements(metal_device_->mtlDevice);
}
bool MetalDeviceQueue::supports_local_atomic_sort() const
{
return metal_device_->use_local_atomic_sort();
}
void MetalDeviceQueue::init_execution()
{
/* Synchronize all textures and memory copies before executing task. */
@@ -552,13 +558,24 @@ bool MetalDeviceQueue::enqueue(DeviceKernel kernel,
/* See parallel_active_index.h for why this amount of shared memory is needed.
* Rounded up to 16 bytes for Metal */
shared_mem_bytes = (int)round_up((num_threads_per_block + 1) * sizeof(int), 16);
[mtlComputeCommandEncoder setThreadgroupMemoryLength:shared_mem_bytes atIndex:0];
break;
case DEVICE_KERNEL_INTEGRATOR_SORT_BUCKET_PASS:
case DEVICE_KERNEL_INTEGRATOR_SORT_WRITE_PASS: {
int key_count = metal_device_->launch_params.data.max_shaders;
shared_mem_bytes = (int)round_up(key_count * sizeof(int), 16);
break;
}
default:
break;
}
if (shared_mem_bytes) {
assert(shared_mem_bytes <= 32 * 1024);
[mtlComputeCommandEncoder setThreadgroupMemoryLength:shared_mem_bytes atIndex:0];
}
MTLSize size_threadgroups_per_dispatch = MTLSizeMake(
divide_up(work_size, num_threads_per_block), 1, 1);
MTLSize size_threads_per_threadgroup = MTLSizeMake(num_threads_per_block, 1, 1);

View File

@@ -29,6 +29,7 @@ enum AppleGPUArchitecture {
APPLE_UNKNOWN,
APPLE_M1,
APPLE_M2,
APPLE_M2_BIG,
};
/* Contains static Metal helper functions. */

View File

@@ -52,7 +52,7 @@ AppleGPUArchitecture MetalInfo::get_apple_gpu_architecture(id<MTLDevice> device)
return APPLE_M1;
}
else if (strstr(device_name, "M2")) {
return APPLE_M2;
return get_apple_gpu_core_count(device) <= 10 ? APPLE_M2 : APPLE_M2_BIG;
}
return APPLE_UNKNOWN;
}
@@ -64,6 +64,12 @@ MetalGPUVendor MetalInfo::get_device_vendor(id<MTLDevice> device)
return METAL_GPU_INTEL;
}
else if (strstr(device_name, "AMD")) {
/* Setting this env var hides AMD devices thus exposing any integrated Intel devices. */
if (auto str = getenv("CYCLES_METAL_FORCE_INTEL")) {
if (atoi(str)) {
return METAL_GPU_UNKNOWN;
}
}
return METAL_GPU_AMD;
}
else if (strstr(device_name, "Apple")) {
@@ -96,6 +102,15 @@ vector<id<MTLDevice>> const &MetalInfo::get_usable_devices()
return usable_devices;
}
/* If the system has both an AMD GPU (discrete) and an Intel one (integrated), prefer the AMD
* one. This can be overriden with CYCLES_METAL_FORCE_INTEL. */
bool has_usable_amd_gpu = false;
if (@available(macos 12.3, *)) {
for (id<MTLDevice> device in MTLCopyAllDevices()) {
has_usable_amd_gpu |= (get_device_vendor(device) == METAL_GPU_AMD);
}
}
metal_printf("Usable Metal devices:\n");
for (id<MTLDevice> device in MTLCopyAllDevices()) {
string device_name = get_device_name(device);
@@ -111,8 +126,10 @@ vector<id<MTLDevice>> const &MetalInfo::get_usable_devices()
}
# if defined(MAC_OS_VERSION_13_0)
if (@available(macos 13.0, *)) {
usable |= (vendor == METAL_GPU_INTEL);
if (!has_usable_amd_gpu) {
if (@available(macos 13.0, *)) {
usable |= (vendor == METAL_GPU_INTEL);
}
}
# endif

View File

@@ -377,7 +377,7 @@ void OneapiDevice::tex_alloc(device_texture &mem)
generic_alloc(mem);
generic_copy_to(mem);
/* Resize if needed. Also, in case of resize - allocate in advance for future allocs. */
/* Resize if needed. Also, in case of resize - allocate in advance for future allocations. */
const uint slot = mem.slot;
if (slot >= texture_info_.size()) {
texture_info_.resize(slot + 128);
@@ -631,9 +631,9 @@ bool OneapiDevice::enqueue_kernel(KernelContext *kernel_context,
/* Compute-runtime (ie. NEO) version is what gets returned by sycl/L0 on Windows
* since Windows driver 101.3268. */
/* The same min compute-runtime version is currently required across Windows and Linux.
* For Windows driver 101.3430, compute-runtime version is 23904. */
static const int lowest_supported_driver_version_win = 1013430;
static const int lowest_supported_driver_version_neo = 23904;
* For Windows driver 101.4032, compute-runtime version is 24931. */
static const int lowest_supported_driver_version_win = 1014032;
static const int lowest_supported_driver_version_neo = 24931;
int OneapiDevice::parse_driver_build_version(const sycl::device &device)
{

View File

@@ -854,12 +854,14 @@ bool OptiXDevice::load_osl_kernels()
context, group_descs, 2, &group_options, nullptr, 0, &osl_groups[i * 2]));
}
OptixStackSizes stack_size[NUM_PROGRAM_GROUPS] = {};
vector<OptixStackSizes> osl_stack_size(osl_groups.size());
/* Update SBT with new entries. */
sbt_data.alloc(NUM_PROGRAM_GROUPS + osl_groups.size());
for (int i = 0; i < NUM_PROGRAM_GROUPS; ++i) {
optix_assert(optixSbtRecordPackHeader(groups[i], &sbt_data[i]));
optix_assert(optixProgramGroupGetStackSize(groups[i], &stack_size[i]));
}
for (size_t i = 0; i < osl_groups.size(); ++i) {
if (osl_groups[i] != NULL) {
@@ -907,13 +909,15 @@ bool OptiXDevice::load_osl_kernels()
0,
&pipelines[PIP_SHADE]));
const unsigned int css = std::max(stack_size[PG_RGEN_SHADE_SURFACE_RAYTRACE].cssRG,
stack_size[PG_RGEN_SHADE_SURFACE_MNEE].cssRG);
unsigned int dss = 0;
for (unsigned int i = 0; i < osl_stack_size.size(); ++i) {
dss = std::max(dss, osl_stack_size[i].dssDC);
}
optix_assert(optixPipelineSetStackSize(
pipelines[PIP_SHADE], 0, dss, 0, pipeline_options.usesMotionBlur ? 3 : 2));
pipelines[PIP_SHADE], 0, dss, css, pipeline_options.usesMotionBlur ? 3 : 2));
}
return !have_error();

View File

@@ -112,6 +112,13 @@ class DeviceQueue {
return 65536;
}
/* Does device support local atomic sorting kernels (INTEGRATOR_SORT_BUCKET_PASS and
* INTEGRATOR_SORT_WRITE_PASS)? */
virtual bool supports_local_atomic_sort() const
{
return false;
}
/* Initialize execution of kernels on this queue.
*
* Will, for example, load all data required by the kernels from Device to global or path state.

View File

@@ -5,6 +5,9 @@ set(INC
..
)
set(INC_SYS
)
set(SRC
node.cpp
node_type.cpp

View File

@@ -5,6 +5,9 @@ set(INC
..
)
set(INC_SYS
)
set(SRC
adaptive_sampling.cpp
denoiser.cpp

View File

@@ -15,6 +15,8 @@ struct GuidingParams {
bool use_volume_guiding = false;
GuidingDistributionType type = GUIDING_TYPE_PARALLAX_AWARE_VMM;
GuidingDirectionalSamplingType sampling_type = GUIDING_DIRECTIONAL_SAMPLING_TYPE_PRODUCT;
float roughness_threshold = 0.05f;
int training_samples = 128;
bool deterministic = false;
@@ -24,7 +26,9 @@ struct GuidingParams {
{
return !((use == other.use) && (use_surface_guiding == other.use_surface_guiding) &&
(use_volume_guiding == other.use_volume_guiding) && (type == other.type) &&
(sampling_type == other.sampling_type) &&
(training_samples == other.training_samples) &&
(roughness_threshold == other.roughness_threshold) &&
(deterministic == other.deterministic));
}
};

View File

@@ -359,8 +359,12 @@ void PathTraceWorkCPU::guiding_push_sample_data_to_global_storage(
# if PATH_GUIDING_LEVEL >= 2
const bool use_direct_light = kernel_data.integrator.use_guiding_direct_light;
const bool use_mis_weights = kernel_data.integrator.use_guiding_mis_weights;
# if OPENPGL_VERSION_MINOR >= 5
kg->opgl_path_segment_storage->PrepareSamples(use_mis_weights, use_direct_light, false);
# else
kg->opgl_path_segment_storage->PrepareSamples(
false, nullptr, use_mis_weights, use_direct_light, false);
# endif
# endif
# ifdef WITH_CYCLES_DEBUG

View File

@@ -71,6 +71,8 @@ PathTraceWorkGPU::PathTraceWorkGPU(Device *device,
device, "integrator_shader_mnee_sort_counter", MEM_READ_WRITE),
integrator_shader_sort_prefix_sum_(
device, "integrator_shader_sort_prefix_sum", MEM_READ_WRITE),
integrator_shader_sort_partition_key_offsets_(
device, "integrator_shader_sort_partition_key_offsets", MEM_READ_WRITE),
integrator_next_main_path_index_(device, "integrator_next_main_path_index", MEM_READ_WRITE),
integrator_next_shadow_path_index_(
device, "integrator_next_shadow_path_index", MEM_READ_WRITE),
@@ -207,33 +209,45 @@ void PathTraceWorkGPU::alloc_integrator_sorting()
integrator_state_gpu_.sort_partition_divisor = (int)divide_up(max_num_paths_,
num_sort_partitions_);
/* Allocate arrays for shader sorting. */
const int sort_buckets = device_scene_->data.max_shaders * num_sort_partitions_;
if (integrator_shader_sort_counter_.size() < sort_buckets) {
integrator_shader_sort_counter_.alloc(sort_buckets);
integrator_shader_sort_counter_.zero_to_device();
integrator_state_gpu_.sort_key_counter[DEVICE_KERNEL_INTEGRATOR_SHADE_SURFACE] =
(int *)integrator_shader_sort_counter_.device_pointer;
integrator_shader_sort_prefix_sum_.alloc(sort_buckets);
integrator_shader_sort_prefix_sum_.zero_to_device();
}
if (device_scene_->data.kernel_features & KERNEL_FEATURE_NODE_RAYTRACE) {
if (integrator_shader_raytrace_sort_counter_.size() < sort_buckets) {
integrator_shader_raytrace_sort_counter_.alloc(sort_buckets);
integrator_shader_raytrace_sort_counter_.zero_to_device();
integrator_state_gpu_.sort_key_counter[DEVICE_KERNEL_INTEGRATOR_SHADE_SURFACE_RAYTRACE] =
(int *)integrator_shader_raytrace_sort_counter_.device_pointer;
if (num_sort_partitions_ > 1 && queue_->supports_local_atomic_sort()) {
/* Allocate array for partitioned shader sorting using local atomics. */
const int num_offsets = (device_scene_->data.max_shaders + 1) * num_sort_partitions_;
if (integrator_shader_sort_partition_key_offsets_.size() < num_offsets) {
integrator_shader_sort_partition_key_offsets_.alloc(num_offsets);
integrator_shader_sort_partition_key_offsets_.zero_to_device();
}
integrator_state_gpu_.sort_partition_key_offsets =
(int *)integrator_shader_sort_partition_key_offsets_.device_pointer;
}
else {
/* Allocate arrays for shader sorting. */
const int sort_buckets = device_scene_->data.max_shaders * num_sort_partitions_;
if (integrator_shader_sort_counter_.size() < sort_buckets) {
integrator_shader_sort_counter_.alloc(sort_buckets);
integrator_shader_sort_counter_.zero_to_device();
integrator_state_gpu_.sort_key_counter[DEVICE_KERNEL_INTEGRATOR_SHADE_SURFACE] =
(int *)integrator_shader_sort_counter_.device_pointer;
if (device_scene_->data.kernel_features & KERNEL_FEATURE_MNEE) {
if (integrator_shader_mnee_sort_counter_.size() < sort_buckets) {
integrator_shader_mnee_sort_counter_.alloc(sort_buckets);
integrator_shader_mnee_sort_counter_.zero_to_device();
integrator_state_gpu_.sort_key_counter[DEVICE_KERNEL_INTEGRATOR_SHADE_SURFACE_MNEE] =
(int *)integrator_shader_mnee_sort_counter_.device_pointer;
integrator_shader_sort_prefix_sum_.alloc(sort_buckets);
integrator_shader_sort_prefix_sum_.zero_to_device();
}
if (device_scene_->data.kernel_features & KERNEL_FEATURE_NODE_RAYTRACE) {
if (integrator_shader_raytrace_sort_counter_.size() < sort_buckets) {
integrator_shader_raytrace_sort_counter_.alloc(sort_buckets);
integrator_shader_raytrace_sort_counter_.zero_to_device();
integrator_state_gpu_.sort_key_counter[DEVICE_KERNEL_INTEGRATOR_SHADE_SURFACE_RAYTRACE] =
(int *)integrator_shader_raytrace_sort_counter_.device_pointer;
}
}
if (device_scene_->data.kernel_features & KERNEL_FEATURE_MNEE) {
if (integrator_shader_mnee_sort_counter_.size() < sort_buckets) {
integrator_shader_mnee_sort_counter_.alloc(sort_buckets);
integrator_shader_mnee_sort_counter_.zero_to_device();
integrator_state_gpu_.sort_key_counter[DEVICE_KERNEL_INTEGRATOR_SHADE_SURFACE_MNEE] =
(int *)integrator_shader_mnee_sort_counter_.device_pointer;
}
}
}
}
@@ -451,8 +465,7 @@ void PathTraceWorkGPU::enqueue_path_iteration(DeviceKernel kernel, const int num
work_size = num_queued;
d_path_index = queued_paths_.device_pointer;
compute_sorted_queued_paths(
DEVICE_KERNEL_INTEGRATOR_SORTED_PATHS_ARRAY, kernel, num_paths_limit);
compute_sorted_queued_paths(kernel, num_paths_limit);
}
else if (num_queued < work_size) {
work_size = num_queued;
@@ -511,11 +524,26 @@ void PathTraceWorkGPU::enqueue_path_iteration(DeviceKernel kernel, const int num
}
}
void PathTraceWorkGPU::compute_sorted_queued_paths(DeviceKernel kernel,
DeviceKernel queued_kernel,
void PathTraceWorkGPU::compute_sorted_queued_paths(DeviceKernel queued_kernel,
const int num_paths_limit)
{
int d_queued_kernel = queued_kernel;
/* Launch kernel to fill the active paths arrays. */
if (num_sort_partitions_ > 1 && queue_->supports_local_atomic_sort()) {
const int work_size = kernel_max_active_main_path_index(queued_kernel);
device_ptr d_queued_paths = queued_paths_.device_pointer;
int partition_size = (int)integrator_state_gpu_.sort_partition_divisor;
DeviceKernelArguments args(
&work_size, &partition_size, &num_paths_limit, &d_queued_paths, &d_queued_kernel);
queue_->enqueue(DEVICE_KERNEL_INTEGRATOR_SORT_BUCKET_PASS, 1024 * num_sort_partitions_, args);
queue_->enqueue(DEVICE_KERNEL_INTEGRATOR_SORT_WRITE_PASS, 1024 * num_sort_partitions_, args);
return;
}
device_ptr d_counter = (device_ptr)integrator_state_gpu_.sort_key_counter[d_queued_kernel];
device_ptr d_prefix_sum = integrator_shader_sort_prefix_sum_.device_pointer;
assert(d_counter != 0 && d_prefix_sum != 0);
@@ -552,7 +580,7 @@ void PathTraceWorkGPU::compute_sorted_queued_paths(DeviceKernel kernel,
&d_prefix_sum,
&d_queued_kernel);
queue_->enqueue(kernel, work_size, args);
queue_->enqueue(DEVICE_KERNEL_INTEGRATOR_SORTED_PATHS_ARRAY, work_size, args);
}
}

View File

@@ -70,9 +70,7 @@ class PathTraceWorkGPU : public PathTraceWork {
void enqueue_path_iteration(DeviceKernel kernel, const int num_paths_limit = INT_MAX);
void compute_queued_paths(DeviceKernel kernel, DeviceKernel queued_kernel);
void compute_sorted_queued_paths(DeviceKernel kernel,
DeviceKernel queued_kernel,
const int num_paths_limit);
void compute_sorted_queued_paths(DeviceKernel queued_kernel, const int num_paths_limit);
void compact_main_paths(const int num_active_paths);
void compact_shadow_paths();
@@ -135,6 +133,7 @@ class PathTraceWorkGPU : public PathTraceWork {
device_vector<int> integrator_shader_raytrace_sort_counter_;
device_vector<int> integrator_shader_mnee_sort_counter_;
device_vector<int> integrator_shader_sort_prefix_sum_;
device_vector<int> integrator_shader_sort_partition_key_offsets_;
/* Path split. */
device_vector<int> integrator_next_main_path_index_;
device_vector<int> integrator_next_shadow_path_index_;

View File

@@ -14,9 +14,7 @@ set(INC_SYS
set(SRC_KERNEL_DEVICE_CPU
device/cpu/kernel.cpp
device/cpu/kernel_sse2.cpp
device/cpu/kernel_sse3.cpp
device/cpu/kernel_sse41.cpp
device/cpu/kernel_avx.cpp
device/cpu/kernel_avx2.cpp
)
@@ -296,6 +294,7 @@ set(SRC_KERNEL_LIGHT_HEADERS
light/spot.h
light/tree.h
light/triangle.h
light/visibility.h
)
set(SRC_KERNEL_SAMPLE_HEADERS
@@ -734,25 +733,25 @@ if(WITH_CYCLES_DEVICE_ONEAPI)
endif()
# SYCL_CPP_FLAGS is a variable that the user can set to pass extra compiler options
set(sycl_compiler_flags
${CMAKE_CURRENT_SOURCE_DIR}/${SRC_KERNEL_DEVICE_ONEAPI}
-fsycl
-fsycl-unnamed-lambda
-fdelayed-template-parsing
-mllvm -inlinedefault-threshold=250
-mllvm -inlinehint-threshold=350
-fsycl-device-code-split=per_kernel
-fsycl-max-parallel-link-jobs=${SYCL_OFFLINE_COMPILER_PARALLEL_JOBS}
-shared
-DWITH_ONEAPI
-ffast-math
-DNDEBUG
-O2
-o ${cycles_kernel_oneapi_lib}
-I${CMAKE_CURRENT_SOURCE_DIR}/..
${SYCL_CPP_FLAGS}
)
${CMAKE_CURRENT_SOURCE_DIR}/${SRC_KERNEL_DEVICE_ONEAPI}
-fsycl
-fsycl-unnamed-lambda
-fdelayed-template-parsing
-mllvm -inlinedefault-threshold=250
-mllvm -inlinehint-threshold=350
-fsycl-device-code-split=per_kernel
-fsycl-max-parallel-link-jobs=${SYCL_OFFLINE_COMPILER_PARALLEL_JOBS}
-shared
-DWITH_ONEAPI
-ffast-math
-DNDEBUG
-O2
-o ${cycles_kernel_oneapi_lib}
-I${CMAKE_CURRENT_SOURCE_DIR}/..
${SYCL_CPP_FLAGS}
)
if (WITH_CYCLES_ONEAPI_HOST_TASK_EXECUTION)
if(WITH_CYCLES_ONEAPI_HOST_TASK_EXECUTION)
list(APPEND sycl_compiler_flags -DWITH_ONEAPI_SYCL_HOST_TASK)
endif()
@@ -940,14 +939,9 @@ set_source_files_properties(device/cpu/kernel.cpp PROPERTIES COMPILE_FLAGS "${CY
if(CXX_HAS_SSE)
set_source_files_properties(device/cpu/kernel_sse2.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_SSE2_KERNEL_FLAGS}")
set_source_files_properties(device/cpu/kernel_sse3.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_SSE3_KERNEL_FLAGS}")
set_source_files_properties(device/cpu/kernel_sse41.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_SSE41_KERNEL_FLAGS}")
endif()
if(CXX_HAS_AVX)
set_source_files_properties(device/cpu/kernel_avx.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_AVX_KERNEL_FLAGS}")
endif()
if(CXX_HAS_AVX2)
set_source_files_properties(device/cpu/kernel_avx2.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_AVX2_KERNEL_FLAGS}")
endif()

View File

@@ -63,8 +63,9 @@ ccl_device void kernel_background_evaluate(KernelGlobals kg,
shader_setup_from_background(kg, &sd, ray_P, ray_D, ray_time);
/* Evaluate shader.
* This is being evaluated for all BSDFs, so path flag does not contain a specific type. */
const uint32_t path_flag = PATH_RAY_EMISSION;
* This is being evaluated for all BSDFs, so path flag does not contain a specific type.
* However, we want to flag the ray visibility to ignore the sun in the background map. */
const uint32_t path_flag = PATH_RAY_EMISSION | PATH_RAY_IMPORTANCE_BAKE;
surface_shader_eval<KERNEL_FEATURE_NODE_MASK_SURFACE_LIGHT &
~(KERNEL_FEATURE_NODE_RAYTRACE | KERNEL_FEATURE_NODE_LIGHT_PATH)>(
kg, INTEGRATOR_STATE_NULL, &sd, NULL, path_flag);

View File

@@ -102,10 +102,9 @@ ccl_device_inline float shift_cos_in(float cos_in, const float frequency_multipl
return val;
}
ccl_device_inline bool bsdf_is_transmission(ccl_private const ShaderClosure *sc,
const float3 omega_in)
ccl_device_inline bool bsdf_is_transmission(ccl_private const ShaderClosure *sc, const float3 wo)
{
return dot(sc->N, omega_in) < 0.0f;
return dot(sc->N, wo) < 0.0f;
}
ccl_device_inline int bsdf_sample(KernelGlobals kg,
@@ -114,55 +113,57 @@ ccl_device_inline int bsdf_sample(KernelGlobals kg,
float randu,
float randv,
ccl_private Spectrum *eval,
ccl_private float3 *omega_in,
ccl_private float3 *wo,
ccl_private float *pdf,
ccl_private float2 *sampled_roughness,
ccl_private float *eta)
{
/* For curves use the smooth normal, particularly for ribbons the geometric
* normal gives too much darkening otherwise. */
int label;
*eval = zero_spectrum();
*pdf = 0.f;
int label = LABEL_NONE;
const float3 Ng = (sd->type & PRIMITIVE_CURVE) ? sc->N : sd->Ng;
switch (sc->type) {
case CLOSURE_BSDF_DIFFUSE_ID:
label = bsdf_diffuse_sample(sc, Ng, sd->I, randu, randv, eval, omega_in, pdf);
label = bsdf_diffuse_sample(sc, Ng, sd->wi, randu, randv, eval, wo, pdf);
*sampled_roughness = one_float2();
*eta = 1.0f;
break;
#if defined(__SVM__) || defined(__OSL__)
case CLOSURE_BSDF_OREN_NAYAR_ID:
label = bsdf_oren_nayar_sample(sc, Ng, sd->I, randu, randv, eval, omega_in, pdf);
label = bsdf_oren_nayar_sample(sc, Ng, sd->wi, randu, randv, eval, wo, pdf);
*sampled_roughness = one_float2();
*eta = 1.0f;
break;
# ifdef __OSL__
case CLOSURE_BSDF_PHONG_RAMP_ID:
label = bsdf_phong_ramp_sample(
sc, Ng, sd->I, randu, randv, eval, omega_in, pdf, sampled_roughness);
sc, Ng, sd->wi, randu, randv, eval, wo, pdf, sampled_roughness);
*eta = 1.0f;
break;
case CLOSURE_BSDF_DIFFUSE_RAMP_ID:
label = bsdf_diffuse_ramp_sample(sc, Ng, sd->I, randu, randv, eval, omega_in, pdf);
label = bsdf_diffuse_ramp_sample(sc, Ng, sd->wi, randu, randv, eval, wo, pdf);
*sampled_roughness = one_float2();
*eta = 1.0f;
break;
# endif
case CLOSURE_BSDF_TRANSLUCENT_ID:
label = bsdf_translucent_sample(sc, Ng, sd->I, randu, randv, eval, omega_in, pdf);
label = bsdf_translucent_sample(sc, Ng, sd->wi, randu, randv, eval, wo, pdf);
*sampled_roughness = one_float2();
*eta = 1.0f;
break;
case CLOSURE_BSDF_REFLECTION_ID:
label = bsdf_reflection_sample(sc, Ng, sd->I, randu, randv, eval, omega_in, pdf, eta);
label = bsdf_reflection_sample(sc, Ng, sd->wi, randu, randv, eval, wo, pdf, eta);
*sampled_roughness = zero_float2();
break;
case CLOSURE_BSDF_REFRACTION_ID:
label = bsdf_refraction_sample(sc, Ng, sd->I, randu, randv, eval, omega_in, pdf, eta);
label = bsdf_refraction_sample(sc, Ng, sd->wi, randu, randv, eval, wo, pdf, eta);
*sampled_roughness = zero_float2();
break;
case CLOSURE_BSDF_TRANSPARENT_ID:
label = bsdf_transparent_sample(sc, Ng, sd->I, randu, randv, eval, omega_in, pdf);
label = bsdf_transparent_sample(sc, Ng, sd->wi, randu, randv, eval, wo, pdf);
*sampled_roughness = zero_float2();
*eta = 1.0f;
break;
@@ -171,85 +172,65 @@ ccl_device_inline int bsdf_sample(KernelGlobals kg,
case CLOSURE_BSDF_MICROFACET_GGX_CLEARCOAT_ID:
case CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID:
label = bsdf_microfacet_ggx_sample(
kg, sc, Ng, sd->I, randu, randv, eval, omega_in, pdf, sampled_roughness, eta);
sc, Ng, sd->wi, randu, randv, eval, wo, pdf, sampled_roughness, eta);
break;
case CLOSURE_BSDF_MICROFACET_MULTI_GGX_ID:
case CLOSURE_BSDF_MICROFACET_MULTI_GGX_FRESNEL_ID:
label = bsdf_microfacet_multi_ggx_sample(kg,
sc,
Ng,
sd->I,
randu,
randv,
eval,
omega_in,
pdf,
&sd->lcg_state,
sampled_roughness,
eta);
label = bsdf_microfacet_multi_ggx_sample(
kg, sc, Ng, sd->wi, randu, randv, eval, wo, pdf, &sd->lcg_state, sampled_roughness, eta);
break;
case CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_ID:
case CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_FRESNEL_ID:
label = bsdf_microfacet_multi_ggx_glass_sample(kg,
sc,
Ng,
sd->I,
randu,
randv,
eval,
omega_in,
pdf,
&sd->lcg_state,
sampled_roughness,
eta);
label = bsdf_microfacet_multi_ggx_glass_sample(
kg, sc, Ng, sd->wi, randu, randv, eval, wo, pdf, &sd->lcg_state, sampled_roughness, eta);
break;
case CLOSURE_BSDF_MICROFACET_BECKMANN_ID:
case CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID:
label = bsdf_microfacet_beckmann_sample(
kg, sc, Ng, sd->I, randu, randv, eval, omega_in, pdf, sampled_roughness, eta);
sc, Ng, sd->wi, randu, randv, eval, wo, pdf, sampled_roughness, eta);
break;
case CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ID:
label = bsdf_ashikhmin_shirley_sample(
sc, Ng, sd->I, randu, randv, eval, omega_in, pdf, sampled_roughness);
sc, Ng, sd->wi, randu, randv, eval, wo, pdf, sampled_roughness);
*eta = 1.0f;
break;
case CLOSURE_BSDF_ASHIKHMIN_VELVET_ID:
label = bsdf_ashikhmin_velvet_sample(sc, Ng, sd->I, randu, randv, eval, omega_in, pdf);
label = bsdf_ashikhmin_velvet_sample(sc, Ng, sd->wi, randu, randv, eval, wo, pdf);
*sampled_roughness = one_float2();
*eta = 1.0f;
break;
case CLOSURE_BSDF_DIFFUSE_TOON_ID:
label = bsdf_diffuse_toon_sample(sc, Ng, sd->I, randu, randv, eval, omega_in, pdf);
label = bsdf_diffuse_toon_sample(sc, Ng, sd->wi, randu, randv, eval, wo, pdf);
*sampled_roughness = one_float2();
*eta = 1.0f;
break;
case CLOSURE_BSDF_GLOSSY_TOON_ID:
label = bsdf_glossy_toon_sample(sc, Ng, sd->I, randu, randv, eval, omega_in, pdf);
label = bsdf_glossy_toon_sample(sc, Ng, sd->wi, randu, randv, eval, wo, pdf);
// double check if this is valid
*sampled_roughness = one_float2();
*eta = 1.0f;
break;
case CLOSURE_BSDF_HAIR_REFLECTION_ID:
label = bsdf_hair_reflection_sample(
sc, Ng, sd->I, randu, randv, eval, omega_in, pdf, sampled_roughness);
sc, Ng, sd->wi, randu, randv, eval, wo, pdf, sampled_roughness);
*eta = 1.0f;
break;
case CLOSURE_BSDF_HAIR_TRANSMISSION_ID:
label = bsdf_hair_transmission_sample(
sc, Ng, sd->I, randu, randv, eval, omega_in, pdf, sampled_roughness);
sc, Ng, sd->wi, randu, randv, eval, wo, pdf, sampled_roughness);
*eta = 1.0f;
break;
case CLOSURE_BSDF_HAIR_PRINCIPLED_ID:
label = bsdf_principled_hair_sample(
kg, sc, sd, randu, randv, eval, omega_in, pdf, sampled_roughness, eta);
kg, sc, sd, randu, randv, eval, wo, pdf, sampled_roughness, eta);
break;
case CLOSURE_BSDF_PRINCIPLED_DIFFUSE_ID:
label = bsdf_principled_diffuse_sample(sc, Ng, sd->I, randu, randv, eval, omega_in, pdf);
label = bsdf_principled_diffuse_sample(sc, Ng, sd->wi, randu, randv, eval, wo, pdf);
*sampled_roughness = one_float2();
*eta = 1.0f;
break;
case CLOSURE_BSDF_PRINCIPLED_SHEEN_ID:
label = bsdf_principled_sheen_sample(sc, Ng, sd->I, randu, randv, eval, omega_in, pdf);
label = bsdf_principled_sheen_sample(sc, Ng, sd->wi, randu, randv, eval, wo, pdf);
*sampled_roughness = one_float2();
*eta = 1.0f;
break;
@@ -274,12 +255,12 @@ ccl_device_inline int bsdf_sample(KernelGlobals kg,
const float frequency_multiplier =
kernel_data_fetch(objects, sd->object).shadow_terminator_shading_offset;
if (frequency_multiplier > 1.0f) {
const float cosNI = dot(*omega_in, sc->N);
*eval *= shift_cos_in(cosNI, frequency_multiplier);
const float cosNO = dot(*wo, sc->N);
*eval *= shift_cos_in(cosNO, frequency_multiplier);
}
if (label & LABEL_DIFFUSE) {
if (!isequal(sc->N, sd->N)) {
*eval *= bump_shadowing_term(sd->N, sc->N, *omega_in);
*eval *= bump_shadowing_term(sd->N, sc->N, *wo);
}
}
}
@@ -426,7 +407,7 @@ ccl_device_inline void bsdf_roughness_eta(const KernelGlobals kg,
ccl_device_inline int bsdf_label(const KernelGlobals kg,
ccl_private const ShaderClosure *sc,
const float3 omega_in)
const float3 wo)
{
/* For curves use the smooth normal, particularly for ribbons the geometric
* normal gives too much darkening otherwise. */
@@ -482,8 +463,8 @@ ccl_device_inline int bsdf_label(const KernelGlobals kg,
}
case CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_ID:
case CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_FRESNEL_ID:
label = (bsdf_is_transmission(sc, omega_in)) ? LABEL_TRANSMIT | LABEL_GLOSSY :
LABEL_REFLECT | LABEL_GLOSSY;
label = (bsdf_is_transmission(sc, wo)) ? LABEL_TRANSMIT | LABEL_GLOSSY :
LABEL_REFLECT | LABEL_GLOSSY;
break;
case CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ID:
label = LABEL_REFLECT | LABEL_GLOSSY;
@@ -504,7 +485,7 @@ ccl_device_inline int bsdf_label(const KernelGlobals kg,
label = LABEL_TRANSMIT | LABEL_GLOSSY;
break;
case CLOSURE_BSDF_HAIR_PRINCIPLED_ID:
if (bsdf_is_transmission(sc, omega_in))
if (bsdf_is_transmission(sc, wo))
label = LABEL_TRANSMIT | LABEL_GLOSSY;
else
label = LABEL_REFLECT | LABEL_GLOSSY;
@@ -543,83 +524,84 @@ ccl_device_inline
bsdf_eval(KernelGlobals kg,
ccl_private ShaderData *sd,
ccl_private const ShaderClosure *sc,
const float3 omega_in,
const float3 wo,
ccl_private float *pdf)
{
Spectrum eval = zero_spectrum();
*pdf = 0.f;
switch (sc->type) {
case CLOSURE_BSDF_DIFFUSE_ID:
eval = bsdf_diffuse_eval(sc, sd->I, omega_in, pdf);
eval = bsdf_diffuse_eval(sc, sd->wi, wo, pdf);
break;
#if defined(__SVM__) || defined(__OSL__)
case CLOSURE_BSDF_OREN_NAYAR_ID:
eval = bsdf_oren_nayar_eval(sc, sd->I, omega_in, pdf);
eval = bsdf_oren_nayar_eval(sc, sd->wi, wo, pdf);
break;
# ifdef __OSL__
case CLOSURE_BSDF_PHONG_RAMP_ID:
eval = bsdf_phong_ramp_eval(sc, sd->I, omega_in, pdf);
eval = bsdf_phong_ramp_eval(sc, sd->wi, wo, pdf);
break;
case CLOSURE_BSDF_DIFFUSE_RAMP_ID:
eval = bsdf_diffuse_ramp_eval(sc, sd->I, omega_in, pdf);
eval = bsdf_diffuse_ramp_eval(sc, sd->wi, wo, pdf);
break;
# endif
case CLOSURE_BSDF_TRANSLUCENT_ID:
eval = bsdf_translucent_eval(sc, sd->I, omega_in, pdf);
eval = bsdf_translucent_eval(sc, sd->wi, wo, pdf);
break;
case CLOSURE_BSDF_REFLECTION_ID:
eval = bsdf_reflection_eval(sc, sd->I, omega_in, pdf);
eval = bsdf_reflection_eval(sc, sd->wi, wo, pdf);
break;
case CLOSURE_BSDF_REFRACTION_ID:
eval = bsdf_refraction_eval(sc, sd->I, omega_in, pdf);
eval = bsdf_refraction_eval(sc, sd->wi, wo, pdf);
break;
case CLOSURE_BSDF_TRANSPARENT_ID:
eval = bsdf_transparent_eval(sc, sd->I, omega_in, pdf);
eval = bsdf_transparent_eval(sc, sd->wi, wo, pdf);
break;
case CLOSURE_BSDF_MICROFACET_GGX_ID:
case CLOSURE_BSDF_MICROFACET_GGX_FRESNEL_ID:
case CLOSURE_BSDF_MICROFACET_GGX_CLEARCOAT_ID:
case CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID:
eval = bsdf_microfacet_ggx_eval(sc, sd->N, sd->I, omega_in, pdf);
eval = bsdf_microfacet_ggx_eval(sc, sd->N, sd->wi, wo, pdf);
break;
case CLOSURE_BSDF_MICROFACET_MULTI_GGX_ID:
case CLOSURE_BSDF_MICROFACET_MULTI_GGX_FRESNEL_ID:
eval = bsdf_microfacet_multi_ggx_eval(sc, sd->N, sd->I, omega_in, pdf, &sd->lcg_state);
eval = bsdf_microfacet_multi_ggx_eval(sc, sd->N, sd->wi, wo, pdf, &sd->lcg_state);
break;
case CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_ID:
case CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_FRESNEL_ID:
eval = bsdf_microfacet_multi_ggx_glass_eval(sc, sd->I, omega_in, pdf, &sd->lcg_state);
eval = bsdf_microfacet_multi_ggx_glass_eval(sc, sd->wi, wo, pdf, &sd->lcg_state);
break;
case CLOSURE_BSDF_MICROFACET_BECKMANN_ID:
case CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID:
eval = bsdf_microfacet_beckmann_eval(sc, sd->N, sd->I, omega_in, pdf);
eval = bsdf_microfacet_beckmann_eval(sc, sd->N, sd->wi, wo, pdf);
break;
case CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ID:
eval = bsdf_ashikhmin_shirley_eval(sc, sd->N, sd->I, omega_in, pdf);
eval = bsdf_ashikhmin_shirley_eval(sc, sd->N, sd->wi, wo, pdf);
break;
case CLOSURE_BSDF_ASHIKHMIN_VELVET_ID:
eval = bsdf_ashikhmin_velvet_eval(sc, sd->I, omega_in, pdf);
eval = bsdf_ashikhmin_velvet_eval(sc, sd->wi, wo, pdf);
break;
case CLOSURE_BSDF_DIFFUSE_TOON_ID:
eval = bsdf_diffuse_toon_eval(sc, sd->I, omega_in, pdf);
eval = bsdf_diffuse_toon_eval(sc, sd->wi, wo, pdf);
break;
case CLOSURE_BSDF_GLOSSY_TOON_ID:
eval = bsdf_glossy_toon_eval(sc, sd->I, omega_in, pdf);
eval = bsdf_glossy_toon_eval(sc, sd->wi, wo, pdf);
break;
case CLOSURE_BSDF_HAIR_PRINCIPLED_ID:
eval = bsdf_principled_hair_eval(kg, sd, sc, omega_in, pdf);
eval = bsdf_principled_hair_eval(kg, sd, sc, wo, pdf);
break;
case CLOSURE_BSDF_HAIR_REFLECTION_ID:
eval = bsdf_hair_reflection_eval(sc, sd->I, omega_in, pdf);
eval = bsdf_hair_reflection_eval(sc, sd->wi, wo, pdf);
break;
case CLOSURE_BSDF_HAIR_TRANSMISSION_ID:
eval = bsdf_hair_transmission_eval(sc, sd->I, omega_in, pdf);
eval = bsdf_hair_transmission_eval(sc, sd->wi, wo, pdf);
break;
case CLOSURE_BSDF_PRINCIPLED_DIFFUSE_ID:
eval = bsdf_principled_diffuse_eval(sc, sd->I, omega_in, pdf);
eval = bsdf_principled_diffuse_eval(sc, sd->wi, wo, pdf);
break;
case CLOSURE_BSDF_PRINCIPLED_SHEEN_ID:
eval = bsdf_principled_sheen_eval(sc, sd->I, omega_in, pdf);
eval = bsdf_principled_sheen_eval(sc, sd->wi, wo, pdf);
break;
#endif
default:
@@ -628,7 +610,7 @@ ccl_device_inline
if (CLOSURE_IS_BSDF_DIFFUSE(sc->type)) {
if (!isequal(sc->N, sd->N)) {
eval *= bump_shadowing_term(sd->N, sc->N, omega_in);
eval *= bump_shadowing_term(sd->N, sc->N, wo);
}
}
@@ -636,9 +618,9 @@ ccl_device_inline
const float frequency_multiplier =
kernel_data_fetch(objects, sd->object).shadow_terminator_shading_offset;
if (frequency_multiplier > 1.0f) {
const float cosNI = dot(omega_in, sc->N);
if (cosNI >= 0.0f) {
eval *= shift_cos_in(cosNI, frequency_multiplier);
const float cosNO = dot(wo, sc->N);
if (cosNO >= 0.0f) {
eval *= shift_cos_in(cosNO, frequency_multiplier);
}
}
@@ -682,4 +664,38 @@ ccl_device void bsdf_blur(KernelGlobals kg, ccl_private ShaderClosure *sc, float
#endif
}
ccl_device_inline Spectrum bsdf_albedo(ccl_private const ShaderData *sd,
ccl_private const ShaderClosure *sc)
{
Spectrum albedo = sc->weight;
/* Some closures include additional components such as Fresnel terms that cause their albedo to
* be below 1. The point of this function is to return a best-effort estimation of their albedo,
* meaning the amount of reflected/refracted light that would be expected when illuminated by a
* uniform white background.
* This is used for the denoising albedo pass and diffuse/glossy/transmission color passes.
* NOTE: This should always match the sample_weight of the closure - as in, if there's an albedo
* adjustment in here, the sample_weight should also be reduced accordingly.
* TODO(lukas): Consider calling this function to determine the sample_weight? Would be a bit of
* extra overhead though. */
#if defined(__SVM__) || defined(__OSL__)
switch (sc->type) {
case CLOSURE_BSDF_MICROFACET_GGX_FRESNEL_ID:
case CLOSURE_BSDF_MICROFACET_MULTI_GGX_FRESNEL_ID:
case CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_FRESNEL_ID:
case CLOSURE_BSDF_MICROFACET_GGX_CLEARCOAT_ID:
albedo *= microfacet_fresnel((ccl_private const MicrofacetBsdf *)sc, sd->wi, sc->N);
break;
case CLOSURE_BSDF_PRINCIPLED_SHEEN_ID:
albedo *= ((ccl_private const PrincipledSheenBsdf *)sc)->avg_value;
break;
case CLOSURE_BSDF_HAIR_PRINCIPLED_ID:
albedo *= bsdf_principled_hair_albedo(sc);
break;
default:
break;
}
#endif
return albedo;
}
CCL_NAMESPACE_END

View File

@@ -41,20 +41,20 @@ ccl_device_inline float bsdf_ashikhmin_shirley_roughness_to_exponent(float rough
ccl_device_forceinline Spectrum bsdf_ashikhmin_shirley_eval(ccl_private const ShaderClosure *sc,
const float3 Ng,
const float3 I,
const float3 omega_in,
const float3 wi,
const float3 wo,
ccl_private float *pdf)
{
ccl_private const MicrofacetBsdf *bsdf = (ccl_private const MicrofacetBsdf *)sc;
const float cosNgI = dot(Ng, omega_in);
const float cosNgO = dot(Ng, wo);
float3 N = bsdf->N;
float NdotI = dot(N, I); /* in Cycles/OSL convention I is omega_out */
float NdotO = dot(N, omega_in); /* and consequently we use for O omaga_in ;) */
float NdotI = dot(N, wi);
float NdotO = dot(N, wo);
float out = 0.0f;
if ((cosNgI < 0.0f) || fmaxf(bsdf->alpha_x, bsdf->alpha_y) <= 1e-4f ||
if ((cosNgO < 0.0f) || fmaxf(bsdf->alpha_x, bsdf->alpha_y) <= 1e-4f ||
!(NdotI > 0.0f && NdotO > 0.0f)) {
*pdf = 0.0f;
return zero_spectrum();
@@ -62,15 +62,15 @@ ccl_device_forceinline Spectrum bsdf_ashikhmin_shirley_eval(ccl_private const Sh
NdotI = fmaxf(NdotI, 1e-6f);
NdotO = fmaxf(NdotO, 1e-6f);
float3 H = normalize(omega_in + I);
float HdotI = fmaxf(fabsf(dot(H, I)), 1e-6f);
float3 H = normalize(wi + wo);
float HdotI = fmaxf(fabsf(dot(H, wi)), 1e-6f);
float HdotN = fmaxf(dot(H, N), 1e-6f);
/* pump from original paper
* (first derivative disc., but cancels the HdotI in the pdf nicely) */
float pump = 1.0f / fmaxf(1e-6f, (HdotI * fmaxf(NdotO, NdotI)));
float pump = 1.0f / fmaxf(1e-6f, (HdotI * fmaxf(NdotI, NdotO)));
/* pump from d-brdf paper */
/*float pump = 1.0f / fmaxf(1e-4f, ((NdotO + NdotI) * (NdotO*NdotI))); */
/*float pump = 1.0f / fmaxf(1e-4f, ((NdotI + NdotO) * (NdotI * NdotO))); */
float n_x = bsdf_ashikhmin_shirley_roughness_to_exponent(bsdf->alpha_x);
float n_y = bsdf_ashikhmin_shirley_roughness_to_exponent(bsdf->alpha_y);
@@ -124,11 +124,11 @@ ccl_device_inline void bsdf_ashikhmin_shirley_sample_first_quadrant(float n_x,
ccl_device int bsdf_ashikhmin_shirley_sample(ccl_private const ShaderClosure *sc,
float3 Ng,
float3 I,
float3 wi,
float randu,
float randv,
ccl_private Spectrum *eval,
ccl_private float3 *omega_in,
ccl_private float3 *wo,
ccl_private float *pdf,
ccl_private float2 *sampled_roughness)
{
@@ -137,7 +137,7 @@ ccl_device int bsdf_ashikhmin_shirley_sample(ccl_private const ShaderClosure *sc
float3 N = bsdf->N;
int label = LABEL_REFLECT | LABEL_GLOSSY;
float NdotI = dot(N, I);
float NdotI = dot(N, wi);
if (!(NdotI > 0.0f)) {
*pdf = 0.0f;
*eval = zero_spectrum();
@@ -198,12 +198,12 @@ ccl_device int bsdf_ashikhmin_shirley_sample(ccl_private const ShaderClosure *sc
/* half vector to world space */
float3 H = h.x * X + h.y * Y + h.z * N;
float HdotI = dot(H, I);
float HdotI = dot(H, wi);
if (HdotI < 0.0f)
H = -H;
/* reflect I on H to get omega_in */
*omega_in = -I + (2.0f * HdotI) * H;
/* reflect wi on H to get wo */
*wo = -wi + (2.0f * HdotI) * H;
if (fmaxf(bsdf->alpha_x, bsdf->alpha_y) <= 1e-4f) {
/* Some high number for MIS. */
@@ -213,7 +213,7 @@ ccl_device int bsdf_ashikhmin_shirley_sample(ccl_private const ShaderClosure *sc
}
else {
/* leave the rest to eval */
*eval = bsdf_ashikhmin_shirley_eval(sc, N, I, *omega_in, pdf);
*eval = bsdf_ashikhmin_shirley_eval(sc, N, wi, *wo, pdf);
}
return label;

View File

@@ -32,35 +32,35 @@ ccl_device int bsdf_ashikhmin_velvet_setup(ccl_private VelvetBsdf *bsdf)
}
ccl_device Spectrum bsdf_ashikhmin_velvet_eval(ccl_private const ShaderClosure *sc,
const float3 I,
const float3 omega_in,
const float3 wi,
const float3 wo,
ccl_private float *pdf)
{
ccl_private const VelvetBsdf *bsdf = (ccl_private const VelvetBsdf *)sc;
float m_invsigma2 = bsdf->invsigma2;
float3 N = bsdf->N;
float cosNO = dot(N, I);
float cosNI = dot(N, omega_in);
if (!(cosNO > 0 && cosNI > 0)) {
float cosNI = dot(N, wi);
float cosNO = dot(N, wo);
if (!(cosNI > 0 && cosNO > 0)) {
*pdf = 0.0f;
return zero_spectrum();
}
float3 H = normalize(omega_in + I);
float3 H = normalize(wi + wo);
float cosNH = dot(N, H);
float cosHO = fabsf(dot(I, H));
float cosHI = fabsf(dot(wi, H));
if (!(fabsf(cosNH) < 1.0f - 1e-5f && cosHO > 1e-5f)) {
if (!(fabsf(cosNH) < 1.0f - 1e-5f && cosHI > 1e-5f)) {
*pdf = 0.0f;
return zero_spectrum();
}
float cosNHdivHO = cosNH / cosHO;
cosNHdivHO = fmaxf(cosNHdivHO, 1e-5f);
float cosNHdivHI = cosNH / cosHI;
cosNHdivHI = fmaxf(cosNHdivHI, 1e-5f);
float fac1 = 2 * fabsf(cosNHdivHO * cosNO);
float fac2 = 2 * fabsf(cosNHdivHO * cosNI);
float fac1 = 2 * fabsf(cosNHdivHI * cosNI);
float fac2 = 2 * fabsf(cosNHdivHI * cosNO);
float sinNH2 = 1 - cosNH * cosNH;
float sinNH4 = sinNH2 * sinNH2;
@@ -69,7 +69,7 @@ ccl_device Spectrum bsdf_ashikhmin_velvet_eval(ccl_private const ShaderClosure *
float D = expf(-cotangent2 * m_invsigma2) * m_invsigma2 * M_1_PI_F / sinNH4;
float G = fminf(1.0f, fminf(fac1, fac2)); // TODO: derive G from D analytically
float out = 0.25f * (D * G) / cosNO;
float out = 0.25f * (D * G) / cosNI;
*pdf = 0.5f * M_1_PI_F;
return make_spectrum(out);
@@ -77,11 +77,11 @@ ccl_device Spectrum bsdf_ashikhmin_velvet_eval(ccl_private const ShaderClosure *
ccl_device int bsdf_ashikhmin_velvet_sample(ccl_private const ShaderClosure *sc,
float3 Ng,
float3 I,
float3 wi,
float randu,
float randv,
ccl_private Spectrum *eval,
ccl_private float3 *omega_in,
ccl_private float3 *wo,
ccl_private float *pdf)
{
ccl_private const VelvetBsdf *bsdf = (ccl_private const VelvetBsdf *)sc;
@@ -90,32 +90,32 @@ ccl_device int bsdf_ashikhmin_velvet_sample(ccl_private const ShaderClosure *sc,
// we are viewing the surface from above - send a ray out with uniform
// distribution over the hemisphere
sample_uniform_hemisphere(N, randu, randv, omega_in, pdf);
sample_uniform_hemisphere(N, randu, randv, wo, pdf);
if (!(dot(Ng, *omega_in) > 0)) {
if (!(dot(Ng, *wo) > 0)) {
*pdf = 0.0f;
*eval = zero_spectrum();
return LABEL_NONE;
}
float3 H = normalize(*omega_in + I);
float3 H = normalize(wi + *wo);
float cosNI = dot(N, *omega_in);
float cosNO = dot(N, I);
float cosNI = dot(N, wi);
float cosNO = dot(N, *wo);
float cosHI = fabsf(dot(wi, H));
float cosNH = dot(N, H);
float cosHO = fabsf(dot(I, H));
if (!(fabsf(cosNO) > 1e-5f && fabsf(cosNH) < 1.0f - 1e-5f && cosHO > 1e-5f)) {
if (!(fabsf(cosNI) > 1e-5f && fabsf(cosNH) < 1.0f - 1e-5f && cosHI > 1e-5f)) {
*pdf = 0.0f;
*eval = zero_spectrum();
return LABEL_NONE;
}
float cosNHdivHO = cosNH / cosHO;
cosNHdivHO = fmaxf(cosNHdivHO, 1e-5f);
float cosNHdivHI = cosNH / cosHI;
cosNHdivHI = fmaxf(cosNHdivHI, 1e-5f);
float fac1 = 2 * fabsf(cosNHdivHO * cosNO);
float fac2 = 2 * fabsf(cosNHdivHO * cosNI);
float fac1 = 2 * fabsf(cosNHdivHI * cosNI);
float fac2 = 2 * fabsf(cosNHdivHI * cosNO);
float sinNH2 = 1 - cosNH * cosNH;
float sinNH4 = sinNH2 * sinNH2;
@@ -124,7 +124,7 @@ ccl_device int bsdf_ashikhmin_velvet_sample(ccl_private const ShaderClosure *sc,
float D = expf(-cotangent2 * m_invsigma2) * m_invsigma2 * M_1_PI_F / sinNH4;
float G = fminf(1.0f, fminf(fac1, fac2)); // TODO: derive G from D analytically
float power = 0.25f * (D * G) / cosNO;
float power = 0.25f * (D * G) / cosNI;
*eval = make_spectrum(power);

View File

@@ -27,34 +27,34 @@ ccl_device int bsdf_diffuse_setup(ccl_private DiffuseBsdf *bsdf)
}
ccl_device Spectrum bsdf_diffuse_eval(ccl_private const ShaderClosure *sc,
const float3 I,
const float3 omega_in,
const float3 wi,
const float3 wo,
ccl_private float *pdf)
{
ccl_private const DiffuseBsdf *bsdf = (ccl_private const DiffuseBsdf *)sc;
float3 N = bsdf->N;
float cos_pi = fmaxf(dot(N, omega_in), 0.0f) * M_1_PI_F;
*pdf = cos_pi;
return make_spectrum(cos_pi);
float cosNO = fmaxf(dot(N, wo), 0.0f) * M_1_PI_F;
*pdf = cosNO;
return make_spectrum(cosNO);
}
ccl_device int bsdf_diffuse_sample(ccl_private const ShaderClosure *sc,
float3 Ng,
float3 I,
float3 wi,
float randu,
float randv,
ccl_private Spectrum *eval,
ccl_private float3 *omega_in,
ccl_private float3 *wo,
ccl_private float *pdf)
{
ccl_private const DiffuseBsdf *bsdf = (ccl_private const DiffuseBsdf *)sc;
float3 N = bsdf->N;
// distribution over the hemisphere
sample_cos_hemisphere(N, randu, randv, omega_in, pdf);
sample_cos_hemisphere(N, randu, randv, wo, pdf);
if (dot(Ng, *omega_in) > 0.0f) {
if (dot(Ng, *wo) > 0.0f) {
*eval = make_spectrum(*pdf);
}
else {
@@ -73,25 +73,25 @@ ccl_device int bsdf_translucent_setup(ccl_private DiffuseBsdf *bsdf)
}
ccl_device Spectrum bsdf_translucent_eval(ccl_private const ShaderClosure *sc,
const float3 I,
const float3 omega_in,
const float3 wi,
const float3 wo,
ccl_private float *pdf)
{
ccl_private const DiffuseBsdf *bsdf = (ccl_private const DiffuseBsdf *)sc;
float3 N = bsdf->N;
float cos_pi = fmaxf(-dot(N, omega_in), 0.0f) * M_1_PI_F;
*pdf = cos_pi;
return make_spectrum(cos_pi);
float cosNO = fmaxf(-dot(N, wo), 0.0f) * M_1_PI_F;
*pdf = cosNO;
return make_spectrum(cosNO);
}
ccl_device int bsdf_translucent_sample(ccl_private const ShaderClosure *sc,
float3 Ng,
float3 I,
float3 wi,
float randu,
float randv,
ccl_private Spectrum *eval,
ccl_private float3 *omega_in,
ccl_private float3 *wo,
ccl_private float *pdf)
{
ccl_private const DiffuseBsdf *bsdf = (ccl_private const DiffuseBsdf *)sc;
@@ -99,8 +99,8 @@ ccl_device int bsdf_translucent_sample(ccl_private const ShaderClosure *sc,
// we are viewing the surface from the right side - send a ray out with cosine
// distribution over the hemisphere
sample_cos_hemisphere(-N, randu, randv, omega_in, pdf);
if (dot(Ng, *omega_in) < 0) {
sample_cos_hemisphere(-N, randu, randv, wo, pdf);
if (dot(Ng, *wo) < 0) {
*eval = make_spectrum(*pdf);
}
else {

View File

@@ -48,17 +48,17 @@ ccl_device void bsdf_diffuse_ramp_blur(ccl_private ShaderClosure *sc, float roug
}
ccl_device Spectrum bsdf_diffuse_ramp_eval(ccl_private const ShaderClosure *sc,
const float3 I,
const float3 omega_in,
const float3 wi,
const float3 wo,
ccl_private float *pdf)
{
const DiffuseRampBsdf *bsdf = (const DiffuseRampBsdf *)sc;
float3 N = bsdf->N;
float cos_pi = fmaxf(dot(N, omega_in), 0.0f);
if (cos_pi >= 0.0f) {
*pdf = cos_pi * M_1_PI_F;
return rgb_to_spectrum(bsdf_diffuse_ramp_get_color(bsdf->colors, cos_pi) * M_1_PI_F);
float cosNO = fmaxf(dot(N, wo), 0.0f);
if (cosNO >= 0.0f) {
*pdf = cosNO * M_1_PI_F;
return rgb_to_spectrum(bsdf_diffuse_ramp_get_color(bsdf->colors, cosNO) * M_1_PI_F);
}
else {
*pdf = 0.0f;
@@ -68,20 +68,20 @@ ccl_device Spectrum bsdf_diffuse_ramp_eval(ccl_private const ShaderClosure *sc,
ccl_device int bsdf_diffuse_ramp_sample(ccl_private const ShaderClosure *sc,
float3 Ng,
float3 I,
float3 wi,
float randu,
float randv,
ccl_private Spectrum *eval,
ccl_private float3 *omega_in,
ccl_private float3 *wo,
ccl_private float *pdf)
{
const DiffuseRampBsdf *bsdf = (const DiffuseRampBsdf *)sc;
float3 N = bsdf->N;
// distribution over the hemisphere
sample_cos_hemisphere(N, randu, randv, omega_in, pdf);
sample_cos_hemisphere(N, randu, randv, wo, pdf);
if (dot(Ng, *omega_in) > 0.0f) {
if (dot(Ng, *wo) > 0.0f) {
*eval = rgb_to_spectrum(bsdf_diffuse_ramp_get_color(bsdf->colors, *pdf * M_PI_F) * M_1_PI_F);
}
else {

View File

@@ -38,12 +38,12 @@ ccl_device int bsdf_hair_transmission_setup(ccl_private HairBsdf *bsdf)
}
ccl_device Spectrum bsdf_hair_reflection_eval(ccl_private const ShaderClosure *sc,
const float3 I,
const float3 omega_in,
const float3 wi,
const float3 wo,
ccl_private float *pdf)
{
ccl_private const HairBsdf *bsdf = (ccl_private const HairBsdf *)sc;
if (dot(bsdf->N, omega_in) < 0.0f) {
if (dot(bsdf->N, wo) < 0.0f) {
*pdf = 0.0f;
return zero_spectrum();
}
@@ -53,16 +53,16 @@ ccl_device Spectrum bsdf_hair_reflection_eval(ccl_private const ShaderClosure *s
float roughness1 = bsdf->roughness1;
float roughness2 = bsdf->roughness2;
float Iz = dot(Tg, I);
float3 locy = normalize(I - Tg * Iz);
float Iz = dot(Tg, wi);
float3 locy = normalize(wi - Tg * Iz);
float theta_r = M_PI_2_F - fast_acosf(Iz);
float omega_in_z = dot(Tg, omega_in);
float3 omega_in_y = normalize(omega_in - Tg * omega_in_z);
float wo_z = dot(Tg, wo);
float3 wo_y = normalize(wo - Tg * wo_z);
float theta_i = M_PI_2_F - fast_acosf(omega_in_z);
float cosphi_i = dot(omega_in_y, locy);
float theta_i = M_PI_2_F - fast_acosf(wo_z);
float cosphi_i = dot(wo_y, locy);
if (M_PI_2_F - fabsf(theta_i) < 0.001f || cosphi_i < 0.0f) {
*pdf = 0.0f;
@@ -90,12 +90,12 @@ ccl_device Spectrum bsdf_hair_reflection_eval(ccl_private const ShaderClosure *s
}
ccl_device Spectrum bsdf_hair_transmission_eval(ccl_private const ShaderClosure *sc,
const float3 I,
const float3 omega_in,
const float3 wi,
const float3 wo,
ccl_private float *pdf)
{
ccl_private const HairBsdf *bsdf = (ccl_private const HairBsdf *)sc;
if (dot(bsdf->N, omega_in) >= 0.0f) {
if (dot(bsdf->N, wo) >= 0.0f) {
*pdf = 0.0f;
return zero_spectrum();
}
@@ -104,16 +104,16 @@ ccl_device Spectrum bsdf_hair_transmission_eval(ccl_private const ShaderClosure
float3 Tg = bsdf->T;
float roughness1 = bsdf->roughness1;
float roughness2 = bsdf->roughness2;
float Iz = dot(Tg, I);
float3 locy = normalize(I - Tg * Iz);
float Iz = dot(Tg, wi);
float3 locy = normalize(wi - Tg * Iz);
float theta_r = M_PI_2_F - fast_acosf(Iz);
float omega_in_z = dot(Tg, omega_in);
float3 omega_in_y = normalize(omega_in - Tg * omega_in_z);
float wo_z = dot(Tg, wo);
float3 wo_y = normalize(wo - Tg * wo_z);
float theta_i = M_PI_2_F - fast_acosf(omega_in_z);
float phi_i = fast_acosf(dot(omega_in_y, locy));
float theta_i = M_PI_2_F - fast_acosf(wo_z);
float phi_i = fast_acosf(dot(wo_y, locy));
if (M_PI_2_F - fabsf(theta_i) < 0.001f) {
*pdf = 0.0f;
@@ -142,11 +142,11 @@ ccl_device Spectrum bsdf_hair_transmission_eval(ccl_private const ShaderClosure
ccl_device int bsdf_hair_reflection_sample(ccl_private const ShaderClosure *sc,
float3 Ng,
float3 I,
float3 wi,
float randu,
float randv,
ccl_private Spectrum *eval,
ccl_private float3 *omega_in,
ccl_private float3 *wo,
ccl_private float *pdf,
ccl_private float2 *sampled_roughness)
{
@@ -156,8 +156,8 @@ ccl_device int bsdf_hair_reflection_sample(ccl_private const ShaderClosure *sc,
float roughness1 = bsdf->roughness1;
float roughness2 = bsdf->roughness2;
*sampled_roughness = make_float2(roughness1, roughness2);
float Iz = dot(Tg, I);
float3 locy = normalize(I - Tg * Iz);
float Iz = dot(Tg, wi);
float3 locy = normalize(wi - Tg * Iz);
float3 locx = cross(locy, Tg);
float theta_r = M_PI_2_F - fast_acosf(Iz);
@@ -182,7 +182,7 @@ ccl_device int bsdf_hair_reflection_sample(ccl_private const ShaderClosure *sc,
float sinphi, cosphi;
fast_sincosf(phi, &sinphi, &cosphi);
*omega_in = (cosphi * costheta_i) * locy - (sinphi * costheta_i) * locx + (sintheta_i)*Tg;
*wo = (cosphi * costheta_i) * locy - (sinphi * costheta_i) * locx + (sintheta_i)*Tg;
*pdf = fabsf(phi_pdf * theta_pdf);
if (M_PI_2_F - fabsf(theta_i) < 0.001f)
@@ -195,11 +195,11 @@ ccl_device int bsdf_hair_reflection_sample(ccl_private const ShaderClosure *sc,
ccl_device int bsdf_hair_transmission_sample(ccl_private const ShaderClosure *sc,
float3 Ng,
float3 I,
float3 wi,
float randu,
float randv,
ccl_private Spectrum *eval,
ccl_private float3 *omega_in,
ccl_private float3 *wo,
ccl_private float *pdf,
ccl_private float2 *sampled_roughness)
{
@@ -209,8 +209,8 @@ ccl_device int bsdf_hair_transmission_sample(ccl_private const ShaderClosure *sc
float roughness1 = bsdf->roughness1;
float roughness2 = bsdf->roughness2;
*sampled_roughness = make_float2(roughness1, roughness2);
float Iz = dot(Tg, I);
float3 locy = normalize(I - Tg * Iz);
float Iz = dot(Tg, wi);
float3 locy = normalize(wi - Tg * Iz);
float3 locx = cross(locy, Tg);
float theta_r = M_PI_2_F - fast_acosf(Iz);
@@ -235,7 +235,7 @@ ccl_device int bsdf_hair_transmission_sample(ccl_private const ShaderClosure *sc
float sinphi, cosphi;
fast_sincosf(phi, &sinphi, &cosphi);
*omega_in = (cosphi * costheta_i) * locy - (sinphi * costheta_i) * locx + (sintheta_i)*Tg;
*wo = (cosphi * costheta_i) * locy - (sinphi * costheta_i) * locx + (sintheta_i)*Tg;
*pdf = fabsf(phi_pdf * theta_pdf);
if (M_PI_2_F - fabsf(theta_i) < 0.001f) {
@@ -247,7 +247,7 @@ ccl_device int bsdf_hair_transmission_sample(ccl_private const ShaderClosure *sc
/* TODO(sergey): Should always be negative, but seems some precision issue
* is involved here.
*/
kernel_assert(dot(locy, *omega_in) < 1e-4f);
kernel_assert(dot(locy, *wo) < 1e-4f);
return LABEL_TRANSMIT | LABEL_GLOSSY;
}

View File

@@ -41,11 +41,6 @@ static_assert(sizeof(ShaderClosure) >= sizeof(PrincipledHairBSDF),
static_assert(sizeof(ShaderClosure) >= sizeof(PrincipledHairExtra),
"PrincipledHairExtra is too large!");
ccl_device_inline float cos_from_sin(const float s)
{
return safe_sqrtf(1.0f - s * s);
}
/* Gives the change in direction in the normal plane for the given angles and p-th-order
* scattering. */
ccl_device_inline float delta_phi(int p, float gamma_o, float gamma_t)
@@ -179,7 +174,7 @@ ccl_device int bsdf_principled_hair_setup(ccl_private ShaderData *sd,
/* Compute local frame, aligned to curve tangent and ray direction. */
float3 X = safe_normalize(sd->dPdu);
float3 Y = safe_normalize(cross(X, sd->I));
float3 Y = safe_normalize(cross(X, sd->wi));
float3 Z = safe_normalize(cross(X, Y));
/* h -1..0..1 means the rays goes from grazing the hair, to hitting it at
@@ -259,7 +254,7 @@ ccl_device_inline void hair_alpha_angles(float sin_theta_i,
ccl_device Spectrum bsdf_principled_hair_eval(KernelGlobals kg,
ccl_private const ShaderData *sd,
ccl_private const ShaderClosure *sc,
const float3 omega_in,
const float3 wo,
ccl_private float *pdf)
{
kernel_assert(isfinite_safe(sd->P) && isfinite_safe(sd->ray_length));
@@ -271,12 +266,13 @@ ccl_device Spectrum bsdf_principled_hair_eval(KernelGlobals kg,
kernel_assert(fabsf(dot(X, Y)) < 1e-3f);
const float3 Z = safe_normalize(cross(X, Y));
const float3 wo = make_float3(dot(sd->I, X), dot(sd->I, Y), dot(sd->I, Z));
const float3 wi = make_float3(dot(omega_in, X), dot(omega_in, Y), dot(omega_in, Z));
/* local_I is the illumination direction. */
const float3 local_O = make_float3(dot(sd->wi, X), dot(sd->wi, Y), dot(sd->wi, Z));
const float3 local_I = make_float3(dot(wo, X), dot(wo, Y), dot(wo, Z));
const float sin_theta_o = wo.x;
const float sin_theta_o = local_O.x;
const float cos_theta_o = cos_from_sin(sin_theta_o);
const float phi_o = atan2f(wo.z, wo.y);
const float phi_o = atan2f(local_O.z, local_O.y);
const float sin_theta_t = sin_theta_o / bsdf->eta;
const float cos_theta_t = cos_from_sin(sin_theta_t);
@@ -295,9 +291,9 @@ ccl_device Spectrum bsdf_principled_hair_eval(KernelGlobals kg,
hair_attenuation(
kg, fresnel_dielectric_cos(cos_theta_o * cos_gamma_o, bsdf->eta), T, Ap, Ap_energy);
const float sin_theta_i = wi.x;
const float sin_theta_i = local_I.x;
const float cos_theta_i = cos_from_sin(sin_theta_i);
const float phi_i = atan2f(wi.z, wi.y);
const float phi_i = atan2f(local_I.z, local_I.y);
const float phi = phi_i - phi_o;
@@ -343,7 +339,7 @@ ccl_device int bsdf_principled_hair_sample(KernelGlobals kg,
float randu,
float randv,
ccl_private Spectrum *eval,
ccl_private float3 *omega_in,
ccl_private float3 *wo,
ccl_private float *pdf,
ccl_private float2 *sampled_roughness,
ccl_private float *eta)
@@ -359,16 +355,16 @@ ccl_device int bsdf_principled_hair_sample(KernelGlobals kg,
kernel_assert(fabsf(dot(X, Y)) < 1e-3f);
const float3 Z = safe_normalize(cross(X, Y));
const float3 wo = make_float3(dot(sd->I, X), dot(sd->I, Y), dot(sd->I, Z));
const float3 local_O = make_float3(dot(sd->wi, X), dot(sd->wi, Y), dot(sd->wi, Z));
float2 u[2];
u[0] = make_float2(randu, randv);
u[1].x = lcg_step_float(&sd->lcg_state);
u[1].y = lcg_step_float(&sd->lcg_state);
const float sin_theta_o = wo.x;
const float sin_theta_o = local_O.x;
const float cos_theta_o = cos_from_sin(sin_theta_o);
const float phi_o = atan2f(wo.z, wo.y);
const float phi_o = atan2f(local_O.z, local_O.y);
const float sin_theta_t = sin_theta_o / bsdf->eta;
const float cos_theta_t = cos_from_sin(sin_theta_t);
@@ -458,7 +454,7 @@ ccl_device int bsdf_principled_hair_sample(KernelGlobals kg,
*eval = F;
*pdf = F_energy;
*omega_in = X * sin_theta_i + Y * cos_theta_i * cosf(phi_i) + Z * cos_theta_i * sinf(phi_i);
*wo = X * sin_theta_i + Y * cos_theta_i * cosf(phi_i) + Z * cos_theta_i * sinf(phi_i);
return LABEL_GLOSSY | ((p == 0) ? LABEL_REFLECT : LABEL_TRANSMIT);
}

File diff suppressed because it is too large Load Diff

View File

@@ -43,7 +43,7 @@ ccl_device_forceinline float2 mf_sampleP22_11(const float cosI,
return make_float2(r * cosf(phi), r * sinf(phi));
}
const float sinI = safe_sqrtf(1.0f - cosI * cosI);
const float sinI = sin_from_cos(cosI);
const float tanI = sinI / cosI;
const float projA = 0.5f * (cosI + 1.0f);
if (projA < 0.0001f)
@@ -401,7 +401,7 @@ ccl_device int bsdf_microfacet_multi_ggx_fresnel_setup(ccl_private MicrofacetBsd
bsdf->type = CLOSURE_BSDF_MICROFACET_MULTI_GGX_FRESNEL_ID;
bsdf_microfacet_fresnel_color(sd, bsdf);
bsdf_microfacet_adjust_weight(sd, bsdf);
return bsdf_microfacet_multi_ggx_common_setup(bsdf);
}
@@ -417,15 +417,15 @@ ccl_device int bsdf_microfacet_multi_ggx_refraction_setup(ccl_private Microfacet
ccl_device Spectrum bsdf_microfacet_multi_ggx_eval(ccl_private const ShaderClosure *sc,
const float3 Ng,
const float3 I,
const float3 omega_in,
const float3 wi,
const float3 wo,
ccl_private float *pdf,
ccl_private uint *lcg_state)
{
ccl_private const MicrofacetBsdf *bsdf = (ccl_private const MicrofacetBsdf *)sc;
const float cosNgI = dot(Ng, omega_in);
const float cosNgO = dot(Ng, wo);
if ((cosNgI < 0.0f) || bsdf->alpha_x * bsdf->alpha_y < 1e-7f) {
if ((cosNgO < 0.0f) || bsdf->alpha_x * bsdf->alpha_y < 1e-7f) {
*pdf = 0.0f;
return zero_spectrum();
}
@@ -434,7 +434,7 @@ ccl_device Spectrum bsdf_microfacet_multi_ggx_eval(ccl_private const ShaderClosu
Z = bsdf->N;
/* Ensure that the both directions are on the outside w.r.t. the shading normal. */
if (dot(Z, I) <= 0.0f || dot(Z, omega_in) <= 0.0f) {
if (dot(Z, wi) <= 0.0f || dot(Z, wo) <= 0.0f) {
*pdf = 0.0f;
return zero_spectrum();
}
@@ -447,21 +447,21 @@ ccl_device Spectrum bsdf_microfacet_multi_ggx_eval(ccl_private const ShaderClosu
else
make_orthonormals(Z, &X, &Y);
float3 localI = make_float3(dot(I, X), dot(I, Y), dot(I, Z));
float3 localO = make_float3(dot(omega_in, X), dot(omega_in, Y), dot(omega_in, Z));
float3 local_I = make_float3(dot(wi, X), dot(wi, Y), dot(wi, Z));
float3 local_O = make_float3(dot(wo, X), dot(wo, Y), dot(wo, Z));
if (is_aniso)
*pdf = mf_ggx_aniso_pdf(localI, localO, make_float2(bsdf->alpha_x, bsdf->alpha_y));
*pdf = mf_ggx_aniso_pdf(local_I, local_O, make_float2(bsdf->alpha_x, bsdf->alpha_y));
else
*pdf = mf_ggx_pdf(localI, localO, bsdf->alpha_x);
*pdf = mf_ggx_pdf(local_I, local_O, bsdf->alpha_x);
if (*pdf <= 0.f) {
*pdf = 0.f;
return make_float3(0.f, 0.f, 0.f);
}
return mf_eval_glossy(localI,
localO,
return mf_eval_glossy(local_I,
local_O,
true,
bsdf->extra->color,
bsdf->alpha_x,
@@ -475,11 +475,11 @@ ccl_device Spectrum bsdf_microfacet_multi_ggx_eval(ccl_private const ShaderClosu
ccl_device int bsdf_microfacet_multi_ggx_sample(KernelGlobals kg,
ccl_private const ShaderClosure *sc,
float3 Ng,
float3 I,
float3 wi,
float randu,
float randv,
ccl_private Spectrum *eval,
ccl_private float3 *omega_in,
ccl_private float3 *wo,
ccl_private float *pdf,
ccl_private uint *lcg_state,
ccl_private float2 *sampled_roughness,
@@ -491,7 +491,7 @@ ccl_device int bsdf_microfacet_multi_ggx_sample(KernelGlobals kg,
Z = bsdf->N;
/* Ensure that the view direction is on the outside w.r.t. the shading normal. */
if (dot(Z, I) <= 0.0f) {
if (dot(Z, wi) <= 0.0f) {
*pdf = 0.0f;
return LABEL_NONE;
}
@@ -499,8 +499,8 @@ ccl_device int bsdf_microfacet_multi_ggx_sample(KernelGlobals kg,
/* Special case: Extremely low roughness.
* Don't bother with microfacets, just do specular reflection. */
if (bsdf->alpha_x * bsdf->alpha_y < 1e-7f) {
*omega_in = 2 * dot(Z, I) * Z - I;
if (dot(Ng, *omega_in) <= 0.0f) {
*wo = 2 * dot(Z, wi) * Z - wi;
if (dot(Ng, *wo) <= 0.0f) {
*pdf = 0.0f;
return LABEL_NONE;
}
@@ -520,11 +520,11 @@ ccl_device int bsdf_microfacet_multi_ggx_sample(KernelGlobals kg,
else
make_orthonormals(Z, &X, &Y);
float3 localI = make_float3(dot(I, X), dot(I, Y), dot(I, Z));
float3 localO;
float3 local_I = make_float3(dot(wi, X), dot(wi, Y), dot(wi, Z));
float3 local_O;
*eval = mf_sample_glossy(localI,
&localO,
*eval = mf_sample_glossy(local_I,
&local_O,
bsdf->extra->color,
bsdf->alpha_x,
bsdf->alpha_y,
@@ -532,18 +532,18 @@ ccl_device int bsdf_microfacet_multi_ggx_sample(KernelGlobals kg,
bsdf->ior,
use_fresnel,
bsdf->extra->cspec0);
*omega_in = X * localO.x + Y * localO.y + Z * localO.z;
*wo = X * local_O.x + Y * local_O.y + Z * local_O.z;
/* Ensure that the light direction is on the outside w.r.t. the geometry normal. */
if (dot(Ng, *omega_in) <= 0.0f) {
if (dot(Ng, *wo) <= 0.0f) {
*pdf = 0.0f;
return LABEL_NONE;
}
if (is_aniso)
*pdf = mf_ggx_aniso_pdf(localI, localO, make_float2(bsdf->alpha_x, bsdf->alpha_y));
*pdf = mf_ggx_aniso_pdf(local_I, local_O, make_float2(bsdf->alpha_x, bsdf->alpha_y));
else
*pdf = mf_ggx_pdf(localI, localO, bsdf->alpha_x);
*pdf = mf_ggx_pdf(local_I, local_O, bsdf->alpha_x);
*pdf = fmaxf(0.f, *pdf);
*eval *= *pdf;
@@ -575,14 +575,14 @@ ccl_device int bsdf_microfacet_multi_ggx_glass_fresnel_setup(ccl_private Microfa
bsdf->type = CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_FRESNEL_ID;
bsdf_microfacet_fresnel_color(sd, bsdf);
bsdf_microfacet_adjust_weight(sd, bsdf);
return SD_BSDF | SD_BSDF_HAS_EVAL | SD_BSDF_NEEDS_LCG;
}
ccl_device Spectrum bsdf_microfacet_multi_ggx_glass_eval(ccl_private const ShaderClosure *sc,
const float3 I,
const float3 omega_in,
const float3 wi,
const float3 wo,
ccl_private float *pdf,
ccl_private uint *lcg_state)
{
@@ -597,17 +597,17 @@ ccl_device Spectrum bsdf_microfacet_multi_ggx_glass_eval(ccl_private const Shade
Z = bsdf->N;
make_orthonormals(Z, &X, &Y);
float3 localI = make_float3(dot(I, X), dot(I, Y), dot(I, Z));
float3 localO = make_float3(dot(omega_in, X), dot(omega_in, Y), dot(omega_in, Z));
float3 local_I = make_float3(dot(wi, X), dot(wi, Y), dot(wi, Z));
float3 local_O = make_float3(dot(wo, X), dot(wo, Y), dot(wo, Z));
const bool is_transmission = localO.z < 0.0f;
const bool is_transmission = local_O.z < 0.0f;
const bool use_fresnel = !is_transmission &&
(bsdf->type == CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_FRESNEL_ID);
*pdf = mf_glass_pdf(localI, localO, bsdf->alpha_x, bsdf->ior);
*pdf = mf_glass_pdf(local_I, local_O, bsdf->alpha_x, bsdf->ior);
kernel_assert(*pdf >= 0.f);
return mf_eval_glass(localI,
localO,
return mf_eval_glass(local_I,
local_O,
!is_transmission,
bsdf->extra->color,
bsdf->alpha_x,
@@ -621,11 +621,11 @@ ccl_device Spectrum bsdf_microfacet_multi_ggx_glass_eval(ccl_private const Shade
ccl_device int bsdf_microfacet_multi_ggx_glass_sample(KernelGlobals kg,
ccl_private const ShaderClosure *sc,
float3 Ng,
float3 I,
float3 wi,
float randu,
float randv,
ccl_private Spectrum *eval,
ccl_private float3 *omega_in,
ccl_private float3 *wo,
ccl_private float *pdf,
ccl_private uint *lcg_state,
ccl_private float2 *sampled_roughness,
@@ -642,16 +642,16 @@ ccl_device int bsdf_microfacet_multi_ggx_glass_sample(KernelGlobals kg,
if (bsdf->alpha_x * bsdf->alpha_y < 1e-7f) {
float3 R, T;
bool inside;
float fresnel = fresnel_dielectric(bsdf->ior, Z, I, &R, &T, &inside);
float fresnel = fresnel_dielectric(bsdf->ior, Z, wi, &R, &T, &inside);
*pdf = 1e6f;
*eval = make_spectrum(1e6f);
if (randu < fresnel) {
*omega_in = R;
*wo = R;
return LABEL_REFLECT | LABEL_SINGULAR;
}
else {
*omega_in = T;
*wo = T;
return LABEL_TRANSMIT | LABEL_SINGULAR;
}
}
@@ -660,11 +660,11 @@ ccl_device int bsdf_microfacet_multi_ggx_glass_sample(KernelGlobals kg,
make_orthonormals(Z, &X, &Y);
float3 localI = make_float3(dot(I, X), dot(I, Y), dot(I, Z));
float3 localO;
float3 local_I = make_float3(dot(wi, X), dot(wi, Y), dot(wi, Z));
float3 local_O;
*eval = mf_sample_glass(localI,
&localO,
*eval = mf_sample_glass(local_I,
&local_O,
bsdf->extra->color,
bsdf->alpha_x,
bsdf->alpha_y,
@@ -672,12 +672,12 @@ ccl_device int bsdf_microfacet_multi_ggx_glass_sample(KernelGlobals kg,
bsdf->ior,
use_fresnel,
bsdf->extra->cspec0);
*pdf = mf_glass_pdf(localI, localO, bsdf->alpha_x, bsdf->ior);
*pdf = mf_glass_pdf(local_I, local_O, bsdf->alpha_x, bsdf->ior);
kernel_assert(*pdf >= 0.f);
*eval *= *pdf;
*omega_in = X * localO.x + Y * localO.y + Z * localO.z;
if (localO.z * localI.z > 0.0f) {
*wo = X * local_O.x + Y * local_O.y + Z * local_O.z;
if (local_O.z * local_I.z > 0.0f) {
return LABEL_REFLECT | LABEL_GLOSSY;
}
else {

View File

@@ -73,9 +73,8 @@ ccl_device_forceinline Spectrum MF_FUNCTION_FULL_NAME(mf_eval)(float3 wi,
eval = make_spectrum(val);
#endif
float F0 = fresnel_dielectric_cos(1.0f, eta);
if (use_fresnel) {
throughput = interpolate_fresnel_color(wi, wh, eta, F0, cspec0);
throughput = interpolate_fresnel_color(wi, wh, eta, cspec0);
eval *= throughput;
}
@@ -144,11 +143,11 @@ ccl_device_forceinline Spectrum MF_FUNCTION_FULL_NAME(mf_eval)(float3 wi,
throughput *= color;
}
else if (use_fresnel && order > 0) {
throughput *= interpolate_fresnel_color(wi_prev, wm, eta, F0, cspec0);
throughput *= interpolate_fresnel_color(wi_prev, wm, eta, cspec0);
}
#else /* MF_MULTI_GLOSSY */
if (use_fresnel && order > 0) {
throughput *= interpolate_fresnel_color(-wr, wm, eta, F0, cspec0);
throughput *= interpolate_fresnel_color(-wr, wm, eta, cspec0);
}
wr = mf_sample_phase_glossy(-wr, &throughput, wm);
#endif
@@ -192,8 +191,6 @@ ccl_device_forceinline Spectrum MF_FUNCTION_FULL_NAME(mf_sample)(float3 wi,
float G1_r = 0.0f;
bool outside = true;
float F0 = fresnel_dielectric_cos(1.0f, eta);
int order;
for (order = 0; order < 10; order++) {
/* Sample microfacet height. */
@@ -229,22 +226,12 @@ ccl_device_forceinline Spectrum MF_FUNCTION_FULL_NAME(mf_sample)(float3 wi,
throughput *= color;
}
else {
Spectrum t_color = interpolate_fresnel_color(wi_prev, wm, eta, F0, cspec0);
if (order == 0)
throughput = t_color;
else
throughput *= t_color;
throughput *= interpolate_fresnel_color(wi_prev, wm, eta, cspec0);
}
}
#else /* MF_MULTI_GLOSSY */
if (use_fresnel) {
Spectrum t_color = interpolate_fresnel_color(-wr, wm, eta, F0, cspec0);
if (order == 0)
throughput = t_color;
else
throughput *= t_color;
throughput *= interpolate_fresnel_color(-wr, wm, eta, cspec0);
}
wr = mf_sample_phase_glossy(-wr, &throughput, wm);
#endif

View File

@@ -48,14 +48,14 @@ ccl_device int bsdf_oren_nayar_setup(ccl_private OrenNayarBsdf *bsdf)
}
ccl_device Spectrum bsdf_oren_nayar_eval(ccl_private const ShaderClosure *sc,
const float3 I,
const float3 omega_in,
const float3 wi,
const float3 wo,
ccl_private float *pdf)
{
ccl_private const OrenNayarBsdf *bsdf = (ccl_private const OrenNayarBsdf *)sc;
if (dot(bsdf->N, omega_in) > 0.0f) {
if (dot(bsdf->N, wo) > 0.0f) {
*pdf = 0.5f * M_1_PI_F;
return bsdf_oren_nayar_get_intensity(sc, bsdf->N, I, omega_in);
return bsdf_oren_nayar_get_intensity(sc, bsdf->N, wi, wo);
}
else {
*pdf = 0.0f;
@@ -65,18 +65,18 @@ ccl_device Spectrum bsdf_oren_nayar_eval(ccl_private const ShaderClosure *sc,
ccl_device int bsdf_oren_nayar_sample(ccl_private const ShaderClosure *sc,
float3 Ng,
float3 I,
float3 wi,
float randu,
float randv,
ccl_private Spectrum *eval,
ccl_private float3 *omega_in,
ccl_private float3 *wo,
ccl_private float *pdf)
{
ccl_private const OrenNayarBsdf *bsdf = (ccl_private const OrenNayarBsdf *)sc;
sample_uniform_hemisphere(bsdf->N, randu, randv, omega_in, pdf);
sample_uniform_hemisphere(bsdf->N, randu, randv, wo, pdf);
if (dot(Ng, *omega_in) > 0.0f) {
*eval = bsdf_oren_nayar_get_intensity(sc, bsdf->N, I, *omega_in);
if (dot(Ng, *wo) > 0.0f) {
*eval = bsdf_oren_nayar_get_intensity(sc, bsdf->N, wi, *wo);
}
else {
*pdf = 0.0f;

View File

@@ -45,23 +45,23 @@ ccl_device int bsdf_phong_ramp_setup(ccl_private PhongRampBsdf *bsdf)
}
ccl_device Spectrum bsdf_phong_ramp_eval(ccl_private const ShaderClosure *sc,
const float3 I,
const float3 omega_in,
const float3 wi,
const float3 wo,
ccl_private float *pdf)
{
ccl_private const PhongRampBsdf *bsdf = (ccl_private const PhongRampBsdf *)sc;
float m_exponent = bsdf->exponent;
float cosNI = dot(bsdf->N, omega_in);
float cosNO = dot(bsdf->N, I);
float cosNI = dot(bsdf->N, wi);
float cosNO = dot(bsdf->N, wo);
if (cosNI > 0 && cosNO > 0) {
// reflect the view vector
float3 R = (2 * cosNO) * bsdf->N - I;
float cosRI = dot(R, omega_in);
if (cosRI > 0) {
float cosp = powf(cosRI, m_exponent);
float3 R = (2 * cosNI) * bsdf->N - wi;
float cosRO = dot(R, wo);
if (cosRO > 0) {
float cosp = powf(cosRO, m_exponent);
float common = 0.5f * M_1_PI_F * cosp;
float out = cosNI * (m_exponent + 2) * common;
float out = cosNO * (m_exponent + 2) * common;
*pdf = (m_exponent + 1) * common;
return rgb_to_spectrum(bsdf_phong_ramp_get_color(bsdf->colors, cosp) * out);
}
@@ -77,39 +77,39 @@ ccl_device_inline float phong_ramp_exponent_to_roughness(float exponent)
ccl_device int bsdf_phong_ramp_sample(ccl_private const ShaderClosure *sc,
float3 Ng,
float3 I,
float3 wi,
float randu,
float randv,
ccl_private Spectrum *eval,
ccl_private float3 *omega_in,
ccl_private float3 *wo,
ccl_private float *pdf,
ccl_private float2 *sampled_roughness)
{
ccl_private const PhongRampBsdf *bsdf = (ccl_private const PhongRampBsdf *)sc;
float cosNO = dot(bsdf->N, I);
float cosNI = dot(bsdf->N, wi);
float m_exponent = bsdf->exponent;
const float m_roughness = phong_ramp_exponent_to_roughness(m_exponent);
*sampled_roughness = make_float2(m_roughness, m_roughness);
if (cosNO > 0) {
if (cosNI > 0) {
// reflect the view vector
float3 R = (2 * cosNO) * bsdf->N - I;
float3 R = (2 * cosNI) * bsdf->N - wi;
float3 T, B;
make_orthonormals(R, &T, &B);
float phi = M_2PI_F * randu;
float cosTheta = powf(randv, 1 / (m_exponent + 1));
float sinTheta2 = 1 - cosTheta * cosTheta;
float sinTheta = sinTheta2 > 0 ? sqrtf(sinTheta2) : 0;
*omega_in = (cosf(phi) * sinTheta) * T + (sinf(phi) * sinTheta) * B + (cosTheta)*R;
if (dot(Ng, *omega_in) > 0.0f) {
*wo = (cosf(phi) * sinTheta) * T + (sinf(phi) * sinTheta) * B + (cosTheta)*R;
if (dot(Ng, *wo) > 0.0f) {
// common terms for pdf and eval
float cosNI = dot(bsdf->N, *omega_in);
float cosNO = dot(bsdf->N, *wo);
// make sure the direction we chose is still in the right hemisphere
if (cosNI > 0) {
if (cosNO > 0) {
float cosp = powf(cosTheta, m_exponent);
float common = 0.5f * M_1_PI_F * cosp;
*pdf = (m_exponent + 1) * common;
float out = cosNI * (m_exponent + 2) * common;
float out = cosNO * (m_exponent + 2) * common;
*eval = rgb_to_spectrum(bsdf_phong_ramp_get_color(bsdf->colors, cosp) * out);
}
}

View File

@@ -110,17 +110,17 @@ ccl_device int bsdf_principled_diffuse_setup(ccl_private PrincipledDiffuseBsdf *
}
ccl_device Spectrum bsdf_principled_diffuse_eval(ccl_private const ShaderClosure *sc,
const float3 I,
const float3 omega_in,
const float3 wi,
const float3 wo,
ccl_private float *pdf)
{
ccl_private const PrincipledDiffuseBsdf *bsdf = (ccl_private const PrincipledDiffuseBsdf *)sc;
const float3 N = bsdf->N;
if (dot(N, omega_in) > 0.0f) {
const float3 V = I; // outgoing
const float3 L = omega_in; // incoming
*pdf = fmaxf(dot(N, omega_in), 0.0f) * M_1_PI_F;
if (dot(N, wo) > 0.0f) {
const float3 V = wi;
const float3 L = wo;
*pdf = fmaxf(dot(N, wo), 0.0f) * M_1_PI_F;
return bsdf_principled_diffuse_compute_brdf(bsdf, N, V, L, pdf);
}
else {
@@ -131,21 +131,21 @@ ccl_device Spectrum bsdf_principled_diffuse_eval(ccl_private const ShaderClosure
ccl_device int bsdf_principled_diffuse_sample(ccl_private const ShaderClosure *sc,
float3 Ng,
float3 I,
float3 wi,
float randu,
float randv,
ccl_private Spectrum *eval,
ccl_private float3 *omega_in,
ccl_private float3 *wo,
ccl_private float *pdf)
{
ccl_private const PrincipledDiffuseBsdf *bsdf = (ccl_private const PrincipledDiffuseBsdf *)sc;
float3 N = bsdf->N;
sample_cos_hemisphere(N, randu, randv, omega_in, pdf);
sample_cos_hemisphere(N, randu, randv, wo, pdf);
if (dot(Ng, *omega_in) > 0) {
*eval = bsdf_principled_diffuse_compute_brdf(bsdf, N, I, *omega_in, pdf);
if (dot(Ng, *wo) > 0) {
*eval = bsdf_principled_diffuse_compute_brdf(bsdf, N, wi, *wo, pdf);
}
else {
*pdf = 0.0f;

View File

@@ -54,25 +54,25 @@ ccl_device int bsdf_principled_sheen_setup(ccl_private const ShaderData *sd,
ccl_private PrincipledSheenBsdf *bsdf)
{
bsdf->type = CLOSURE_BSDF_PRINCIPLED_SHEEN_ID;
bsdf->avg_value = calculate_avg_principled_sheen_brdf(bsdf->N, sd->I);
bsdf->avg_value = calculate_avg_principled_sheen_brdf(bsdf->N, sd->wi);
bsdf->sample_weight *= bsdf->avg_value;
return SD_BSDF | SD_BSDF_HAS_EVAL;
}
ccl_device Spectrum bsdf_principled_sheen_eval(ccl_private const ShaderClosure *sc,
const float3 I,
const float3 omega_in,
const float3 wi,
const float3 wo,
ccl_private float *pdf)
{
ccl_private const PrincipledSheenBsdf *bsdf = (ccl_private const PrincipledSheenBsdf *)sc;
const float3 N = bsdf->N;
if (dot(N, omega_in) > 0.0f) {
const float3 V = I; // outgoing
const float3 L = omega_in; // incoming
if (dot(N, wo) > 0.0f) {
const float3 V = wi;
const float3 L = wo;
const float3 H = normalize(L + V);
*pdf = fmaxf(dot(N, omega_in), 0.0f) * M_1_PI_F;
*pdf = fmaxf(dot(N, wo), 0.0f) * M_1_PI_F;
return calculate_principled_sheen_brdf(N, V, L, H, pdf);
}
else {
@@ -83,23 +83,23 @@ ccl_device Spectrum bsdf_principled_sheen_eval(ccl_private const ShaderClosure *
ccl_device int bsdf_principled_sheen_sample(ccl_private const ShaderClosure *sc,
float3 Ng,
float3 I,
float3 wi,
float randu,
float randv,
ccl_private Spectrum *eval,
ccl_private float3 *omega_in,
ccl_private float3 *wo,
ccl_private float *pdf)
{
ccl_private const PrincipledSheenBsdf *bsdf = (ccl_private const PrincipledSheenBsdf *)sc;
float3 N = bsdf->N;
sample_cos_hemisphere(N, randu, randv, omega_in, pdf);
sample_cos_hemisphere(N, randu, randv, wo, pdf);
if (dot(Ng, *omega_in) > 0) {
float3 H = normalize(I + *omega_in);
if (dot(Ng, *wo) > 0) {
float3 H = normalize(wi + *wo);
*eval = calculate_principled_sheen_brdf(N, I, *omega_in, H, pdf);
*eval = calculate_principled_sheen_brdf(N, wi, *wo, H, pdf);
}
else {
*eval = zero_spectrum();

View File

@@ -19,8 +19,8 @@ ccl_device int bsdf_reflection_setup(ccl_private MicrofacetBsdf *bsdf)
}
ccl_device Spectrum bsdf_reflection_eval(ccl_private const ShaderClosure *sc,
const float3 I,
const float3 omega_in,
const float3 wi,
const float3 wo,
ccl_private float *pdf)
{
*pdf = 0.0f;
@@ -29,11 +29,11 @@ ccl_device Spectrum bsdf_reflection_eval(ccl_private const ShaderClosure *sc,
ccl_device int bsdf_reflection_sample(ccl_private const ShaderClosure *sc,
float3 Ng,
float3 I,
float3 wi,
float randu,
float randv,
ccl_private Spectrum *eval,
ccl_private float3 *omega_in,
ccl_private float3 *wo,
ccl_private float *pdf,
ccl_private float *eta)
{
@@ -42,10 +42,10 @@ ccl_device int bsdf_reflection_sample(ccl_private const ShaderClosure *sc,
*eta = bsdf->ior;
// only one direction is possible
float cosNO = dot(N, I);
if (cosNO > 0) {
*omega_in = (2 * cosNO) * N - I;
if (dot(Ng, *omega_in) > 0) {
float cosNI = dot(N, wi);
if (cosNI > 0) {
*wo = (2 * cosNI) * N - wi;
if (dot(Ng, *wo) > 0) {
/* Some high number for MIS. */
*pdf = 1e6f;
*eval = make_spectrum(1e6f);

View File

@@ -19,8 +19,8 @@ ccl_device int bsdf_refraction_setup(ccl_private MicrofacetBsdf *bsdf)
}
ccl_device Spectrum bsdf_refraction_eval(ccl_private const ShaderClosure *sc,
const float3 I,
const float3 omega_in,
const float3 wi,
const float3 wo,
ccl_private float *pdf)
{
*pdf = 0.0f;
@@ -29,11 +29,11 @@ ccl_device Spectrum bsdf_refraction_eval(ccl_private const ShaderClosure *sc,
ccl_device int bsdf_refraction_sample(ccl_private const ShaderClosure *sc,
float3 Ng,
float3 I,
float3 wi,
float randu,
float randv,
ccl_private Spectrum *eval,
ccl_private float3 *omega_in,
ccl_private float3 *wo,
ccl_private float *pdf,
ccl_private float *eta)
{
@@ -46,13 +46,13 @@ ccl_device int bsdf_refraction_sample(ccl_private const ShaderClosure *sc,
float3 R, T;
bool inside;
float fresnel;
fresnel = fresnel_dielectric(m_eta, N, I, &R, &T, &inside);
fresnel = fresnel_dielectric(m_eta, N, wi, &R, &T, &inside);
if (!inside && fresnel != 1.0f) {
/* Some high number for MIS. */
*pdf = 1e6f;
*eval = make_spectrum(1e6f);
*omega_in = T;
*wo = T;
}
else {
*pdf = 0.0f;

View File

@@ -50,17 +50,17 @@ ccl_device float bsdf_toon_get_sample_angle(float max_angle, float smooth)
}
ccl_device Spectrum bsdf_diffuse_toon_eval(ccl_private const ShaderClosure *sc,
const float3 I,
const float3 omega_in,
const float3 wi,
const float3 wo,
ccl_private float *pdf)
{
ccl_private const ToonBsdf *bsdf = (ccl_private const ToonBsdf *)sc;
float cosNI = dot(bsdf->N, omega_in);
float cosNO = dot(bsdf->N, wo);
if (cosNI >= 0.0f) {
if (cosNO >= 0.0f) {
float max_angle = bsdf->size * M_PI_2_F;
float smooth = bsdf->smooth * M_PI_2_F;
float angle = safe_acosf(fmaxf(cosNI, 0.0f));
float angle = safe_acosf(fmaxf(cosNO, 0.0f));
float eval = bsdf_toon_get_intensity(max_angle, smooth, angle);
@@ -78,11 +78,11 @@ ccl_device Spectrum bsdf_diffuse_toon_eval(ccl_private const ShaderClosure *sc,
ccl_device int bsdf_diffuse_toon_sample(ccl_private const ShaderClosure *sc,
float3 Ng,
float3 I,
float3 wi,
float randu,
float randv,
ccl_private Spectrum *eval,
ccl_private float3 *omega_in,
ccl_private float3 *wo,
ccl_private float *pdf)
{
ccl_private const ToonBsdf *bsdf = (ccl_private const ToonBsdf *)sc;
@@ -92,9 +92,9 @@ ccl_device int bsdf_diffuse_toon_sample(ccl_private const ShaderClosure *sc,
float angle = sample_angle * randu;
if (sample_angle > 0.0f) {
sample_uniform_cone(bsdf->N, sample_angle, randu, randv, omega_in, pdf);
sample_uniform_cone(bsdf->N, sample_angle, randu, randv, wo, pdf);
if (dot(Ng, *omega_in) > 0.0f) {
if (dot(Ng, *wo) > 0.0f) {
*eval = make_spectrum(*pdf * bsdf_toon_get_intensity(max_angle, smooth, angle));
}
else {
@@ -122,22 +122,22 @@ ccl_device int bsdf_glossy_toon_setup(ccl_private ToonBsdf *bsdf)
}
ccl_device Spectrum bsdf_glossy_toon_eval(ccl_private const ShaderClosure *sc,
const float3 I,
const float3 omega_in,
const float3 wi,
const float3 wo,
ccl_private float *pdf)
{
ccl_private const ToonBsdf *bsdf = (ccl_private const ToonBsdf *)sc;
float max_angle = bsdf->size * M_PI_2_F;
float smooth = bsdf->smooth * M_PI_2_F;
float cosNI = dot(bsdf->N, omega_in);
float cosNO = dot(bsdf->N, I);
float cosNI = dot(bsdf->N, wi);
float cosNO = dot(bsdf->N, wo);
if (cosNI > 0 && cosNO > 0) {
/* reflect the view vector */
float3 R = (2 * cosNO) * bsdf->N - I;
float cosRI = dot(R, omega_in);
float3 R = (2 * cosNI) * bsdf->N - wi;
float cosRO = dot(R, wo);
float angle = safe_acosf(fmaxf(cosRI, 0.0f));
float angle = safe_acosf(fmaxf(cosRO, 0.0f));
float eval = bsdf_toon_get_intensity(max_angle, smooth, angle);
float sample_angle = bsdf_toon_get_sample_angle(max_angle, smooth);
@@ -151,32 +151,32 @@ ccl_device Spectrum bsdf_glossy_toon_eval(ccl_private const ShaderClosure *sc,
ccl_device int bsdf_glossy_toon_sample(ccl_private const ShaderClosure *sc,
float3 Ng,
float3 I,
float3 wi,
float randu,
float randv,
ccl_private Spectrum *eval,
ccl_private float3 *omega_in,
ccl_private float3 *wo,
ccl_private float *pdf)
{
ccl_private const ToonBsdf *bsdf = (ccl_private const ToonBsdf *)sc;
float max_angle = bsdf->size * M_PI_2_F;
float smooth = bsdf->smooth * M_PI_2_F;
float cosNO = dot(bsdf->N, I);
float cosNI = dot(bsdf->N, wi);
if (cosNO > 0) {
if (cosNI > 0) {
/* reflect the view vector */
float3 R = (2 * cosNO) * bsdf->N - I;
float3 R = (2 * cosNI) * bsdf->N - wi;
float sample_angle = bsdf_toon_get_sample_angle(max_angle, smooth);
float angle = sample_angle * randu;
sample_uniform_cone(R, sample_angle, randu, randv, omega_in, pdf);
sample_uniform_cone(R, sample_angle, randu, randv, wo, pdf);
if (dot(Ng, *omega_in) > 0.0f) {
float cosNI = dot(bsdf->N, *omega_in);
if (dot(Ng, *wo) > 0.0f) {
float cosNO = dot(bsdf->N, *wo);
/* make sure the direction we chose is still in the right hemisphere */
if (cosNI > 0) {
if (cosNO > 0) {
*eval = make_spectrum(*pdf * bsdf_toon_get_intensity(max_angle, smooth, angle));
}
else {

View File

@@ -60,8 +60,8 @@ ccl_device void bsdf_transparent_setup(ccl_private ShaderData *sd,
}
ccl_device Spectrum bsdf_transparent_eval(ccl_private const ShaderClosure *sc,
const float3 I,
const float3 omega_in,
const float3 wi,
const float3 wo,
ccl_private float *pdf)
{
*pdf = 0.0f;
@@ -70,15 +70,15 @@ ccl_device Spectrum bsdf_transparent_eval(ccl_private const ShaderClosure *sc,
ccl_device int bsdf_transparent_sample(ccl_private const ShaderClosure *sc,
float3 Ng,
float3 I,
float3 wi,
float randu,
float randv,
ccl_private Spectrum *eval,
ccl_private float3 *omega_in,
ccl_private float3 *wo,
ccl_private float *pdf)
{
// only one direction is possible
*omega_in = -I;
*wo = -wi;
*pdf = 1;
*eval = one_spectrum();
return LABEL_TRANSMIT | LABEL_TRANSPARENT;

Some files were not shown because too many files have changed in this diff Show More