Compare commits

...

407 Commits

Author SHA1 Message Date
e8f8c13d4b PointCloud: Initial rendering support for Workbench
Also includes outline overlays. Removes the temp overlay drawing

We make the geometry follow camera like billboards this uses less
geometry. Currently we use half octahedron for now. Goal would be
to use icospheres.

This patch also optimize the case when pointcloud has uniform radius.
However we should premultiply the radius prop by the default radius
beforehand to avoid a multiplication on CPU.

Differential Revision: https://developer.blender.org/D8301
2020-07-15 14:23:35 +02:00
0c062a9e08 PointCloud: Change visualization to use octahedron
This reduces the number of polygon needed. Also optimize
the case when pointcloud has uniform radius.
2020-07-15 14:08:32 +02:00
38655c43fb PointCloud: Make geometry follow camera
A bit like billboards. This will allow to use less geometry
in the future.
2020-07-15 13:23:22 +02:00
44bb73e765 Revert "Cleanup: simplify Weld Modifier logic"
This reverts commit 98b1a716d6.

That commit broke a few modifiers.py tests
(Screw+Weld and a weld merge threshold).

And some pairs may be lost in the first loop.
2020-07-15 08:10:41 -03:00
ff2fa59689 Fix T76690: Incorrect liquid particle count displayed
Reviewers: sergey, sebbas

Differential Revision: https://developer.blender.org/D7852
2020-07-15 12:53:05 +02:00
4e8fc14120 GPencil: Fix name typo error 2020-07-15 12:47:55 +02:00
7e2ffbfb25 Add missing NULL assignment to D8293
Missed reseting "next_td" in that patch.
Shouldn't have caused any issues in practice, but it is nice to be
extra clear and safe in the code.
2020-07-15 12:36:48 +02:00
50c6448781 Fix T78909: Curve-edit proportional connected-only broken
Now it calculates the actual distance when traveling along the curve.

I addition to this, it also now supports cyclic curves.

Reviewed By: Campbell

Differential Revision: http://developer.blender.org/D8293
2020-07-15 12:29:45 +02:00
e8b26a0501 Fix signed/unsigned comparison 2020-07-15 11:06:54 +02:00
680a81fc49 LibOverride: rework 'make override' 3DView operator.
Removed the 'select main object to override' menu when overriding an
instanced collection, this was no more used anyway.

Added new behavior allowing to select which directly linked collection
to override when trying to override an inderctly linked object. This
allows to link collections without instancing them with an empty object,
select one of their objects, and call override operator.
2020-07-15 11:01:40 +02:00
eb87b1c8f6 Cleanup: remove assignment from a NULL struct
Quiet ASAN 'member access within null pointer' warning.

While this doesn't crash, access to 'shading'
without checking if the 'v3d' would have.
2020-07-15 15:37:03 +10:00
Liam Scaife
920b138f83 UI: Add manifold extrude to extrude menu 2020-07-15 15:20:34 +10:00
e062def3b4 Cleanup: spelling 2020-07-15 13:11:22 +10:00
061d76f55c Revert "Cleanup: remove public unused function."
This reverts commit 03c8b048a1.

This commit re-introduced T76837.

While there is a comment explaining why this function is needed,
the naming of the poll function does make this confusing.
The API could be changed to avoid confusion here.
2020-07-15 13:09:06 +10:00
d493fc43bd Fix T78875: Numerical display of delta of translation is not updating in 3d view 2020-07-14 17:45:57 -03:00
7f67e3200a Fluid: Fix liquid mesh scaling
Fixes issue with .bobj.gz and .obj mesh files not always being scaled correctly in the viewport.
2020-07-14 22:21:15 +02:00
7e0289b618 Fluid: Updated Mantaflow source files
New files include fixes for obj mesh import and minor cleanups.
2020-07-14 22:21:15 +02:00
98b1a716d6 Cleanup: simplify Weld Modifier logic
The original code to rearrange the weld vertices map was confusing.

It traverses the overlap result multiple times within a loop.

This part of the code has therefore been rethought, simplified and commented.

This also results in a slight improvement in the performance of the modifier.
2020-07-14 15:18:22 -03:00
dbcc74f801 Fix T77263: Mantaflow: Cache gets deleted at changing upres factor under Particles section.
Moved fluid simulation reset to separate functions based on type.
2020-07-14 18:11:35 +02:00
0b100e21fb Fix T78704: RenderPass normals disapear when view isn't updated
When the view isn't updated the renderpass thought that it was rendering
the next sample, skipping the conversion from encoded to blender
normals.

This patch resets the current sample when only rendering single sample
layers.

Reviewed By: Clément Foucault

Differential Revision: https://developer.blender.org/D8280
2020-07-14 17:42:15 +02:00
6cc88e330b Fix T78431: Update mesh_cd_layers_type_ to support 8 bytes.
Sculpt vertex colors changed the `DRW_MeshCDMask` from 4 bytes to 8 bytes, but
the functions assumed it still was 4 bytes. This patch updates the functions and
adds a compile time check.

Reviewed By: Clément Foucault

Differential Revision: https://developer.blender.org/D8215
2020-07-14 17:41:05 +02:00
2ba1cf4b40 Fix T78880: UV Editor - Match prop edit connected behavior with mesh editing and fix Rip Region double proportional checkbox
This fixes the double prop edit checkbox in the redo menu.

This also makes it so that proportional edit in connected mode now
matches how it behaves in mesh edit mode.

Without this change, ripping in UV edit mode with proportional edit on
would be useless as the UV verts you ripped will still be stuck together
even if they were not connected anymore.

Reviewed By: Campbell

Differential Revision: http://developer.blender.org/D8289
2020-07-14 17:27:48 +02:00
102f66c0a4 PointCloud: Initial rendering support for Workbench
Also includes outline overlays. Removes the temp overlay drawing
2020-07-14 16:47:45 +02:00
797027be6b Fluid: Fix missing flag update for cache
These flags need to be set correctly in order to distinguish between data that comes from cache files and raw data that comes directly from pointers to the data in Mantaflow.
2020-07-14 16:30:15 +02:00
14eaa9ed63 LibOverride: fix for removing use_override_library in rB3d587efef2872.
Thanks to @JacquesLucke for the heads up.
2020-07-14 16:04:44 +02:00
8e9dd5492a Gpencil: Simplify modifier sample mode minimal vert count fix.
For this mode is possible use strokes of 2 points.

Differential revision: https://developer.blender.org/D8138
2020-07-14 15:59:49 +02:00
c8a62e4f50 Cleanup: function name not following its module conventions. 2020-07-14 15:28:08 +02:00
6068f49c33 BLI: remove static assert noexcept move constructors
The move constructor of `mpq_class` from GMP currently
allocates when it is moved. So, it cannot be noexcept.
Since we want to use this type, this static assert cannot
stay there.
2020-07-14 15:23:40 +02:00
2e8a78f4d1 Fluid bake: fix memory leak when path validation fails
Reviewed By: sebbas

Differential Revision: https://developer.blender.org/D8284
2020-07-14 15:21:08 +02:00
78148e20fa Cleanup: remove tab indention 2020-07-14 22:52:50 +10:00
fa7ace2215 PyAPI: support element multiplication for vector, matrix, quaternions
This was disabled during 2.8x for smooth porting of 2.7x scripts,

Now '@' is used for matrix multiplication,
support '*' to multiple vector elements.

See T56276.
2020-07-14 22:52:50 +10:00
e3fd60b182 LibOverride: Outliner: Add an operation to override the selected ID and its parents.
This will override all linked data-blocks in the tree branch leading to
the selected one.
2020-07-14 14:51:13 +02:00
140b26909e LibOverride: Move code tagging reauired dependencies of an override into BKE.
This is fairly generic code that can be re-used in other places.
2020-07-14 14:51:13 +02:00
1e5ce39156 Fix T78900: Single vertex sliding crashes
As we can see in `initVertSlide_ex`, `sld` can be `NULL`.
`sld` is dereferenced, but can still be `NULL`.
2020-07-14 09:31:05 -03:00
01ec76842f Fix T77766: support animated global gravity toggle
Reviewers: sebbas

Differential Revision: https://developer.blender.org/D8281
2020-07-14 13:47:32 +02:00
4096330b81 Cleanup: typo 2020-07-14 13:01:46 +02:00
25fc84bf2e Fix wrong vector size functions used in knife tool
Should not use copy_v3_v3 on a 2 element vectors.
2020-07-14 10:43:32 +02:00
26793d619c GPencil: Cleanup Build modifier and fix potential div by zero errors 2020-07-14 10:26:19 +02:00
0fb08b7cc4 Cleanup: sort header, cmake paths 2020-07-14 16:04:18 +10:00
93e14e5935 Fix T78883: New bezier curve points to uninitialized memory 2020-07-14 15:53:56 +10:00
5338b36fcc Cleanup: spelling 2020-07-14 15:19:52 +10:00
b818f6b55f Fix T78902: Only check main modifier panel for expansion property
Internally the "show_expanded" property stores the expansion for every
subpanel, but for RNA we should only check the first bit of the flag that
corresponds to the main panel.
2020-07-13 20:10:49 -04:00
0b24930541 UI: Add missing row in curve profile template 2020-07-13 17:16:01 -04:00
37fb586a0b Cleanup: remove unnecessary member
`Kfv-> sco` was being treated as a local variable, and can be
confusing since this value is not updated when navigating the viewport.
2020-07-13 16:10:45 -03:00
70992ae270 Fix: Fix build error with MSVC in BLI_span_test
span.size() returns an uint, causing a signed/unsigned comparison
using 3u sidesteps the issue
2020-07-13 12:29:53 -06:00
6e74a8b69f Fix T78881: Cycles OpenImageDenoise not using albedo and normal correctly
Properly normalize buffers now. Also expose option to not use albedo and normal
just like OptiX.
2020-07-13 19:38:49 +02:00
2b5e21fe00 Sculpt: Add extra deform types to Smear
The smear brush was using the stroke direction to slide colors across
the mesh surface (this is called drag in other sculpt tools). Similarly,
other deformations can be included. The most common ones in image
editing are pinch and expand, which can be used to sharpen transitions
between colors.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D8270
2020-07-13 17:53:24 +02:00
1076952209 Fix wrong variable name in Sculpt Vertex Colors experimental check
Reviewed By: sergey

Differential Revision: https://developer.blender.org/D8269
2020-07-13 17:52:11 +02:00
eb3f74a0fe Sculpt: Enable color palettes for sculpt vertex colors
Enables the color palette subpanel for brushes that have color
capabilities (only the paint brush for now)

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D8268
2020-07-13 17:51:12 +02:00
8dd2386a68 IDTemplate: Minor tweak to 'make local/override' code.
Only update pointer of the template if we actually changed it...
2020-07-13 17:43:22 +02:00
fcc91faf3f Fix (unreported) bad handling of undo for some IDTemplates operations. 2020-07-13 17:03:39 +02:00
91e67c7bda Cleanup: remove some incorrectly placed consts
Clang-tidy reported that those parameters could be const,
but that is not true on windows.
2020-07-13 16:55:39 +02:00
3d587efef2 LibOverride: Cleanup: Remove option to disable library overrides.
Code is mature enough now to not need this anymore, people who do not
want to use liboverrides can just not create them.
2020-07-13 16:45:55 +02:00
5c8dd2a703 Cleanup: silence warnings 2020-07-13 11:40:21 -03:00
3dcc7c73e2 MSVC: Fix build error with the 8.1 SDK
shobjidl_core.h only exists in the windows 10 SDK in the 8.1
SDK ShObjIdl.h will have the definitions we need, which still
exists in the 10 SDK and implicitly includes shobjidl_core.h.

so ShObjIdl.h will work on both SDK versions.
2020-07-13 08:38:31 -06:00
Szymon Ulatowski
29da019cb3 EEVEE: Fix sky zenith bug
Careless use of acos() in spherical coordinates transformation was
deteriorating the precision near zenith (and nadir) and producing
glitchy pixels (best seen in longer focal lengths).

Reviewed By: fclem

Differential Revision: https://developer.blender.org/D8266
2020-07-13 17:08:58 +02:00
16989c4d1d Fix T78037: fresh install of blender 2.83.0 not able to save user startup file.
Simply remove that check ob userdef's themes, we are never read any
userdef from startup file anymore, so this check makes no more sense.

To be backported to 2.83.
2020-07-13 16:17:35 +02:00
952279a366 Fix T76687: [Mantaflow] low domain transformation performance
Implemented G.moving suggestion from comments.
2020-07-13 16:15:43 +02:00
5ecefc6a07 Build: make update support for git tags
Previously it only picked the appropriate version with the
blender-vX.XX-release branches.
2020-07-13 15:54:12 +02:00
2be7a11e43 Python API: new RNA property Screen.is_scrubbing
This commit adds a new read-only boolean property `Screen.is_scrubbing`.

The related property `Screen.is_animation_playing` is set to `True` in
two situations:

- Animation is actually playing (for example via the Play button in the
  timeline)
- The user is scrubbing through time (in the timeline, dopesheet, graph
  editor, etc.)

To distinguish between these two cases, the property
`Screen.is_scrubbing` has been added.

Concept approved by @brecht.
2020-07-13 15:26:00 +02:00
b9f565881e VSE: Python API, allow creation of VSE Movie strips with missing file
It was already possible to create Sound and Image strips that reference
non-existing files. Now it's also possible to create Movie strips
referencing missing files via the Python API call
`Sequences.new_movie()`. In this case, the duration of the strip will be
set to 1 frame.

Note that this commit does not change anything in the user interface.

The Python API of the `MovieStrip` class is extended with a function
`reload_if_needed()`. This function only performs disk I/O if the movie
strip cannot produce frames, that is either when its filepath points to
a non-existing file, or when the video sequence editor has not been
shown yet (for example because it is in an inactive workspace).

This allows for the following:

```
import bpy

scene = bpy.context.scene
vse = scene.sequence_editor_create()

filepath = bpy.path.abspath('//demo.mkv')
strip = vse.sequences.new_movie("movie", filepath,
    channel=2,
    frame_start=47,
    file_must_exist=False)
strip.frame_final_end = 327
```

This will create a new movie strip, even when `demo.mkv` does not exist.

Once `demo.mkv` has appeared at the expected location, either
`strip.reload_if_needed()` or `strip.filepath = strip.filepath` will
load it.

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

Reviewed By: Sergey, ISS
2020-07-13 15:09:18 +02:00
9db0c36af1 LibOverride: add more polling checks to operators not supposed to work on overrides.
This is long work, we are still likely missing a lot of cases...
2020-07-13 14:29:54 +02:00
03c8b048a1 Cleanup: remove public unused function. 2020-07-13 14:29:54 +02:00
9c9eb03d78 Fix T78855: Knife tool crashes when the geometry has no face
I don't see the need for a BVH Tree to have root but not have leafs.
But apparently this case is possible.
2020-07-13 08:59:47 -03:00
f019164f1f Optimization: Use dedicated function to restore customdata
Called when canceling a transform operation.
2020-07-13 08:59:47 -03:00
8074a18964 Cleanup: move unchanged condition out of loop 2020-07-13 08:58:04 -03:00
7b558a20a9 Fix Extrude Manifold losing original UV 2020-07-13 08:48:35 -03:00
976a0ff691 RNA code cleanup: Fix wrong usages of rna_idproperty_check().
This function is more expansive than the simpler `rna_ensure_property()`
one, and should only be used when IDProperty data is actually needed.

If one only needs to ensure it has a valid PropertyRNA pointer,
`rna_ensure_property()` is much more efficient.

Also add compiler warnings when results of those functions are unused,
this should never be the case.
2020-07-13 12:51:29 +02:00
f8afbb7657 RNA property management: tweak to 'is set' information.
Only consider a full IDProperty as set if it actually exists in given
PointerRNA data.
2020-07-13 12:51:29 +02:00
0158571b34 I18n utils: fix broken case when 'settings' argument is default NULL one. 2020-07-13 12:51:29 +02:00
7453ff73ad Cleanup: quiet warnings by adding const in some places
The warnings were introduced in rB725973485a909c2b732c5.
2020-07-13 12:48:51 +02:00
725973485a Clang Tidy: enable readability-non-const-parameter warning
Clang Tidy reported a couple of false positives. I disabled
those `NOLINTNEXTLINE`.

Differential Revision: https://developer.blender.org/D8199
2020-07-13 11:27:09 +02:00
a19584a471 BLI: fix constructor regression for Vector and Array
This was introduced in rB403384998a6bb5f428e15ced5.
2020-07-13 10:51:46 +02:00
644a915b1b BLI: don't allow mutable span of initializer list 2020-07-13 10:49:59 +02:00
0718c6fae0 Cleanup: fix clang tidy warning
The code was actually correct, but clang tidy complaint about
using the Vector after it was moved from.
2020-07-13 10:40:05 +02:00
91c763af3e Cleanup: typo 2020-07-13 10:34:44 +02:00
6dabfacb38 Sky: Code style and formatting fixes
Differential Revision: https://developer.blender.org/D8091
2020-07-13 03:08:11 +02:00
6a3c91f7ad Cycles: Clamp Sky Texture altitude to avoid numerical issues
Differential Revision: https://developer.blender.org/D8091
2020-07-13 03:08:11 +02:00
7aacf2e119 Cycles: Account for Sky Texture mapping in the sun sampling code
Differential Revision: https://developer.blender.org/D8091
2020-07-13 03:08:11 +02:00
192bd2605f Cycles: Change precomputed Sky Texture mapping to prioritize the horizon
Differential Revision: https://developer.blender.org/D8091
2020-07-13 03:08:11 +02:00
41e6f9bd43 Cycles: Add control for sun intensity in Sky Texture and change altitude to km
Differential Revision: https://developer.blender.org/D8091
2020-07-13 03:08:11 +02:00
e2736afdbe Cycles: Add versioning code for the new Sky Texture model
Differential Revision: https://developer.blender.org/D8091
2020-07-13 03:08:07 +02:00
77cd8182f8 Cycles: Remove Vector input on Sky texture when using the included sun
When using the sun, we need to sun sampling logic to avoid excessive
sampling map resolution, but that logic assumes that the Vector input
comes from the view direction.
That is the case in the vast majority of cases anyways, so the easiest
solution is to just remove the input for that case.

Differential Revision: https://developer.blender.org/D8091
2020-07-13 02:00:38 +02:00
474dcbcf12 Cycles: Remove limits on the Sky texture's sun rotation
For animation/driver purposes, being able to go outside of the 0-360
range makes things easier.

Differential Revision: https://developer.blender.org/D8091
2020-07-13 02:00:24 +02:00
f319eec881 Cleanup: disable debug code 2020-07-12 11:05:43 +02:00
30ed51d60a Cleanup: unused debug variable 2020-07-12 12:50:19 +02:00
21b20ae5ec Particles: initial support for forces in simulation node trees
The force node can now be used to control the behavior of particles.
Forces can access particles attributes. Currently, there are three attributes:
`Position` (vector), `Velocity` (vector) and `ID` (integer).

Supported nodes are: Math, Vector Math, Separate Vector, Combine Vector and Value.

Next, I'll have to split `simulation.cc` into multiple files and move
some stuff out of blenkernel into another folder.
2020-07-12 12:38:57 +02:00
ebf9082e1c Nodes: support more implicit conversions in simulation node tree 2020-07-12 12:38:30 +02:00
838b1742fb Functions: minor improvements 2020-07-12 12:38:03 +02:00
404486e66c Functions: minor api improvements 2020-07-12 10:01:37 +02:00
ee5c2f6ead GPencil: Replace "ShaderFX" with "Shader Effects" in RNA prop text 2020-07-11 20:41:21 +02:00
c7eada103c Nodes: support implicit conversions and incorrectly linked sockets 2020-07-11 18:02:06 +02:00
06401157a6 Fix: incorrect attribute type in network 2020-07-11 17:59:43 +02:00
46b79b3d4a Nodes: support vector math node in simulation node tree 2020-07-11 16:55:57 +02:00
b920875893 Nodes: support math node in simulation node tree 2020-07-11 16:47:53 +02:00
8fae58ce0b Nodes: support Value node in simulation node tree 2020-07-11 16:39:17 +02:00
16d4373158 Nodes: move Math, Vector Math and Value shader nodes to c++ files
This required a little bit of refactoring, because we were using c-only
syntax for the gpu shader names. All tests are still passing.
2020-07-11 16:24:53 +02:00
5e12123685 DRW: Add common point cloud rendering functions 2020-07-11 14:46:02 +02:00
415d3ee05b UV: add path select operator that uses the selection
Instead of using the mouse cursor position,
this selects between existing selected elements.

Access this since picking a selection path doesn't
work from the menu.
2020-07-11 22:09:45 +10:00
6e698653df Cleanup: remove unused function 2020-07-11 20:34:17 +10:00
651db1b26f Cleanup: spelling 2020-07-11 15:32:59 +10:00
020e0f11ff Docs: remove reference to PYTHONHOME
This is no longer used by default, when '--python-use-system-env' is set
there are many Python environment variables, don't list them in
Blender's help message.
2020-07-11 14:50:47 +10:00
d2b910fafe UI: UV: Add Select Shortest Path to menu
This matches the 3D Viewport
2020-07-10 16:07:31 -04:00
3dc0178390 Fix T78662: Cycles baking fails if denoising is enabled, after recent changes
This is not supported yet.
2020-07-10 20:08:46 +02:00
6fbacd6048 Fix build error building without OpenImageDenoise 2020-07-10 19:56:53 +02:00
48f10319c6 Fix T78801: Eevee missing setting to enable/disable freestyle per view layer
This was only visible when Cycles was enabled.
2020-07-10 18:41:16 +02:00
4e8fc15586 UI: Improve transform constraint layout
- Remove the "mapping" subpanel and moves the source axis
    selection ot the destination subpanel.
  - Rename "Source" and "Destination" to "Map From" and "Map To" to
    make the action more clear
  - Gray out source axes when their data isn't selected.

  These changes were discussed in D8041.
2020-07-10 12:21:32 -04:00
3e4f49fe71 Revert "Fix T78296: Performance - Use Binary Search for MDeformWeight"
This reverts commit 39b525e0f0 and
3121015dce as tests are failing.
2020-07-10 18:03:21 +02:00
d5208c45fa GPencil: Fix unreported Use Falloff curve for active frame not working
For the active frame it was using always a value of 1.0 and it was not using the curve.
2020-07-10 17:56:35 +02:00
6eeb32706a Cycles: support OpenImageDenoise in final renders
Performance is not great currently due to the API not seeming to support
efficient denoising of multiple tiles at the same time. So in many cases
only one or a few threads will actually be denoising at the same time.

In renders with many samples this is not a big problem, but for faster
renders it's a signficant overhead.

We should try to optimize this still, possibly by batching denoising of
a bigger neighborhood of multiple tiles at once.
2020-07-10 17:10:05 +02:00
93791381fe Cleanup: reduce hardcoded numbers in denoising neighbor tiles code 2020-07-10 17:10:05 +02:00
e65c78cd43 Cleanup: minor refactoring in Cycles update detection code 2020-07-10 17:10:05 +02:00
Milan Jaros
ad45b8d6a4 Cycles: optimize camera inside volume tests
Only run when there are volumes in the scene, and compute in parallel.

Ref T56939

Differential Revision: https://developer.blender.org/D8261
2020-07-10 17:10:05 +02:00
d8e648c352 Fix T78776: Cycles OpenCL error after recent changes for holdouts 2020-07-10 17:10:05 +02:00
9dbe9a753a Fix T78766: Blender crashes after deleting vertices with Custom Normals.
Some core BMesh topology changing functions were not properly tagging
custom normal runtime caches as dirty...
2020-07-10 16:51:37 +02:00
5372924983 Fix T78579: Proxy produces wrong preview when using Offset or Crop
Make sure that proxy and original images are scaled to same size before
applying offset or crop.

During testing, I discovered, that raw cache will lose information whether
this image was proxy or not. Because of this, proxy images will not create
this cache type. It would be fairly easy to implement this functionality for
cache, but I have decided to not do it now, because I did not want to pass yet
another mostly hard-coded bool flag to cache system. Since image is proxy, it
should be fast to read anyway.

In case of using offset property, code was modified to make sure we scale
image only once. I also tried to make code more readable and streamlined and
cleaned up surrounding functions a bit.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D8203
2020-07-10 16:16:42 +02:00
77f823a240 Fix T78573: Crash when removing strips with prefetching
Stop prefetching before changing content of seqbase.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D8256
2020-07-10 16:16:42 +02:00
47e71f4623 Fix T69440: Memory leak adding strips via python
seq->strip was overwritten in python API function.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D8204
2020-07-10 16:16:42 +02:00
cbfedf2139 BLI: add C++ random number generator
This adds `blender::RandomNumberGenerator` in `BLI_rand.hh`.
Furthermore, `RNG` is now implemented in terms of this new generator.
No functional changes are expected, the generated random numbers
are not changed by this commit.

Reviewers: campbellbarton, brecht

Differential Revision: https://developer.blender.org/D8259
2020-07-10 15:54:01 +02:00
c2304d2f02 Expose override flags to python RNA properties definition.
Time will tell whether we need to expose more RNA override flags here.

Implements/Fix T78534.

Differential Revision: https://developer.blender.org/D8250
2020-07-10 15:50:21 +02:00
4d1c3c029e Cleanup: declaration and implementation function signature did not match 2020-07-10 15:48:46 +02:00
f93e0f1a9e Refactor override code to properly deal with runtime rna properties too.
The triplet static RNA / runtime RNA / custom properties is a real pain to
deal with...

Using the new `PropertyRNAOrID` struct helps clarifying and properly
dealing with all three cases.

Note that this makes override of py-defined RNA properties working
(support for that will be committed next).

Differential Revision: https://developer.blender.org/D8249
2020-07-10 15:23:52 +02:00
337e2c9029 RNA: refactor how we get 'ensured' RNA properties.
Introduce new PropertyRNAOrID structure, storing most useful data about
an 'opaque' PropertyRNA in relation with a given PointerRNA struct.

It deals with all the three cases (pure static RNA, runtime RNA where
data is actually stored in IDProperties, and pure IDProperties, aka
custom data.
2020-07-10 15:19:40 +02:00
6c1157201a Cleanup: simplify platform define checks
Platforms besides WIN32 were in a single else clause, use elif instead.
2020-07-10 23:01:21 +10:00
45287f909c Fix for building on systems besides apple/windows/linux 2020-07-10 23:00:17 +10:00
26d28ade26 Cleanup: follow code style 2020-07-10 14:40:23 +02:00
c806db6313 Functions: add utility to find dependencies of input sockets 2020-07-10 14:23:13 +02:00
60133ff98d Functions: store derived node tree and network in map for future access 2020-07-10 14:23:13 +02:00
295b3aefb0 Functions: make constant folding work on unfinished networks 2020-07-10 14:23:13 +02:00
7bae599232 Nodes: add redundant name check in debug builds to prevent errors 2020-07-10 14:23:13 +02:00
3121015dce Fix Crash due to recent changes
{39b525e0f07fa25dcda54226ade789959b642dec} could write in unallocated
space.
2020-07-10 13:38:38 +02:00
00eb6a56aa GPencil: Fix tooltip error
The tooltip was copied by error from Lattice modifier.
2020-07-10 13:30:21 +02:00
8fd65a2252 Functions: use new is-equal and hash function of CPPType 2020-07-10 12:57:28 +02:00
3edd2832b2 Functions: make generic types hashable 2020-07-10 12:57:28 +02:00
f62204718b BLI: initial hash function for Color4b and float4x4 2020-07-10 12:57:28 +02:00
8f6c0f2242 Functions: make generic types equality comparable 2020-07-10 12:57:28 +02:00
52636c3059 Cleanup: various cleanups in for CPPType 2020-07-10 12:57:28 +02:00
39b525e0f0 Fix T78296: Performance - Use Binary Search for MDeformWeight
Use binary search for querying deform weights.

Spring 02_020_A.anim.blend on Ryzen 1700X goes from 12.4 to 12.7fps.

During profiling it was detected that adding new items to the head was faster than adding to the tail.

Reviewed By: Campbell Barton

Differential Revision: https://developer.blender.org/D8127
2020-07-10 12:09:40 +02:00
77a646279d Cleanup: structure CPPType according to code style guide 2020-07-10 12:04:49 +02:00
9c25731781 LibOverride: Fix improper tagging of more of the backward pointers in RNA nodetrees. 2020-07-10 11:53:11 +02:00
582a0b7e5a Fix T78756: White UV drawing is displayed as Dashed 2020-07-10 19:02:18 +10:00
7a9028cad1 Fix UV rip failing to disable proportional edit-mode 2020-07-10 18:58:36 +10:00
a148c4676b Cleanup: spelling 2020-07-10 16:04:09 +10:00
03f5acd445 Cleanup: clang-format 2020-07-10 16:03:12 +10:00
8b660ea0ec Fix UV path redo in vert/edge mode
Redo was only working in some situations,
some options were also not being forwarded.
2020-07-10 13:41:51 +10:00
96068324cd Fix BM_loop_at_index_find lookup 2020-07-10 13:35:44 +10:00
89cb41faa0 UV: allow ripping face-regions
This changes the behavior of rip when entire faces are selected.
Now face regions are isolated and moved instead of ripping the edge-loop
extracted from the selection boundary.

This is a convenient alternative to separate selection & move.
Resolves T78751.
2020-07-10 13:01:46 +10:00
3fdd092649 Cleanup: face-center mesh calculation
Loop over faces and calculate their centers instead of zeroing the
face center array and accumulating all faces vertex corners.

Move subsurf face center extraction into it's own loop since it works
differently.
2020-07-10 12:44:42 +10:00
b0378440ce Fix missing adjacent UV check for recent UV path select
Path selection could cross UV islands if the destination element was
on an island boundary.
2020-07-10 12:19:30 +10:00
8f24ec2e26 Cleanup: add BLI_linklist_find_last
This makes adding to the end of a linked list simpler,
In most cases we avoid this in favor of BLI_linklist_append.

For one off operations it's OK.
2020-07-10 12:14:32 +10:00
3dd460aa7f Cleanup: spelling 2020-07-10 11:49:46 +10:00
a0d3b60015 Cleanup: use FLT_MAX for the maximum path selection cost
A large number below FLT_MAX was used to avoid overflow,
however this doesn't cause any problems.
2020-07-10 11:49:46 +10:00
0b77e2f4c4 Cleanup: variable names, use define for maximum path cost 2020-07-10 11:49:46 +10:00
92bc277950 Cleanup: undeclared warnings 2020-07-10 11:49:46 +10:00
3623db7784 BLI: add more operator overloads for float2 2020-07-09 19:04:47 +02:00
03a00bda2b Sculpt: Make Sculpt Vertex Colors features experimental
This disables all Sculpt Vertex Colors tools, operators, panels and rendering capabilities and puts them under the "Use Sculpt Vertex Colors" experimental option.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D8239
2020-07-09 18:24:50 +02:00
1e3247c078 Fix: add missing extern "C" 2020-07-09 18:19:39 +02:00
a90b69d065 Build: add more libc compatibility functions for upcoming libraries update
These are needed by the x264 library.
2020-07-09 18:10:05 +02:00
6778949e01 Fix repeated Face Sets IDs when joining meshes
As Face Sets IDs start from 0 and increase by 1 each time a new face set
is created in a mesh, when joining multiple meshes it could happen that
the same ID is used by several unrelated areas in multiple objects. This
checks the Face Sets IDs when joining meshes and ensures that they are
not repeated between different objects when joining them, so in the
resulting mesh all previous face sets will have different IDs.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D8224
2020-07-09 17:56:56 +02:00
7b1c406b54 Implement T77959: Never duplicate linked data during deep-copy.
Note that this behavior is enforced on user level for now, but on code
side it is controlled with a flag, which should make it easy to refine
that behavior if needed.

Only exception is when we duplicate a linked ID directly (then we assume
user wants a local deep-copy of that linked data, and we always also
duplicate linked sub-data-blocks).

Note that this commit also slightly refactor the handling of actions of
animdata, by simplifying `BKE_animdata_copy_id_action()` and adding an
explicit new `BKE_animdata_duplicate_id_action()` to be used during ID
duplication (deep copy).

This also allows us to get rid of the special case for liboverrides.
2020-07-09 17:56:05 +02:00
78b629a98f Sculpt: Skip fully hidden nodes in sculpt tools
As tools iterators skip not visible vertices, fully hidden nodes can
also be skipped and considered as masked.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D8244
2020-07-09 17:51:09 +02:00
1fb667da01 Fix wrong upate flag when updating the PBVH visibility
This function was using the wrong flag to update the visibility state of
the nodes, so I assume that most of the partially visible optimizations
were not working.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D8243
2020-07-09 17:50:10 +02:00
e5ebaa9fd6 Fix T78664: Implement Mesh and Face Set boundary automasking in Multires
This implements the SCULPT_vertex_is_boundary and SCULPT_vertex_has_unique_face_set functions for PBVH_GRIDS, which makes features such as automasking now work in multires. It also fixes some other face sets related features in multires, like face set boundary smoothing.

This uses the BKE_subdiv_ccg_coarse_mesh_adjacency_info_get function to get the vertex indicies in the base mesh from multires. This way the API functions can get topology or face set information directly from it. In the future, these vertex indices can be used to get any other information from the base mesh from multires, like seams, sharp edges, disconnected elements IDs...

Reviewed By: sergey

Maniphest Tasks: T78664

Differential Revision: https://developer.blender.org/D8227
2020-07-09 17:48:24 +02:00
bd84b2cbcc Fix Sculpt Vertex Colors sample color changing brush alpha
It is not practical to change the alpha of the paint color with the
color picker as with the current brush design alpha is the main strength
control for the brush.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D8208
2020-07-09 17:42:27 +02:00
13b1374497 Fix crash when using Mask by Color in Multires
Reviewed By: sergey

Differential Revision: https://developer.blender.org/D8207
2020-07-09 17:41:14 +02:00
78d48343ae Make deps: Fix compilation error on CentOS
There were two issues.

First is related on ISPC's CMake configuration forcing C and C++
compilers to be clang and clang++. This goes against of desired
behavior when we use our own compiled clang compilers.

The second issue was related on linker failure: CLang libraries
are linked statically, and they need some of C++ 11 STL symbols
which are coming from libstdc++.

Differential Revision: https://developer.blender.org/D8258
2020-07-09 17:24:49 +02:00
2be0ae7c99 Fix Cycles unnecessary updates to camera in viewport render
Problem identified by Milan Jaros.
2020-07-09 16:53:28 +02:00
Szymon Ulatowski
9de09220fc EEVEE: Implement the missing Sky texture
I'm not sure if the Sky was deliberately left out or was just waiting for a
better moment, but so many I was disappointed that Sky in EEVEE is
completely white.

There are already 2 implementations (osl and gpu) so this is the third one.
Looking at other cases it seems that we are not supposed to share sources
between cycles and the rest? So the new util_sky_model files are just
copies of what is already in cycles, except that the data file uses the RGB
variant of the Hosek/Wilkie model, because we output RGB anyway (but can be
easily changed to XYZ if desired - the results are nearly identical).
I am not sure if it is okay to pass 3*9 float values as 3 mat4 uniforms (I
wanted to use mat3 but it does not work).
Also, should I cache the sky model data between renders if the parameters
do not change?

Reviewed By: fclem, brecht

Differential Revision: https://developer.blender.org/D7108
2020-07-09 17:31:36 +02:00
42c99ec15b BLI: rename rand.c to rand.cc 2020-07-09 16:37:44 +02:00
580d50091c Particles: Create a simulation state for every Particle Simulation node
Every Particle Simulation node has a name (or a path when it is in a node group).
This name has to be used in the Simulation modifier on a point cloud to see
the particles.

Caching has been disabled for now, because it was holding back development
a bit. To reset the simulation, go back to frame 1.

Currently, there is no way to influence the simulation. There are just some
randomly moving points. Changing that is the next step.
2020-07-09 15:40:27 +02:00
31ad43a3c7 Blenloader: make BLO_read_data_address work in C++ 2020-07-09 15:29:25 +02:00
544c435fdd Fix T78745: Cycles error baking with multiple materials 2020-07-09 12:28:33 +02:00
8ddf7556a5 Fix T78718: Crash when deleting particle system modifier with the X Shortcut.
Duplication and deletion code of modifiers was totally wrong for
particle system, that special weird thing needs its own custom
management.

Note that for now I chose not to duplicate the particle settings ID when
duplicating the modifier...
2020-07-09 11:46:28 +02:00
ea5fe7abc1 UV: path selection support
This adds support for path selection for vertex edge & face selection
modes, matching mesh editing behavior, useful with the UV rip tool.

Region select & edge tagging are currently not supported,
although they could be added eventually.
2020-07-09 18:43:23 +10:00
0b8221683f BMesh: add utility functions
- BM_edge_uv_share_vert_check
- BM_face_uv_calc_center_median_weighted
- BM_loop_at_index_find
2020-07-09 18:23:16 +10:00
0b3bf69d3c Cleanup: move BMesh UV queries into their own file 2020-07-09 13:33:15 +10:00
754c5d6a14 Cleanup: clang-format 2020-07-09 13:29:48 +10:00
31bc76ea4e Cleanup: remove unnecessary calls to as_span
This uses the new implicit conversions and constructors
that have been committed in the previous commit.

I tested these changes on Linux with gcc and on Windows.
2020-07-08 22:30:23 +02:00
403384998a BLI: improve constructors and conversions to span
This allows us to avoid many calls to `as_span()` methods. I will
remove those in the next commit. Furthermore, constructors
of Vector and Array can convert from one type to another now.

I tested these changes on Linux with gcc and on Windows.
2020-07-08 22:27:25 +02:00
4b85ed819d Cleanup: remove unused function
This is not necessary in C++17 anymore.
2020-07-08 20:41:00 +02:00
f7d5d4ee3b Cleanup: use c++17 helper variable templates 2020-07-08 20:39:20 +02:00
e4926c167b Fix T78718: Crash when deleting particle system modifier with the X Shortcut.
Again those backward pointers not properly flagged in RNA, hence
generating infinite loops.
2020-07-08 18:08:08 +02:00
f4a39cafa1 Functions: add AttributesRef class
This is the same as MutableAttributesRef, but the data in it cannot be changed.
2020-07-08 17:05:52 +02:00
439c238bb4 Cleanup: use different internal socket name 2020-07-08 17:05:52 +02:00
05365d1376 Functions: support hashing MFDataType and CPPType 2020-07-08 17:05:52 +02:00
2de5de57c5 Build: fix stack linker warning with ffmpeg on macOS
The ff_cfhd_init_vlcs() function was using a lot of stack space, which
made linker on macOS unhappy. Using heap allocation allows to silence
the warning without causing other side-effects.

Kept the patch enabled for all platforms to avoid difference in behavior
and performance on different platforms, which could make certain types
of investigation very tricky.

Differential Revision: https://developer.blender.org/D8248
2020-07-08 15:49:55 +02:00
cb3c4218bf Minor cleanup in rna override code. 2020-07-08 15:43:57 +02:00
d1f4546a59 Functions: implement common subnetwork elimination optimization
This was the last of the three network optimizations I developed in
the functions branch. Common subnetwork elimination and constant
folding together can get rid of most unnecessary nodes.
2020-07-08 15:10:30 +02:00
e3e42c00cb Functions: Support getting MFSocket based on its id 2020-07-08 15:10:30 +02:00
2b9d62b73a Functions: Support accessing socket index of MFSocket 2020-07-08 15:10:30 +02:00
34d175f372 Functions: initial hash/equals implementation for constant multi-functions 2020-07-08 15:10:30 +02:00
840941215d Functions: allow multi-functions to override a hash and equals function 2020-07-08 15:10:30 +02:00
36a547af7b Cleanup: add correct license header to tests 2020-07-08 15:10:30 +02:00
ff133bbd33 BLI: add disjoint set data structure
This can be used to find separate islands in meshes efficiently (as is
done in cycles already). Furthermore, this helps to implement some
algorithms on node trees more efficiently.
2020-07-08 15:10:30 +02:00
a8ff8b64dc BLI: add comparison operators and hash functions for float3, etc. 2020-07-08 15:10:30 +02:00
ff444da7c4 macOS: upgrade minimum required version to 10.13 High Sierra
C++17 does not work on 10.12, and Apple extended support ended for 10.12 in
October 2019.

Maniphest Tasks: T76783, T76184

Differential Revision: https://developer.blender.org/D8179
2020-07-08 14:43:28 +02:00
6435acd8f6 Cycles: support shader transparency for holdout objects
Now transparent areas of the object will render objects behind.

Fixes T78728.
2020-07-08 13:18:19 +02:00
643196cc37 CMake: Fix spelling of Embree passed to find package
The spelling and capitalization of package name passed to find_package()
and find_package_handle_standard_args() needs to match.

Silences CMake warning about mismatch.

Differential Revision: https://developer.blender.org/D8247
2020-07-08 12:35:56 +02:00
45004d82e0 Functions: add dead node removal and constant folding optimization
Those optimizations work on the multi-function network level.
Not only will they make the network evaluation faster, but they also
simplify the network a lot. That makes it easier to understand the
exported dot graph.
2020-07-08 11:18:43 +02:00
50d7c00d9c Cleanup: fix comment 2020-07-08 10:16:56 +02:00
01c8aa12a1 Apply Modifier: support applying as shape key and keeping the modifier.
This can be useful to save the result of a cloth simulation as a
shape key without destroying the simulation, so it's possible to
e.g. re-run it to get other shapes, or simply use the new shape
key to start the simulation already in a draped state.

It also makes sense to allow applying as shape key even when the
mesh is shared, because the operation itself just adds a shape
key. To support this, split the apply operator into Apply and
Apply As Shapekey so that they can have different poll callbacks.

Differential Revision: https://developer.blender.org/D8173
2020-07-08 11:06:57 +03:00
7fcb6bc59c Fix T78324: Different Sky Texture results between CPU and GPU
The problem here was numerical precision: The code calculates the angle between
sun and view direction, and the usual acos(dot(a, b)) approach for that has
poor numerical performance for almost parallel angles.

As a result, the generally tiny difference between floating point computation
between CPU and GPU was enough to make the sun vanish at different radii,
causing different results.

The new version fixes the difference by making the computation much more robust
on both platforms.
2020-07-08 02:15:37 +02:00
afcb41a0aa BLI: simplify copy constructor of Array 2020-07-07 20:32:40 +02:00
eb5fb1741d Cleanup: don't end description with a '.' 2020-07-07 20:29:35 +02:00
8713109212 Cleanup: fix typo 2020-07-07 20:27:34 +02:00
902ee4d13c Functions: cleanup loop that traverses the MFNetwork 2020-07-07 19:46:10 +02:00
22158162ef Functions: add generic functions that output constants 2020-07-07 19:34:35 +02:00
f4633cf46c BLI: simplify copy constructor of vector 2020-07-07 19:16:31 +02:00
67042aa6a1 Functions: extend multi-function network api 2020-07-07 18:45:34 +02:00
adfae89f96 BLI: provide access to underlying node in dot exporter 2020-07-07 18:40:42 +02:00
a8627ea66d Functions: Add debug print and destruct callback to CPPType 2020-07-07 18:39:24 +02:00
4990e4dd01 Nodes: Generate multi-function network from node tree
This adds new callbacks to `bNodeSocketType` and `bNodeType`.
Those are used to generate a multi-function network from a node
tree. Later, this network is evaluated on e.g. particle data.

Reviewers: brecht

Differential Revision: https://developer.blender.org/D8169
2020-07-07 18:23:33 +02:00
ff97545c50 Fix T75943 EEVEE: Cubemaps shows black
Caused by faulty driver implementation. Force fallback method.
2020-07-07 18:38:21 +02:00
1e2ff4f81b Cleanup: Add braces for clang tidy 2020-07-07 11:10:42 -04:00
0edf2fc128 BLI: Correct spin lock definition
The MSVC atomic function is defined for an unsigned type.

Not sure why this became an issue after switch to TBB by default,
maybe some CFLAGS changed to be more strict after that.
2020-07-07 16:51:03 +02:00
dad3de89dc Fix: remove accidental code
`v1` and `v2` are already set.
2020-07-07 11:27:23 -03:00
d352902758 Make deps: Use own nasm for ffmpeg and x264
Fixes the warning: building for macOS, but linking in object file

Differential Revision: https://developer.blender.org/D8235
2020-07-07 16:26:47 +02:00
1e3c0b4b03 Make deps: Compile own version of nasm for Apple
The upstream version of nasm does not put version information to the
generated object files, which makes linker to show the following
warning:

  building for macOS, but linking in object file

Using own patched version of nasm which puts required information to
the object file, making linker happy.

The plan is to either streamline the patch and provide it to the
upstream, or, it that takes too long, get an independent fix from the
upstream.
2020-07-07 16:26:13 +02:00
202e7ccaae Fix T77455: Blender Freezes when using the 3d Scale Gizmo
Issue is reported on Linux ith Intel HD6xx iGPU. Inside
`gpu_select_sample_query.c` the call to `glGetQueryObjectuiv` froze. After
bisecting this lead to the polyline shader. When using a 3d color shader
in stead of the polyline shader during selection seems to fix the issue.

Other parts of blender might also be effective, but I wasn't able to
freeze blender in these areas. When it does, we might want to add
a similar work-around to button2d, cage2d, cage3d & move3d, navigate.

Backport this patch to 2.83.

Reviewed By: Clément Foucault

Differential Revision: https://developer.blender.org/D8217
2020-07-07 16:22:05 +02:00
d1dcd2b464 BLI: Fix mistake in SpinLock TBB migration
Copy-paste mistake.
2020-07-07 16:17:58 +02:00
20558848d3 Optimization: use BLI_bvhtree_intersect_plane to detect faces that will be affected by the knife tool
The knife code currently calls the `BLI_bvhtree_overlap` function that
tests the overlap between the mesh tree and an AABB that encompasses the
points projected in the clip_start, clip_end and or clip_planes of the
view.

This resulted in many false positives since the AABB is very large.
Often all the triangles "overlapped".

The solution was to create a new function that actually tests the
intersection of AABB with a plane.

Even not considering the clip_planes of the view, this solution is more
appropriate than using overlap.

Differential Revision: https://developer.blender.org/D8229
2020-07-07 10:55:57 -03:00
630c6226e2 Fix T78307 UI: Drawing artifacts in the Blender UI on macOS
This was due to a bad driver which was not respecting this bit of the
specification:

`If the current primitive does not originate from an instanced draw command, the value of gl_InstanceID is zero.`
2020-07-07 16:26:01 +02:00
737bd549b6 Cycles: Add support for native OptiX curve primitive
This patch adds support for the curve primitive from OptiX to Cycles. It's currently hidden
behind a debug option, since there can be some slight rendering differences still (because no
backface culling is performed and something seems off with endcaps). The curve primitive
was added with the OptiX 7.1 SDK and requires a r450 driver or newer, so this also updates
the codebase to be able to build with the new SDK.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D8223
2020-07-07 15:39:02 +02:00
95f0f31279 Fix T78692: improve UI regarding the effect of the denoiser on denoising passes
It wasn't obvious that the choice of Cycles denoiser also generates different
denoising data passes for compositing.
2020-07-07 15:12:41 +02:00
a394aac8b4 Fix T78666: Cycles non-uniformly scaled hair renders wrong for static objects
Don't apply the matrix transform optimization in this case, curve points and
radius can't represent non-uniform scale the way is possible with triangle
meshes and vertices.

This would cause abrupt change if objects had e.g. motion blur in one frame
and not in the next.
2020-07-07 15:08:21 +02:00
98bee41c8a IO: Reversed persistent ID order in exports to Alembic and USD
Each duplicated (a.k.a. instanced) object has a Persistent ID, which
identifies a dupli within the context of its duplicator. This ID
consists of several numbers when there are nested duplis (for example a
mesh instancing empties on its vertices, where each empty instances a
collection). When exporting to Alembic/USD, these are used to uniquely
name the duplicated objects in the export.

This commit reverses the order of the persistent ID numbers, so that the
first number identifies the first level of recursion. This produces
trees like this:

    ABC
     `--Triangle
         |--Triangle
         |--Empty-1
         |    `--Pole-1-0
         |        |--Pole
         |        `--Block-1-1
         |            `--Block
         |--Empty
         |    `--Pole-0
         |        |--Pole
         |        `--Block-1
         |            `--Block
         |--Empty-2
         |    `--Pole-2-0
         |        |--Pole
         |        `--Block-2-1
         |            `--Block
         `--Empty-0
             `--Pole-0-0
                 |--Pole
                 `--Block-0-1
                     `--Block

It is now clearer that `Pole-2-0` and `Block-2-1` are instanced by
`Empty-2`. Before this commit, they would have been named `Pole-0-2` and
`Block-1-2`.
2020-07-07 14:30:55 +02:00
70b1c09d7a IO: Fix bug exporting dupli parent/child relations
Exporting a scene to USD or Alembic would fail when there are multiple
duplicates of parent & child objects, duplicated by the same object. For
example, this happens when such a hierarchy of objects is contained in a
collection, and that collection is instanced multiple times by mesh
vertices. The problem here is that the 'parent' pointer of each
duplicated object points to the real parent; Blender would not figure
out properly which duplicated parent should be used.

This is now resolved by keeping track of the persistent ID of each
duplicated instance, which makes it possible to reconstruct the
parent-child relations of duplicated objects. This does use up some
memory for each dupli, so it could be heavy to export a Spring scene
(with all the pebbles and leaves), but it's only a small addition on top
of the USD/Alembic writer objects that have to be created anyway. At
least with this patch, they're created correctly.

Code-wise, the following changes are made:

- The export graph (that maps export parent to its export children) used
  to have as its key (Object, Duplicator). This is insufficient to
  correctly distinguish between multiple duplis of the same object by
  the same duplicator, so this is now extended to (Object, Duplicator,
  Persistent ID). To make this possible, new classes `ObjectIdentifier`
  and `PersistentID` are introduced.
- Finding the parent of a duplicated object is done via its persistent
  ID. In Python notation, the code first tries to find the parent
  instance where `child_persistent_id[1:] == parent_persistent_id[1:]`.
  If that fails, the dupli with persistent ID `child_persistent_id[1:]`
  is used as parent.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D8233
2020-07-07 13:01:07 +02:00
f2175e06a7 Mae deps: Ensure Brotli is disabled for FreeType
We don't need it and it was optionally enabled, causing Blender to fail
to link on certain configuration (when Brotli is installed via Homebrew
for example).
2020-07-07 12:44:12 +02:00
02cd159539 Cleanup: add comment explaining operator delete 2020-07-07 12:31:25 +02:00
cc311e4a52 IO: print export name instead of object name in debug export graph output
This is just a change in `AbstractHierarchyIterator::debug_print_export_graph()`
to aid in debugging. It'll make it possible to distinguish between
different duplicates of the same object.

No functional changes to Blender itself.
2020-07-07 12:02:49 +02:00
5761cb9ee2 Guarded Allocator: add missing operator delete
This resolves warning C4291 on windows.
2020-07-07 11:52:45 +02:00
Johan Walles
80fe5e1b15 UI: Add units to motion tracking solve errors
The unit being "pixels".

Before this change the solve errors were unitless in the UI.

With this change in place, the UI is now clear on that the unit of the
reprojection errors is pixels (px).

Differential Revision: https://developer.blender.org/D8000
2020-07-07 11:22:12 +02:00
6d9a6f12b3 Make deps: Fix compilation error of Python on macOS
The configuration was confused about gettext installed via Homebrew
and isysroot passed to Python's compilation but not to test programs.

After this change `import gettext` still works, but it is unclear how
to test it further,

Differential Revision: https://developer.blender.org/D8231
2020-07-07 11:17:47 +02:00
955abbeff2 Fix sign conversion error 2020-07-07 09:01:01 +02:00
e233ee1c1f Fix T78186: Dyntopo panel error with tools that dont have a brush
Maniphest Tasks: T78186

Differential Revision: https://developer.blender.org/D8120
2020-07-07 10:38:56 +02:00
19d4e265b6 Cleanup: remove redundant comments
Searching in these files for "_as" will reveal a comment at the
top, that explains what these methods are for. There is no need
to duplicate that knowledge all over the place.
2020-07-07 10:35:55 +02:00
6e609f0eb0 Cleanup: use doxy comments 2020-07-07 17:52:05 +10:00
62774baded UI: add merge/split menus
This makes the menus and keymap match the edit-mesh
(M for merge, Alt-M for split).
2020-07-07 17:52:05 +10:00
d212b3dc43 Make deps: Fixes for macOS platform
Set of fixes which had to be made in order to have dependencies built
on own laptop:

- Require bison as a dependent software. It is required by ISPC.

  On macOS it is required to be installed via Homebrew. This is because
  Bison from Xcode toolchain is too old.

- Made sure Boost is compiled using clang.

  Without this gcc was used, and some unsupported command line argument
  was passed to it.

- Modify OGG in a way which does in fact pull fixed sized types.
  They are defined in stdint.h.

  Without this fix FFmpeg will not detect presence of OGG because the
  test program fails to compile.

- Force disable zstd compression and make wepb optional for the TIFF
  library. Without this TIFF might pick up development libraries from
  Homebrew.

Differential Revision: https://developer.blender.org/D8221
2020-07-07 09:31:46 +02:00
b28683b8b5 Cleanup: remove unused arguments 2020-07-07 16:04:10 +10:00
0c58970da7 Cleanup: spelling 2020-07-07 12:49:13 +10:00
ad0edc626d Cleanup: unused World struct members linfac, logfac 2020-07-07 12:44:20 +10:00
e20171e59f Fix build error with tests for removed functions
These GHash functions were removed in 12817083ec,
so the tests should be removed too.
2020-07-06 16:39:28 -04:00
d557f05502 Cleanup: Use bool instead of int 2020-07-06 16:07:54 -04:00
053e0c0af3 UI: Add shortcuts for shader effect panels
Only the delete shortcut applies here, although the move up and down
operators can optionally be assigned in the keymap.

See rB1fa40c9f8a81 for more details and rB5d2005cbb54b for the
grease pencil modifier panel implementation, which is the same.
2020-07-06 15:35:21 -04:00
12817083ec Cleanup: Use the BLI_edgehash API in the sewing simulation of cloths
Also remove the code in the ghash that is no longer used.

This change simplifies the existing code.

Differential Revision: https://developer.blender.org/D8219
2020-07-06 14:44:30 -03:00
a856de700b Fix T77730: ShaderFx Missing Update Notifier
This adds a notification type for shaderfx so the properties editor can
be properly notified to redraw.

Another possible solution would be to also redraw the shaderfx tab
 with a ND_MODIFIER update, but this solution allows us to avoid
 some unecessary redraws too. There were no existing cases of
ND_OBJECT | NC_MODIFIER updates, so those cases were
removed from buttons_area_listener.

Differential Revision: https://developer.blender.org/D8159
2020-07-06 13:17:07 -04:00
f6f4043924 BLI: add methods to lookup a stored key in a set 2020-07-06 17:59:27 +02:00
1562c9f031 Fix OptiX viewport denoising not working when rendering scene (without OptiX) that uses unsupported features
Denoising devices do not need to load the full feature set of kernels, so only activate the denoising
feature for them (so that it is possible to use features that are supported by the render devices, but
not the denoising devices).
2020-07-06 17:33:04 +02:00
aabfd2fb9b Cleanup: readfile: remove old deprecated OldNewMap for runtime caches. 2020-07-06 16:55:38 +02:00
ee3eba902a Runtime cache preservation during undo: add support for nodes and embedded IDs. 2020-07-06 16:55:38 +02:00
bfc644dcfb Reduce DupliObject::persistent_id from 16 to 8 items
For historical reasons, `DupliObject::persistent_id` was of size
`2*MAX_DUPLI_RECUR`. These reasons are now gone, and the persistent ID
always gets exactly one array element for every dupli-recursion.

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

Reviewed by: brecht
2020-07-06 16:52:28 +02:00
0b07f9b717 Fix T78608: Memory leak in Material properties: "Data from SCE".
Caused by recent own refactor of cache presevation handling in readfile,
EEVEE's lightcache are weird birds that can also be saved in .blend
files, need a special handling for those 'persistent' caches...
2020-07-06 15:09:39 +02:00
99feb10b8b Cleanup: warning, spelling 2020-07-06 23:07:18 +10:00
20446f07f6 Docs: reference bl_rna_get_subclass_py instead of bl_rna_get_subclass
bl_rna_get_subclass only works for Nodes at the moment.
2020-07-06 23:07:18 +10:00
ffaf294c3f Fix alignment/size issue on ARM/RPi architecture
Addresses 964305 from Debian bug tracker.
2020-07-06 14:53:39 +02:00
924578ce19 Optimization: Don't compute the snap to face on the knife tool twice
Both `knife_find_closest_vert` and `knife_find_closest_edge` call
`knife_find_closest_face`. Thus, running the raycast twice and setting
values like `kcd->curr.bmface` and `kcd->curr.is_space` repeatedly.

So:
- separate `knife_find_closest_face` from `knife_find_closest_vert` and `knife_find_closest_edge`.
- rename `knife_find_closest_vert` to `knife_find_closest_vert_of_face`
- rename `knife_find_closest_edge `to `knife_find_closest_edge_of_face`.
- do not set parameters previously set.

Differential Revision: https://developer.blender.org/D8198
2020-07-06 09:49:00 -03:00
073c426900 Fix faces disappearing when AutoMerge & Split 2020-07-06 09:03:33 -03:00
c632cf9ccd Fix UV select separate not refreshing the display 2020-07-06 21:23:35 +10:00
2c0cab03ca UV: add rip region to toolbar 2020-07-06 21:15:18 +10:00
dbe171fb26 Cleanup: spelling, comments 2020-07-06 21:03:45 +10:00
18b6c49a90 Cleanup: rename namespace TimeIt to timeit
According to our style guide, namespaces should have
lower case names.
2020-07-06 12:37:11 +02:00
572c48cf98 BLI: improve exception safety of memory utils
Even if we do not use exception in many places in Blender, our core C++ library
should become exception safe. Otherwise, we don't even have the option
to work with exceptions if we decide to do so.
2020-07-06 09:08:53 +02:00
703a73fa84 BLI: refactor how buffers for small object optimization are stored
Previously, there was an error when operator-> was returning an
invalid type. See error C2839.
2020-07-06 10:56:26 +02:00
80393a0eba UV: add rip tool
New rip tool matching edit-mesh rip functionality.

Useful as disconnecting UV's, especially for loops is inconvenient
without this.

This uses 'V' to rip, changing stitch to 'Alt-V'.
2020-07-06 18:27:51 +10:00
9353477383 BMesh: add BM_face_calc_uv_cross 2020-07-06 18:23:38 +10:00
b51b893df8 BMesh: add BM_loop_other_vert_loop_by_edge 2020-07-06 18:23:38 +10:00
705015e0a4 Fix T78481: Workbench Shadow effects XRay
When in XRay some effects (shadow, cavity & depth of field) aren't supported.
This patch makes sure that these effects aren't enabled.
2020-07-06 10:21:14 +02:00
4f3045999d Cleanup: warnings, spelling 2020-07-06 17:35:41 +10:00
0f617cd67e GPU: Remove local shaders workaround for Intel/Windows
It has been tested that local shaders workaround isn't needed for the
latest Windows/Intel 6xx GPU's.

Currently the local shaders workaround doesn't work anymore during the
investigation it was detected that the intel drivers didn't need it
anymore.

Local shaders should still be fixed as it is also used for some legacy
iGPU's. The current work around crashes when doing preview renders in
EEVEE as the default materials aren't available but for the work around
they should. (See T77346 for more information)
2020-07-06 07:45:10 +02:00
baf124c753 RNA Manual Reference: Update links 2020-07-05 16:45:56 -04:00
247a28f242 Revert "BLI: refactor how buffers for small object optimization are stored"
This reverts commit 5d79f9f276.

This was introducing build errors in windows. Need a bit more time to check it.
2020-07-05 15:08:26 +02:00
5d79f9f276 BLI: refactor how buffers for small object optimization are stored 2020-07-05 16:30:26 +02:00
464aaf2701 Fix T78603: GPencil Noise modifier Vertex Group influence filter missing
This was removed by error during the last refactor of modiifers.
2020-07-04 17:31:15 +02:00
169bb4b9ce BLI: fix mistake in move constructor of Stack 2020-07-04 17:28:25 +02:00
8e97694c8a Fix T78588: Material preview not visible in selection list
Logic to determine if the library icon should be used was too general.
2020-07-04 17:06:57 +02:00
9168ea8aab Cleanup: Fix small typo error 2020-07-04 11:15:11 +02:00
17603816f2 GPencil: Cleanup some comments typo 2020-07-04 11:04:21 +02:00
b0da78084b UI: Attempt to fix OSX widget shader issue
Some OSX GL driver implementation needs a dummy vbo read. This fixed issues
with the Hair shaders in the past.

Related to T78307
2020-07-04 01:27:59 +02:00
cad98923d0 Cleanup: spelling 2020-07-04 01:03:34 +02:00
ea65c6a153 Fix T78433: Adding Fade Generates Python Exception
This was caused by typo in rB67a822e08684.
2020-07-04 00:59:09 +02:00
4bf56b37ca Cleanup: Use C-style comments in outliner files
No functional changes. Convert all C++ style comments to C comments.
Also capitalize and add full stops.

The comments themselves were not cleaned up. Some could be removed or
reworded.
2020-07-03 13:40:12 -06:00
59ef43147e Cleanup: Remove unused outliner activation code
No functional changes. Remove commented calls to extern_set_butspace
and unused text activation code.
2020-07-03 13:40:12 -06:00
57a48bd0ca Cleanup: Use _fn suffix for outliner button callbacks
No functional changes. Use _fn instead of _cb.
2020-07-03 13:40:12 -06:00
d7dbf90a02 Clang-tidy: Enable braces-around-statements warning 2020-07-03 21:23:33 +02:00
185fe9cd8b Cleanup: compiler warning 2020-07-03 19:12:37 +02:00
46fcc12e83 Fix error in new Hair data type file reading 2020-07-03 19:12:36 +02:00
d2db481dc7 Cleanup: Blendkernel, Clang-Tidy else-after-return fixes (incomplete)
This addresses warnings from Clang-Tidy's `readability-else-after-return`
rule in the `source/blender/blenkernel` module. Not all warnings are
addressed in this commit.

No functional changes.
2020-07-03 18:18:16 +02:00
a21cb22f8b Cleanup: Deduplicate code for finding context object
Instead of manually checking the pinned object, use the existing
ED_object_active_context function. This requires adding const
to the context in that function.
2020-07-03 11:58:43 -04:00
33a74941c5 Cleanup: Editors, Clang-Tidy else-after-return fixes
This addresses warnings from Clang-Tidy's `readability-else-after-return`
rule in the `source/blender/editors` module.

No functional changes.
2020-07-03 17:42:46 +02:00
367034f210 Cleanup: Editors/Space/UV-Edit, Clang-Tidy else-after-return fixes
This addresses warnings from Clang-Tidy's `readability-else-after-return`
rule in the `source/blender/editors/uv_edit` module.

No functional changes.
2020-07-03 17:42:45 +02:00
651d1aa7c8 Cleanup: Editors/Transform, Clang-Tidy else-after-return fixes
This addresses warnings from Clang-Tidy's `readability-else-after-return`
rule in the `source/blender/editors/transform` module.

No functional changes.
2020-07-03 17:42:45 +02:00
35ce16939c Cleanup: Editors/Space/sequencer, Clang-Tidy else-after-return fixes
This addresses warnings from Clang-Tidy's `readability-else-after-return`
rule in the `source/blender/editors/space_sequencer` module.

No functional changes.
2020-07-03 17:42:45 +02:00
a201020cd3 Cleanup: Editors/Space/Clip, Clang-Tidy else-after-return fixes
This addresses warnings from Clang-Tidy's `readability-else-after-return`
rule in the `source/blender/editors/space_clip` module.

No functional changes.
2020-07-03 17:42:45 +02:00
f254f66587 Cleanup: Editors/Space/Outliner, Clang-Tidy else-after-return fixes
This addresses warnings from Clang-Tidy's `readability-else-after-return`
rule in the `source/blender/editors/space_outliner` module.

No functional changes.
2020-07-03 17:42:45 +02:00
3aa53b361d Cleanup: Editors/Space/Node, Clang-Tidy else-after-return fixes
This addresses warnings from Clang-Tidy's `readability-else-after-return`
rule in the `source/blender/editors/space_node` module.

No functional changes.
2020-07-03 17:42:45 +02:00
bf532b1106 Cleanup: Editors/Space/Text, Clang-Tidy else-after-return fixes
This addresses warnings from Clang-Tidy's `readability-else-after-return`
rule in the `source/blender/editors/space_text` module.

No functional changes.
2020-07-03 17:42:45 +02:00
2f6fc5a7e8 Cleanup: Editors/Space/View3D, Clang-Tidy else-after-return fixes
This addresses warnings from Clang-Tidy's `readability-else-after-return`
rule in the `source/blender/editors/space_view3d` module.

No functional changes.
2020-07-03 17:42:45 +02:00
b61ecb785c Cleanup: Explicit return in each else if block in buttons_context()
This is a similar change as in rB4283da83cc9.

No functional changes.
2020-07-03 17:42:45 +02:00
f43fedd400 Cleanup: remove side effect in assertion 2020-07-03 17:35:40 +02:00
4a48939f04 UI: Fix bevel modifier not showing vertex group 2020-07-03 11:18:24 -04:00
cad2d32be6 Clang-Tidy: Enable bugprone-misplaced-widening-cast 2020-07-03 17:10:27 +02:00
4a5389816b Clang-Tidy: enable readability-named-parameter 2020-07-03 17:07:13 +02:00
fac2e63bc0 Fix utterly broken code regarding GPUtextures of MovieClip in readfile.c
Treat those as pure runtime code, reset to NULL by reading code, for
now.

Think those could be handled like Image gputextures (i.e. considered
runtime cache and preserved across undo steps), but probably not
critical for now.
2020-07-03 17:01:21 +02:00
1bdabd7b4f Move MovieClip to new undo cache management system. 2020-07-03 17:01:21 +02:00
1019c9f582 Clang-Tidy: enable bugprone-too-small-loop-variable 2020-07-03 16:54:08 +02:00
883f9dd6e5 Clang-Tidy: enable bugprone-assert-side-effect
Looks like we have no assertions with side effects.
2020-07-03 16:48:16 +02:00
9739fc4d1b Clang-Tidy: More fixed of redundant check before delete
For some reason got unnoticed in the original cleanup pass.
2020-07-03 16:47:59 +02:00
14fd91e7e8 Clang-Tidy: enable bugprone-argument-comment
It was called `inverted` in the header.
2020-07-03 16:39:06 +02:00
f4fdb8efc5 Cleanup: Remove redundant logic 2020-07-03 10:38:49 -04:00
f66aafa391 Fix memory leak when dragging shaderfx 2020-07-03 10:37:58 -04:00
f891d4e2ad Clang-Tidy: Fix readability-delete-null-pointer warnings
Also enable it in the configuration.
2020-07-03 16:32:51 +02:00
53d41e1a6f UI: Use sliders and [0, 1] ranges in ocean modifier
The ocean modifier has two properties that use a [0, 10] hard min and
hard max. The values act as factors though, so it makes more sense to
use sliders and a 0 to 1 range.

This commit also bumps the file subversion to avoid repeatedly applying
the change to the properties' range.

Differential Revision: https://developer.blender.org/D8186
2020-07-03 10:28:13 -04:00
2a39b34a09 Cleanup: Editors/Sculpt/Paint, Clang-Tidy else-after-return fixes
This addresses warnings from Clang-Tidy's `readability-else-after-return`
rule in the `source/blender/editors/sculpt_paint` module.

No functional changes.
2020-07-03 16:15:01 +02:00
fd5b093f84 Cleanup: Editors/Screen, Clang-Tidy else-after-return fixes
This addresses warnings from Clang-Tidy's `readability-else-after-return`
rule in the `source/blender/editors/screen` module.

No functional changes.
2020-07-03 16:15:01 +02:00
4283da83cc Cleanup: Explicit return in each else if block in ed_screen_context()
The `ed_screen_context()` function is approximately 700 lines long, and
its main structure is a huge chain of `else if` statements. Some of the
bodies did not return, but rather fell through and relied on the `return
-1;` at the bottom of the function. This means that in order to truly
understand what is going on in one of those `else if` blocks, it could
be required to scroll past all the following `else if` blocks,
double-checking that they all had an `else`, and then see what happens
below.

By adding explicit `return -1;` everywhere this happened, this is all
avoided, increasing local understandability of the code. Furthermore, it
makes the upcoming cleanup with the Clang-Tidy rule
`readability-else-after-return` a lot easier to do.

No functional changes.
2020-07-03 16:15:01 +02:00
de7c9f41e6 Cleanup: Editors/Object, Clang-Tidy else-after-return fixes
This addresses warnings from Clang-Tidy's `readability-else-after-return`
rule in the `source/blender/editors/object` module.

No functional changes.
2020-07-03 16:15:01 +02:00
19483125f8 Cleanup: Editors/Mesh, Clang-Tidy else-after-return fixes
This addresses warnings from Clang-Tidy's `readability-else-after-return`
rule in the `source/blender/editors/mesh` module.

No functional changes.
2020-07-03 16:15:00 +02:00
7d0a0b8a6d Cleanup: Editors/Armature, Clang-Tidy else-after-return fixes
This addresses warnings from Clang-Tidy's `readability-else-after-return`
rule in the `source/blender/editors/armature` module.

No functional changes.
2020-07-03 16:15:00 +02:00
f82e52ebc8 Cleanup: Editors/Animation, Clang-Tidy else-after-return fixes
This addresses warnings from Clang-Tidy's `readability-else-after-return`
rule in the `source/blender/editors/animation` module.

No functional changes.
2020-07-03 16:15:00 +02:00
17ba566018 Fix Pose Brush crashing after disabling connected only in FK mode
This function was returning the ik_chain before disabling the
fake_neighbors, so when the brush was used again with fake neighbors
disabled after rebuilding the PBVH and free them, they were still
enabled in the SculptSession, causing a the crash.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D8195
2020-07-03 16:13:49 +02:00
3a59c184b9 Move Scene's cache management during undo to new system. 2020-07-03 16:10:33 +02:00
a33756d783 Cleanup: Unused variables in non-debug build 2020-07-03 10:09:19 -04:00
6a58e15548 Cleanup: Remove obsolete code in interface_panel.c
Some code delt with panel merging in earlier versions of Blender,
which is no longer needed. Other code delt with controls that aren't
used anymore, and in some cases have region-level equivalents.

There's a surprising amount of this unused code in this file, so removing it
will be helpful for the future.

Differential Revision: https://developer.blender.org/D7938
2020-07-03 10:03:16 -04:00
88d358902f Clang-Tidy: Enable readability-redundant-string-cstr 2020-07-03 15:55:09 +02:00
405e6c6cc9 Fix T78555: GPencil bake animation operator loose frame setting
The values were reset for each run
2020-07-03 15:53:44 +02:00
19ff145e66 Clang-Tidy: Enable readability-redundant-control-flow 2020-07-03 09:41:55 -04:00
ffef562bf7 Disable clang-tidy for code-generated RNA files
This needs some extra care, which is probably easier once the initial
pass over integration is done.
2020-07-03 15:33:27 +02:00
c9975088a9 Move volume to new cache management system for undo. 2020-07-03 15:28:09 +02:00
1e255ce031 Fix T72214: Fluids: noise does not work with negative frame numbers
The issue is duplicated code. There are two functions that zero-fill
the frame number. They worked the same for positive frames numbers, but
behaved differently for negative ones.

On frame `-100`, `BLI_path_frame` outputs `-0100` and
`fluid_cache_get_framenr_formatted_$ID$` outputted `-100`.

I changed the behavior of the latter, because we depend on the behavior
of the former for much longer already.

Reviewers: sebbas

Differential Revision: https://developer.blender.org/D8107
2020-07-03 15:27:02 +02:00
2633683b52 Clang-tidy: enable readability-container-size-empty warning
Reviewers: sergey

Differential Revision: https://developer.blender.org/D8197
2020-07-03 14:59:27 +02:00
93da09d717 Cleanup: add const in various places 2020-07-03 14:53:06 +02:00
9dce2c9d14 Cleanup: Editors/GPencil, Clang-Tidy else-after-return fixes
This addresses warnings from Clang-Tidy's `readability-else-after-return`
rule in the `source/blender/editors/gpencil` module.

No functional changes.
2020-07-03 14:48:38 +02:00
20869065b8 Cleanup: BMesh, Clang-Tidy else-after-return fixes
This addresses warnings from Clang-Tidy's `readability-else-after-return`
rule in the `source/blender/bmesh` module.

No functional changes.
2020-07-03 14:48:37 +02:00
f3b8792b96 Cleanup: Interface, Clang-Tidy else-after-return fixes
This addresses warnings from Clang-Tidy's `readability-else-after-return`
rule in the `source/blender/editors/interface` module.

No functional changes.
2020-07-03 14:48:37 +02:00
86e7648f0e Cleanup: Mark overriding function with override keyword
No functional changes.
2020-07-03 14:48:37 +02:00
7704e6a678 Cleanup: bring operator overloads closer together 2020-07-03 14:31:26 +02:00
395b294b61 Cleanup: use nested namespaces 2020-07-03 14:25:20 +02:00
5fbf70b0d0 Cleanup: use trailing underscore for non-public data members 2020-07-03 14:20:42 +02:00
d64803f63b Cleanup: Use trailing underscore for non-public data members
This makes the code conform better with our style guide.
2020-07-03 14:16:02 +02:00
e797c4f28f Fix T78570: Vert/Edge slide doesn't adjust UVs 2020-07-03 09:01:32 -03:00
dfbb13b593 GPencil: Cleanup more comments (cont) 2020-07-03 13:52:04 +02:00
6fea8ec183 Clang-Tidy: Enable redundant static qualifier warning
This change enables readability-static-definition-in-anonymous-namespace
warning in .clang-tidy configuration.
2020-07-03 12:58:13 +02:00
aab41401f9 Move bSound cache handling during undo to new system. 2020-07-03 12:56:21 +02:00
ae5529c848 Cleanup: do not use magic values for enums... 2020-07-03 12:56:21 +02:00
8e0f8bb3e1 New undo cache management: Add Image IDs.
Some notes:
* `Image.cache` acts as some kind of 'main' cache, when it is NULL
  (could not be restored), other caches should also be cleared. Oddly
  enough, previous code was not clearing **all** caches, could not find
  any reason for that behavior, so new code does a full clear.
* `imamap` is still used for Node previews from scenes' compositor,
  however this is actually fully disabled in `direct_link_node()`.
* For render slots we cannot use offsetof as third part of the cache
  key, so we are using a hash of the slot's name instead.

As far as I can tell, this fixes T76989: Visual glitches when undo after
reload multiple images by script (in Material Preview).
2020-07-03 12:56:21 +02:00
5fa6bd8a8d Readfile/Undo: initial refactor of cache preservation code.
Main goal here is to have better specificity using cache keys, to avoid
same memroy address being re-used messing up with cache pointers
restoration after undo had to re-read a data-block.

Once all caches handling are ported  to this new system, it should fix
random issues like the one reported in T76989.

Part of D8183, refactoring how we preserve caches across undo steps in
readfile code.
2020-07-03 12:56:21 +02:00
6cb796e98e IDTypeInfo: add new callback to loop over all cache pointers of an ID.
Part of D8183, refactoring how we preserve caches across undo steps in
readfile code.
2020-07-03 12:56:21 +02:00
5dda6cefb6 Add key structure and hashing utils for ID caches.
Part of D8183, refactoring how we preserve caches across undo steps in
readfile code.
2020-07-03 12:56:21 +02:00
a06d95987e GPencil: Cleanup more comments (cont) 2020-07-03 12:55:47 +02:00
972d1700cd GPencil: Cleanup more comments (cont) 2020-07-03 12:55:47 +02:00
4ccd96f1a4 Cycles: rename viewport denoise Fastest option to Automatic and extend tooltip 2020-07-03 12:36:17 +02:00
83eeaddce8 Clang-tidy: Enable bugprone-lambda-function-name warning 2020-07-03 12:30:20 +02:00
bbeb1b2b52 Depsgraph: Use C++ style of guarded allocation of objects 2020-07-03 12:30:20 +02:00
468adfa4fd Guarded allocator: Override placement new operator
Allows to in-place construct objects which are using guarded allocator.
2020-07-03 12:30:20 +02:00
cdea648117 GPencil: Cleanup move functions to geom from modifier 2020-07-03 11:54:07 +02:00
2193c37768 GPencil: Cleanup Doxygen comments (cont) 2020-07-03 11:54:07 +02:00
b1d3850333 Cleanup: Fluid renaming from old 'manta' naming to new 'fluid' naming
Changed variable names from mmd, mds, mfs, and mes to fmd, fds, ffs, and fes. The author of this commits lights a candle for all the merge conflicts this will cause.
2020-07-03 11:52:08 +02:00
868d6ba1a7 GPencil: Cleanup Doxygen comments 2020-07-03 11:20:00 +02:00
746aec51a7 Cycles: Use TBB's spin mutex
First benefit is reduced boilerplate code.

Second benefit is fixed warnings about using deprecated spin lock
on macOS when using SDK 10.12 and above.

Differential Revision: https://developer.blender.org/D8182
2020-07-03 11:14:26 +02:00
0e1ee29f77 BLI: Use TBB spin_mutex as SpinLock implementation
When building without TBB use native to the platform spin lock
implementation. For Windows it is an atomic-based busy-wait,
for Linux it is pthreads' spin lock.

For macOS it is a mutex lock. The reason behind this is to stop
using atomics library which has been declared deprecated in SDK
version 10.12. So this changes fixes a lot of noisy warnings on
the newer SDK.

Differential Revision: https://developer.blender.org/D8180
2020-07-03 11:14:17 +02:00
0f4049db5f BLI: Switch threads implementation file to C++
Allows to use C++ primitives in the primitive implementation.
2020-07-03 11:14:06 +02:00
edb49d3dc2 Clang-Tidy: Allow use with GCC but warn about possible failure
The compilation using GCC + Clang-Tidy succeeded for me and Sybren
(with some linker caveats for Sybren) but seems that it is doable
to make GCC + Clang-Tidy to officially work for Blender.

Now it should be possible to enable Clang-Tidy doing something like

  make developer debug BUILD_CMAKE_ARGS='-DWITH_CLANG_TIDY=ON'
2020-07-03 10:58:24 +02:00
dfdd23bae6 Clang-Tidy: Silence warning affecting newer code
For now Clang-Tidy should be passable with the codebase as is. This warning
will be addressed as quality day task.
2020-07-03 10:23:44 +02:00
9ea5469178 Initial support of clang-tidy toolchain
Clang Tidy is a Clang based "linter" tool which goal is to help
fixing typical programming errors.

It is run as a separate compile step of every file, which slows
compilation down but allows to fully analyze the file the same
way as compiler does and catch non-trivial bugprone cases.

This change includes:

- CMake option called `WITH_CLANG_TIDY` which enables Clang Tidy
  linter tool on all source in the `source/` directory.

  This option is only available on Linux, as it is currently the
  easiest platform to get the Clang Tidy toolchain to work.

- CMake module which is aimed to find latest available Clang Tidy.

- Set of rules which allows to have Blender fully compiled without
  extra issues.

The goal of this change is to provide a base ground so that solving
all the warnings can happen later on, as a team effort.

It should be possible to use Clang Tidy side-by-side with both GCC
and Clang, but there seems to be some tweaks to be done in CMake to
make it really work for Blender. For now use Clang toolchain if
there are issues with GCC+Clang Tidy.

It will be worked on in the nearest future to bring seamless
experience for all configurations.

Currently there is no official way of getting Clang Tidy on macOS,
and on Windows there are some difficulties of hooking up Clang Tidy
from LLVM package to the MSVC compiler toolchain.

The actual warnings in the code will be addressed as a part of the
Code Quality Days, task T78535.

Differential Revision: https://developer.blender.org/D7937
2020-07-03 09:57:41 +02:00
a272a2a6cd Cleanup: spelling 2020-07-03 11:58:13 +10:00
0fdb79fe58 UI: Add Edge Loopcut Slide to edge menu
This was exposed in the context menu but not the main edge menu.
2020-07-02 20:33:49 -04:00
a68fd2561e Fix T78551 EEVEE: Fix memleak from renderpass ubo 2020-07-03 02:28:06 +02:00
0961ce04cb Fix T78124 Overlay: Image: Camera background image transparency not working
This changes to premultiplied blending for all cases and put the premult
in the shader.
2020-07-03 01:48:39 +02:00
5a13f682ee Fix T77559 Avoid wrong ob->imat leading to several bugs
This fixes T77559 Scale to zero in object mode unable to select
2020-07-03 00:21:56 +02:00
Philip Holzmann
a07922159d Fix T78527: GPencil Mirror modifier is inconsistent with Mesh Mirror (redo)
Simply the same code the regular mesh mirror modifier uses.

Differential Revision: https://developer.blender.org/D8188
2020-07-02 23:02:02 +02:00
Juan
1278657cc2 UI: rename Alpha to Opacity
There was a discrepancy between the Tooltip of the Camera's Background Image that controls the opacity of the image and the operator's name that reads Alpha. The tooltip says **"Image opacity to blend the image against the background color"**, so it was renamed to Opacity to follow the tooltip.
The decision for this change is that the naming Alpha is not the most appropriated, since it has nothing to do if a loaded image has an embedded Alpha channel or not.

{F8540101}

Reviewed By: #user_interface, pablovazquez

Differential Revision: https://developer.blender.org/D7760
2020-07-02 16:47:46 -04:00
Nicola De Mitri
3ea302cf8e UI: Replace "Grease Pencil" with "Annotation" in user-facing options in the Clip editor
This revision affects the menu under: Clip > Track > Detect Features > Placement.
A bit of UI that was probably missed when the legacy GP was renamed to Annotation

{F8647693}

In this state, it may be confusing for the user.

Reviewed By: Blendify

Differential Revision: https://developer.blender.org/D8139
2020-07-02 16:40:42 -04:00
Valentin
f3e4a3473e Cleanup: Remove useless duplicated lines
I spotted a duplicate struct declaration, so I had to check for other duplicated as well
There might be some other but i am not confident enough for deleting them

this regex search for duplicate ^(.*;)$\n(\1)$

Reviewed By: JacquesLucke

Differential Revision: https://developer.blender.org/D8146
2020-07-02 16:36:39 -04:00
ef0ec01461 UI: Dont abbriviate location & rotation
This resolves one of the last few areas where we still use inappropriate
abbreviations. Reading abbreviated words is usually slower, because
users must parse, guess and translate the words. Using abbreviations
such as 'rot' is also especially bad since it's a word in itself too.

The main advantage of abbreviations is that they are faster to *write*,
which just isn't a concern for text in the UI.

Differential Revision: https://developer.blender.org/D8174
2020-07-02 16:28:45 -04:00
33f36b453a GPencil: Cleanup - More rename from gp_ to gpencil_ 2020-07-02 20:04:56 +02:00
c5ec8d91bd Sculpt: Mask By Color
This tool generates masks based on the sculpt vertex colors by clicking
on the model, similar to automatic selection tools in image editing
software.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D8157
2020-07-02 18:20:47 +02:00
85980743b0 Cleanup: Fix build error with clang on windows.
Header and implementation signature for ED_object_add_duplicate
were not the same leading to a build error with clang on windows.
2020-07-02 10:16:54 -06:00
95f3397a68 Fix T78525: Status bar not reset after Edit Voxel Size
Reviewed By: sergey

Maniphest Tasks: T78525

Differential Revision: https://developer.blender.org/D8181
2020-07-02 18:08:38 +02:00
7099459245 UI: Use consistent order in ocean modifier 2020-07-02 11:55:37 -04:00
Phil Stopford
17b89f6dac Ocean modifier: Expose eigenvectors for use as map
The eigenvectors in the ocean modifier (plus and minus) can be useful,
but are not exposed. Assuming the particle system was capable, the
eigenvectors could be used to drive spray emission velocities.

This exposes the controls to allow a map to be generated from these
eigenvectors. Currently, the values are mapped into a 0-255 range
similar to foam.

Differential Revision: https://developer.blender.org/D7182
2020-07-02 11:49:15 -04:00
35481fde40 GPUOffScreen: Remove the sample parameter
This is because the DRW module is no longer compatible with drawing using
MSAA.

This also change the Python API.
2020-07-02 17:28:41 +02:00
a4fe8ef236 Fix T78527: GPencil Mirror modifier is inconsistent with Mesh Mirror
The grease pencil mirror was using the current axis rotation but the mesh modifier doesn't use it.
2020-07-02 16:57:20 +02:00
06de1bddae UI: Small Tweaks to Modifier Layouts for Consistency
These changes are smaller, made based on feedback and a pass on all
the layouts for clarity and consistency. The Multires modifier UI will
be addressed in a separate patch. Here is an overview of the changes:

Renaming Options:
  - Build: "Start" -> "Start Frame"
  - Curve: "From Radius" -> "Size from Radius"
  - Screw: "Calc Order" -> "Calculate Order"
  - Displace, Warp, Wave: "Texture Coordinates Object" -> "Object"

Move Mode Toggle to Top & Expand:
  - Bevel, Boolean, Normal Edit, Subdivision

Use Columns for Tighter Spacing:
  - Displace, Explode, Ocean, Particle Instance, Remesh, Shrinkwrap,
    Solidify, Warp, Weighted Normal, Wave

Misc:
  - Bevel: Set inactive properties for vertex bevel
  - Mesh Sequence Cache: Remove box for cache file
  - Skin: Don't align "Mark Loose" and "Clear Loose"
  - Array: Expand relative offset subpanel by default
  - Array: Move start cap, end cap to a new subpanel
  - Bevel: Move width type above width

Differential Revision: https://developer.blender.org/D8115
2020-07-02 10:47:02 -04:00
fb0f0f4d79 Fluid: Added offset to control frame range
Added an offset field to control when to load the simulation files. Since this is a very small but helpful addition it is in my view safe to commit at this point of the bcon cycle.
2020-07-02 16:31:35 +02:00
f58f09c9a9 Fix T78513: Modifier apply shortcut not displayed
We can't specify the "apply_as" enum value, even though it's the default.
2020-07-02 08:26:59 -04:00
Jeroen Bakker
46ae115b88 Fix T78054: Crash Editing Instanced Objects with Tangent Normals
Similar track as for normal mesh. Don't store the tangent normals in CustomData
of the mesh, but in an unassociated CustomData instance.

Reviewed By: Clément Foucault

Differential Revision: https://developer.blender.org/D8161
2020-07-02 11:34:25 +02:00
Jeroen Bakker
ba2c039b05 Fix T77686: EEVEE environment pass with film transparency
When the film is set to transparent the environment pass should still be
rendered solid. otherwise it renders black.

Reviewed By: Clément Foucault

Differential Revision: https://developer.blender.org/D8046
2020-07-02 11:27:23 +02:00
945d0269e3 Fix crash calculating vertex parent in edit-mode
Regression in deaff945d0.
2020-07-02 19:12:54 +10:00
22197d7f8a Fix T76886: GPencil - Flickering when use Background or Camera image
The problem was if some stroke was empty and the changed flag was set to the last stroke wrongly.
2020-07-02 09:29:30 +02:00
26ffed7466 Cleanup: spelling 2020-07-02 13:03:46 +10:00
afd976a3b4 Fix T76806 UV Editor: Display as Outline do not work on macOS
This is a simple workaround using polyline shader. This is temporary and
a better solution should be found when we refactor the 2D view using DRW.
2020-07-02 02:32:10 +02:00
8bee200e2f Fix T76229 Overlay: Sulpt overlay not working if object use in-front option
Simple fix similar to paint overlay.
2020-07-02 01:41:02 +02:00
52b125a790 Fix alignment test when snap to edge while in vert or edge slide 2020-07-01 17:17:05 -03:00
b6f35531b6 Revert "Fix alignment test when snap to edge while in constraint"
This reverts commit e16972389e.
2020-07-01 17:13:13 -03:00
e16972389e Fix alignment test when snap to edge while in constraint 2020-07-01 16:42:06 -03:00
792cb8bdc7 Fix T77984: Cycles OpenCL error rendering empty scene 2020-07-01 20:01:25 +02:00
755c5c6e4c EEVEE: Shadows: Remove 1 pixel padding to the cubemap
This avoid having a much higher memory footprint as the underlying texture
size allocated by the driver is likely to be much higher (rounded to next
Power of 2 or other alignement requirements).
2020-07-01 19:52:05 +02:00
4723644e7f Fix T67587 Overlay: WeightPaint color blends with background in wireframe mode
Fix this by rendering to the overlay framebuffer when using alpha blend
mode.
2020-07-01 19:15:52 +02:00
6358c7754c Cleanup: Add functions to check the first brush step and symmetry passes
This adds three functions to check the state of the stroke in the
StrokeCache, removing the references to first_time and
mirror_symmetry_pass from the code. This makes easier to understand what
each code path is doing inside of each tool.

Some tools were using mirror_symmetry_pass incorrectly, so this should
also fix unreported bugs with radial and tiling symmetry related to that.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D8164
2020-07-01 19:03:22 +02:00
bf5a656ff6 GPencil: Fix unreported primitive color always set as Vertex Color
When drawing a primitive, the color was always assigned as vertex color, so it was impossible to change it in the material settings.

Now, the color is set to material color or vertex color as expected.
2020-07-01 18:55:02 +02:00
11a1ddfd30 Fix T77780 Overlay: Weight colors are not in render in the right colorspace
This was just a missing conversion.
2020-07-01 18:53:48 +02:00
f228a8948b Cleanup: Two two spaces around python class 2020-07-01 12:36:00 -04:00
927448a1da Cleanup: typos in comment. 2020-07-01 18:10:05 +02:00
e9d1d1f725 Fix T77655 Overlay: Edit mode + wire drawtype + infront not transparent 2020-07-01 18:00:05 +02:00
2788b0261c Cloth: use the original vertex positions to build internal springs.
In order to ensure correct operation of the rest shape key feature,
it's necessary to create a temporary copy of the mesh with rest
vertex positions to run the BVH lookup on. If the rest shape key
isn't used, there is no need for additional overhead.
2020-07-01 18:16:44 +03:00
f4f00661a5 Fix T78330: Duplicating parented objects does not preserve relationships.
Caused by refactor of duplicate code in rBad6cccf058d0, we need to take
into account the duplication of groups of objects here too...
2020-07-01 17:12:12 +02:00
982 changed files with 26503 additions and 16537 deletions

43
.clang-tidy Normal file
View File

@@ -0,0 +1,43 @@
Checks: >
-*,
readability-*,
-readability-uppercase-literal-suffix,
-readability-magic-numbers,
-readability-isolate-declaration,
-readability-convert-member-functions-to-static,
-readability-implicit-bool-conversion,
-readability-avoid-const-params-in-decls,
-readability-simplify-boolean-expr,
-readability-make-member-function-const,
-readability-misleading-indentation,
-readability-else-after-return,
-readability-inconsistent-declaration-parameter-name,
-readability-redundant-preprocessor,
-readability-function-size,
-readability-function-size,
-readability-redundant-string-init,
-readability-redundant-member-init,
-readability-const-return-type,
-readability-static-accessed-through-instance,
-readability-redundant-declaration,
-readability-qualified-auto,
bugprone-*,
-bugprone-narrowing-conversions,
-bugprone-unhandled-self-assignment,
-bugprone-branch-clone,
-bugprone-macro-parentheses,
-bugprone-sizeof-expression,
-bugprone-integer-division,
-bugprone-incorrect-roundings,
-bugprone-suspicious-string-compare,
-bugprone-not-null-terminated-result,
-bugprone-suspicious-missing-comma,
-bugprone-parent-virtual-call,
-bugprone-infinite-loop,
-bugprone-copy-constructor-init,
WarningsAsErrors: '*'

View File

@@ -415,6 +415,11 @@ mark_as_advanced(WITH_CXX_GUARDEDALLOC)
option(WITH_ASSERT_ABORT "Call abort() when raising an assertion through BLI_assert()" ON)
mark_as_advanced(WITH_ASSERT_ABORT)
if(UNIX AND NOT APPLE)
option(WITH_CLANG_TIDY "Use Clang Tidy to analyze the source code (only enable for development on Linux using Clang)" OFF)
mark_as_advanced(WITH_CLANG_TIDY)
endif()
option(WITH_BOOST "Enable features depending on boost" ON)
option(WITH_TBB "Enable features depending on TBB (OpenVDB, OpenImageDenoise, sculpt multithreading)" ON)

View File

@@ -30,7 +30,7 @@
# build_deps 2015 x64 / build_deps 2015 x86
#
# MAC OS X USAGE:
# Install with homebrew: brew install cmake autoconf automake libtool yasm nasm
# Install with homebrew: brew install cmake autoconf automake libtool yasm nasm bison
# Run "make deps" from main Blender directory
#
# LINUX USAGE:
@@ -76,6 +76,7 @@ include(cmake/llvm.cmake)
include(cmake/clang.cmake)
if(APPLE)
include(cmake/openmp.cmake)
include(cmake/nasm.cmake)
endif()
include(cmake/openimageio.cmake)
include(cmake/tiff.cmake)

View File

@@ -44,7 +44,7 @@ if(WIN32)
elseif(APPLE)
set(BOOST_CONFIGURE_COMMAND ./bootstrap.sh)
set(BOOST_BUILD_COMMAND ./b2)
set(BOOST_BUILD_OPTIONS toolset=darwin cxxflags=${PLATFORM_CXXFLAGS} linkflags=${PLATFORM_LDFLAGS} visibility=global --disable-icu boost.locale.icu=off)
set(BOOST_BUILD_OPTIONS toolset=clang-darwin cxxflags=${PLATFORM_CXXFLAGS} linkflags=${PLATFORM_LDFLAGS} visibility=global --disable-icu boost.locale.icu=off)
set(BOOST_HARVEST_CMD echo .)
set(BOOST_PATCH_COMMAND echo .)
else()

View File

@@ -30,6 +30,7 @@ if(UNIX)
nasm
yasm
tclsh
bison
)
foreach(_software ${_required_software})
@@ -40,6 +41,12 @@ if(UNIX)
unset(_software_find CACHE)
endforeach()
if(APPLE)
if(NOT EXISTS "/usr/local/opt/bison/bin/bison")
set(_software_missing "${_software_missing} bison")
endif()
endif()
if(_software_missing)
message(
"\n"
@@ -50,7 +57,7 @@ if(UNIX)
" apt install autoconf automake libtool yasm nasm tcl\n"
"\n"
"On macOS (with homebrew):\n"
" brew install cmake autoconf automake libtool yasm nasm\n"
" brew install cmake autoconf automake libtool yasm nasm bison\n"
"\n"
"Other platforms:\n"
" Install equivalent packages.\n")

View File

@@ -50,7 +50,8 @@ if(APPLE)
set(FFMPEG_EXTRA_FLAGS
${FFMPEG_EXTRA_FLAGS}
--target-os=darwin
)
--x86asmexe=${LIBDIR}/nasm/bin/nasm
)
endif()
ExternalProject_Add(external_ffmpeg
@@ -143,6 +144,12 @@ if(WIN32)
external_zlib_mingw
)
endif()
if(APPLE)
add_dependencies(
external_ffmpeg
external_nasm
)
endif()
if(BUILD_MODE STREQUAL Release AND WIN32)
ExternalProject_Add_Step(external_ffmpeg after_install

View File

@@ -24,7 +24,8 @@ set(FREETYPE_EXTRA_ARGS
-DFT_WITH_HARFBUZZ=OFF
-DFT_WITH_BZIP2=OFF
-DCMAKE_DISABLE_FIND_PACKAGE_HarfBuzz=TRUE
-DCMAKE_DISABLE_FIND_PACKAGE_BZip2=TRUE)
-DCMAKE_DISABLE_FIND_PACKAGE_BZip2=TRUE
-DCMAKE_DISABLE_FIND_PACKAGE_BrotliDec=TRUE)
ExternalProject_Add(external_freetype
URL ${FREETYPE_URI}

View File

@@ -22,6 +22,17 @@ if(WIN32)
-DBISON_EXECUTABLE=${LIBDIR}/flexbison/win_bison.exe
-DM4_EXECUTABLE=${DOWNLOAD_DIR}/mingw/mingw64/msys/1.0/bin/m4.exe
)
elseif(APPLE)
# Use bison installed via Homebrew.
# The one which comes which Xcode toolset is too old.
set(ISPC_EXTRA_ARGS_APPLE
-DBISON_EXECUTABLE=/usr/local/opt/bison/bin/bison
)
elseif(UNIX)
set(ISPC_EXTRA_ARGS_UNIX
-DCMAKE_C_COMPILER=${LIBDIR}/clang/bin/clang
-DCMAKE_CXX_COMPILER=${LIBDIR}/clang/bin/clang++
)
endif()
set(ISPC_EXTRA_ARGS
@@ -36,6 +47,8 @@ set(ISPC_EXTRA_ARGS
-DCLANG_LIBRARY_DIR=${LIBDIR}/clang/lib
-DCLANG_INCLUDE_DIRS=${LIBDIR}/clang/include
${ISPC_EXTRA_ARGS_WIN}
${ISPC_EXTRA_ARGS_APPLE}
${ISPC_EXTRA_ARGS_UNIX}
)
ExternalProject_Add(external_ispc

View File

@@ -0,0 +1,29 @@
# ***** BEGIN GPL LICENSE BLOCK *****
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ***** END GPL LICENSE BLOCK *****
ExternalProject_Add(external_nasm
URL ${NASM_URI}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
URL_HASH SHA256=${NASM_HASH}
PREFIX ${BUILD_DIR}/nasm
PATCH_COMMAND ${PATCH_CMD} --verbose -p 1 -N -d ${BUILD_DIR}/nasm/src/external_nasm < ${PATCH_DIR}/nasm.diff
CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/nasm/src/external_nasm/ && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/nasm
BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/nasm/src/external_nasm/ && make -j${MAKE_THREADS}
INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/nasm/src/external_nasm/ && make install
INSTALL_DIR ${LIBDIR}/nasm
)

View File

@@ -21,6 +21,7 @@ ExternalProject_Add(external_ogg
DOWNLOAD_DIR ${DOWNLOAD_DIR}
URL_HASH SHA256=${OGG_HASH}
PREFIX ${BUILD_DIR}/ogg
PATCH_COMMAND ${PATCH_CMD} --verbose -p 1 -N -d ${BUILD_DIR}/ogg/src/external_ogg < ${PATCH_DIR}/ogg.diff
CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/ogg/src/external_ogg/ && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/ogg --disable-shared --enable-static
BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/ogg/src/external_ogg/ && make -j${MAKE_THREADS}
INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/ogg/src/external_ogg/ && make install

View File

@@ -113,14 +113,18 @@ else()
COMMAND xcode-select --print-path
OUTPUT_VARIABLE XCODE_DEV_PATH OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND xcodebuild -version -sdk macosx SDKVersion
OUTPUT_VARIABLE MACOSX_SDK_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
set(OSX_ARCHITECTURES x86_64)
set(OSX_DEPLOYMENT_TARGET 10.11)
set(OSX_DEPLOYMENT_TARGET 10.13)
set(OSX_SYSROOT ${XCODE_DEV_PATH}/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk)
set(PLATFORM_CFLAGS "-isysroot ${OSX_SYSROOT} -mmacosx-version-min=${OSX_DEPLOYMENT_TARGET}")
set(PLATFORM_CXXFLAGS "-isysroot ${OSX_SYSROOT} -mmacosx-version-min=${OSX_DEPLOYMENT_TARGET} -std=c++11 -stdlib=libc++")
set(PLATFORM_LDFLAGS "-isysroot ${OSX_SYSROOT} -mmacosx-version-min=${OSX_DEPLOYMENT_TARGET}")
set(PLATFORM_BUILD_TARGET --build=x86_64-apple-darwin15.0.0) # OS X 10.11
set(PLATFORM_BUILD_TARGET --build=x86_64-apple-darwin17.0.0) # OS X 10.13
set(PLATFORM_CMAKE_FLAGS
-DCMAKE_OSX_ARCHITECTURES:STRING=${OSX_ARCHITECTURES}
-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=${OSX_DEPLOYMENT_TARGET}
@@ -155,6 +159,7 @@ else()
set(CONFIGURE_ENV
export MACOSX_DEPLOYMENT_TARGET=${OSX_DEPLOYMENT_TARGET} &&
export MACOSX_SDK_VERSION=${OSX_DEPLOYMENT_TARGET} &&
export CFLAGS=${PLATFORM_CFLAGS} &&
export CXXFLAGS=${PLATFORM_CXXFLAGS} &&
export LDFLAGS=${PLATFORM_LDFLAGS}

View File

@@ -48,7 +48,12 @@ if(WIN32)
else()
if(APPLE)
# disable functions that can be in 10.13 sdk but aren't available on 10.9 target
# Disable functions that can be in 10.13 sdk but aren't available on 10.9 target.
#
# Disable libintl (gettext library) as it might come from Homebrew, which makes
# it so test program compiles, but the Python does not. This is because for Python
# we use isysroot, which seems to forbid using libintl.h.
# The gettext functionality seems to come from CoreFoundation, so should be all fine.
set(PYTHON_FUNC_CONFIGS
export ac_cv_func_futimens=no &&
export ac_cv_func_utimensat=no &&
@@ -60,7 +65,10 @@ else()
export ac_cv_func_getentropy=no &&
export ac_cv_func_mkostemp=no &&
export ac_cv_func_mkostemps=no &&
export ac_cv_func_timingsafe_bcmp=no)
export ac_cv_func_timingsafe_bcmp=no &&
export ac_cv_header_libintl_h=no &&
export ac_cv_lib_intl_textdomain=no
)
set(PYTHON_CONFIGURE_ENV ${CONFIGURE_ENV} && ${PYTHON_FUNC_CONFIGS})
set(PYTHON_BINARY ${BUILD_DIR}/python/src/external_python/python.exe)
else()

View File

@@ -16,6 +16,12 @@
#
# ***** END GPL LICENSE BLOCK *****
if(WITH_WEBP)
set(WITH_TIFF_WEBP ON)
else()
set(WITH_TIFF_WEBP OFF)
endif()
set(TIFF_EXTRA_ARGS
-DZLIB_LIBRARY=${LIBDIR}/zlib/lib/${ZLIB_LIBRARY}
-DZLIB_INCLUDE_DIR=${LIBDIR}/zlib/include
@@ -23,6 +29,8 @@ set(TIFF_EXTRA_ARGS
-DBUILD_SHARED_LIBS=OFF
-Dlzma=OFF
-Djbig=OFF
-Dzstd=OFF
-Dwebp=${WITH_TIFF_WEBP}
)
ExternalProject_Add(external_tiff

View File

@@ -305,6 +305,10 @@ set(MESA_VERSION 18.3.1)
set(MESA_URI ftp://ftp.freedesktop.org/pub/mesa//mesa-${MESA_VERSION}.tar.xz)
set(MESA_HASH d60828056d77bfdbae0970f9b15fb1be)
set(NASM_VERSION 2.15.02)
set(NASM_URI https://www.nasm.us/pub/nasm/releasebuilds/${NASM_VERSION}/nasm-${NASM_VERSION}.tar.xz)
set(NASM_HASH f4fd1329b1713e1ccd34b2fc121c4bcd278c9f91cc4cb205ae8fcd2e4728dd14)
set(XR_OPENXR_SDK_VERSION 1.0.8)
set(XR_OPENXR_SDK_URI https://github.com/KhronosGroup/OpenXR-SDK/archive/release-${XR_OPENXR_SDK_VERSION}.tar.gz)
set(XR_OPENXR_SDK_HASH c6de63d2e0f9029aa58dfa97cad8ce07)

View File

@@ -21,12 +21,21 @@ if(WIN32)
endif()
if(APPLE)
set(X264_CONFIGURE_ENV
export AS=${LIBDIR}/nasm/bin/nasm
)
else()
set(X264_CONFIGURE_ENV echo .)
endif()
ExternalProject_Add(external_x264
URL ${X264_URI}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
URL_HASH SHA256=${X264_HASH}
PREFIX ${BUILD_DIR}/x264
CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/x264/src/external_x264/ && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/x264
CONFIGURE_COMMAND ${CONFIGURE_ENV} && ${X264_CONFIGURE_ENV} && cd ${BUILD_DIR}/x264/src/external_x264/ &&
${CONFIGURE_COMMAND} --prefix=${LIBDIR}/x264
--enable-static
--enable-pic
--disable-lavf
@@ -39,3 +48,10 @@ ExternalProject_Add(external_x264
if(MSVC)
set_target_properties(external_x264 PROPERTIES FOLDER Mingw)
endif()
if(APPLE)
add_dependencies(
external_x264
external_nasm
)
endif()

View File

@@ -9,3 +9,62 @@
enabled libopenmpt && require_pkg_config libopenmpt "libopenmpt >= 0.2.6557" libopenmpt/libopenmpt.h openmpt_module_create -lstdc++ && append libopenmpt_extralibs "-lstdc++"
enabled libopus && {
enabled libopus_decoder && {
--- a/libavcodec/cfhddata.c
+++ b/libavcodec/cfhddata.c
@@ -276,10 +276,10 @@
av_cold int ff_cfhd_init_vlcs(CFHDContext *s)
{
int i, j, ret = 0;
- uint32_t new_cfhd_vlc_bits[NB_VLC_TABLE_18 * 2];
- uint8_t new_cfhd_vlc_len[NB_VLC_TABLE_18 * 2];
- uint16_t new_cfhd_vlc_run[NB_VLC_TABLE_18 * 2];
- int16_t new_cfhd_vlc_level[NB_VLC_TABLE_18 * 2];
+ uint32_t *new_cfhd_vlc_bits = av_calloc(sizeof(uint32_t), NB_VLC_TABLE_18 * 2);
+ uint8_t *new_cfhd_vlc_len = av_calloc(sizeof(uint8_t), NB_VLC_TABLE_18 * 2);
+ uint16_t *new_cfhd_vlc_run = av_calloc(sizeof(uint16_t), NB_VLC_TABLE_18 * 2);
+ int16_t *new_cfhd_vlc_level = av_calloc(sizeof(int16_t), NB_VLC_TABLE_18 * 2);
/** Similar to dv.c, generate signed VLC tables **/
@@ -305,8 +305,13 @@
ret = init_vlc(&s->vlc_9, VLC_BITS, j, new_cfhd_vlc_len,
1, 1, new_cfhd_vlc_bits, 4, 4, 0);
- if (ret < 0)
+ if (ret < 0) {
+ av_free(new_cfhd_vlc_bits);
+ av_free(new_cfhd_vlc_len);
+ av_free(new_cfhd_vlc_run);
+ av_free(new_cfhd_vlc_level);
return ret;
+ }
for (i = 0; i < s->vlc_9.table_size; i++) {
int code = s->vlc_9.table[i][0];
int len = s->vlc_9.table[i][1];
@@ -346,8 +351,14 @@
ret = init_vlc(&s->vlc_18, VLC_BITS, j, new_cfhd_vlc_len,
1, 1, new_cfhd_vlc_bits, 4, 4, 0);
- if (ret < 0)
+ if (ret < 0) {
+ av_free(new_cfhd_vlc_bits);
+ av_free(new_cfhd_vlc_len);
+ av_free(new_cfhd_vlc_run);
+ av_free(new_cfhd_vlc_level);
return ret;
+ }
+
av_assert0(s->vlc_18.table_size == 4572);
for (i = 0; i < s->vlc_18.table_size; i++) {
@@ -367,5 +378,10 @@
s->table_18_rl_vlc[i].run = run;
}
+ av_free(new_cfhd_vlc_bits);
+ av_free(new_cfhd_vlc_len);
+ av_free(new_cfhd_vlc_run);
+ av_free(new_cfhd_vlc_level);
+
return ret;
}

View File

@@ -34,3 +34,52 @@ diff -Naur orig/cmake/GenerateBuiltins.cmake.txt external_ispc/cmake/GenerateBui
elseif ("${bit}" STREQUAL "64" AND ${arch} STREQUAL "x86")
set(target_arch "x86_64")
elseif ("${bit}" STREQUAL "32" AND ${arch} STREQUAL "arm")
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 46a8db8..f53beef 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -36,8 +36,12 @@
cmake_minimum_required(VERSION 3.13)
if (UNIX)
- set(CMAKE_C_COMPILER "clang")
- set(CMAKE_CXX_COMPILER "clang++")
+ if (NOT CMAKE_C_COMPILER)
+ set(CMAKE_C_COMPILER "clang")
+ endif()
+ if (NOT CMAKE_CXX_COMPILER)
+ set(CMAKE_CXX_COMPILER "clang++")
+ endif()
endif()
set(PROJECT_NAME ispc)
@@ -412,6 +416,29 @@ else()
endif()
endif()
+# Link against libstdc++.a which must be provided to the linker after
+# LLVM and CLang libraries.
+# This is needed because some of LLVM/CLang dependencies are using
+# std::make_shared, which is defined in one of those:
+# - libclang-cpp.so
+# - libstdc++.a
+# Using the former one is tricky because then generated binary depends
+# on a library which is outside of the LD_LIBRARY_PATH.
+#
+# Hence, using C++ implementation from G++ which seems to work just fine.
+# In fact, from investigation seems that libclang-cpp.so itself is pulling
+# std::_Sp_make_shared_tag from G++'s libstdc++.a.
+if(UNIX AND NOT APPLE)
+ execute_process(
+ COMMAND g++ --print-file-name libstdc++.a
+ OUTPUT_VARIABLE GCC_LIBSTDCXX_A
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+ if(GCC_LIBSTDCXX_A AND EXISTS ${GCC_LIBSTDCXX_A})
+ target_link_libraries(${PROJECT_NAME} ${GCC_LIBSTDCXX_A})
+ endif()
+endif()
+
# Build target for utility checking host ISA
if (ISPC_INCLUDE_UTILS)
add_executable(check_isa "")

View File

@@ -0,0 +1,129 @@
diff --git a/output/macho.h b/output/macho.h
index 538c531e..fd5e8849 100644
--- a/output/macho.h
+++ b/output/macho.h
@@ -60,6 +60,8 @@
#define LC_SEGMENT 0x1
#define LC_SEGMENT_64 0x19
#define LC_SYMTAB 0x2
+#define LC_VERSION_MIN_MACOSX 0x24
+#define LC_BUILD_VERSION 0x32
/* Symbol type bits */
#define N_STAB 0xe0
diff --git a/output/outmacho.c b/output/outmacho.c
index 08147883..de6ec902 100644
--- a/output/outmacho.c
+++ b/output/outmacho.c
@@ -38,6 +38,8 @@
#include "compiler.h"
+#include <stdlib.h>
+
#include "nctype.h"
#include "nasm.h"
@@ -64,6 +66,8 @@
#define MACHO_SYMCMD_SIZE 24
#define MACHO_NLIST_SIZE 12
#define MACHO_RELINFO_SIZE 8
+#define MACHO_BUILD_VERSION_SIZE 24
+#define MACHO_VERSION_MIN_MACOSX_SIZE 16
#define MACHO_HEADER64_SIZE 32
#define MACHO_SEGCMD64_SIZE 72
@@ -1224,6 +1228,46 @@ static void macho_layout_symbols (uint32_t *numsyms,
}
}
+static bool get_full_version_from_env (const char *variable_name,
+ int *r_major,
+ int *r_minor,
+ int *r_patch) {
+ *r_major = 0;
+ *r_minor = 0;
+ *r_patch = 0;
+
+ const char *value = getenv(variable_name);
+ if (value == NULL || value[0] == '\0') {
+ return false;
+ }
+
+ const char *current_value = value;
+ const char *end_value = value + strlen(value);
+
+ char *endptr;
+
+ *r_major = strtol(current_value, &endptr, 10);
+ if (endptr >= end_value) {
+ return true;
+ }
+ current_value = endptr + 1;
+
+ *r_minor = strtol(current_value, &endptr, 10);
+ if (endptr >= end_value) {
+ return true;
+ }
+ current_value = endptr + 1;
+
+ *r_patch = strtol(current_value, &endptr, 10);
+
+ return true;
+}
+
+static bool need_version_min_macosx_command (void) {
+ return getenv("MACOSX_DEPLOYMENT_TARGET") &&
+ getenv("MACOSX_SDK_VERSION");
+}
+
/* Calculate some values we'll need for writing later. */
static void macho_calculate_sizes (void)
@@ -1270,6 +1314,12 @@ static void macho_calculate_sizes (void)
head_sizeofcmds += fmt.segcmd_size + seg_nsects * fmt.sectcmd_size;
}
+ /* LC_VERSION_MIN_MACOSX */
+ if (need_version_min_macosx_command()) {
+ ++head_ncmds;
+ head_sizeofcmds += MACHO_VERSION_MIN_MACOSX_SIZE;
+ }
+
if (nsyms > 0) {
++head_ncmds;
head_sizeofcmds += MACHO_SYMCMD_SIZE;
@@ -1653,6 +1703,33 @@ static void macho_write (void)
else
nasm_warn(WARN_OTHER, "no sections?");
+#define ENCODE_BUILD_VERSION(major, minor, patch) \
+ (((major) << 16) | ((minor) << 8) | (patch))
+
+ if (0) {
+ fwriteint32_t(LC_BUILD_VERSION, ofile); /* cmd == LC_BUILD_VERSION */
+ fwriteint32_t(MACHO_BUILD_VERSION_SIZE, ofile); /* size of load command */
+ fwriteint32_t(1, ofile); /* platform */
+ fwriteint32_t(ENCODE_BUILD_VERSION(10, 13, 0), ofile); /* minos, X.Y.Z is encoded in nibbles xxxx.yy.zz */
+ fwriteint32_t(ENCODE_BUILD_VERSION(10, 15, 4), ofile); /* sdk, X.Y.Z is encoded in nibbles xxxx.yy.zz */
+ fwriteint32_t(0, ofile); /* number of tool entries following this */
+ }
+
+ if (need_version_min_macosx_command()) {
+ int sdk_major, sdk_minor, sdk_patch;
+ get_full_version_from_env("MACOSX_SDK_VERSION", &sdk_major, &sdk_minor, &sdk_patch);
+
+ int version_major, version_minor, version_patch;
+ get_full_version_from_env("MACOSX_DEPLOYMENT_TARGET", &version_major, &version_minor, &version_patch);
+
+ fwriteint32_t(LC_VERSION_MIN_MACOSX, ofile); /* cmd == LC_VERSION_MIN_MACOSX */
+ fwriteint32_t(MACHO_VERSION_MIN_MACOSX_SIZE, ofile); /* size of load command */
+ fwriteint32_t(ENCODE_BUILD_VERSION(version_major, version_minor, version_patch), ofile); /* minos, X.Y.Z is encoded in nibbles xxxx.yy.zz */
+ fwriteint32_t(ENCODE_BUILD_VERSION(sdk_major, sdk_minor, sdk_patch), ofile); /* sdk, X.Y.Z is encoded in nibbles xxxx.yy.zz */
+ }
+
+#undef ENCODE_BUILD_VERSION
+
if (nsyms > 0) {
/* write out symbol command */
fwriteint32_t(LC_SYMTAB, ofile); /* cmd == LC_SYMTAB */

View File

@@ -0,0 +1,12 @@
diff --git a/include/ogg/os_types.h b/include/ogg/os_types.h
index eb8a322..6f73b72 100644
--- a/include/ogg/os_types.h
+++ b/include/ogg/os_types.h
@@ -71,6 +71,7 @@
#elif (defined(__APPLE__) && defined(__MACH__)) /* MacOS X Framework build */
# include <sys/types.h>
+# include <stdint.h>
typedef int16_t ogg_int16_t;
typedef uint16_t ogg_uint16_t;
typedef int32_t ogg_int32_t;

View File

@@ -0,0 +1,104 @@
# - Find clang-tidy executable
#
# Find the native clang-tidy executable
#
# This module defines
# CLANG_TIDY_EXECUTABLE, the ful lpath to clang-tidy executable
#
# CLANG_TIDY_VERSION, the full version of the clang-tidy in the
# major,minor.patch format
#
# CLANG_TIDY_VERSION_MAJOR,
# CLANG_TIDY_VERSION_MINOR,
# CLANG_TIDY_VERSION_PATCH, individual components of the clang-tidy version.
#
# CLANG_TIDY_FOUND, If false, do not try to use Eigen3.
#=============================================================================
# Copyright 2020 Blender Foundation.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# If CLANG_TIDY_ROOT_DIR was defined in the environment, use it.
if(NOT CLANG_TIDY_ROOT_DIR AND NOT $ENV{CLANG_TIDY_ROOT_DIR} STREQUAL "")
set(CLANG_TIDY_ROOT_DIR $ENV{CLANG_TIDY_ROOT_DIR})
endif()
set(_clang_tidy_SEARCH_DIRS
${CLANG_TIDY_ROOT_DIR}
/usr/local/bin
)
# TODO(sergey): Find more reliable way of finding the latest clang-tidy.
find_program(CLANG_TIDY_EXECUTABLE
NAMES
clang-tidy-10
clang-tidy-9
clang-tidy-8
clang-tidy-7
clang-tidy
HINTS
${_clang_tidy_SEARCH_DIRS}
)
if(CLANG_TIDY_EXECUTABLE)
# Mark clang-tidy as found.
set(CLANG_TIDY_FOUND TRUE)
# Setup fallback values.
set(CLANG_TIDY_VERSION_MAJOR 0)
set(CLANG_TIDY_VERSION_MINOR 0)
set(CLANG_TIDY_VERSION_PATCH 0)
# Get version from the output.
#
# NOTE: Don't use name of the executable file since that only includes a
# major version. Also, even the major version might be missing in the
# executable name.
execute_process(COMMAND ${CLANG_TIDY_EXECUTABLE} -version
OUTPUT_VARIABLE CLANG_TIDY_VERSION_RAW
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
# Parse parts.
if(CLANG_TIDY_VERSION_RAW MATCHES "LLVM version .*")
# Strip the LLVM prefix and get list of individual version components.
string(REGEX REPLACE
".*LLVM version ([.0-9]+).*" "\\1"
CLANG_SEMANTIC_VERSION "${CLANG_TIDY_VERSION_RAW}")
string(REPLACE "." ";" CLANG_VERSION_PARTS "${CLANG_SEMANTIC_VERSION}")
list(LENGTH CLANG_VERSION_PARTS NUM_CLANG_TIDY_VERSION_PARTS)
# Extract components into corresponding variables.
if(NUM_CLANG_TIDY_VERSION_PARTS GREATER 0)
list(GET CLANG_VERSION_PARTS 0 CLANG_TIDY_VERSION_MAJOR)
endif()
if(NUM_CLANG_TIDY_VERSION_PARTS GREATER 1)
list(GET CLANG_VERSION_PARTS 1 CLANG_TIDY_VERSION_MINOR)
endif()
if(NUM_CLANG_TIDY_VERSION_PARTS GREATER 2)
list(GET CLANG_VERSION_PARTS 2 CLANG_TIDY_VERSION_PATCH)
endif()
# Unset temp variables.
unset(NUM_CLANG_TIDY_VERSION_PARTS)
unset(CLANG_SEMANTIC_VERSION)
unset(CLANG_VERSION_PARTS)
endif()
# Construct full semantic version.
set(CLANG_TIDY_VERSION "${CLANG_TIDY_VERSION_MAJOR}.\
${CLANG_TIDY_VERSION_MINOR}.\
${CLANG_TIDY_VERSION_PATCH}")
unset(CLANG_TIDY_VERSION_RAW)
message(STATUS "Found clang-tidy ${CLANG_TIDY_EXECUTABLE} (${CLANG_TIDY_VERSION})")
else()
set(CLANG_TIDY_FOUND FALSE)
endif()

View File

@@ -82,7 +82,7 @@ FIND_LIBRARY(EMBREE_LIBRARY
# handle the QUIETLY and REQUIRED arguments and set EMBREE_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(EMBREE DEFAULT_MSG
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Embree DEFAULT_MSG
_embree_LIBRARIES EMBREE_INCLUDE_DIR)
IF(EMBREE_FOUND)

View File

@@ -20,7 +20,7 @@
# Libraries configuration for Apple.
set(MACOSX_DEPLOYMENT_TARGET "10.11")
set(MACOSX_DEPLOYMENT_TARGET "10.13")
macro(find_package_wrapper)
# do nothing, just satisfy the macro

View File

@@ -65,13 +65,9 @@ endif()
message(STATUS "Detected OS X ${OSX_SYSTEM} and Xcode ${XCODE_VERSION} at ${XCODE_BUNDLE}")
# Older Xcode versions had different approach to the directory hiearchy.
# Require newer Xcode which is also have better chances of being able to compile with the
# required deployment target.
#
# NOTE: Xcode version 8.2 is the latest one which runs on macOS 10.11.
if(${XCODE_VERSION} VERSION_LESS 8.2)
message(FATAL_ERROR "Only Xcode version 8.2 and newer is supported")
# Require a relatively recent Xcode version.
if(${XCODE_VERSION} VERSION_LESS 10.0)
message(FATAL_ERROR "Only Xcode version 10.0 and newer is supported")
endif()
# note: xcode-select path could be ambiguous,
@@ -133,14 +129,14 @@ if(${CMAKE_GENERATOR} MATCHES "Xcode")
endif()
unset(OSX_SDKROOT)
# 10.11 is our min. target, if you use higher sdk, weak linking happens
# 10.13 is our min. target, if you use higher sdk, weak linking happens
if(CMAKE_OSX_DEPLOYMENT_TARGET)
if(${CMAKE_OSX_DEPLOYMENT_TARGET} VERSION_LESS 10.11)
message(STATUS "Setting deployment target to 10.11, lower versions are not supported")
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.11" CACHE STRING "" FORCE)
if(${CMAKE_OSX_DEPLOYMENT_TARGET} VERSION_LESS 10.13)
message(STATUS "Setting deployment target to 10.13, lower versions are not supported")
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13" CACHE STRING "" FORCE)
endif()
else()
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.11" CACHE STRING "" FORCE)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13" CACHE STRING "" FORCE)
endif()
if(NOT ${CMAKE_GENERATOR} MATCHES "Xcode")

View File

@@ -40,7 +40,8 @@ if make_utils.command_missing(git_command):
# Test if we are building a specific release version.
branch = make_utils.git_branch(git_command)
release_version = make_utils.git_branch_release_version(branch)
tag = make_utils.git_tag(git_command)
release_version = make_utils.git_branch_release_version(branch, tag)
lib_tests_dirpath = os.path.join('..', 'lib', "tests")
if not os.path.exists(lib_tests_dirpath):

View File

@@ -197,7 +197,8 @@ if __name__ == "__main__":
# Test if we are building a specific release version.
branch = make_utils.git_branch(args.git_command)
release_version = make_utils.git_branch_release_version(branch)
tag = make_utils.git_tag(args.git_command)
release_version = make_utils.git_branch_release_version(branch, tag)
if not args.no_libraries:
svn_update(args, release_version)

View File

@@ -36,7 +36,7 @@ def check_output(cmd, exit_on_error=True):
return output.strip()
def git_branch(git_command):
# Test if we are building a specific release version.
# Get current branch name.
try:
branch = subprocess.check_output([git_command, "rev-parse", "--abbrev-ref", "HEAD"])
except subprocess.CalledProcessError as e:
@@ -45,10 +45,23 @@ def git_branch(git_command):
return branch.strip().decode('utf8')
def git_branch_release_version(branch):
def git_tag(git_command):
# Get current tag name.
try:
tag = subprocess.check_output([git_command, "describe", "--exact-match"])
except subprocess.CalledProcessError as e:
return None
return tag.strip().decode('utf8')
def git_branch_release_version(branch, tag):
release_version = re.search("^blender-v(.*)-release$", branch)
if release_version:
release_version = release_version.group(1)
elif tag:
release_version = re.search("^v([0-9]*\.[0-9]*).*", tag)
if release_version:
release_version = release_version.group(1)
return release_version
def svn_libraries_base_url(release_version):

View File

@@ -248,7 +248,7 @@ using the ``bl_idname`` rather than the classes original name.
.. note::
There are some exceptions to this for class names which aren't guarantee to be unique.
In this case use: :func:`bpy.types.Struct.bl_rna_get_subclass`.
In this case use: :func:`bpy.types.Struct.bl_rna_get_subclass_py`.
When loading a class, Blender performs sanity checks making sure all required properties and functions are found,

View File

@@ -248,12 +248,14 @@ template<class S> class Vector3D {
protected:
};
//! helper to check whether float/double value is non-zero
inline bool notZero(Real f)
//! helper to check whether value is non-zero
template<class S> inline bool notZero(S v)
{
if (std::abs(f) > VECTOR_EPSILON)
return true;
return false;
return (std::abs(v) > VECTOR_EPSILON);
}
template<class S> inline bool notZero(Vector3D<S> v)
{
return (std::abs(norm(v)) > VECTOR_EPSILON);
}
//************************************************************************

View File

@@ -315,10 +315,14 @@ int readObjFile(const std::string &name, Mesh *mesh, bool append)
return 0;
}
const Real dx = mesh->getParent()->getDx();
const Vec3 gs = toVec3(mesh->getParent()->getGridSize());
if (!append)
mesh->clear();
int nodebase = mesh->numNodes();
int cnt = nodebase;
int cntNodes = nodebase, cntNormals = nodebase;
while (ifs.good() && !ifs.eof()) {
string id;
ifs >> id;
@@ -333,19 +337,23 @@ int readObjFile(const std::string &name, Mesh *mesh, bool append)
}
else if (id == "vn") {
// normals
if (!mesh->numNodes()) {
if (mesh->numNodes() != cntNodes) {
errMsg("invalid amount of nodes");
return 0;
}
Node n = mesh->nodes(cnt);
ifs >> n.normal.x >> n.normal.y >> n.normal.z;
cnt++;
Node *n = &mesh->nodes(cntNormals);
ifs >> n->normal.x >> n->normal.y >> n->normal.z;
cntNormals++;
}
else if (id == "v") {
// vertex
Node n;
ifs >> n.pos.x >> n.pos.y >> n.pos.z;
// convert to grid space
n.pos /= dx;
n.pos += gs * 0.5;
mesh->addNode(n);
cntNodes++;
}
else if (id == "g") {
// group
@@ -408,7 +416,6 @@ int writeObjFile(const string &name, Mesh *mesh)
// write normals
for (int i = 0; i < numVerts; i++) {
Vector3D<float> n = toVec3f(mesh->nodes(i).normal);
// normalize to unit cube around 0
ofs << "vn " << n.value[0] << " " << n.value[1] << " " << n.value[2] << " "
<< "\n";
}

View File

@@ -1,3 +1,3 @@
#define MANTA_GIT_VERSION "commit d80d3c821de74315ab26b5efd153d41477b976c4"
#define MANTA_GIT_VERSION "commit 7395d36e3f504edbdabe34b30edc855b422c7baa"

View File

@@ -30,6 +30,7 @@ add_subdirectory(opensubdiv)
add_subdirectory(mikktspace)
add_subdirectory(glew-mx)
add_subdirectory(eigen)
add_subdirectory(sky)
if(WITH_AUDASPACE)
add_subdirectory(audaspace)

View File

@@ -35,7 +35,7 @@ if(WITH_CYCLES_OSL)
endif()
if(NOT CYCLES_STANDALONE_REPOSITORY)
list(APPEND LIBRARIES bf_intern_glew_mx bf_intern_guardedalloc bf_intern_numaapi)
list(APPEND LIBRARIES bf_intern_glew_mx bf_intern_guardedalloc bf_intern_numaapi bf_intern_sky)
endif()
if(WITH_CYCLES_LOGGING)

View File

@@ -224,7 +224,7 @@ def system_info():
import _cycles
return _cycles.system_info()
def list_render_passes(srl):
def list_render_passes(scene, srl):
# Builtin Blender passes.
yield ("Combined", "RGBA", 'COLOR')
@@ -279,14 +279,17 @@ def list_render_passes(srl):
yield ("Denoising Normal", "XYZ", 'VECTOR')
yield ("Denoising Albedo", "RGB", 'COLOR')
yield ("Denoising Depth", "Z", 'VALUE')
yield ("Denoising Shadowing", "X", 'VALUE')
yield ("Denoising Variance", "RGB", 'COLOR')
yield ("Denoising Intensity", "X", 'VALUE')
clean_options = ("denoising_diffuse_direct", "denoising_diffuse_indirect",
"denoising_glossy_direct", "denoising_glossy_indirect",
"denoising_transmission_direct", "denoising_transmission_indirect")
if any(getattr(crl, option) for option in clean_options):
yield ("Denoising Clean", "RGB", 'COLOR')
if scene.cycles.denoiser == 'NLM':
yield ("Denoising Shadowing", "X", 'VALUE')
yield ("Denoising Variance", "RGB", 'COLOR')
yield ("Denoising Intensity", "X", 'VALUE')
clean_options = ("denoising_diffuse_direct", "denoising_diffuse_indirect",
"denoising_glossy_direct", "denoising_glossy_indirect",
"denoising_transmission_direct", "denoising_transmission_indirect")
if any(getattr(crl, option) for option in clean_options):
yield ("Denoising Clean", "RGB", 'COLOR')
# Custom AOV passes.
for aov in crl.aovs:
@@ -298,15 +301,15 @@ def list_render_passes(srl):
def register_passes(engine, scene, view_layer):
# Detect duplicate render pass names, first one wins.
listed = set()
for name, channelids, channeltype in list_render_passes(view_layer):
for name, channelids, channeltype in list_render_passes(scene, view_layer):
if name not in listed:
engine.register_pass(scene, view_layer, name, len(channelids), channelids, channeltype)
listed.add(name)
def detect_conflicting_passes(view_layer):
def detect_conflicting_passes(scene, view_layer):
# Detect conflicting render pass names for UI.
counter = {}
for name, _, _ in list_render_passes(view_layer):
for name, _, _ in list_render_passes(scene, view_layer):
counter[name] = counter.get(name, 0) + 1
for aov in view_layer.cycles.aovs:

View File

@@ -182,6 +182,7 @@ enum_aov_types = (
('COLOR', "Color", "Write a Color pass", 1),
)
def enum_openimagedenoise_denoiser(self, context):
if _cycles.with_openimagedenoise:
return [('OPENIMAGEDENOISE', "OpenImageDenoise", "Use Intel OpenImageDenoise AI denoiser running on the CPU", 4)]
@@ -196,14 +197,11 @@ def enum_preview_denoiser(self, context):
optix_items = enum_optix_denoiser(self, context)
oidn_items = enum_openimagedenoise_denoiser(self, context)
if len(optix_items):
auto_label = "Fastest (Optix)"
elif len(oidn_items):
auto_label = "Fastest (OpenImageDenoise)"
if len(optix_items) or len(oidn_items):
items = [('AUTO', "Automatic", "Use the fastest available denoiser for viewport rendering (OptiX if available, OpenImageDenoise otherwise)", 0)]
else:
auto_label = "None"
items = [('AUTO', "None", "Blender was compiled without a viewport denoiser", 0)]
items = [('AUTO', auto_label, "Use the fastest available denoiser for viewport rendering", 0)]
items += optix_items
items += oidn_items
return items
@@ -211,14 +209,23 @@ def enum_preview_denoiser(self, context):
def enum_denoiser(self, context):
items = [('NLM', "NLM", "Cycles native non-local means denoiser, running on any compute device", 1)]
items += enum_optix_denoiser(self, context)
items += enum_openimagedenoise_denoiser(self, context)
return items
enum_denoising_optix_input_passes = (
enum_denoising_input_passes = (
('RGB', "Color", "Use only color as input", 1),
('RGB_ALBEDO', "Color + Albedo", "Use color and albedo data as input", 2),
('RGB_ALBEDO_NORMAL', "Color + Albedo + Normal", "Use color, albedo and normal data as input", 3),
)
def update_render_passes(self, context):
scene = context.scene
view_layer = context.view_layer
view_layer.update_render_passes()
engine.detect_conflicting_passes(scene, view_layer)
class CyclesRenderSettings(bpy.types.PropertyGroup):
device: EnumProperty(
@@ -264,9 +271,12 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
denoiser: EnumProperty(
name="Denoiser",
description="Denoise the image with the selected denoiser",
description="Denoise the image with the selected denoiser. "
"For denoising the image after rendering, denoising data render passes "
"also adapt to the selected denoiser",
items=enum_denoiser,
default=1,
update=update_render_passes,
)
preview_denoiser: EnumProperty(
name="Viewport Denoiser",
@@ -821,6 +831,7 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
debug_use_cuda_split_kernel: BoolProperty(name="Split Kernel", default=False)
debug_optix_cuda_streams: IntProperty(name="CUDA Streams", default=1, min=1)
debug_optix_curves_api: BoolProperty(name="Native OptiX Curve Primitive", default=False)
debug_opencl_kernel_type: EnumProperty(
name="OpenCL Kernel Type",
@@ -1294,12 +1305,6 @@ class CyclesCurveRenderSettings(bpy.types.PropertyGroup):
del bpy.types.Scene.cycles_curves
def update_render_passes(self, context):
view_layer = context.view_layer
view_layer.update_render_passes()
engine.detect_conflicting_passes(view_layer)
class CyclesAOVPass(bpy.types.PropertyGroup):
name: StringProperty(
name="Name",
@@ -1433,7 +1438,7 @@ class CyclesRenderLayerSettings(bpy.types.PropertyGroup):
)
denoising_store_passes: BoolProperty(
name="Store Denoising Passes",
description="Store the denoising feature passes and the noisy image",
description="Store the denoising feature passes and the noisy image. The passes adapt to the denoiser selected for rendering",
default=False,
update=update_render_passes,
)
@@ -1446,11 +1451,18 @@ class CyclesRenderLayerSettings(bpy.types.PropertyGroup):
denoising_optix_input_passes: EnumProperty(
name="Input Passes",
description="Passes handed over to the OptiX denoiser (this can have different effects on the denoised image)",
items=enum_denoising_optix_input_passes,
description="Passes used by the denoiser to distinguish noise from shader and geometry detail",
items=enum_denoising_input_passes,
default='RGB_ALBEDO',
)
denoising_openimagedenoise_input_passes: EnumProperty(
name="Input Passes",
description="Passes used by the denoiser to distinguish noise from shader and geometry detail",
items=enum_denoising_input_passes,
default='RGB_ALBEDO_NORMAL',
)
use_pass_crypto_object: BoolProperty(
name="Cryptomatte Object",
description="Render cryptomatte object pass, for isolating objects in compositing",

View File

@@ -265,7 +265,12 @@ class CYCLES_RENDER_PT_sampling_denoising(CyclesButtonsPanel, Panel):
row = heading.row(align=True)
row.prop(cscene, "use_denoising", text="")
sub = row.row()
sub.active = cscene.use_denoising
for view_layer in scene.view_layers:
if view_layer.cycles.denoising_store_passes:
sub.active = True
sub.prop(cscene, "denoiser", text="")
heading = layout.column(align=False, heading="Viewport")
@@ -777,10 +782,6 @@ class CYCLES_RENDER_PT_filter(CyclesButtonsPanel, Panel):
col.prop(view_layer, "use_solid", text="Surfaces")
col.prop(view_layer, "use_strand", text="Hair")
col.prop(view_layer, "use_volumes", text="Volumes")
if with_freestyle:
sub = col.row(align=True)
sub.prop(view_layer, "use_freestyle", text="Freestyle")
sub.active = rd.use_freestyle
class CYCLES_RENDER_PT_override(CyclesButtonsPanel, Panel):
@@ -1007,6 +1008,7 @@ class CYCLES_RENDER_PT_denoising(CyclesButtonsPanel, Panel):
col.prop(cycles_view_layer, "denoising_optix_input_passes")
return
elif denoiser == 'OPENIMAGEDENOISE':
col.prop(cycles_view_layer, "denoising_openimagedenoise_input_passes")
return
col.prop(cycles_view_layer, "denoising_radius", text="Radius")
@@ -1222,6 +1224,7 @@ def has_geometry_visibility(ob):
return ob and ((ob.type in {'MESH', 'CURVE', 'SURFACE', 'FONT', 'META', 'LIGHT'}) or
(ob.instance_type == 'COLLECTION' and ob.instance_collection))
class CYCLES_OBJECT_PT_shading(CyclesButtonsPanel, Panel):
bl_label = "Shading"
bl_context = "object"
@@ -1244,6 +1247,7 @@ class CYCLES_OBJECT_PT_shading(CyclesButtonsPanel, Panel):
col = flow.column()
col.prop(cob, "shadow_terminator_offset")
class CYCLES_OBJECT_PT_visibility(CyclesButtonsPanel, Panel):
bl_label = "Visibility"
bl_context = "object"
@@ -2024,6 +2028,7 @@ class CYCLES_RENDER_PT_debug(CyclesButtonsPanel, Panel):
col = layout.column()
col.label(text="OptiX Flags:")
col.prop(cscene, "debug_optix_cuda_streams")
col.prop(cscene, "debug_optix_curves_api")
col.separator()

View File

@@ -709,6 +709,10 @@ static void blender_camera_from_view(BlenderCamera *bcam,
/* 3d view transform */
bcam->matrix = transform_inverse(get_transform(b_rv3d.view_matrix()));
/* dimensions */
bcam->full_width = width;
bcam->full_height = height;
}
static void blender_camera_view_subset(BL::RenderEngine &b_engine,

View File

@@ -200,7 +200,7 @@ template<typename K, typename T> class id_map {
* To uniquely identify instances, we use the parent, object and persistent instance ID.
* We also export separate object for a mesh and its particle hair. */
enum { OBJECT_PERSISTENT_ID_SIZE = 16 };
enum { OBJECT_PERSISTENT_ID_SIZE = 8 /* MAX_DUPLI_RECUR in Blender. */ };
struct ObjectKey {
void *parent;

View File

@@ -59,7 +59,7 @@ bool BlenderSync::BKE_object_is_modified(BL::Object &b_ob)
return false;
}
bool BlenderSync::object_is_mesh(BL::Object &b_ob)
bool BlenderSync::object_is_geometry(BL::Object &b_ob)
{
BL::ID b_ob_data = b_ob.data();
@@ -143,7 +143,7 @@ Object *BlenderSync::sync_object(BL::Depsgraph &b_depsgraph,
}
/* only interested in object that we can create meshes from */
if (!object_is_mesh(b_ob)) {
if (!object_is_geometry(b_ob)) {
return NULL;
}

View File

@@ -92,6 +92,7 @@ bool debug_flags_sync_from_scene(BL::Scene b_scene)
flags.cuda.split_kernel = get_boolean(cscene, "debug_use_cuda_split_kernel");
/* Synchronize OptiX flags. */
flags.optix.cuda_streams = get_int(cscene, "debug_optix_cuda_streams");
flags.optix.curves_api = get_boolean(cscene, "debug_optix_curves_api");
/* Synchronize OpenCL device type. */
switch (get_enum(cscene, "debug_opencl_device_type")) {
case 0:

View File

@@ -815,9 +815,10 @@ static ShaderNode *add_node(Scene *scene,
sky->ground_albedo = b_sky_node.ground_albedo();
sky->sun_disc = b_sky_node.sun_disc();
sky->sun_size = b_sky_node.sun_size();
sky->sun_intensity = b_sky_node.sun_intensity();
sky->sun_elevation = b_sky_node.sun_elevation();
sky->sun_rotation = b_sky_node.sun_rotation();
sky->altitude = b_sky_node.altitude();
sky->altitude = 1000.0f * b_sky_node.altitude();
sky->air_density = b_sky_node.air_density();
sky->dust_density = b_sky_node.dust_density();
sky->ozone_density = b_sky_node.ozone_density();

View File

@@ -147,30 +147,43 @@ void BlenderSync::sync_recalc(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d
/* Object */
else if (b_id.is_a(&RNA_Object)) {
BL::Object b_ob(b_id);
const bool updated_geometry = b_update->is_updated_geometry();
const bool is_geometry = object_is_geometry(b_ob);
const bool is_light = !is_geometry && object_is_light(b_ob);
if (b_update->is_updated_transform() || b_update->is_updated_shading()) {
object_map.set_recalc(b_ob);
light_map.set_recalc(b_ob);
}
if (is_geometry || is_light) {
const bool updated_geometry = b_update->is_updated_geometry();
if (object_is_mesh(b_ob)) {
if (updated_geometry ||
(object_subdivision_type(b_ob, preview, experimental) != Mesh::SUBDIVISION_NONE)) {
BL::ID key = BKE_object_is_modified(b_ob) ? b_ob : b_ob.data();
geometry_map.set_recalc(key);
/* Geometry (mesh, hair, volume). */
if (is_geometry) {
if (b_update->is_updated_transform() || b_update->is_updated_shading()) {
object_map.set_recalc(b_ob);
}
if (updated_geometry ||
(object_subdivision_type(b_ob, preview, experimental) != Mesh::SUBDIVISION_NONE)) {
BL::ID key = BKE_object_is_modified(b_ob) ? b_ob : b_ob.data();
geometry_map.set_recalc(key);
}
if (updated_geometry) {
BL::Object::particle_systems_iterator b_psys;
for (b_ob.particle_systems.begin(b_psys); b_psys != b_ob.particle_systems.end();
++b_psys) {
particle_system_map.set_recalc(b_ob);
}
}
}
}
else if (object_is_light(b_ob)) {
if (updated_geometry) {
light_map.set_recalc(b_ob);
}
}
/* Light */
else if (is_light) {
if (b_update->is_updated_transform() || b_update->is_updated_shading()) {
object_map.set_recalc(b_ob);
light_map.set_recalc(b_ob);
}
if (updated_geometry) {
BL::Object::particle_systems_iterator b_psys;
for (b_ob.particle_systems.begin(b_psys); b_psys != b_ob.particle_systems.end(); ++b_psys)
particle_system_map.set_recalc(b_ob);
if (updated_geometry) {
light_map.set_recalc(b_ob);
}
}
}
}
/* Mesh */
@@ -941,7 +954,13 @@ DenoiseParams BlenderSync::get_denoise_params(BL::Scene &b_scene,
denoising.strength = get_float(clayer, "denoising_strength");
denoising.feature_strength = get_float(clayer, "denoising_feature_strength");
denoising.relative_pca = get_boolean(clayer, "denoising_relative_pca");
denoising.optix_input_passes = get_enum(clayer, "denoising_optix_input_passes");
denoising.input_passes = (DenoiserInput)get_enum(
clayer,
(denoising.type == DENOISER_OPTIX) ? "denoising_optix_input_passes" :
"denoising_openimagedenoise_input_passes",
DENOISER_INPUT_NUM,
DENOISER_INPUT_RGB_ALBEDO_NORMAL);
denoising.store_passes = get_boolean(clayer, "denoising_store_passes");
}

View File

@@ -208,7 +208,7 @@ class BlenderSync {
/* util */
void find_shader(BL::ID &id, vector<Shader *> &used_shaders, Shader *default_shader);
bool BKE_object_is_modified(BL::Object &b_ob);
bool object_is_mesh(BL::Object &b_ob);
bool object_is_geometry(BL::Object &b_ob);
bool object_is_light(BL::Object &b_ob);
/* variables */

View File

@@ -133,9 +133,9 @@ if(CYCLES_STANDALONE_REPOSITORY)
set(BOOST_DEFINITIONS "-DBOOST_ALL_NO_LIB")
####
# embree
# Embree
if(WITH_CYCLES_EMBREE)
find_package(embree 3.8.0 REQUIRED)
find_package(Embree 3.8.0 REQUIRED)
endif()
####

View File

@@ -1760,7 +1760,7 @@ void CUDADevice::denoise(RenderTile &rtile, DenoisingTask &denoising)
denoising.render_buffer.samples = rtile.sample;
denoising.buffer.gpu_temporary_mem = true;
denoising.run_denoising(&rtile);
denoising.run_denoising(rtile);
}
void CUDADevice::adaptive_sampling_filter(uint filter_sample,

View File

@@ -209,13 +209,13 @@ bool Device::bind_fallback_display_space_shader(const float width, const float h
glUseProgram(fallback_shader_program);
image_texture_location = glGetUniformLocation(fallback_shader_program, "image_texture");
if (image_texture_location < 0) {
LOG(ERROR) << "Shader doesn't containt the 'image_texture' uniform.";
LOG(ERROR) << "Shader doesn't contain the 'image_texture' uniform.";
return false;
}
fullscreen_location = glGetUniformLocation(fallback_shader_program, "fullscreen");
if (fullscreen_location < 0) {
LOG(ERROR) << "Shader doesn't containt the 'fullscreen' uniform.";
LOG(ERROR) << "Shader doesn't contain the 'fullscreen' uniform.";
return false;
}

View File

@@ -439,10 +439,10 @@ class Device {
{
return 0;
}
virtual void map_neighbor_tiles(Device * /*sub_device*/, RenderTile * /*tiles*/)
virtual void map_neighbor_tiles(Device * /*sub_device*/, RenderTileNeighbors & /*neighbors*/)
{
}
virtual void unmap_neighbor_tiles(Device * /*sub_device*/, RenderTile * /*tiles*/)
virtual void unmap_neighbor_tiles(Device * /*sub_device*/, RenderTileNeighbors & /*neighbors*/)
{
}

View File

@@ -182,6 +182,7 @@ class CPUDevice : public Device {
oidn::DeviceRef oidn_device;
oidn::FilterRef oidn_filter;
#endif
thread_spin_lock oidn_task_lock;
bool use_split_kernel;
@@ -948,12 +949,25 @@ class CPUDevice : public Device {
}
}
void denoise_openimagedenoise(DeviceTask &task, RenderTile &rtile)
void denoise_openimagedenoise_buffer(DeviceTask &task,
float *buffer,
const size_t offset,
const size_t stride,
const size_t x,
const size_t y,
const size_t w,
const size_t h,
const float scale)
{
#ifdef WITH_OPENIMAGEDENOISE
assert(openimagedenoise_supported());
/* Only one at a time, since OpenImageDenoise itself is multithreaded. */
/* Only one at a time, since OpenImageDenoise itself is multithreaded for full
* buffers, and for tiled rendering because creating multiple devices and filters
* is slow and memory hungry as well.
*
* TODO: optimize tiled rendering case, by batching together denoising of many
* tiles somehow? */
static thread_mutex mutex;
thread_scoped_lock lock(mutex);
@@ -964,54 +978,192 @@ class CPUDevice : public Device {
}
if (!oidn_filter) {
oidn_filter = oidn_device.newFilter("RT");
oidn_filter.set("hdr", true);
oidn_filter.set("srgb", false);
}
/* Copy pixels from compute device to CPU (no-op for CPU device). */
rtile.buffers->buffer.copy_from_device();
/* Set images with appropriate stride for our interleaved pass storage. */
const struct {
struct {
const char *name;
int offset;
} passes[] = {{"color", task.pass_denoising_data + DENOISING_PASS_COLOR},
{"normal", task.pass_denoising_data + DENOISING_PASS_NORMAL},
{"albedo", task.pass_denoising_data + DENOISING_PASS_ALBEDO},
{"output", 0},
const int offset;
const bool scale;
const bool use;
array<float> scaled_buffer;
} passes[] = {{"color", task.pass_denoising_data + DENOISING_PASS_COLOR, false, true},
{"albedo",
task.pass_denoising_data + DENOISING_PASS_ALBEDO,
true,
task.denoising.input_passes >= DENOISER_INPUT_RGB_ALBEDO},
{"normal",
task.pass_denoising_data + DENOISING_PASS_NORMAL,
true,
task.denoising.input_passes >= DENOISER_INPUT_RGB_ALBEDO_NORMAL},
{"output", 0, false, true},
{ NULL,
0 }};
for (int i = 0; passes[i].name; i++) {
const int64_t offset = rtile.offset + rtile.x + rtile.y * rtile.stride;
const int64_t buffer_offset = (offset * task.pass_stride + passes[i].offset) * sizeof(float);
const int64_t pixel_stride = task.pass_stride * sizeof(float);
const int64_t row_stride = rtile.stride * pixel_stride;
if (!passes[i].use) {
continue;
}
oidn_filter.setImage(passes[i].name,
(char *)rtile.buffer + buffer_offset,
oidn::Format::Float3,
rtile.w,
rtile.h,
0,
pixel_stride,
row_stride);
const int64_t pixel_offset = offset + x + y * stride;
const int64_t buffer_offset = (pixel_offset * task.pass_stride + passes[i].offset);
const int64_t pixel_stride = task.pass_stride;
const int64_t row_stride = stride * pixel_stride;
if (passes[i].scale && scale != 1.0f) {
/* Normalize albedo and normal passes as they are scaled by the number of samples.
* For the color passes OIDN will perform auto-exposure making it unnecessary. */
array<float> &scaled_buffer = passes[i].scaled_buffer;
scaled_buffer.resize(w * h * 3);
for (int y = 0; y < h; y++) {
const float *pass_row = buffer + buffer_offset + y * row_stride;
float *scaled_row = scaled_buffer.data() + y * w * 3;
for (int x = 0; x < w; x++) {
scaled_row[x * 3 + 0] = pass_row[x * pixel_stride + 0] * scale;
scaled_row[x * 3 + 1] = pass_row[x * pixel_stride + 1] * scale;
scaled_row[x * 3 + 2] = pass_row[x * pixel_stride + 2] * scale;
}
}
oidn_filter.setImage(
passes[i].name, scaled_buffer.data(), oidn::Format::Float3, w, h, 0, 0, 0);
}
else {
oidn_filter.setImage(passes[i].name,
buffer + buffer_offset,
oidn::Format::Float3,
w,
h,
0,
pixel_stride * sizeof(float),
row_stride * sizeof(float));
}
}
/* Execute filter. */
oidn_filter.set("hdr", true);
oidn_filter.set("srgb", false);
oidn_filter.commit();
oidn_filter.execute();
/* todo: it may be possible to avoid this copy, but we have to ensure that
* when other code copies data from the device it doesn't overwrite the
* denoiser buffers. */
rtile.buffers->buffer.copy_to_device();
#else
(void)task;
(void)rtile;
(void)buffer;
(void)offset;
(void)stride;
(void)x;
(void)y;
(void)w;
(void)h;
(void)scale;
#endif
}
void denoise_openimagedenoise(DeviceTask &task, RenderTile &rtile)
{
if (task.type == DeviceTask::DENOISE_BUFFER) {
/* Copy pixels from compute device to CPU (no-op for CPU device). */
rtile.buffers->buffer.copy_from_device();
denoise_openimagedenoise_buffer(task,
(float *)rtile.buffer,
rtile.offset,
rtile.stride,
rtile.x,
rtile.y,
rtile.w,
rtile.h,
1.0f / rtile.sample);
/* todo: it may be possible to avoid this copy, but we have to ensure that
* when other code copies data from the device it doesn't overwrite the
* denoiser buffers. */
rtile.buffers->buffer.copy_to_device();
}
else {
/* Per-tile denoising. */
rtile.sample = rtile.start_sample + rtile.num_samples;
const float scale = 1.0f / rtile.sample;
const float invscale = rtile.sample;
const size_t pass_stride = task.pass_stride;
/* Map neighboring tiles into one buffer for denoising. */
RenderTileNeighbors neighbors(rtile);
task.map_neighbor_tiles(neighbors, this);
RenderTile &center_tile = neighbors.tiles[RenderTileNeighbors::CENTER];
rtile = center_tile;
/* Calculate size of the tile to denoise (including overlap). The overlap
* size was chosen empirically. OpenImageDenoise specifies an overlap size
* of 128 but this is significantly bigger than typical tile size. */
const int4 rect = rect_clip(rect_expand(center_tile.bounds(), 64), neighbors.bounds());
const int2 rect_size = make_int2(rect.z - rect.x, rect.w - rect.y);
/* Adjacent tiles are in separate memory regions, copy into single buffer. */
array<float> merged(rect_size.x * rect_size.y * task.pass_stride);
for (int i = 0; i < RenderTileNeighbors::SIZE; i++) {
RenderTile &ntile = neighbors.tiles[i];
if (!ntile.buffer) {
continue;
}
const int xmin = max(ntile.x, rect.x);
const int ymin = max(ntile.y, rect.y);
const int xmax = min(ntile.x + ntile.w, rect.z);
const int ymax = min(ntile.y + ntile.h, rect.w);
const size_t tile_offset = ntile.offset + xmin + ymin * ntile.stride;
const float *tile_buffer = (float *)ntile.buffer + tile_offset * pass_stride;
const size_t merged_stride = rect_size.x;
const size_t merged_offset = (xmin - rect.x) + (ymin - rect.y) * merged_stride;
float *merged_buffer = merged.data() + merged_offset * pass_stride;
for (int y = ymin; y < ymax; y++) {
for (int x = 0; x < pass_stride * (xmax - xmin); x++) {
merged_buffer[x] = tile_buffer[x] * scale;
}
tile_buffer += ntile.stride * pass_stride;
merged_buffer += merged_stride * pass_stride;
}
}
/* Denoise */
denoise_openimagedenoise_buffer(
task, merged.data(), 0, rect_size.x, 0, 0, rect_size.x, rect_size.y, 1.0f);
/* Copy back result from merged buffer. */
RenderTile &ntile = neighbors.target;
if (ntile.buffer) {
const int xmin = max(ntile.x, rect.x);
const int ymin = max(ntile.y, rect.y);
const int xmax = min(ntile.x + ntile.w, rect.z);
const int ymax = min(ntile.y + ntile.h, rect.w);
const size_t tile_offset = ntile.offset + xmin + ymin * ntile.stride;
float *tile_buffer = (float *)ntile.buffer + tile_offset * pass_stride;
const size_t merged_stride = rect_size.x;
const size_t merged_offset = (xmin - rect.x) + (ymin - rect.y) * merged_stride;
const float *merged_buffer = merged.data() + merged_offset * pass_stride;
for (int y = ymin; y < ymax; y++) {
for (int x = 0; x < pass_stride * (xmax - xmin); x += pass_stride) {
tile_buffer[x + 0] = merged_buffer[x + 0] * invscale;
tile_buffer[x + 1] = merged_buffer[x + 1] * invscale;
tile_buffer[x + 2] = merged_buffer[x + 2] * invscale;
}
tile_buffer += ntile.stride * pass_stride;
merged_buffer += merged_stride * pass_stride;
}
}
task.unmap_neighbor_tiles(neighbors, this);
}
}
void denoise_nlm(DenoisingTask &denoising, RenderTile &tile)
{
ProfilingHelper profiling(denoising.profiler, PROFILING_DENOISING);
@@ -1040,7 +1192,7 @@ class CPUDevice : public Device {
denoising.render_buffer.samples = tile.sample;
denoising.buffer.gpu_temporary_mem = false;
denoising.run_denoising(&tile);
denoising.run_denoising(tile);
}
void thread_render(DeviceTask &task)
@@ -1070,10 +1222,23 @@ class CPUDevice : public Device {
}
}
/* NLM denoiser. */
DenoisingTask *denoising = NULL;
/* OpenImageDenoise: we can only denoise with one thread at a time, so to
* avoid waiting with mutex locks in the denoiser, we let only a single
* thread acquire denoising tiles. */
uint tile_types = task.tile_types;
bool hold_denoise_lock = false;
if ((tile_types & RenderTile::DENOISE) && task.denoising.type == DENOISER_OPENIMAGEDENOISE) {
if (!oidn_task_lock.try_lock()) {
tile_types &= ~RenderTile::DENOISE;
hold_denoise_lock = true;
}
}
RenderTile tile;
while (task.acquire_tile(this, tile, task.tile_types)) {
while (task.acquire_tile(this, tile, tile_types)) {
if (tile.task == RenderTile::PATH_TRACE) {
if (use_split_kernel) {
device_only_memory<uchar> void_buffer(this, "void_buffer");
@@ -1108,6 +1273,10 @@ class CPUDevice : public Device {
}
}
if (hold_denoise_lock) {
oidn_task_lock.unlock();
}
profiler.remove_state(&kg->profiler);
thread_kernel_globals_free((KernelGlobals *)kgbuffer.device_pointer);

View File

@@ -71,29 +71,30 @@ DenoisingTask::~DenoisingTask()
tile_info_mem.free();
}
void DenoisingTask::set_render_buffer(RenderTile *rtiles)
void DenoisingTask::set_render_buffer(RenderTileNeighbors &neighbors)
{
for (int i = 0; i < 9; i++) {
tile_info->offsets[i] = rtiles[i].offset;
tile_info->strides[i] = rtiles[i].stride;
tile_info->buffers[i] = rtiles[i].buffer;
for (int i = 0; i < RenderTileNeighbors::SIZE; i++) {
RenderTile &rtile = neighbors.tiles[i];
tile_info->offsets[i] = rtile.offset;
tile_info->strides[i] = rtile.stride;
tile_info->buffers[i] = rtile.buffer;
}
tile_info->x[0] = rtiles[3].x;
tile_info->x[1] = rtiles[4].x;
tile_info->x[2] = rtiles[5].x;
tile_info->x[3] = rtiles[5].x + rtiles[5].w;
tile_info->y[0] = rtiles[1].y;
tile_info->y[1] = rtiles[4].y;
tile_info->y[2] = rtiles[7].y;
tile_info->y[3] = rtiles[7].y + rtiles[7].h;
tile_info->x[0] = neighbors.tiles[3].x;
tile_info->x[1] = neighbors.tiles[4].x;
tile_info->x[2] = neighbors.tiles[5].x;
tile_info->x[3] = neighbors.tiles[5].x + neighbors.tiles[5].w;
tile_info->y[0] = neighbors.tiles[1].y;
tile_info->y[1] = neighbors.tiles[4].y;
tile_info->y[2] = neighbors.tiles[7].y;
tile_info->y[3] = neighbors.tiles[7].y + neighbors.tiles[7].h;
target_buffer.offset = rtiles[9].offset;
target_buffer.stride = rtiles[9].stride;
target_buffer.ptr = rtiles[9].buffer;
target_buffer.offset = neighbors.target.offset;
target_buffer.stride = neighbors.target.stride;
target_buffer.ptr = neighbors.target.buffer;
if (do_prefilter && rtiles[9].buffers) {
if (do_prefilter && neighbors.target.buffers) {
target_buffer.denoising_output_offset =
rtiles[9].buffers->params.get_denoising_prefiltered_offset();
neighbors.target.buffers->params.get_denoising_prefiltered_offset();
}
else {
target_buffer.denoising_output_offset = 0;
@@ -320,12 +321,11 @@ void DenoisingTask::reconstruct()
functions.solve(target_buffer.ptr);
}
void DenoisingTask::run_denoising(RenderTile *tile)
void DenoisingTask::run_denoising(RenderTile &tile)
{
RenderTile rtiles[10];
rtiles[4] = *tile;
functions.map_neighbor_tiles(rtiles);
set_render_buffer(rtiles);
RenderTileNeighbors neighbors(tile);
functions.map_neighbor_tiles(neighbors);
set_render_buffer(neighbors);
setup_denoising_buffer();
@@ -347,7 +347,7 @@ void DenoisingTask::run_denoising(RenderTile *tile)
write_buffer();
}
functions.unmap_neighbor_tiles(rtiles);
functions.unmap_neighbor_tiles(neighbors);
}
CCL_NAMESPACE_END

View File

@@ -102,8 +102,8 @@ class DenoisingTask {
device_ptr output_ptr)>
detect_outliers;
function<bool(int out_offset, device_ptr frop_ptr, device_ptr buffer_ptr)> write_feature;
function<void(RenderTile *rtiles)> map_neighbor_tiles;
function<void(RenderTile *rtiles)> unmap_neighbor_tiles;
function<void(RenderTileNeighbors &neighbors)> map_neighbor_tiles;
function<void(RenderTileNeighbors &neighbors)> unmap_neighbor_tiles;
} functions;
/* Stores state of the current Reconstruction operation,
@@ -154,7 +154,7 @@ class DenoisingTask {
DenoisingTask(Device *device, const DeviceTask &task);
~DenoisingTask();
void run_denoising(RenderTile *tile);
void run_denoising(RenderTile &tile);
struct DenoiseBuffers {
int pass_stride;
@@ -179,7 +179,7 @@ class DenoisingTask {
protected:
Device *device;
void set_render_buffer(RenderTile *rtiles);
void set_render_buffer(RenderTileNeighbors &neighbors);
void setup_denoising_buffer();
void prefilter_shadowing();
void prefilter_features();

View File

@@ -177,8 +177,11 @@ class MultiDevice : public Device {
return false;
if (requested_features.use_denoising) {
/* Only need denoising feature, everything else is unused. */
DeviceRequestedFeatures denoising_features;
denoising_features.use_denoising = true;
foreach (SubDevice &sub, denoising_devices)
if (!sub.device->load_kernels(requested_features))
if (!sub.device->load_kernels(denoising_features))
return false;
}
@@ -581,20 +584,22 @@ class MultiDevice : public Device {
return -1;
}
void map_neighbor_tiles(Device *sub_device, RenderTile *tiles)
void map_neighbor_tiles(Device *sub_device, RenderTileNeighbors &neighbors)
{
for (int i = 0; i < 9; i++) {
if (!tiles[i].buffers) {
for (int i = 0; i < RenderTileNeighbors::SIZE; i++) {
RenderTile &tile = neighbors.tiles[i];
if (!tile.buffers) {
continue;
}
device_vector<float> &mem = tiles[i].buffers->buffer;
tiles[i].buffer = mem.device_pointer;
device_vector<float> &mem = tile.buffers->buffer;
tile.buffer = mem.device_pointer;
if (mem.device == this && matching_rendering_and_denoising_devices) {
/* Skip unnecessary copies in viewport mode (buffer covers the
* whole image), but still need to fix up the tile device pointer. */
map_tile(sub_device, tiles[i]);
map_tile(sub_device, tile);
continue;
}
@@ -607,15 +612,15 @@ class MultiDevice : public Device {
* also required for the case where a CPU thread is denoising
* a tile rendered on the GPU. In that case we have to avoid
* overwriting the buffer being de-noised by the CPU thread. */
if (!tiles[i].buffers->map_neighbor_copied) {
tiles[i].buffers->map_neighbor_copied = true;
if (!tile.buffers->map_neighbor_copied) {
tile.buffers->map_neighbor_copied = true;
mem.copy_from_device();
}
if (mem.device == this) {
/* Can re-use memory if tile is already allocated on the sub device. */
map_tile(sub_device, tiles[i]);
mem.swap_device(sub_device, mem.device_size, tiles[i].buffer);
map_tile(sub_device, tile);
mem.swap_device(sub_device, mem.device_size, tile.buffer);
}
else {
mem.swap_device(sub_device, 0, 0);
@@ -623,40 +628,42 @@ class MultiDevice : public Device {
mem.copy_to_device();
tiles[i].buffer = mem.device_pointer;
tiles[i].device_size = mem.device_size;
tile.buffer = mem.device_pointer;
tile.device_size = mem.device_size;
mem.restore_device();
}
}
}
void unmap_neighbor_tiles(Device *sub_device, RenderTile *tiles)
void unmap_neighbor_tiles(Device *sub_device, RenderTileNeighbors &neighbors)
{
device_vector<float> &mem = tiles[9].buffers->buffer;
RenderTile &target_tile = neighbors.target;
device_vector<float> &mem = target_tile.buffers->buffer;
if (mem.device == this && matching_rendering_and_denoising_devices) {
return;
}
/* Copy denoised result back to the host. */
mem.swap_device(sub_device, tiles[9].device_size, tiles[9].buffer);
mem.swap_device(sub_device, target_tile.device_size, target_tile.buffer);
mem.copy_from_device();
mem.restore_device();
/* Copy denoised result to the original device. */
mem.copy_to_device();
for (int i = 0; i < 9; i++) {
if (!tiles[i].buffers) {
for (int i = 0; i < RenderTileNeighbors::SIZE; i++) {
RenderTile &tile = neighbors.tiles[i];
if (!tile.buffers) {
continue;
}
device_vector<float> &mem = tiles[i].buffers->buffer;
device_vector<float> &mem = tile.buffers->buffer;
if (mem.device != sub_device && mem.device != this) {
/* Free up memory again if it was allocated for the copy above. */
mem.swap_device(sub_device, tiles[i].device_size, tiles[i].buffer);
mem.swap_device(sub_device, tile.device_size, tile.buffer);
sub_device->mem_free(mem);
mem.restore_device();
}

View File

@@ -131,8 +131,12 @@ class OptiXDevice : public CUDADevice {
PG_RGEN,
PG_MISS,
PG_HITD, // Default hit group
PG_HITL, // __BVH_LOCAL__ hit group
PG_HITS, // __SHADOW_RECORD_ALL__ hit group
PG_HITL, // __BVH_LOCAL__ hit group (only used for triangles)
# if OPTIX_ABI_VERSION >= 36
PG_HITD_MOTION,
PG_HITS_MOTION,
# endif
# ifdef WITH_CYCLES_DEBUG
PG_EXCP,
# endif
@@ -177,6 +181,7 @@ class OptiXDevice : public CUDADevice {
OptixDeviceContext context = NULL;
OptixModule optix_module = NULL; // All necessary OptiX kernels are in one module
OptixModule builtin_modules[2] = {};
OptixPipeline pipelines[NUM_PIPELINES] = {};
bool motion_blur = false;
@@ -264,6 +269,9 @@ class OptiXDevice : public CUDADevice {
// Unload modules
if (optix_module != NULL)
optixModuleDestroy(optix_module);
for (unsigned int i = 0; i < 2; ++i)
if (builtin_modules[i] != NULL)
optixModuleDestroy(builtin_modules[i]);
for (unsigned int i = 0; i < NUM_PIPELINES; ++i)
if (pipelines[i] != NULL)
optixPipelineDestroy(pipelines[i]);
@@ -338,6 +346,12 @@ class OptiXDevice : public CUDADevice {
optixModuleDestroy(optix_module);
optix_module = NULL;
}
for (unsigned int i = 0; i < 2; ++i) {
if (builtin_modules[i] != NULL) {
optixModuleDestroy(builtin_modules[i]);
builtin_modules[i] = NULL;
}
}
for (unsigned int i = 0; i < NUM_PIPELINES; ++i) {
if (pipelines[i] != NULL) {
optixPipelineDestroy(pipelines[i]);
@@ -369,6 +383,18 @@ class OptiXDevice : public CUDADevice {
# endif
pipeline_options.pipelineLaunchParamsVariableName = "__params"; // See kernel_globals.h
# if OPTIX_ABI_VERSION >= 36
pipeline_options.usesPrimitiveTypeFlags = OPTIX_PRIMITIVE_TYPE_FLAGS_TRIANGLE;
if (requested_features.use_hair) {
if (DebugFlags().optix.curves_api && requested_features.use_hair_thick) {
pipeline_options.usesPrimitiveTypeFlags |= OPTIX_PRIMITIVE_TYPE_FLAGS_ROUND_CUBIC_BSPLINE;
}
else {
pipeline_options.usesPrimitiveTypeFlags |= OPTIX_PRIMITIVE_TYPE_FLAGS_CUSTOM;
}
}
# endif
// Keep track of whether motion blur is enabled, so to enable/disable motion in BVH builds
// This is necessary since objects may be reported to have motion if the Vector pass is
// active, but may still need to be rendered without motion blur if that isn't active as well
@@ -442,6 +468,34 @@ class OptiXDevice : public CUDADevice {
group_descs[PG_HITD].hitgroup.entryFunctionNameIS = "__intersection__curve_ribbon";
group_descs[PG_HITS].hitgroup.entryFunctionNameIS = "__intersection__curve_ribbon";
}
# if OPTIX_ABI_VERSION >= 36
if (DebugFlags().optix.curves_api && requested_features.use_hair_thick) {
OptixBuiltinISOptions builtin_options;
builtin_options.builtinISModuleType = OPTIX_PRIMITIVE_TYPE_ROUND_CUBIC_BSPLINE;
builtin_options.usesMotionBlur = false;
check_result_optix_ret(optixBuiltinISModuleGet(
context, &module_options, &pipeline_options, &builtin_options, &builtin_modules[0]));
group_descs[PG_HITD].hitgroup.moduleIS = builtin_modules[0];
group_descs[PG_HITD].hitgroup.entryFunctionNameIS = nullptr;
group_descs[PG_HITS].hitgroup.moduleIS = builtin_modules[0];
group_descs[PG_HITS].hitgroup.entryFunctionNameIS = nullptr;
if (motion_blur) {
builtin_options.usesMotionBlur = true;
check_result_optix_ret(optixBuiltinISModuleGet(
context, &module_options, &pipeline_options, &builtin_options, &builtin_modules[1]));
group_descs[PG_HITD_MOTION] = group_descs[PG_HITD];
group_descs[PG_HITD_MOTION].hitgroup.moduleIS = builtin_modules[1];
group_descs[PG_HITS_MOTION] = group_descs[PG_HITS];
group_descs[PG_HITS_MOTION].hitgroup.moduleIS = builtin_modules[1];
}
}
# endif
}
if (requested_features.use_subsurface || requested_features.use_shader_raytrace) {
@@ -493,8 +547,14 @@ class OptiXDevice : public CUDADevice {
unsigned int trace_css = stack_size[PG_HITD].cssCH;
// This is based on the maximum of closest-hit and any-hit/intersection programs
trace_css = std::max(trace_css, stack_size[PG_HITD].cssIS + stack_size[PG_HITD].cssAH);
trace_css = std::max(trace_css, stack_size[PG_HITL].cssIS + stack_size[PG_HITL].cssAH);
trace_css = std::max(trace_css, stack_size[PG_HITS].cssIS + stack_size[PG_HITS].cssAH);
trace_css = std::max(trace_css, stack_size[PG_HITL].cssIS + stack_size[PG_HITL].cssAH);
# if OPTIX_ABI_VERSION >= 36
trace_css = std::max(trace_css,
stack_size[PG_HITD_MOTION].cssIS + stack_size[PG_HITD_MOTION].cssAH);
trace_css = std::max(trace_css,
stack_size[PG_HITS_MOTION].cssIS + stack_size[PG_HITS_MOTION].cssAH);
# endif
OptixPipelineLinkOptions link_options;
link_options.maxTraceDepth = 1;
@@ -503,17 +563,23 @@ class OptiXDevice : public CUDADevice {
# else
link_options.debugLevel = OPTIX_COMPILE_DEBUG_LEVEL_LINEINFO;
# endif
link_options.overrideUsesMotionBlur = pipeline_options.usesMotionBlur;
# if OPTIX_ABI_VERSION < 24
link_options.overrideUsesMotionBlur = motion_blur;
# endif
{ // Create path tracing pipeline
OptixProgramGroup pipeline_groups[] = {
groups[PG_RGEN],
groups[PG_MISS],
groups[PG_HITD],
groups[PG_HITS],
groups[PG_HITL],
groups[PG_RGEN],
groups[PG_MISS],
groups[PG_HITD],
groups[PG_HITS],
groups[PG_HITL],
# if OPTIX_ABI_VERSION >= 36
groups[PG_HITD_MOTION],
groups[PG_HITS_MOTION],
# endif
# ifdef WITH_CYCLES_DEBUG
groups[PG_EXCP],
groups[PG_EXCP],
# endif
};
check_result_optix_ret(
@@ -530,8 +596,8 @@ class OptiXDevice : public CUDADevice {
const unsigned int css = stack_size[PG_RGEN].cssRG + link_options.maxTraceDepth * trace_css;
// Set stack size depending on pipeline options
check_result_optix_ret(optixPipelineSetStackSize(
pipelines[PIP_PATH_TRACE], 0, 0, css, (pipeline_options.usesMotionBlur ? 3 : 2)));
check_result_optix_ret(
optixPipelineSetStackSize(pipelines[PIP_PATH_TRACE], 0, 0, css, (motion_blur ? 3 : 2)));
}
// Only need to create shader evaluation pipeline if one of these features is used:
@@ -541,15 +607,19 @@ class OptiXDevice : public CUDADevice {
if (use_shader_eval_pipeline) { // Create shader evaluation pipeline
OptixProgramGroup pipeline_groups[] = {
groups[PG_BAKE],
groups[PG_DISP],
groups[PG_BACK],
groups[PG_MISS],
groups[PG_HITD],
groups[PG_HITS],
groups[PG_HITL],
groups[PG_BAKE],
groups[PG_DISP],
groups[PG_BACK],
groups[PG_MISS],
groups[PG_HITD],
groups[PG_HITS],
groups[PG_HITL],
# if OPTIX_ABI_VERSION >= 36
groups[PG_HITD_MOTION],
groups[PG_HITS_MOTION],
# endif
# ifdef WITH_CYCLES_DEBUG
groups[PG_EXCP],
groups[PG_EXCP],
# endif
};
check_result_optix_ret(
@@ -672,7 +742,11 @@ class OptiXDevice : public CUDADevice {
sbt_params.missRecordCount = 1;
sbt_params.hitgroupRecordBase = sbt_data.device_pointer + PG_HITD * sizeof(SbtRecord);
sbt_params.hitgroupRecordStrideInBytes = sizeof(SbtRecord);
sbt_params.hitgroupRecordCount = 3; // PG_HITD, PG_HITL, PG_HITS
# if OPTIX_ABI_VERSION >= 36
sbt_params.hitgroupRecordCount = 5; // PG_HITD(_MOTION), PG_HITS(_MOTION), PG_HITL
# else
sbt_params.hitgroupRecordCount = 3; // PG_HITD, PG_HITS, PG_HITL
# endif
// Launch the ray generation program
check_result_optix(optixLaunch(pipelines[PIP_PATH_TRACE],
@@ -727,19 +801,18 @@ class OptiXDevice : public CUDADevice {
// 0 1 2
// 3 4 5
// 6 7 8 9
RenderTile rtiles[10];
rtiles[4] = rtile;
task.map_neighbor_tiles(rtiles, this);
rtile = rtiles[4]; // Tile may have been modified by mapping code
RenderTileNeighbors neighbors(rtile);
task.map_neighbor_tiles(neighbors, this);
RenderTile &center_tile = neighbors.tiles[RenderTileNeighbors::CENTER];
RenderTile &target_tile = neighbors.target;
rtile = center_tile; // Tile may have been modified by mapping code
// Calculate size of the tile to denoise (including overlap)
int4 rect = make_int4(
rtiles[4].x, rtiles[4].y, rtiles[4].x + rtiles[4].w, rtiles[4].y + rtiles[4].h);
int4 rect = center_tile.bounds();
// Overlap between tiles has to be at least 64 pixels
// TODO(pmours): Query this value from OptiX
rect = rect_expand(rect, 64);
int4 clip_rect = make_int4(
rtiles[3].x, rtiles[1].y, rtiles[5].x + rtiles[5].w, rtiles[7].y + rtiles[7].h);
int4 clip_rect = neighbors.bounds();
rect = rect_clip(rect, clip_rect);
int2 rect_size = make_int2(rect.z - rect.x, rect.w - rect.y);
int2 overlap_offset = make_int2(rtile.x - rect.x, rtile.y - rect.y);
@@ -760,14 +833,14 @@ class OptiXDevice : public CUDADevice {
device_only_memory<float> input(this, "denoiser input");
device_vector<TileInfo> tile_info_mem(this, "denoiser tile info", MEM_READ_WRITE);
if ((!rtiles[0].buffer || rtiles[0].buffer == rtile.buffer) &&
(!rtiles[1].buffer || rtiles[1].buffer == rtile.buffer) &&
(!rtiles[2].buffer || rtiles[2].buffer == rtile.buffer) &&
(!rtiles[3].buffer || rtiles[3].buffer == rtile.buffer) &&
(!rtiles[5].buffer || rtiles[5].buffer == rtile.buffer) &&
(!rtiles[6].buffer || rtiles[6].buffer == rtile.buffer) &&
(!rtiles[7].buffer || rtiles[7].buffer == rtile.buffer) &&
(!rtiles[8].buffer || rtiles[8].buffer == rtile.buffer)) {
bool contiguous_memory = true;
for (int i = 0; i < RenderTileNeighbors::SIZE; i++) {
if (neighbors.tiles[i].buffer && neighbors.tiles[i].buffer != rtile.buffer) {
contiguous_memory = false;
}
}
if (contiguous_memory) {
// Tiles are in continous memory, so can just subtract overlap offset
input_ptr -= (overlap_offset.x + overlap_offset.y * rtile.stride) * pixel_stride;
// Stride covers the whole width of the image and not just a single tile
@@ -782,19 +855,19 @@ class OptiXDevice : public CUDADevice {
input_stride *= rect_size.x;
TileInfo *tile_info = tile_info_mem.alloc(1);
for (int i = 0; i < 9; i++) {
tile_info->offsets[i] = rtiles[i].offset;
tile_info->strides[i] = rtiles[i].stride;
tile_info->buffers[i] = rtiles[i].buffer;
for (int i = 0; i < RenderTileNeighbors::SIZE; i++) {
tile_info->offsets[i] = neighbors.tiles[i].offset;
tile_info->strides[i] = neighbors.tiles[i].stride;
tile_info->buffers[i] = neighbors.tiles[i].buffer;
}
tile_info->x[0] = rtiles[3].x;
tile_info->x[1] = rtiles[4].x;
tile_info->x[2] = rtiles[5].x;
tile_info->x[3] = rtiles[5].x + rtiles[5].w;
tile_info->y[0] = rtiles[1].y;
tile_info->y[1] = rtiles[4].y;
tile_info->y[2] = rtiles[7].y;
tile_info->y[3] = rtiles[7].y + rtiles[7].h;
tile_info->x[0] = neighbors.tiles[3].x;
tile_info->x[1] = neighbors.tiles[4].x;
tile_info->x[2] = neighbors.tiles[5].x;
tile_info->x[3] = neighbors.tiles[5].x + neighbors.tiles[5].w;
tile_info->y[0] = neighbors.tiles[1].y;
tile_info->y[1] = neighbors.tiles[4].y;
tile_info->y[2] = neighbors.tiles[7].y;
tile_info->y[3] = neighbors.tiles[7].y + neighbors.tiles[7].h;
tile_info_mem.copy_to_device();
void *args[] = {
@@ -804,7 +877,7 @@ class OptiXDevice : public CUDADevice {
# if OPTIX_DENOISER_NO_PIXEL_STRIDE
device_only_memory<float> input_rgb(this, "denoiser input rgb");
input_rgb.alloc_to_device(rect_size.x * rect_size.y * 3 * task.denoising.optix_input_passes);
input_rgb.alloc_to_device(rect_size.x * rect_size.y * 3 * task.denoising.input_passes);
void *input_args[] = {&input_rgb.device_pointer,
&input_ptr,
@@ -813,7 +886,7 @@ class OptiXDevice : public CUDADevice {
&input_stride,
&task.pass_stride,
const_cast<int *>(pass_offset),
&task.denoising.optix_input_passes,
&task.denoising.input_passes,
&rtile.sample};
launch_filter_kernel(
"kernel_cuda_filter_convert_to_rgb", rect_size.x, rect_size.y, input_args);
@@ -824,7 +897,7 @@ class OptiXDevice : public CUDADevice {
# endif
const bool recreate_denoiser = (denoiser == NULL) ||
(task.denoising.optix_input_passes != denoiser_input_passes);
(task.denoising.input_passes != denoiser_input_passes);
if (recreate_denoiser) {
// Destroy existing handle before creating new one
if (denoiser != NULL) {
@@ -833,23 +906,29 @@ class OptiXDevice : public CUDADevice {
// Create OptiX denoiser handle on demand when it is first used
OptixDenoiserOptions denoiser_options;
assert(task.denoising.optix_input_passes >= 1 && task.denoising.optix_input_passes <= 3);
assert(task.denoising.input_passes >= 1 && task.denoising.input_passes <= 3);
denoiser_options.inputKind = static_cast<OptixDenoiserInputKind>(
OPTIX_DENOISER_INPUT_RGB + (task.denoising.optix_input_passes - 1));
OPTIX_DENOISER_INPUT_RGB + (task.denoising.input_passes - 1));
# if OPTIX_ABI_VERSION < 28
denoiser_options.pixelFormat = OPTIX_PIXEL_FORMAT_FLOAT3;
# endif
check_result_optix_ret(optixDenoiserCreate(context, &denoiser_options, &denoiser));
check_result_optix_ret(
optixDenoiserSetModel(denoiser, OPTIX_DENOISER_MODEL_KIND_HDR, NULL, 0));
// OptiX denoiser handle was created with the requested number of input passes
denoiser_input_passes = task.denoising.optix_input_passes;
denoiser_input_passes = task.denoising.input_passes;
}
OptixDenoiserSizes sizes = {};
check_result_optix_ret(
optixDenoiserComputeMemoryResources(denoiser, rect_size.x, rect_size.y, &sizes));
# if OPTIX_ABI_VERSION < 28
const size_t scratch_size = sizes.recommendedScratchSizeInBytes;
# else
const size_t scratch_size = sizes.withOverlapScratchSizeInBytes;
# endif
const size_t scratch_offset = sizes.stateSizeInBytes;
// Allocate denoiser state if tile size has changed since last setup
@@ -897,10 +976,10 @@ class OptiXDevice : public CUDADevice {
int2 output_offset = overlap_offset;
overlap_offset = make_int2(0, 0); // Not supported by denoiser API, so apply manually
# else
output_layers[0].data = rtiles[9].buffer + pixel_offset;
output_layers[0].width = rtiles[9].w;
output_layers[0].height = rtiles[9].h;
output_layers[0].rowStrideInBytes = rtiles[9].stride * pixel_stride;
output_layers[0].data = target_tile.buffer + pixel_offset;
output_layers[0].width = target_tile.w;
output_layers[0].height = target_tile.h;
output_layers[0].rowStrideInBytes = target_tile.stride * pixel_stride;
output_layers[0].pixelStrideInBytes = pixel_stride;
# endif
output_layers[0].format = OPTIX_PIXEL_FORMAT_FLOAT3;
@@ -913,7 +992,7 @@ class OptiXDevice : public CUDADevice {
denoiser_state.device_pointer,
scratch_offset,
input_layers,
task.denoising.optix_input_passes,
task.denoising.input_passes,
overlap_offset.x,
overlap_offset.y,
output_layers,
@@ -922,26 +1001,26 @@ class OptiXDevice : public CUDADevice {
# if OPTIX_DENOISER_NO_PIXEL_STRIDE
void *output_args[] = {&input_ptr,
&rtiles[9].buffer,
&target_tile.buffer,
&output_offset.x,
&output_offset.y,
&rect_size.x,
&rect_size.y,
&rtiles[9].x,
&rtiles[9].y,
&rtiles[9].w,
&rtiles[9].h,
&rtiles[9].offset,
&rtiles[9].stride,
&target_tile.x,
&target_tile.y,
&target_tile.w,
&target_tile.h,
&target_tile.offset,
&target_tile.stride,
&task.pass_stride,
&rtile.sample};
launch_filter_kernel(
"kernel_cuda_filter_convert_from_rgb", rtiles[9].w, rtiles[9].h, output_args);
"kernel_cuda_filter_convert_from_rgb", target_tile.w, target_tile.h, output_args);
# endif
check_result_cuda_ret(cuStreamSynchronize(0));
task.unmap_neighbor_tiles(rtiles, this);
task.unmap_neighbor_tiles(neighbors, this);
}
else {
// Run CUDA denoising kernels
@@ -993,7 +1072,11 @@ class OptiXDevice : public CUDADevice {
sbt_params.missRecordCount = 1;
sbt_params.hitgroupRecordBase = sbt_data.device_pointer + PG_HITD * sizeof(SbtRecord);
sbt_params.hitgroupRecordStrideInBytes = sizeof(SbtRecord);
sbt_params.hitgroupRecordCount = 3; // PG_HITD, PG_HITL, PG_HITS
# if OPTIX_ABI_VERSION >= 36
sbt_params.hitgroupRecordCount = 5; // PG_HITD(_MOTION), PG_HITS(_MOTION), PG_HITL
# else
sbt_params.hitgroupRecordCount = 3; // PG_HITD, PG_HITS, PG_HITL
# endif
check_result_optix(optixLaunch(pipelines[PIP_SHADER_EVAL],
cuda_stream[thread_index],
@@ -1070,7 +1153,7 @@ class OptiXDevice : public CUDADevice {
&build_input,
1,
temp_mem.device_pointer,
temp_mem.device_size,
sizes.tempSizeInBytes,
out_data,
sizes.outputSizeInBytes,
&out_handle,
@@ -1142,7 +1225,6 @@ class OptiXDevice : public CUDADevice {
continue;
}
const size_t num_curves = hair->num_curves();
const size_t num_segments = hair->num_segments();
size_t num_motion_steps = 1;
@@ -1152,7 +1234,18 @@ class OptiXDevice : public CUDADevice {
}
device_vector<OptixAabb> aabb_data(this, "temp_aabb_data", MEM_READ_ONLY);
aabb_data.alloc(num_segments * num_motion_steps);
# if OPTIX_ABI_VERSION >= 36
device_vector<int> index_data(this, "temp_index_data", MEM_READ_ONLY);
device_vector<float4> vertex_data(this, "temp_vertex_data", MEM_READ_ONLY);
// Four control points for each curve segment
const size_t num_vertices = num_segments * 4;
if (DebugFlags().optix.curves_api && hair->curve_shape == CURVE_THICK) {
index_data.alloc(num_segments);
vertex_data.alloc(num_vertices * num_motion_steps);
}
else
# endif
aabb_data.alloc(num_segments * num_motion_steps);
// Get AABBs for each motion step
for (size_t step = 0; step < num_motion_steps; ++step) {
@@ -1165,44 +1258,127 @@ class OptiXDevice : public CUDADevice {
keys = motion_keys->data_float3() + attr_offset * hair->curve_keys.size();
}
size_t i = step * num_segments;
for (size_t j = 0; j < num_curves; ++j) {
const Hair::Curve c = hair->get_curve(j);
for (size_t j = 0, i = 0; j < hair->num_curves(); ++j) {
const Hair::Curve curve = hair->get_curve(j);
for (size_t k = 0; k < c.num_segments(); ++i, ++k) {
BoundBox bounds = BoundBox::empty;
c.bounds_grow(k, keys, hair->curve_radius.data(), bounds);
for (int segment = 0; segment < curve.num_segments(); ++segment, ++i) {
# if OPTIX_ABI_VERSION >= 36
if (DebugFlags().optix.curves_api && hair->curve_shape == CURVE_THICK) {
int k0 = curve.first_key + segment;
int k1 = k0 + 1;
int ka = max(k0 - 1, curve.first_key);
int kb = min(k1 + 1, curve.first_key + curve.num_keys - 1);
aabb_data[i].minX = bounds.min.x;
aabb_data[i].minY = bounds.min.y;
aabb_data[i].minZ = bounds.min.z;
aabb_data[i].maxX = bounds.max.x;
aabb_data[i].maxY = bounds.max.y;
aabb_data[i].maxZ = bounds.max.z;
const float4 px = make_float4(keys[ka].x, keys[k0].x, keys[k1].x, keys[kb].x);
const float4 py = make_float4(keys[ka].y, keys[k0].y, keys[k1].y, keys[kb].y);
const float4 pz = make_float4(keys[ka].z, keys[k0].z, keys[k1].z, keys[kb].z);
const float4 pw = make_float4(hair->curve_radius[ka],
hair->curve_radius[k0],
hair->curve_radius[k1],
hair->curve_radius[kb]);
// Convert Catmull-Rom data to Bezier spline
static const float4 cr2bsp0 = make_float4(+7, -4, +5, -2) / 6.f;
static const float4 cr2bsp1 = make_float4(-2, 11, -4, +1) / 6.f;
static const float4 cr2bsp2 = make_float4(+1, -4, 11, -2) / 6.f;
static const float4 cr2bsp3 = make_float4(-2, +5, -4, +7) / 6.f;
index_data[i] = i * 4;
float4 *const v = vertex_data.data() + step * num_vertices + index_data[i];
v[0] = make_float4(
dot(cr2bsp0, px), dot(cr2bsp0, py), dot(cr2bsp0, pz), dot(cr2bsp0, pw));
v[1] = make_float4(
dot(cr2bsp1, px), dot(cr2bsp1, py), dot(cr2bsp1, pz), dot(cr2bsp1, pw));
v[2] = make_float4(
dot(cr2bsp2, px), dot(cr2bsp2, py), dot(cr2bsp2, pz), dot(cr2bsp2, pw));
v[3] = make_float4(
dot(cr2bsp3, px), dot(cr2bsp3, py), dot(cr2bsp3, pz), dot(cr2bsp3, pw));
}
else
# endif
{
BoundBox bounds = BoundBox::empty;
curve.bounds_grow(segment, keys, hair->curve_radius.data(), bounds);
const size_t index = step * num_segments + i;
aabb_data[index].minX = bounds.min.x;
aabb_data[index].minY = bounds.min.y;
aabb_data[index].minZ = bounds.min.z;
aabb_data[index].maxX = bounds.max.x;
aabb_data[index].maxY = bounds.max.y;
aabb_data[index].maxZ = bounds.max.z;
}
}
}
}
// Upload AABB data to GPU
aabb_data.copy_to_device();
# if OPTIX_ABI_VERSION >= 36
index_data.copy_to_device();
vertex_data.copy_to_device();
# endif
vector<device_ptr> aabb_ptrs;
aabb_ptrs.reserve(num_motion_steps);
# if OPTIX_ABI_VERSION >= 36
vector<device_ptr> width_ptrs;
vector<device_ptr> vertex_ptrs;
width_ptrs.reserve(num_motion_steps);
vertex_ptrs.reserve(num_motion_steps);
# endif
for (size_t step = 0; step < num_motion_steps; ++step) {
aabb_ptrs.push_back(aabb_data.device_pointer + step * num_segments * sizeof(OptixAabb));
# if OPTIX_ABI_VERSION >= 36
const device_ptr base_ptr = vertex_data.device_pointer +
step * num_vertices * sizeof(float4);
width_ptrs.push_back(base_ptr + 3 * sizeof(float)); // Offset by vertex size
vertex_ptrs.push_back(base_ptr);
# endif
}
// Disable visibility test anyhit program, since it is already checked during intersection
// Those trace calls that require anyhit can force it with OPTIX_RAY_FLAG_ENFORCE_ANYHIT
unsigned int build_flags = OPTIX_GEOMETRY_FLAG_DISABLE_ANYHIT;
// Force a single any-hit call, so shadow record-all behavior works correctly
unsigned int build_flags = OPTIX_GEOMETRY_FLAG_REQUIRE_SINGLE_ANYHIT_CALL;
OptixBuildInput build_input = {};
build_input.type = OPTIX_BUILD_INPUT_TYPE_CUSTOM_PRIMITIVES;
build_input.aabbArray.aabbBuffers = (CUdeviceptr *)aabb_ptrs.data();
build_input.aabbArray.numPrimitives = num_segments;
build_input.aabbArray.strideInBytes = sizeof(OptixAabb);
build_input.aabbArray.flags = &build_flags;
build_input.aabbArray.numSbtRecords = 1;
build_input.aabbArray.primitiveIndexOffset = hair->optix_prim_offset;
# if OPTIX_ABI_VERSION >= 36
if (DebugFlags().optix.curves_api && hair->curve_shape == CURVE_THICK) {
build_input.type = OPTIX_BUILD_INPUT_TYPE_CURVES;
build_input.curveArray.curveType = OPTIX_PRIMITIVE_TYPE_ROUND_CUBIC_BSPLINE;
build_input.curveArray.numPrimitives = num_segments;
build_input.curveArray.vertexBuffers = (CUdeviceptr *)vertex_ptrs.data();
build_input.curveArray.numVertices = num_vertices;
build_input.curveArray.vertexStrideInBytes = sizeof(float4);
build_input.curveArray.widthBuffers = (CUdeviceptr *)width_ptrs.data();
build_input.curveArray.widthStrideInBytes = sizeof(float4);
build_input.curveArray.indexBuffer = (CUdeviceptr)index_data.device_pointer;
build_input.curveArray.indexStrideInBytes = sizeof(int);
build_input.curveArray.flag = build_flags;
build_input.curveArray.primitiveIndexOffset = hair->optix_prim_offset;
}
else
# endif
{
// Disable visibility test any-hit program, since it is already checked during
// intersection. Those trace calls that require anyhit can force it with a ray flag.
build_flags |= OPTIX_GEOMETRY_FLAG_DISABLE_ANYHIT;
build_input.type = OPTIX_BUILD_INPUT_TYPE_CUSTOM_PRIMITIVES;
# if OPTIX_ABI_VERSION < 23
build_input.aabbArray.aabbBuffers = (CUdeviceptr *)aabb_ptrs.data();
build_input.aabbArray.numPrimitives = num_segments;
build_input.aabbArray.strideInBytes = sizeof(OptixAabb);
build_input.aabbArray.flags = &build_flags;
build_input.aabbArray.numSbtRecords = 1;
build_input.aabbArray.primitiveIndexOffset = hair->optix_prim_offset;
# else
build_input.customPrimitiveArray.aabbBuffers = (CUdeviceptr *)aabb_ptrs.data();
build_input.customPrimitiveArray.numPrimitives = num_segments;
build_input.customPrimitiveArray.strideInBytes = sizeof(OptixAabb);
build_input.customPrimitiveArray.flags = &build_flags;
build_input.customPrimitiveArray.numSbtRecords = 1;
build_input.customPrimitiveArray.primitiveIndexOffset = hair->optix_prim_offset;
# endif
}
// Allocate memory for new BLAS and build it
OptixTraversableHandle handle;
@@ -1257,8 +1433,8 @@ class OptiXDevice : public CUDADevice {
vertex_ptrs.push_back(vertex_data.device_pointer + num_verts * step * sizeof(float3));
}
// No special build flags for triangle primitives
unsigned int build_flags = OPTIX_GEOMETRY_FLAG_NONE;
// Force a single any-hit call, so shadow record-all behavior works correctly
unsigned int build_flags = OPTIX_GEOMETRY_FLAG_REQUIRE_SINGLE_ANYHIT_CALL;
OptixBuildInput build_input = {};
build_input.type = OPTIX_BUILD_INPUT_TYPE_TRIANGLES;
build_input.triangleArray.vertexBuffers = (CUdeviceptr *)vertex_ptrs.data();
@@ -1324,9 +1500,26 @@ class OptiXDevice : public CUDADevice {
// Set user instance ID to object index
instance.instanceId = ob->get_device_index();
// Volumes have a special bit set in the visibility mask so a trace can mask only volumes
// See 'scene_intersect_volume' in bvh.h
instance.visibilityMask = (ob->geometry->has_volume ? 3 : 1);
// Have to have at least one bit in the mask, or else instance would always be culled
instance.visibilityMask = 1;
if (ob->geometry->has_volume) {
// Volumes have a special bit set in the visibility mask so a trace can mask only volumes
instance.visibilityMask |= 2;
}
if (ob->geometry->type == Geometry::HAIR) {
// Same applies to curves (so they can be skipped in local trace calls)
instance.visibilityMask |= 4;
# if OPTIX_ABI_VERSION >= 36
if (motion_blur && ob->geometry->has_motion_blur() && DebugFlags().optix.curves_api &&
static_cast<const Hair *>(ob->geometry)->curve_shape == CURVE_THICK) {
// Select between motion blur and non-motion blur built-in intersection module
instance.sbtOffset = PG_HITD_MOTION - PG_HITD;
}
# endif
}
// Insert motion traversable if object has motion
if (motion_blur && ob->use_motion()) {

View File

@@ -29,6 +29,7 @@ CCL_NAMESPACE_BEGIN
class Device;
class RenderBuffers;
class RenderTile;
class RenderTileNeighbors;
class Tile;
enum DenoiserType {
@@ -41,6 +42,14 @@ enum DenoiserType {
DENOISER_ALL = ~0,
};
enum DenoiserInput {
DENOISER_INPUT_RGB = 1,
DENOISER_INPUT_RGB_ALBEDO = 2,
DENOISER_INPUT_RGB_ALBEDO_NORMAL = 3,
DENOISER_INPUT_NUM,
};
typedef int DenoiserTypeMask;
class DenoiseParams {
@@ -72,10 +81,10 @@ class DenoiseParams {
/* Clamp the input to the range of +-1e8. Should be enough for any legitimate data. */
bool clamp_input;
/** Optix Denoiser **/
/** OIDN/Optix Denoiser **/
/* Passes handed over to the OptiX denoiser (default to color + albedo). */
int optix_input_passes;
/* Passes handed over to the OIDN/OptiX denoiser (default to color + albedo). */
DenoiserInput input_passes;
DenoiseParams()
{
@@ -91,7 +100,7 @@ class DenoiseParams {
neighbor_frames = 2;
clamp_input = true;
optix_input_passes = 2;
input_passes = DENOISER_INPUT_RGB_ALBEDO_NORMAL;
start_sample = 0;
}
@@ -150,8 +159,8 @@ class DeviceTask {
function<void(RenderTile &)> update_tile_sample;
function<void(RenderTile &)> release_tile;
function<bool()> get_cancel;
function<void(RenderTile *, Device *)> map_neighbor_tiles;
function<void(RenderTile *, Device *)> unmap_neighbor_tiles;
function<void(RenderTileNeighbors &, Device *)> map_neighbor_tiles;
function<void(RenderTileNeighbors &, Device *)> unmap_neighbor_tiles;
uint tile_types;
DenoiseParams denoising;

View File

@@ -1850,7 +1850,7 @@ void OpenCLDevice::denoise(RenderTile &rtile, DenoisingTask &denoising)
denoising.render_buffer.samples = rtile.sample;
denoising.buffer.gpu_temporary_mem = true;
denoising.run_denoising(&rtile);
denoising.run_denoising(rtile);
}
void OpenCLDevice::shader(DeviceTask &task)

View File

@@ -64,6 +64,9 @@ void MemoryManager::DeviceBuffer::update_device_memory(OpenCLDevice *device)
total_size += alloc_size;
}
/* Always allocate non-empty buffer, NULL pointers cause problems with some drivers. */
total_size = max(total_size, 16);
if (need_realloc) {
cl_ulong max_buffer_size;
clGetDeviceInfo(
@@ -251,7 +254,7 @@ void MemoryManager::set_kernel_arg_buffers(cl_kernel kernel, cl_uint *narg)
device->kernel_set_args(kernel, (*narg)++, *device_buffer.buffer);
}
else {
device->kernel_set_args(kernel, (*narg)++, 0);
device->kernel_set_args(kernel, (*narg)++);
}
}
}

View File

@@ -172,11 +172,11 @@ ccl_device_intersect bool scene_intersect(KernelGlobals *kg,
0.0f,
ray->t,
ray->time,
0xFF,
0xF,
OPTIX_RAY_FLAG_NONE,
0,
0,
0, // SBT offset for PG_HITD
0,
0,
p0,
p1,
p2,
@@ -264,12 +264,13 @@ ccl_device_intersect bool scene_intersect_local(KernelGlobals *kg,
0.0f,
ray->t,
ray->time,
// Skip curves
0x3,
// Need to always call into __anyhit__kernel_optix_local_hit
0xFF,
OPTIX_RAY_FLAG_ENFORCE_ANYHIT,
1,
2, // SBT offset for PG_HITL
0,
0,
0, // SBT offset for PG_HITL
p0,
p1,
p2,
@@ -374,12 +375,12 @@ ccl_device_intersect bool scene_intersect_shadow_all(KernelGlobals *kg,
0.0f,
ray->t,
ray->time,
0xF,
// Need to always call into __anyhit__kernel_optix_shadow_all_hit
0xFF,
OPTIX_RAY_FLAG_ENFORCE_ANYHIT,
2,
1, // SBT offset for PG_HITS
0,
0,
0, // SBT offset for PG_HITS
p0,
p1,
*num_hits,
@@ -458,12 +459,12 @@ ccl_device_intersect bool scene_intersect_volume(KernelGlobals *kg,
0.0f,
ray->t,
ray->time,
// Visibility mask set to only intersect objects with volumes
0x02,
// Skip everything but volumes
0x2,
OPTIX_RAY_FLAG_NONE,
0,
0,
0, // SBT offset for PG_HITD
0,
0,
p0,
p1,
p2,

View File

@@ -734,7 +734,6 @@ ccl_device_inline void curve_shader_setup(KernelGlobals *kg,
}
sd->u = isect->u;
sd->v = isect->v;
P = P + D * t;
@@ -750,6 +749,7 @@ ccl_device_inline void curve_shader_setup(KernelGlobals *kg,
sd->N = normalize(sine * bitangent - cosine * normalize(cross(tangent, bitangent)));
sd->Ng = -D;
sd->v = isect->v;
# if 0
/* This approximates the position and geometric normal of a thick curve too,
@@ -764,8 +764,11 @@ ccl_device_inline void curve_shader_setup(KernelGlobals *kg,
* This could be optimized by recording the normal in the intersection,
* however for Optix this would go beyond the size of the payload. */
const float3 P_inside = float4_to_float3(catmull_rom_basis_eval(P_curve, isect->u));
sd->Ng = normalize(P - P_inside);
sd->N = sd->Ng;
const float3 Ng = normalize(P - P_inside);
sd->N = Ng;
sd->Ng = Ng;
sd->v = 0.0f;
}
# ifdef __DPDU__

View File

@@ -379,7 +379,7 @@ ccl_device_inline void camera_sample(KernelGlobals *kg,
const int shutter_table_offset = kernel_data.cam.shutter_table_offset;
ray->time = lookup_table_read(kg, time, shutter_table_offset, SHUTTER_TABLE_SIZE);
/* TODO(sergey): Currently single rolling shutter effect type only
* where scan-lines are acquired from top to bottom and whole scanline
* where scan-lines are acquired from top to bottom and whole scan-line
* is acquired at once (no delay in acquisition happens between pixels
* of single scan-line).
*

View File

@@ -284,19 +284,11 @@ ccl_device_forceinline bool kernel_path_shader_apply(KernelGlobals *kg,
#ifdef __HOLDOUT__
if (((sd->flag & SD_HOLDOUT) || (sd->object_flag & SD_OBJECT_HOLDOUT_MASK)) &&
(state->flag & PATH_RAY_TRANSPARENT_BACKGROUND)) {
const float3 holdout_weight = shader_holdout_apply(kg, sd);
if (kernel_data.background.transparent) {
float3 holdout_weight;
if (sd->object_flag & SD_OBJECT_HOLDOUT_MASK) {
holdout_weight = make_float3(1.0f, 1.0f, 1.0f);
}
else {
holdout_weight = shader_holdout_eval(kg, sd);
}
/* any throughput is ok, should all be identical here */
L->transparent += average(holdout_weight * throughput);
}
if (sd->object_flag & SD_OBJECT_HOLDOUT_MASK) {
if (isequal_float3(holdout_weight, make_float3(1.0f, 1.0f, 1.0f))) {
return false;
}
}

View File

@@ -1017,15 +1017,36 @@ ccl_device float3 shader_emissive_eval(ShaderData *sd)
/* Holdout */
ccl_device float3 shader_holdout_eval(KernelGlobals *kg, ShaderData *sd)
ccl_device float3 shader_holdout_apply(KernelGlobals *kg, ShaderData *sd)
{
float3 weight = make_float3(0.0f, 0.0f, 0.0f);
for (int i = 0; i < sd->num_closure; i++) {
ShaderClosure *sc = &sd->closure[i];
/* For objects marked as holdout, preserve transparency and remove all other
* closures, replacing them with a holdout weight. */
if (sd->object_flag & SD_OBJECT_HOLDOUT_MASK) {
if ((sd->flag & SD_TRANSPARENT) && !(sd->flag & SD_HAS_ONLY_VOLUME)) {
weight = make_float3(1.0f, 1.0f, 1.0f) - sd->closure_transparent_extinction;
if (CLOSURE_IS_HOLDOUT(sc->type))
weight += sc->weight;
for (int i = 0; i < sd->num_closure; i++) {
ShaderClosure *sc = &sd->closure[i];
if (!CLOSURE_IS_BSDF_TRANSPARENT(sc->type)) {
sc->type = NBUILTIN_CLOSURES;
}
}
sd->flag &= ~(SD_CLOSURE_FLAGS - (SD_TRANSPARENT | SD_BSDF));
}
else {
weight = make_float3(1.0f, 1.0f, 1.0f);
}
}
else {
for (int i = 0; i < sd->num_closure; i++) {
ShaderClosure *sc = &sd->closure[i];
if (CLOSURE_IS_HOLDOUT(sc->type)) {
weight += sc->weight;
}
}
}
return weight;

View File

@@ -15,6 +15,7 @@
* limitations under the License.
*/
// clang-format off
#include "kernel/kernel_compat_optix.h"
#include "util/util_atomic.h"
#include "kernel/kernel_types.h"
@@ -23,6 +24,7 @@
#include "kernel/kernel_path.h"
#include "kernel/kernel_bake.h"
// clang-format on
template<typename T> ccl_device_forceinline T *get_payload_ptr_0()
{
@@ -139,8 +141,8 @@ extern "C" __global__ void __anyhit__kernel_optix_local_hit()
}
else {
if (local_isect->num_hits && optixGetRayTmax() > local_isect->hits[0].t) {
// Record closest intersection only (do not terminate ray here, since there is no guarantee
// about distance ordering in anyhit)
// Record closest intersection only
// Do not terminate ray here, since there is no guarantee about distance ordering in any-hit
return optixIgnoreIntersection();
}
@@ -153,15 +155,9 @@ extern "C" __global__ void __anyhit__kernel_optix_local_hit()
isect->object = get_object_id();
isect->type = kernel_tex_fetch(__prim_type, isect->prim);
if (optixIsTriangleHit()) {
const float2 barycentrics = optixGetTriangleBarycentrics();
isect->u = 1.0f - barycentrics.y - barycentrics.x;
isect->v = barycentrics.x;
}
else {
isect->u = __uint_as_float(optixGetAttribute_0());
isect->v = __uint_as_float(optixGetAttribute_1());
}
const float2 barycentrics = optixGetTriangleBarycentrics();
isect->u = 1.0f - barycentrics.y - barycentrics.x;
isect->v = barycentrics.x;
// Record geometric normal
const uint tri_vindex = kernel_tex_fetch(__prim_tri_index, isect->prim);
@@ -198,10 +194,18 @@ extern "C" __global__ void __anyhit__kernel_optix_shadow_all_hit()
isect->u = 1.0f - barycentrics.y - barycentrics.x;
isect->v = barycentrics.x;
}
# ifdef __HAIR__
else {
isect->u = __uint_as_float(optixGetAttribute_0());
const float u = __uint_as_float(optixGetAttribute_0());
isect->u = u;
isect->v = __uint_as_float(optixGetAttribute_1());
// Filter out curve endcaps
if (u == 0.0f || u == 1.0f) {
return optixIgnoreIntersection();
}
}
# endif
# ifdef __TRANSPARENT_SHADOWS__
// Detect if this surface has a shader with transparent shadows
@@ -213,7 +217,6 @@ extern "C" __global__ void __anyhit__kernel_optix_shadow_all_hit()
# ifdef __TRANSPARENT_SHADOWS__
}
// TODO(pmours): Do we need REQUIRE_UNIQUE_ANYHIT for this to work?
optixSetPayload_2(optixGetPayload_2() + 1); // num_hits++
// Continue tracing
@@ -227,13 +230,25 @@ extern "C" __global__ void __anyhit__kernel_optix_visibility_test()
uint visibility = optixGetPayload_4();
#ifdef __VISIBILITY_FLAG__
const uint prim = optixGetPrimitiveIndex();
if ((kernel_tex_fetch(__prim_visibility, prim) & visibility) == 0)
if ((kernel_tex_fetch(__prim_visibility, prim) & visibility) == 0) {
return optixIgnoreIntersection();
}
#endif
#ifdef __HAIR__
if (!optixIsTriangleHit()) {
// Filter out curve endcaps
const float u = __uint_as_float(optixGetAttribute_0());
if (u == 0.0f || u == 1.0f) {
return optixIgnoreIntersection();
}
}
#endif
// Shadow ray early termination
if (visibility & PATH_RAY_SHADOW_OPAQUE)
if (visibility & PATH_RAY_SHADOW_OPAQUE) {
return optixTerminateRay();
}
}
extern "C" __global__ void __closesthit__kernel_optix_hit()
@@ -250,7 +265,7 @@ extern "C" __global__ void __closesthit__kernel_optix_hit()
optixSetPayload_2(__float_as_uint(barycentrics.x));
}
else {
optixSetPayload_1(optixGetAttribute_0());
optixSetPayload_1(optixGetAttribute_0()); // Same as 'optixGetCurveParameter()'
optixSetPayload_2(optixGetAttribute_1());
}
}
@@ -286,7 +301,6 @@ ccl_device_inline void optix_intersection_curve(const uint prim, const uint type
__float_as_int(isect.u), // Attribute_0
__float_as_int(isect.v)); // Attribute_1
}
}
extern "C" __global__ void __intersection__curve_ribbon()

View File

@@ -122,12 +122,18 @@ vector geographical_to_direction(float lat, float lon)
return vector(cos(lat) * cos(lon), cos(lat) * sin(lon), sin(lat));
}
color sky_radiance_nishita(vector dir, float nishita_data[9], string filename)
float precise_angle(vector a, vector b)
{
return 2.0 * atan2(length(a - b), length(a + b));
}
color sky_radiance_nishita(vector dir, float nishita_data[10], string filename)
{
/* definitions */
float sun_elevation = nishita_data[6];
float sun_rotation = nishita_data[7];
float angular_diameter = nishita_data[8];
float sun_intensity = nishita_data[9];
int sun_disc = angular_diameter > 0;
float alpha = 1.0;
color xyz;
@@ -138,13 +144,13 @@ color sky_radiance_nishita(vector dir, float nishita_data[9], string filename)
if (dir[2] >= 0.0) {
/* definitions */
vector sun_dir = geographical_to_direction(sun_elevation, sun_rotation + M_PI_2);
float sun_dir_angle = acos(dot(dir, sun_dir));
float sun_dir_angle = precise_angle(dir, sun_dir);
float half_angular = angular_diameter / 2.0;
float dir_elevation = M_PI_2 - direction[0];
/* if ray inside sun disc render it, otherwise render sky */
if (sun_dir_angle < half_angular && sun_disc == 1) {
/* get 3 pixels data */
/* get 2 pixels data */
color pixel_bottom = color(nishita_data[0], nishita_data[1], nishita_data[2]);
color pixel_top = color(nishita_data[3], nishita_data[4], nishita_data[5]);
float y;
@@ -153,13 +159,13 @@ color sky_radiance_nishita(vector dir, float nishita_data[9], string filename)
if (sun_elevation - half_angular > 0.0) {
if ((sun_elevation + half_angular) > 0.0) {
y = ((dir_elevation - sun_elevation) / angular_diameter) + 0.5;
xyz = mix(pixel_bottom, pixel_top, y);
xyz = mix(pixel_bottom, pixel_top, y) * sun_intensity;
}
}
else {
if (sun_elevation + half_angular > 0.0) {
y = dir_elevation / (sun_elevation + half_angular);
xyz = mix(pixel_bottom, pixel_top, y);
xyz = mix(pixel_bottom, pixel_top, y) * sun_intensity;
}
}
/* limb darkening, coefficient is 0.6f */
@@ -171,7 +177,8 @@ color sky_radiance_nishita(vector dir, float nishita_data[9], string filename)
else {
/* sky interpolation */
float x = (direction[1] + M_PI + sun_rotation) / M_2PI;
float y = 1.0 - (dir_elevation / M_PI_2);
/* more pixels toward horizon compensation */
float y = 1.0 - sqrt(dir_elevation / M_PI_2);
if (x > 1.0) {
x = x - 1.0;
}
@@ -201,19 +208,20 @@ color sky_radiance_nishita(vector dir, float nishita_data[9], string filename)
return xyz_to_rgb(xyz[0], xyz[1], xyz[2]) * 120000.0;
}
shader node_sky_texture(int use_mapping = 0,
matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
vector Vector = P,
string type = "hosek_wilkie",
float theta = 0.0,
float phi = 0.0,
string filename = "",
color radiance = color(0.0, 0.0, 0.0),
float config_x[9] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
float config_y[9] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
float config_z[9] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
float nishita_data[9] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
output color Color = color(0.0, 0.0, 0.0))
shader node_sky_texture(
int use_mapping = 0,
matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
vector Vector = P,
string type = "hosek_wilkie",
float theta = 0.0,
float phi = 0.0,
string filename = "",
color radiance = color(0.0, 0.0, 0.0),
float config_x[9] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
float config_y[9] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
float config_z[9] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
float nishita_data[10] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
output color Color = color(0.0, 0.0, 0.0))
{
vector p = Vector;

View File

@@ -136,6 +136,7 @@ ccl_device float3 sky_radiance_nishita(KernelGlobals *kg,
float sun_elevation = nishita_data[6];
float sun_rotation = nishita_data[7];
float angular_diameter = nishita_data[8];
float sun_intensity = nishita_data[9];
bool sun_disc = (angular_diameter > 0.0f);
float3 xyz;
/* convert dir to spherical coordinates */
@@ -145,13 +146,13 @@ ccl_device float3 sky_radiance_nishita(KernelGlobals *kg,
if (dir.z >= 0.0f) {
/* definitions */
float3 sun_dir = geographical_to_direction(sun_elevation, sun_rotation + M_PI_2_F);
float sun_dir_angle = acos(dot(dir, sun_dir));
float sun_dir_angle = precise_angle(dir, sun_dir);
float half_angular = angular_diameter / 2.0f;
float dir_elevation = M_PI_2_F - direction.x;
/* if ray inside sun disc render it, otherwise render sky */
if (sun_disc && sun_dir_angle < half_angular) {
/* get 3 pixels data */
/* get 2 pixels data */
float3 pixel_bottom = make_float3(nishita_data[0], nishita_data[1], nishita_data[2]);
float3 pixel_top = make_float3(nishita_data[3], nishita_data[4], nishita_data[5]);
float y;
@@ -160,13 +161,13 @@ ccl_device float3 sky_radiance_nishita(KernelGlobals *kg,
if (sun_elevation - half_angular > 0.0f) {
if (sun_elevation + half_angular > 0.0f) {
y = ((dir_elevation - sun_elevation) / angular_diameter) + 0.5f;
xyz = interp(pixel_bottom, pixel_top, y);
xyz = interp(pixel_bottom, pixel_top, y) * sun_intensity;
}
}
else {
if (sun_elevation + half_angular > 0.0f) {
y = dir_elevation / (sun_elevation + half_angular);
xyz = interp(pixel_bottom, pixel_top, y);
xyz = interp(pixel_bottom, pixel_top, y) * sun_intensity;
}
}
/* limb darkening, coefficient is 0.6f */
@@ -178,7 +179,8 @@ ccl_device float3 sky_radiance_nishita(KernelGlobals *kg,
else {
/* sky interpolation */
float x = (direction.y + M_PI_F + sun_rotation) / M_2PI_F;
float y = dir_elevation / M_PI_2_F;
/* more pixels toward horizon compensation */
float y = safe_sqrtf(dir_elevation / M_PI_2_F);
if (x > 1.0f) {
x -= 1.0f;
}
@@ -301,7 +303,7 @@ ccl_device void svm_node_tex_sky(
/* Nishita */
else {
/* Define variables */
float nishita_data[9];
float nishita_data[10];
float4 data = read_node_float(kg, offset);
nishita_data[0] = data.x;
@@ -317,7 +319,8 @@ ccl_device void svm_node_tex_sky(
data = read_node_float(kg, offset);
nishita_data[8] = data.x;
uint texture_id = __float_as_uint(data.y);
nishita_data[9] = data.y;
uint texture_id = __float_as_uint(data.z);
/* Compute Sky */
f = sky_radiance_nishita(kg, dir, nishita_data, texture_id);

View File

@@ -2,6 +2,7 @@
set(INC
..
../../glew-mx
../../sky/include
)
set(INC_SYS
@@ -92,6 +93,7 @@ set(LIB
cycles_device
cycles_subd
cycles_util
bf_intern_sky
)
if(WITH_CYCLES_OSL)

View File

@@ -52,7 +52,7 @@ class BufferParams {
/* passes */
vector<Pass> passes;
bool denoising_data_pass;
/* If only some light path types should be denoised, an additional pass is needed. */
/* If only some light path types should be target, an additional pass is needed. */
bool denoising_clean_pass;
/* When we're prefiltering the passes during rendering, we need to keep both the
* original and the prefiltered data around because neighboring tiles might still
@@ -149,6 +149,50 @@ class RenderTile {
RenderBuffers *buffers;
RenderTile();
int4 bounds() const
{
return make_int4(x, /* xmin */
y, /* ymin */
x + w, /* xmax */
y + h); /* ymax */
}
};
/* Render Tile Neighbors
* Set of neighboring tiles used for denoising. Tile order:
* 0 1 2
* 3 4 5
* 6 7 8 */
class RenderTileNeighbors {
public:
static const int SIZE = 9;
static const int CENTER = 4;
RenderTile tiles[SIZE];
RenderTile target;
RenderTileNeighbors(const RenderTile &center)
{
tiles[CENTER] = center;
}
int4 bounds() const
{
return make_int4(tiles[3].x, /* xmin */
tiles[1].y, /* ymin */
tiles[5].x + tiles[5].w, /* xmax */
tiles[7].y + tiles[7].h); /* ymax */
}
void set_bounds_from_center()
{
tiles[3].x = tiles[CENTER].x;
tiles[1].y = tiles[CENTER].y;
tiles[5].x = tiles[CENTER].x + tiles[CENTER].w;
tiles[7].y = tiles[CENTER].y + tiles[CENTER].h;
}
};
CCL_NAMESPACE_END

View File

@@ -26,6 +26,7 @@
#include "util/util_function.h"
#include "util/util_logging.h"
#include "util/util_math_cdf.h"
#include "util/util_task.h"
#include "util/util_vector.h"
/* needed for calculating differentials */
@@ -496,20 +497,35 @@ void Camera::device_update_volume(Device * /*device*/, DeviceScene *dscene, Scen
if (!need_device_update && !need_flags_update) {
return;
}
KernelCamera *kcam = &dscene->data.cam;
BoundBox viewplane_boundbox = viewplane_bounds_get();
for (size_t i = 0; i < scene->objects.size(); ++i) {
Object *object = scene->objects[i];
if (object->geometry->has_volume && viewplane_boundbox.intersects(object->bounds)) {
/* TODO(sergey): Consider adding more grained check. */
VLOG(1) << "Detected camera inside volume.";
kcam->is_inside_volume = 1;
break;
KernelIntegrator *kintegrator = &dscene->data.integrator;
if (kintegrator->use_volumes) {
KernelCamera *kcam = &dscene->data.cam;
BoundBox viewplane_boundbox = viewplane_bounds_get();
/* Parallel object update, with grain size to avoid too much threading overhead
* for individual objects. */
static const int OBJECTS_PER_TASK = 32;
parallel_for(blocked_range<size_t>(0, scene->objects.size(), OBJECTS_PER_TASK),
[&](const blocked_range<size_t> &r) {
for (size_t i = r.begin(); i != r.end(); i++) {
Object *object = scene->objects[i];
if (object->geometry->has_volume &&
viewplane_boundbox.intersects(object->bounds)) {
/* TODO(sergey): Consider adding more grained check. */
VLOG(1) << "Detected camera inside volume.";
kcam->is_inside_volume = 1;
parallel_for_cancel();
break;
}
}
});
if (!kcam->is_inside_volume) {
VLOG(1) << "Camera is outside of the volume.";
}
}
if (!kcam->is_inside_volume) {
VLOG(1) << "Camera is outside of the volume.";
}
need_device_update = false;
need_flags_update = false;
}

View File

@@ -266,7 +266,7 @@ inline void processor_apply_pixels(const OCIO::Processor *processor, T *pixels,
{
/* TODO: implement faster version for when we know the conversion
* is a simple matrix transform between linear spaces. In that case
* unpremultiply is not needed. */
* un-premultiply is not needed. */
/* Process large images in chunks to keep temporary memory requirement down. */
const size_t chunk_size = std::min((size_t)(16 * 1024 * 1024), num_pixels);
@@ -354,7 +354,7 @@ void ColorSpaceManager::to_scene_linear(ColorSpaceProcessor *processor_,
processor->applyRGB(pixel);
}
else {
/* Unassociate and associate alpha since color management should not
/* Un-associate and associate alpha since color management should not
* be affected by transparency. */
float alpha = pixel[3];
float inv_alpha = 1.0f / alpha;

View File

@@ -271,42 +271,45 @@ bool DenoiseTask::acquire_tile(Device *device, Device *tile_device, RenderTile &
*
* However, since there is only one large memory, the denoised result has to be written to
* a different buffer to avoid having to copy an entire horizontal slice of the image. */
void DenoiseTask::map_neighboring_tiles(RenderTile *tiles, Device *tile_device)
void DenoiseTask::map_neighboring_tiles(RenderTileNeighbors &neighbors, Device *tile_device)
{
RenderTile &center_tile = neighbors.tiles[RenderTileNeighbors::CENTER];
RenderTile &target_tile = neighbors.target;
/* Fill tile information. */
for (int i = 0; i < 9; i++) {
if (i == 4) {
for (int i = 0; i < RenderTileNeighbors::SIZE; i++) {
if (i == RenderTileNeighbors::CENTER) {
continue;
}
RenderTile &tile = neighbors.tiles[i];
int dx = (i % 3) - 1;
int dy = (i / 3) - 1;
tiles[i].x = clamp(tiles[4].x + dx * denoiser->tile_size.x, 0, image.width);
tiles[i].w = clamp(tiles[4].x + (dx + 1) * denoiser->tile_size.x, 0, image.width) - tiles[i].x;
tiles[i].y = clamp(tiles[4].y + dy * denoiser->tile_size.y, 0, image.height);
tiles[i].h = clamp(tiles[4].y + (dy + 1) * denoiser->tile_size.y, 0, image.height) -
tiles[i].y;
tile.x = clamp(center_tile.x + dx * denoiser->tile_size.x, 0, image.width);
tile.w = clamp(center_tile.x + (dx + 1) * denoiser->tile_size.x, 0, image.width) - tile.x;
tile.y = clamp(center_tile.y + dy * denoiser->tile_size.y, 0, image.height);
tile.h = clamp(center_tile.y + (dy + 1) * denoiser->tile_size.y, 0, image.height) - tile.y;
tiles[i].buffer = tiles[4].buffer;
tiles[i].offset = tiles[4].offset;
tiles[i].stride = image.width;
tile.buffer = center_tile.buffer;
tile.offset = center_tile.offset;
tile.stride = image.width;
}
/* Allocate output buffer. */
device_vector<float> *output_mem = new device_vector<float>(
tile_device, "denoising_output", MEM_READ_WRITE);
output_mem->alloc(OUTPUT_NUM_CHANNELS * tiles[4].w * tiles[4].h);
output_mem->alloc(OUTPUT_NUM_CHANNELS * center_tile.w * center_tile.h);
/* Fill output buffer with noisy image, assumed by kernel_filter_finalize
* when skipping denoising of some pixels. */
float *result = output_mem->data();
float *in = &image.pixels[image.num_channels * (tiles[4].y * image.width + tiles[4].x)];
float *in = &image.pixels[image.num_channels * (center_tile.y * image.width + center_tile.x)];
const DenoiseImageLayer &layer = image.layers[current_layer];
const int *input_to_image_channel = layer.input_to_image_channel.data();
for (int y = 0; y < tiles[4].h; y++) {
for (int x = 0; x < tiles[4].w; x++, result += OUTPUT_NUM_CHANNELS) {
for (int y = 0; y < center_tile.h; y++) {
for (int x = 0; x < center_tile.w; x++, result += OUTPUT_NUM_CHANNELS) {
for (int i = 0; i < OUTPUT_NUM_CHANNELS; i++) {
result[i] = in[image.num_channels * x + input_to_image_channel[INPUT_NOISY_IMAGE + i]];
}
@@ -317,35 +320,38 @@ void DenoiseTask::map_neighboring_tiles(RenderTile *tiles, Device *tile_device)
output_mem->copy_to_device();
/* Fill output tile info. */
tiles[9] = tiles[4];
tiles[9].buffer = output_mem->device_pointer;
tiles[9].stride = tiles[9].w;
tiles[9].offset -= tiles[9].x + tiles[9].y * tiles[9].stride;
target_tile = center_tile;
target_tile.buffer = output_mem->device_pointer;
target_tile.stride = target_tile.w;
target_tile.offset -= target_tile.x + target_tile.y * target_tile.stride;
thread_scoped_lock output_lock(output_mutex);
assert(output_pixels.count(tiles[4].tile_index) == 0);
output_pixels[tiles[9].tile_index] = output_mem;
assert(output_pixels.count(center_tile.tile_index) == 0);
output_pixels[target_tile.tile_index] = output_mem;
}
void DenoiseTask::unmap_neighboring_tiles(RenderTile *tiles)
void DenoiseTask::unmap_neighboring_tiles(RenderTileNeighbors &neighbors)
{
RenderTile &center_tile = neighbors.tiles[RenderTileNeighbors::CENTER];
RenderTile &target_tile = neighbors.target;
thread_scoped_lock output_lock(output_mutex);
assert(output_pixels.count(tiles[4].tile_index) == 1);
device_vector<float> *output_mem = output_pixels[tiles[9].tile_index];
output_pixels.erase(tiles[4].tile_index);
assert(output_pixels.count(center_tile.tile_index) == 1);
device_vector<float> *output_mem = output_pixels[target_tile.tile_index];
output_pixels.erase(center_tile.tile_index);
output_lock.unlock();
/* Copy denoised pixels from device. */
output_mem->copy_from_device(0, OUTPUT_NUM_CHANNELS * tiles[9].w, tiles[9].h);
output_mem->copy_from_device(0, OUTPUT_NUM_CHANNELS * target_tile.w, target_tile.h);
float *result = output_mem->data();
float *out = &image.pixels[image.num_channels * (tiles[9].y * image.width + tiles[9].x)];
float *out = &image.pixels[image.num_channels * (target_tile.y * image.width + target_tile.x)];
const DenoiseImageLayer &layer = image.layers[current_layer];
const int *output_to_image_channel = layer.output_to_image_channel.data();
for (int y = 0; y < tiles[9].h; y++) {
for (int x = 0; x < tiles[9].w; x++, result += OUTPUT_NUM_CHANNELS) {
for (int y = 0; y < target_tile.h; y++) {
for (int x = 0; x < target_tile.w; x++, result += OUTPUT_NUM_CHANNELS) {
for (int i = 0; i < OUTPUT_NUM_CHANNELS; i++) {
out[image.num_channels * x + output_to_image_channel[i]] = result[i];
}

View File

@@ -196,8 +196,8 @@ class DenoiseTask {
/* Device task callbacks */
bool acquire_tile(Device *device, Device *tile_device, RenderTile &tile);
void map_neighboring_tiles(RenderTile *tiles, Device *tile_device);
void unmap_neighboring_tiles(RenderTile *tiles);
void map_neighboring_tiles(RenderTileNeighbors &neighbors, Device *tile_device);
void unmap_neighboring_tiles(RenderTileNeighbors &neighbors);
void release_tile();
bool get_cancel();
};

View File

@@ -942,12 +942,12 @@ void ShaderGraph::refine_bump_nodes()
foreach (NodePair &pair, nodes_dy)
add(pair.second);
/* connect what is connected is bump to samplecenter input*/
/* Connect what is connected is bump to sample-center input. */
connect(out, node->input("SampleCenter"));
/* bump input is just for connectivity purpose for the graph input,
* we re-connected this input to samplecenter, so lets disconnect it
* from bump input */
/* Bump input is just for connectivity purpose for the graph input,
* we re-connected this input to sample-center, so lets disconnect it
* from bump input. */
disconnect(bump_input);
}
}

View File

@@ -16,16 +16,20 @@
#include "render/image_sky.h"
#include "sky_model.h"
#include "util/util_image.h"
#include "util/util_logging.h"
#include "util/util_path.h"
#include "util/util_sky_model.h"
#include "util/util_task.h"
CCL_NAMESPACE_BEGIN
SkyLoader::SkyLoader(
float sun_elevation, int altitude, float air_density, float dust_density, float ozone_density)
SkyLoader::SkyLoader(float sun_elevation,
float altitude,
float air_density,
float dust_density,
float ozone_density)
: sun_elevation(sun_elevation),
altitude(altitude),
air_density(air_density),
@@ -56,23 +60,22 @@ bool SkyLoader::load_pixels(const ImageMetaData &metadata,
int width = metadata.width;
int height = metadata.height;
float *pixel_data = (float *)pixels;
float altitude_f = (float)altitude;
/* precompute sky texture */
const int rows_per_task = divide_up(1024, width);
parallel_for(blocked_range<size_t>(0, height, rows_per_task),
[&](const blocked_range<size_t> &r) {
nishita_skymodel_precompute_texture(pixel_data,
metadata.channels,
r.begin(),
r.end(),
width,
height,
sun_elevation,
altitude_f,
air_density,
dust_density,
ozone_density);
SKY_nishita_skymodel_precompute_texture(pixel_data,
metadata.channels,
r.begin(),
r.end(),
width,
height,
sun_elevation,
altitude,
air_density,
dust_density,
ozone_density);
});
return true;

View File

@@ -21,14 +21,14 @@ CCL_NAMESPACE_BEGIN
class SkyLoader : public ImageLoader {
private:
float sun_elevation;
int altitude;
float altitude;
float air_density;
float dust_density;
float ozone_density;
public:
SkyLoader(float sun_elevation,
int altitude,
float altitude,
float air_density,
float dust_density,
float ozone_density);

View File

@@ -625,13 +625,19 @@ void LightManager::device_update_background(Device *device,
}
}
/* Determine sun direction from lat/long and texture mapping. */
float latitude = sky->sun_elevation;
float longitude = M_2PI_F - sky->sun_rotation + M_PI_2_F;
float3 sun_direction = make_float3(
cosf(latitude) * cosf(longitude), cosf(latitude) * sinf(longitude), sinf(latitude));
Transform sky_transform = transform_inverse(sky->tex_mapping.compute_transform());
sun_direction = transform_direction(&sky_transform, sun_direction);
/* Pack sun direction and size. */
float half_angle = sky->sun_size * 0.5f;
kbackground->sun = make_float4(cosf(latitude) * cosf(longitude),
cosf(latitude) * sinf(longitude),
sinf(latitude),
half_angle);
kbackground->sun = make_float4(
sun_direction.x, sun_direction.y, sun_direction.z, half_angle);
kbackground->sun_weight = 4.0f;
environment_res.x = max(environment_res.x, 512);
environment_res.y = max(environment_res.y, 256);

View File

@@ -27,9 +27,10 @@
#include "render/scene.h"
#include "render/svm.h"
#include "sky_model.h"
#include "util/util_foreach.h"
#include "util/util_logging.h"
#include "util/util_sky_model.h"
#include "util/util_transform.h"
#include "kernel/svm/svm_color_util.h"
@@ -631,7 +632,7 @@ typedef struct SunSky {
/* Parameter */
float radiance_x, radiance_y, radiance_z;
float config_x[9], config_y[9], config_z[9], nishita_data[9];
float config_x[9], config_y[9], config_z[9], nishita_data[10];
} SunSky;
/* Preetham model */
@@ -726,8 +727,8 @@ static void sky_texture_precompute_hosek(SunSky *sunsky,
float solarElevation = M_PI_2_F - theta;
/* Initialize Sky Model */
ArHosekSkyModelState *sky_state;
sky_state = arhosek_xyz_skymodelstate_alloc_init(
SKY_ArHosekSkyModelState *sky_state;
sky_state = SKY_arhosek_xyz_skymodelstate_alloc_init(
(double)turbidity, (double)ground_albedo, (double)solarElevation);
/* Copy values from sky_state to SunSky */
@@ -741,25 +742,31 @@ static void sky_texture_precompute_hosek(SunSky *sunsky,
sunsky->radiance_z = (float)sky_state->radiances[2];
/* Free sky_state */
arhosekskymodelstate_free(sky_state);
SKY_arhosekskymodelstate_free(sky_state);
}
/* Nishita improved */
static void sky_texture_precompute_nishita(SunSky *sunsky,
bool sun_disc,
float sun_size,
float sun_intensity,
float sun_elevation,
float sun_rotation,
int altitude,
float altitude,
float air_density,
float dust_density)
{
/* sample 2 sun pixels */
float pixel_bottom[3];
float pixel_top[3];
float altitude_f = (float)altitude;
nishita_skymodel_precompute_sun(
sun_elevation, sun_size, altitude_f, air_density, dust_density, pixel_bottom, pixel_top);
SKY_nishita_skymodel_precompute_sun(
sun_elevation, sun_size, altitude, air_density, dust_density, pixel_bottom, pixel_top);
/* limit sun rotation between 0 and 360 degrees */
sun_rotation = fmodf(sun_rotation, M_2PI_F);
if (sun_rotation < 0.0f) {
sun_rotation += M_2PI_F;
}
sun_rotation = M_2PI_F - sun_rotation;
/* send data to svm_sky */
sunsky->nishita_data[0] = pixel_bottom[0];
sunsky->nishita_data[1] = pixel_bottom[1];
@@ -768,8 +775,9 @@ static void sky_texture_precompute_nishita(SunSky *sunsky,
sunsky->nishita_data[4] = pixel_top[1];
sunsky->nishita_data[5] = pixel_top[2];
sunsky->nishita_data[6] = sun_elevation;
sunsky->nishita_data[7] = M_2PI_F - sun_rotation;
sunsky->nishita_data[7] = sun_rotation;
sunsky->nishita_data[8] = sun_disc ? sun_size : 0.0f;
sunsky->nishita_data[9] = sun_intensity;
}
NODE_DEFINE(SkyTextureNode)
@@ -789,9 +797,10 @@ NODE_DEFINE(SkyTextureNode)
SOCKET_FLOAT(ground_albedo, "Ground Albedo", 0.3f);
SOCKET_BOOLEAN(sun_disc, "Sun Disc", true);
SOCKET_FLOAT(sun_size, "Sun Size", 0.009512f);
SOCKET_FLOAT(sun_intensity, "Sun Intensity", 1.0f);
SOCKET_FLOAT(sun_elevation, "Sun Elevation", M_PI_2_F);
SOCKET_FLOAT(sun_rotation, "Sun Rotation", 0.0f);
SOCKET_INT(altitude, "Altitude", 0);
SOCKET_FLOAT(altitude, "Altitude", 1.0f);
SOCKET_FLOAT(air_density, "Air", 1.0f);
SOCKET_FLOAT(dust_density, "Dust", 1.0f);
SOCKET_FLOAT(ozone_density, "Ozone", 1.0f);
@@ -819,12 +828,17 @@ void SkyTextureNode::compile(SVMCompiler &compiler)
else if (type == NODE_SKY_HOSEK)
sky_texture_precompute_hosek(&sunsky, sun_direction, turbidity, ground_albedo);
else if (type == NODE_SKY_NISHITA) {
/* Clamp altitude to reasonable values.
* Below 1m causes numerical issues and above 60km is space. */
float clamped_altitude = clamp(altitude, 1.0f, 59999.0f);
sky_texture_precompute_nishita(&sunsky,
sun_disc,
sun_size,
sun_intensity,
sun_elevation,
sun_rotation,
altitude,
clamped_altitude,
air_density,
dust_density);
/* precomputed texture image parameters */
@@ -836,7 +850,7 @@ void SkyTextureNode::compile(SVMCompiler &compiler)
/* precompute sky texture */
if (handle.empty()) {
SkyLoader *loader = new SkyLoader(
sun_elevation, altitude, air_density, dust_density, ozone_density);
sun_elevation, clamped_altitude, air_density, dust_density, ozone_density);
handle = image_manager->add_image(loader, impar);
}
}
@@ -891,7 +905,10 @@ void SkyTextureNode::compile(SVMCompiler &compiler)
__float_as_uint(sunsky.nishita_data[5]),
__float_as_uint(sunsky.nishita_data[6]),
__float_as_uint(sunsky.nishita_data[7]));
compiler.add_node(__float_as_uint(sunsky.nishita_data[8]), handle.svm_slot(), 0, 0);
compiler.add_node(__float_as_uint(sunsky.nishita_data[8]),
__float_as_uint(sunsky.nishita_data[9]),
handle.svm_slot(),
0);
}
tex_mapping.compile_end(compiler, vector_in, vector_offset);
@@ -907,12 +924,17 @@ void SkyTextureNode::compile(OSLCompiler &compiler)
else if (type == NODE_SKY_HOSEK)
sky_texture_precompute_hosek(&sunsky, sun_direction, turbidity, ground_albedo);
else if (type == NODE_SKY_NISHITA) {
/* Clamp altitude to reasonable values.
* Below 1m causes numerical issues and above 60km is space. */
float clamped_altitude = clamp(altitude, 1.0f, 59999.0f);
sky_texture_precompute_nishita(&sunsky,
sun_disc,
sun_size,
sun_intensity,
sun_elevation,
sun_rotation,
altitude,
clamped_altitude,
air_density,
dust_density);
/* precomputed texture image parameters */
@@ -924,7 +946,7 @@ void SkyTextureNode::compile(OSLCompiler &compiler)
/* precompute sky texture */
if (handle.empty()) {
SkyLoader *loader = new SkyLoader(
sun_elevation, altitude, air_density, dust_density, ozone_density);
sun_elevation, clamped_altitude, air_density, dust_density, ozone_density);
handle = image_manager->add_image(loader, impar);
}
}
@@ -939,7 +961,7 @@ void SkyTextureNode::compile(OSLCompiler &compiler)
compiler.parameter_array("config_x", sunsky.config_x, 9);
compiler.parameter_array("config_y", sunsky.config_y, 9);
compiler.parameter_array("config_z", sunsky.config_z, 9);
compiler.parameter_array("nishita_data", sunsky.nishita_data, 9);
compiler.parameter_array("nishita_data", sunsky.nishita_data, 10);
/* nishita texture */
if (type == NODE_SKY_NISHITA) {
compiler.parameter_texture("filename", handle.svm_slot());

View File

@@ -170,9 +170,10 @@ class SkyTextureNode : public TextureNode {
float ground_albedo;
bool sun_disc;
float sun_size;
float sun_intensity;
float sun_elevation;
float sun_rotation;
int altitude;
float altitude;
float air_density;
float dust_density;
float ozone_density;

View File

@@ -823,6 +823,12 @@ void ObjectManager::apply_static_transforms(DeviceScene *dscene, Scene *scene, P
Mesh *mesh = static_cast<Mesh *>(geom);
apply = apply && mesh->subdivision_type == Mesh::SUBDIVISION_NONE;
}
else if (geom->type == Geometry::HAIR) {
/* Can't apply non-uniform scale to curves, this can't be represented by
* control points and radius alone. */
float scale;
apply = apply && transform_uniform_scale(object->tfm, scale);
}
if (apply) {
if (!(motion_blur && object->use_motion())) {

View File

@@ -536,7 +536,7 @@ void Session::release_tile(RenderTile &rtile, const bool need_denoise)
denoising_cond.notify_all();
}
void Session::map_neighbor_tiles(RenderTile *tiles, Device *tile_device)
void Session::map_neighbor_tiles(RenderTileNeighbors &neighbors, Device *tile_device)
{
thread_scoped_lock tile_lock(tile_mutex);
@@ -546,75 +546,77 @@ void Session::map_neighbor_tiles(RenderTile *tiles, Device *tile_device)
tile_manager.state.buffer.full_x + tile_manager.state.buffer.width,
tile_manager.state.buffer.full_y + tile_manager.state.buffer.height);
RenderTile &center_tile = neighbors.tiles[RenderTileNeighbors::CENTER];
if (!tile_manager.schedule_denoising) {
/* Fix up tile slices with overlap. */
if (tile_manager.slice_overlap != 0) {
int y = max(tiles[4].y - tile_manager.slice_overlap, image_region.y);
tiles[4].h = min(tiles[4].y + tiles[4].h + tile_manager.slice_overlap, image_region.w) - y;
tiles[4].y = y;
int y = max(center_tile.y - tile_manager.slice_overlap, image_region.y);
center_tile.h = min(center_tile.y + center_tile.h + tile_manager.slice_overlap,
image_region.w) -
y;
center_tile.y = y;
}
/* Tiles are not being denoised individually, which means the entire image is processed. */
tiles[3].x = tiles[4].x;
tiles[1].y = tiles[4].y;
tiles[5].x = tiles[4].x + tiles[4].w;
tiles[7].y = tiles[4].y + tiles[4].h;
neighbors.set_bounds_from_center();
}
else {
int center_idx = tiles[4].tile_index;
int center_idx = center_tile.tile_index;
assert(tile_manager.state.tiles[center_idx].state == Tile::DENOISE);
for (int dy = -1, i = 0; dy <= 1; dy++) {
for (int dx = -1; dx <= 1; dx++, i++) {
RenderTile &rtile = neighbors.tiles[i];
int nindex = tile_manager.get_neighbor_index(center_idx, i);
if (nindex >= 0) {
Tile *tile = &tile_manager.state.tiles[nindex];
tiles[i].x = image_region.x + tile->x;
tiles[i].y = image_region.y + tile->y;
tiles[i].w = tile->w;
tiles[i].h = tile->h;
rtile.x = image_region.x + tile->x;
rtile.y = image_region.y + tile->y;
rtile.w = tile->w;
rtile.h = tile->h;
if (buffers) {
tile_manager.state.buffer.get_offset_stride(tiles[i].offset, tiles[i].stride);
tile_manager.state.buffer.get_offset_stride(rtile.offset, rtile.stride);
tiles[i].buffer = buffers->buffer.device_pointer;
tiles[i].buffers = buffers;
rtile.buffer = buffers->buffer.device_pointer;
rtile.buffers = buffers;
}
else {
assert(tile->buffers);
tile->buffers->params.get_offset_stride(tiles[i].offset, tiles[i].stride);
tile->buffers->params.get_offset_stride(rtile.offset, rtile.stride);
tiles[i].buffer = tile->buffers->buffer.device_pointer;
tiles[i].buffers = tile->buffers;
rtile.buffer = tile->buffers->buffer.device_pointer;
rtile.buffers = tile->buffers;
}
}
else {
int px = tiles[4].x + dx * params.tile_size.x;
int py = tiles[4].y + dy * params.tile_size.y;
int px = center_tile.x + dx * params.tile_size.x;
int py = center_tile.y + dy * params.tile_size.y;
tiles[i].x = clamp(px, image_region.x, image_region.z);
tiles[i].y = clamp(py, image_region.y, image_region.w);
tiles[i].w = tiles[i].h = 0;
rtile.x = clamp(px, image_region.x, image_region.z);
rtile.y = clamp(py, image_region.y, image_region.w);
rtile.w = rtile.h = 0;
tiles[i].buffer = (device_ptr)NULL;
tiles[i].buffers = NULL;
rtile.buffer = (device_ptr)NULL;
rtile.buffers = NULL;
}
}
}
}
assert(tiles[4].buffers);
device->map_neighbor_tiles(tile_device, tiles);
assert(center_tile.buffers);
device->map_neighbor_tiles(tile_device, neighbors);
/* The denoised result is written back to the original tile. */
tiles[9] = tiles[4];
neighbors.target = center_tile;
}
void Session::unmap_neighbor_tiles(RenderTile *tiles, Device *tile_device)
void Session::unmap_neighbor_tiles(RenderTileNeighbors &neighbors, Device *tile_device)
{
thread_scoped_lock tile_lock(tile_mutex);
device->unmap_neighbor_tiles(tile_device, tiles);
device->unmap_neighbor_tiles(tile_device, neighbors);
}
void Session::run_cpu()
@@ -1003,7 +1005,7 @@ bool Session::update_scene()
int height = tile_manager.state.buffer.full_height;
int resolution = tile_manager.state.resolution_divider;
if (width != cam->width || height != cam->height) {
if (width != cam->width || height != cam->height || resolution != cam->resolution) {
cam->width = width;
cam->height = height;
cam->resolution = resolution;
@@ -1126,6 +1128,11 @@ bool Session::render_need_denoise(bool &delayed)
{
delayed = false;
/* Not supported yet for baking. */
if (read_bake_tile_cb) {
return false;
}
/* Denoising enabled? */
if (!params.denoising.need_denoising_task()) {
return false;

View File

@@ -198,8 +198,8 @@ class Session {
void update_tile_sample(RenderTile &tile);
void release_tile(RenderTile &tile, const bool need_denoise);
void map_neighbor_tiles(RenderTile *tiles, Device *tile_device);
void unmap_neighbor_tiles(RenderTile *tiles, Device *tile_device);
void map_neighbor_tiles(RenderTileNeighbors &neighbors, Device *tile_device);
void unmap_neighbor_tiles(RenderTileNeighbors &neighbors, Device *tile_device);
bool device_use_gl;

View File

@@ -98,10 +98,6 @@ set(SRC_HEADERS
util_rect.h
util_set.h
util_simd.h
util_sky_model.cpp
util_sky_model.h
util_sky_model_data.h
util_sky_nishita.cpp
util_avxf.h
util_avxb.h
util_semaphore.h

View File

@@ -83,6 +83,7 @@ DebugFlags::OptiX::OptiX()
void DebugFlags::OptiX::reset()
{
cuda_streams = 1;
curves_api = false;
}
DebugFlags::OpenCL::OpenCL() : device_type(DebugFlags::OpenCL::DEVICE_ALL), debug(false)

View File

@@ -108,6 +108,9 @@ class DebugFlags {
/* Number of CUDA streams to launch kernels concurrently from. */
int cuda_streams;
/* Use OptiX curves API for hair instead of custom implementation. */
bool curves_api;
};
/* Descriptor of OpenCL feature-set to be used. */

View File

@@ -787,6 +787,16 @@ ccl_device_inline float compare_floats(float a, float b, float abs_diff, int ulp
return (abs(__float_as_int(a) - __float_as_int(b)) < ulp_diff);
}
/* Calculate the angle between the two vectors a and b.
* The usual approach acos(dot(a, b)) has severe precision issues for small angles,
* which are avoided by this method.
* Based on "Mangled Angles" from https://people.eecs.berkeley.edu/~wkahan/Mindless.pdf
*/
ccl_device_inline float precise_angle(float3 a, float3 b)
{
return 2.0f * atan2f(len(a - b), len(a + b));
}
CCL_NAMESPACE_END
#endif /* __UTIL_MATH_H__ */

View File

@@ -34,6 +34,11 @@ using tbb::blocked_range;
using tbb::enumerable_thread_specific;
using tbb::parallel_for;
static inline void parallel_for_cancel()
{
tbb::task::self().cancel_group_execution();
}
CCL_NAMESPACE_END
#endif /* __UTIL_TBB_H__ */

View File

@@ -29,9 +29,9 @@
# include <pthread.h>
#endif
#ifdef __APPLE__
# include <libkern/OSAtomic.h>
#endif
/* NOTE: Use tbb/spin_mutex.h instead of util_tbb.h because some of the TBB
* functionality requires RTTI, which is disabled for OSL kernel. */
#include <tbb/spin_mutex.h>
#include "util/util_function.h"
@@ -65,76 +65,7 @@ class thread {
int node_;
};
/* Own wrapper around pthread's spin lock to make it's use easier. */
class thread_spin_lock {
public:
#ifdef __APPLE__
inline thread_spin_lock()
{
spin_ = OS_SPINLOCK_INIT;
}
inline void lock()
{
OSSpinLockLock(&spin_);
}
inline void unlock()
{
OSSpinLockUnlock(&spin_);
}
#elif defined(_WIN32)
inline thread_spin_lock()
{
const DWORD SPIN_COUNT = 50000;
InitializeCriticalSectionAndSpinCount(&cs_, SPIN_COUNT);
}
inline ~thread_spin_lock()
{
DeleteCriticalSection(&cs_);
}
inline void lock()
{
EnterCriticalSection(&cs_);
}
inline void unlock()
{
LeaveCriticalSection(&cs_);
}
#else
inline thread_spin_lock()
{
pthread_spin_init(&spin_, 0);
}
inline ~thread_spin_lock()
{
pthread_spin_destroy(&spin_);
}
inline void lock()
{
pthread_spin_lock(&spin_);
}
inline void unlock()
{
pthread_spin_unlock(&spin_);
}
#endif
protected:
#ifdef __APPLE__
OSSpinLock spin_;
#elif defined(_WIN32)
CRITICAL_SECTION cs_;
#else
pthread_spinlock_t spin_;
#endif
};
using thread_spin_lock = tbb::spin_mutex;
class thread_scoped_spin_lock {
public:

View File

@@ -362,8 +362,8 @@ extern GHOST_TSuccess GHOST_HasCursorShape(GHOST_WindowHandle windowhandle,
* \param mask The mask data for the cursor.
* \param sizex The width of the cursor
* \param sizey The height of the cursor
* \param hotX The X coordinate of the cursor hotspot.
* \param hotY The Y coordinate of the cursor hotspot.
* \param hotX The X coordinate of the cursor hot-spot.
* \param hotY The Y coordinate of the cursor hot-spot.
* \param canInvertColor Let macOS invert cursor color to match platform convention.
* \return Indication of success.
*/

View File

@@ -287,8 +287,8 @@ class GHOST_IWindow {
* Set the shape of the cursor to a custom cursor.
* \param bitmap The bitmap data for the cursor.
* \param mask The mask data for the cursor.
* \param hotX The X coordinate of the cursor hotspot.
* \param hotY The Y coordinate of the cursor hotspot.
* \param hotX The X coordinate of the cursor hot-spot.
* \param hotY The Y coordinate of the cursor hot-spot.
* \return Indication of success.
*/
virtual GHOST_TSuccess setCustomCursorShape(GHOST_TUns8 *bitmap,

View File

@@ -1324,7 +1324,7 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
int revert_to;
/* as ICCCM say, we need reply this event
* with a SetInputFocus, the data[1] have
* with a #SetInputFocus, the data[1] have
* the valid timestamp (send by the wm).
*
* Some WM send this event before the
@@ -1345,7 +1345,7 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
else {
#ifdef WITH_XDND
/* try to handle drag event
* (if there's no such events, GHOST_HandleClientMessage will return zero) */
* (if there's no such events, #GHOST_HandleClientMessage will return zero) */
if (window->getDropTarget()->GHOST_HandleClientMessage(xe) == false) {
/* Unknown client message, ignore */
}
@@ -1366,12 +1366,12 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
case EnterNotify:
case LeaveNotify: {
/* XCrossingEvents pointer leave enter window.
* also do cursor move here, MotionNotify only
/* #XCrossingEvents pointer leave enter window.
* also do cursor move here, #MotionNotify only
* happens when motion starts & ends inside window.
* we only do moves when the crossing mode is 'normal'
* (really crossing between windows) since some windowmanagers
* also send grab/ungrab crossings for mousewheel events.
* (really crossing between windows) since some window-managers
* also send grab/un-grab crossings for mouse-wheel events.
*/
XCrossingEvent &xce = xe->xcrossing;
if (xce.mode == NotifyNormal) {
@@ -1396,11 +1396,11 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
case MapNotify:
/*
* From ICCCM:
* [ Clients can select for StructureNotify on their
* [ Clients can select for #StructureNotify on their
* top-level windows to track transition between
* Normal and Iconic states. Receipt of a MapNotify
* Normal and Iconic states. Receipt of a #MapNotify
* event will indicate a transition to the Normal
* state, and receipt of an UnmapNotify event will
* state, and receipt of an #UnmapNotify event will
* indicate a transition to the Iconic state. ]
*/
if (window->m_post_init == True) {
@@ -1441,7 +1441,7 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
nxe.xselection.target = xse->target;
nxe.xselection.time = xse->time;
/* Check to see if the requestor is asking for String */
/* Check to see if the requester is asking for String */
if (xse->target == utf8_string || xse->target == string || xse->target == compound_text ||
xse->target == c_string) {
if (xse->selection == XInternAtom(m_display, "PRIMARY", False)) {
@@ -1487,7 +1487,7 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
nxe.xselection.property = None;
}
/* Send the event to the client 0 0 == False, SelectionNotify */
/* Send the event to the client 0 0 == False, #SelectionNotify */
XSendEvent(m_display, xse->requestor, 0, 0, &nxe);
XFlush(m_display);
break;
@@ -1513,7 +1513,7 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
/* Note: This event might be generated with incomplete data-set
* (don't exactly know why, looks like in some cases, if the value does not change,
* it is not included in subsequent XDeviceMotionEvent events).
* it is not included in subsequent #XDeviceMotionEvent events).
* So we have to check which values this event actually contains!
*/
@@ -1569,14 +1569,13 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
GHOST_TSuccess GHOST_SystemX11::getModifierKeys(GHOST_ModifierKeys &keys) const
{
/* Analyze the masks returned from XQueryPointer. */
/* Analyze the masks returned from #XQueryPointer. */
memset((void *)m_keyboard_vector, 0, sizeof(m_keyboard_vector));
XQueryKeymap(m_display, (char *)m_keyboard_vector);
/* now translate key symbols into keycodes and
* test with vector. */
/* Now translate key symbols into key-codes and test with vector. */
const static KeyCode shift_l = XKeysymToKeycode(m_display, XK_Shift_L);
const static KeyCode shift_r = XKeysymToKeycode(m_display, XK_Shift_R);
@@ -1671,7 +1670,7 @@ GHOST_TSuccess GHOST_SystemX11::setCursorPosition(GHOST_TInt32 x, GHOST_TInt32 y
{
/* This is a brute force move in screen coordinates
* XWarpPointer does relative moves so first determine the
* #XWarpPointer does relative moves so first determine the
* current pointer position. */
int cx, cy;

View File

@@ -34,7 +34,7 @@ class GHOST_Context;
* Dimensions are given in screen coordinates that are relative to the
* upper-left corner of the screen.
* Implements part of the GHOST_IWindow interface and adds some methods to
* be implemented by childs of this class.
* be implemented by sub-classes of this class.
*/
class GHOST_Window : public GHOST_IWindow {
public:
@@ -124,8 +124,8 @@ class GHOST_Window : public GHOST_IWindow {
* Set the shape of the cursor to a custom cursor.
* \param bitmap The bitmap data for the cursor.
* \param mask The mask data for the cursor.
* \param hotX The X coordinate of the cursor hotspot.
* \param hotY The Y coordinate of the cursor hotspot.
* \param hotX The X coordinate of the cursor hot-spot.
* \param hotY The Y coordinate of the cursor hot-spot.
* \return Indication of success.
*/
GHOST_TSuccess setCustomCursorShape(GHOST_TUns8 *bitmap,

View File

@@ -239,6 +239,15 @@ void MEM_use_guarded_allocator(void);
{ \
if (mem) \
MEM_freeN(mem); \
} \
void *operator new(size_t /*count*/, void *ptr) \
{ \
return ptr; \
} \
/* This is the matching delete operator to the placement-new operator above. Both parameters \
* will have the same value. Without this, we get the warning C4291 on windows. */ \
void operator delete(void * /*ptr_to_free*/, void * /*ptr*/) \
{ \
}
/* Needed when type includes a namespace, then the namespace should not be

View File

@@ -198,10 +198,12 @@ print_error(const char *str, ...)
va_end(ap);
buf[sizeof(buf) - 1] = '\0';
if (error_callback)
if (error_callback) {
error_callback(buf);
else
}
else {
fputs(buf, stderr);
}
}
static pthread_mutex_t thread_lock = PTHREAD_MUTEX_INITIALIZER;
@@ -261,13 +263,16 @@ void *MEM_guarded_dupallocN(const void *vmemh)
memh--;
#ifndef DEBUG_MEMDUPLINAME
if (LIKELY(memh->alignment == 0))
if (LIKELY(memh->alignment == 0)) {
newp = MEM_guarded_mallocN(memh->len, "dupli_alloc");
else
}
else {
newp = MEM_guarded_mallocN_aligned(memh->len, (size_t)memh->alignment, "dupli_alloc");
}
if (newp == NULL)
if (newp == NULL) {
return NULL;
}
#else
{
MemHead *nmemh;
@@ -450,8 +455,9 @@ void *MEM_guarded_mallocN(size_t len, const char *str)
if (LIKELY(memh)) {
make_memhead_header(memh, len, str);
if (UNLIKELY(malloc_debug_memset && len))
if (UNLIKELY(malloc_debug_memset && len)) {
memset(memh + 1, 255, len);
}
#ifdef DEBUG_MEMCOUNTER
if (_mallocn_count == DEBUG_MEMCOUNTER_ERROR_VAL)
@@ -522,8 +528,9 @@ void *MEM_guarded_mallocN_aligned(size_t len, size_t alignment, const char *str)
make_memhead_header(memh, len, str);
memh->alignment = (short)alignment;
if (UNLIKELY(malloc_debug_memset && len))
if (UNLIKELY(malloc_debug_memset && len)) {
memset(memh + 1, 255, len);
}
#ifdef DEBUG_MEMCOUNTER
if (_mallocn_count == DEBUG_MEMCOUNTER_ERROR_VAL)
@@ -601,12 +608,15 @@ static int compare_len(const void *p1, const void *p2)
const MemPrintBlock *pb1 = (const MemPrintBlock *)p1;
const MemPrintBlock *pb2 = (const MemPrintBlock *)p2;
if (pb1->len < pb2->len)
if (pb1->len < pb2->len) {
return 1;
else if (pb1->len == pb2->len)
}
else if (pb1->len == pb2->len) {
return 0;
else
}
else {
return -1;
}
}
void MEM_guarded_printmemlist_stats(void)
@@ -636,8 +646,9 @@ void MEM_guarded_printmemlist_stats(void)
totpb = 0;
membl = membase->first;
if (membl)
if (membl) {
membl = MEMNEXT(membl);
}
while (membl && pb) {
pb->name = membl->name;
@@ -654,10 +665,12 @@ void MEM_guarded_printmemlist_stats(void)
}
#endif
if (membl->next)
if (membl->next) {
membl = MEMNEXT(membl->next);
else
}
else {
break;
}
}
/* sort by name and add together blocks with the same name */
@@ -737,8 +750,9 @@ static void MEM_guarded_printmemlist_internal(int pydict)
mem_lock_thread();
membl = membase->first;
if (membl)
if (membl) {
membl = MEMNEXT(membl);
}
if (pydict) {
print_error("# membase_debug.py\n");
@@ -771,10 +785,12 @@ static void MEM_guarded_printmemlist_internal(int pydict)
print_memhead_backtrace(membl);
#endif
}
if (membl->next)
if (membl->next) {
membl = MEMNEXT(membl->next);
else
}
else {
break;
}
}
if (pydict) {
print_error("]\n\n");
@@ -791,15 +807,18 @@ void MEM_guarded_callbackmemlist(void (*func)(void *))
mem_lock_thread();
membl = membase->first;
if (membl)
if (membl) {
membl = MEMNEXT(membl);
}
while (membl) {
func(membl + 1);
if (membl->next)
if (membl->next) {
membl = MEMNEXT(membl->next);
else
}
else {
break;
}
}
mem_unlock_thread();
@@ -890,24 +909,25 @@ void MEM_guarded_freeN(void *vmemh)
MemorY_ErroR(memh->name, "end corrupt");
name = check_memlist(memh);
if (name != NULL) {
if (name != memh->name)
if (name != memh->name) {
MemorY_ErroR(name, "is also corrupt");
}
}
}
else {
mem_lock_thread();
name = check_memlist(memh);
mem_unlock_thread();
if (name == NULL)
if (name == NULL) {
MemorY_ErroR("free", "pointer not in memlist");
else
}
else {
MemorY_ErroR(name, "error in header");
}
}
totblock--;
/* here a DUMP should happen */
return;
}
/* --------------------------------------------------------------------- */
@@ -930,10 +950,12 @@ static void addtail(volatile localListBase *listbase, void *vlink)
link->next = NULL;
link->prev = listbase->last;
if (listbase->last)
if (listbase->last) {
((struct localLink *)listbase->last)->next = link;
if (listbase->first == NULL)
}
if (listbase->first == NULL) {
listbase->first = link;
}
listbase->last = link;
}
@@ -950,15 +972,19 @@ static void remlink(volatile localListBase *listbase, void *vlink)
return;
#endif
if (link->next)
if (link->next) {
link->next->prev = link->prev;
if (link->prev)
}
if (link->prev) {
link->prev->next = link->next;
}
if (listbase->last == link)
if (listbase->last == link) {
listbase->last = link->prev;
if (listbase->first == link)
}
if (listbase->first == link) {
listbase->first = link->next;
}
}
static void rem_memblock(MemHead *memh)
@@ -966,10 +992,12 @@ static void rem_memblock(MemHead *memh)
mem_lock_thread();
remlink(membase, &memh->next);
if (memh->prev) {
if (memh->next)
if (memh->next) {
MEMNEXT(memh->prev)->nextname = MEMNEXT(memh->next)->name;
else
}
else {
MEMNEXT(memh->prev)->nextname = NULL;
}
}
mem_unlock_thread();
@@ -981,8 +1009,9 @@ static void rem_memblock(MemHead *memh)
free((char *)memh->name);
#endif
if (UNLIKELY(malloc_debug_memset && memh->len))
if (UNLIKELY(malloc_debug_memset && memh->len)) {
memset(memh + 1, 255, memh->len);
}
if (LIKELY(memh->alignment == 0)) {
free(memh);
}
@@ -1006,78 +1035,100 @@ static const char *check_memlist(MemHead *memh)
const char *name;
forw = membase->first;
if (forw)
if (forw) {
forw = MEMNEXT(forw);
}
forwok = NULL;
while (forw) {
if (forw->tag1 != MEMTAG1 || forw->tag2 != MEMTAG2)
if (forw->tag1 != MEMTAG1 || forw->tag2 != MEMTAG2) {
break;
}
forwok = forw;
if (forw->next)
if (forw->next) {
forw = MEMNEXT(forw->next);
else
}
else {
forw = NULL;
}
}
back = (MemHead *)membase->last;
if (back)
if (back) {
back = MEMNEXT(back);
}
backok = NULL;
while (back) {
if (back->tag1 != MEMTAG1 || back->tag2 != MEMTAG2)
if (back->tag1 != MEMTAG1 || back->tag2 != MEMTAG2) {
break;
}
backok = back;
if (back->prev)
if (back->prev) {
back = MEMNEXT(back->prev);
else
}
else {
back = NULL;
}
}
if (forw != back)
if (forw != back) {
return ("MORE THAN 1 MEMORYBLOCK CORRUPT");
}
if (forw == NULL && back == NULL) {
/* no wrong headers found then but in search of memblock */
forw = membase->first;
if (forw)
if (forw) {
forw = MEMNEXT(forw);
}
forwok = NULL;
while (forw) {
if (forw == memh)
if (forw == memh) {
break;
if (forw->tag1 != MEMTAG1 || forw->tag2 != MEMTAG2)
}
if (forw->tag1 != MEMTAG1 || forw->tag2 != MEMTAG2) {
break;
}
forwok = forw;
if (forw->next)
if (forw->next) {
forw = MEMNEXT(forw->next);
else
}
else {
forw = NULL;
}
}
if (forw == NULL)
if (forw == NULL) {
return NULL;
}
back = (MemHead *)membase->last;
if (back)
if (back) {
back = MEMNEXT(back);
}
backok = NULL;
while (back) {
if (back == memh)
if (back == memh) {
break;
if (back->tag1 != MEMTAG1 || back->tag2 != MEMTAG2)
}
if (back->tag1 != MEMTAG1 || back->tag2 != MEMTAG2) {
break;
}
backok = back;
if (back->prev)
if (back->prev) {
back = MEMNEXT(back->prev);
else
}
else {
back = NULL;
}
}
}
if (forwok)
if (forwok) {
name = forwok->nextname;
else
}
else {
name = "No name found";
}
if (forw == memh) {
/* to be sure but this block is removed from the list */

View File

@@ -148,7 +148,7 @@ int main(int argc, char *argv[])
fprintf(stderr, "|\n|--* Errors were detected\n");
}
else {
fprintf(stderr, "|\n|--* Test exited succesfully\n");
fprintf(stderr, "|\n|--* Test exited successfully\n");
}
fprintf(stderr, "|\n*** Finished test\n\n");

View File

@@ -28,6 +28,7 @@
# if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 31)
double __exp_finite(double x);
double __exp2_finite(double x);
double __acos_finite(double x);
double __asin_finite(double x);
double __log2_finite(double x);
@@ -35,6 +36,7 @@ double __log10_finite(double x);
double __log_finite(double x);
double __pow_finite(double x, double y);
float __expf_finite(float x);
float __exp2f_finite(float x);
float __acosf_finite(float x);
float __asinf_finite(float x);
float __log2f_finite(float x);
@@ -47,6 +49,11 @@ double __exp_finite(double x)
return exp(x);
}
double __exp2_finite(double x)
{
return exp2(x);
}
double __acos_finite(double x)
{
return acos(x);
@@ -82,6 +89,11 @@ float __expf_finite(float x)
return expf(x);
}
float __exp2f_finite(float x)
{
return exp2f(x);
}
float __acosf_finite(float x)
{
return acosf(x);

View File

@@ -316,8 +316,8 @@ double InternalReprojectionError(
}
LG << "Skipped " << num_skipped << " markers.";
LG << "Reprojected " << num_reprojected << " markers.";
LG << "Total error: " << total_error;
LG << "Average error: " << (total_error / num_reprojected) << " [pixels].";
LG << "Total error: " << total_error << " px";
LG << "Average error: " << (total_error / num_reprojected) << " px";
return total_error / num_reprojected;
}

View File

@@ -31,52 +31,52 @@ extern "C" {
struct MANTA;
/* Fluid functions */
struct MANTA *manta_init(int *res, struct FluidModifierData *mmd);
struct MANTA *manta_init(int *res, struct FluidModifierData *fmd);
void manta_free(struct MANTA *fluid);
void manta_ensure_obstacle(struct MANTA *fluid, struct FluidModifierData *mmd);
void manta_ensure_guiding(struct MANTA *fluid, struct FluidModifierData *mmd);
void manta_ensure_invelocity(struct MANTA *fluid, struct FluidModifierData *mmd);
void manta_ensure_outflow(struct MANTA *fluid, struct FluidModifierData *mmd);
int manta_write_config(struct MANTA *fluid, struct FluidModifierData *mmd, int framenr);
int manta_write_data(struct MANTA *fluid, struct FluidModifierData *mmd, int framenr);
int manta_write_noise(struct MANTA *fluid, struct FluidModifierData *mmd, int framenr);
int manta_read_config(struct MANTA *fluid, struct FluidModifierData *mmd, int framenr);
void manta_ensure_obstacle(struct MANTA *fluid, struct FluidModifierData *fmd);
void manta_ensure_guiding(struct MANTA *fluid, struct FluidModifierData *fmd);
void manta_ensure_invelocity(struct MANTA *fluid, struct FluidModifierData *fmd);
void manta_ensure_outflow(struct MANTA *fluid, struct FluidModifierData *fmd);
int manta_write_config(struct MANTA *fluid, struct FluidModifierData *fmd, int framenr);
int manta_write_data(struct MANTA *fluid, struct FluidModifierData *fmd, int framenr);
int manta_write_noise(struct MANTA *fluid, struct FluidModifierData *fmd, int framenr);
int manta_read_config(struct MANTA *fluid, struct FluidModifierData *fmd, int framenr);
int manta_read_data(struct MANTA *fluid,
struct FluidModifierData *mmd,
struct FluidModifierData *fmd,
int framenr,
bool resumable);
int manta_read_noise(struct MANTA *fluid,
struct FluidModifierData *mmd,
struct FluidModifierData *fmd,
int framenr,
bool resumable);
int manta_read_mesh(struct MANTA *fluid, struct FluidModifierData *mmd, int framenr);
int manta_read_mesh(struct MANTA *fluid, struct FluidModifierData *fmd, int framenr);
int manta_read_particles(struct MANTA *fluid,
struct FluidModifierData *mmd,
struct FluidModifierData *fmd,
int framenr,
bool resumable);
int manta_read_guiding(struct MANTA *fluid,
struct FluidModifierData *mmd,
struct FluidModifierData *fmd,
int framenr,
bool sourceDomain);
int manta_bake_data(struct MANTA *fluid, struct FluidModifierData *mmd, int framenr);
int manta_bake_noise(struct MANTA *fluid, struct FluidModifierData *mmd, int framenr);
int manta_bake_mesh(struct MANTA *fluid, struct FluidModifierData *mmd, int framenr);
int manta_bake_particles(struct MANTA *fluid, struct FluidModifierData *mmd, int framenr);
int manta_bake_guiding(struct MANTA *fluid, struct FluidModifierData *mmd, int framenr);
int manta_has_data(struct MANTA *fluid, struct FluidModifierData *mmd, int framenr);
int manta_has_noise(struct MANTA *fluid, struct FluidModifierData *mmd, int framenr);
int manta_has_mesh(struct MANTA *fluid, struct FluidModifierData *mmd, int framenr);
int manta_has_particles(struct MANTA *fluid, struct FluidModifierData *mmd, int framenr);
int manta_bake_data(struct MANTA *fluid, struct FluidModifierData *fmd, int framenr);
int manta_bake_noise(struct MANTA *fluid, struct FluidModifierData *fmd, int framenr);
int manta_bake_mesh(struct MANTA *fluid, struct FluidModifierData *fmd, int framenr);
int manta_bake_particles(struct MANTA *fluid, struct FluidModifierData *fmd, int framenr);
int manta_bake_guiding(struct MANTA *fluid, struct FluidModifierData *fmd, int framenr);
int manta_has_data(struct MANTA *fluid, struct FluidModifierData *fmd, int framenr);
int manta_has_noise(struct MANTA *fluid, struct FluidModifierData *fmd, int framenr);
int manta_has_mesh(struct MANTA *fluid, struct FluidModifierData *fmd, int framenr);
int manta_has_particles(struct MANTA *fluid, struct FluidModifierData *fmd, int framenr);
int manta_has_guiding(struct MANTA *fluid,
struct FluidModifierData *mmd,
struct FluidModifierData *fmd,
int framenr,
bool domain);
void manta_update_variables(struct MANTA *fluid, struct FluidModifierData *mmd);
void manta_update_variables(struct MANTA *fluid, struct FluidModifierData *fmd);
int manta_get_frame(struct MANTA *fluid);
float manta_get_timestep(struct MANTA *fluid);
void manta_adapt_timestep(struct MANTA *fluid);
bool manta_needs_realloc(struct MANTA *fluid, struct FluidModifierData *mmd);
bool manta_needs_realloc(struct MANTA *fluid, struct FluidModifierData *fmd);
/* Fluid accessors */
size_t manta_get_index(int x, int max_x, int y, int max_y, int z /*, int max_z */);
@@ -110,7 +110,7 @@ float *manta_get_phiout_in(struct MANTA *fluid);
float *manta_get_phioutstatic_in(struct MANTA *fluid);
/* Smoke functions */
void manta_smoke_export_script(struct MANTA *smoke, struct FluidModifierData *mmd);
void manta_smoke_export_script(struct MANTA *smoke, struct FluidModifierData *fmd);
void manta_smoke_export(struct MANTA *smoke,
float *dt,
float *dx,
@@ -151,9 +151,9 @@ void manta_smoke_turbulence_get_rgba_fixed_color(struct MANTA *smoke,
float color[3],
float *data,
int sequential);
void manta_smoke_ensure_heat(struct MANTA *smoke, struct FluidModifierData *mmd);
void manta_smoke_ensure_fire(struct MANTA *smoke, struct FluidModifierData *mmd);
void manta_smoke_ensure_colors(struct MANTA *smoke, struct FluidModifierData *mmd);
void manta_smoke_ensure_heat(struct MANTA *smoke, struct FluidModifierData *fmd);
void manta_smoke_ensure_fire(struct MANTA *smoke, struct FluidModifierData *fmd);
void manta_smoke_ensure_colors(struct MANTA *smoke, struct FluidModifierData *fmd);
/* Smoke accessors */
float *manta_smoke_get_density(struct MANTA *smoke);
@@ -190,8 +190,8 @@ void manta_smoke_turbulence_get_res(struct MANTA *smoke, int *res);
int manta_smoke_turbulence_get_cells(struct MANTA *smoke);
/* Liquid functions */
void manta_liquid_export_script(struct MANTA *smoke, struct FluidModifierData *mmd);
void manta_liquid_ensure_sndparts(struct MANTA *fluid, struct FluidModifierData *mmd);
void manta_liquid_export_script(struct MANTA *smoke, struct FluidModifierData *fmd);
void manta_liquid_ensure_sndparts(struct MANTA *fluid, struct FluidModifierData *fmd);
/* Liquid accessors */
int manta_liquid_get_particle_res_x(struct MANTA *liquid);

File diff suppressed because it is too large Load Diff

View File

@@ -37,7 +37,7 @@ using std::vector;
struct MANTA {
public:
MANTA(int *res, struct FluidModifierData *mmd);
MANTA(int *res, struct FluidModifierData *fmd);
MANTA(){};
virtual ~MANTA();
@@ -61,68 +61,68 @@ struct MANTA {
} Triangle;
// Manta step, handling everything
void step(struct FluidModifierData *mmd, int startFrame);
void step(struct FluidModifierData *fmd, int startFrame);
// Grid initialization functions
void initHeat(struct FluidModifierData *mmd = NULL);
void initFire(struct FluidModifierData *mmd = NULL);
void initColors(struct FluidModifierData *mmd = NULL);
void initFireHigh(struct FluidModifierData *mmd = NULL);
void initColorsHigh(struct FluidModifierData *mmd = NULL);
void initLiquid(FluidModifierData *mmd = NULL);
void initLiquidMesh(FluidModifierData *mmd = NULL);
void initObstacle(FluidModifierData *mmd = NULL);
void initCurvature(FluidModifierData *mmd = NULL);
void initGuiding(FluidModifierData *mmd = NULL);
void initFractions(FluidModifierData *mmd = NULL);
void initInVelocity(FluidModifierData *mmd = NULL);
void initOutflow(FluidModifierData *mmd = NULL);
void initSndParts(FluidModifierData *mmd = NULL);
void initLiquidSndParts(FluidModifierData *mmd = NULL);
void initHeat(struct FluidModifierData *fmd = NULL);
void initFire(struct FluidModifierData *fmd = NULL);
void initColors(struct FluidModifierData *fmd = NULL);
void initFireHigh(struct FluidModifierData *fmd = NULL);
void initColorsHigh(struct FluidModifierData *fmd = NULL);
void initLiquid(FluidModifierData *fmd = NULL);
void initLiquidMesh(FluidModifierData *fmd = NULL);
void initObstacle(FluidModifierData *fmd = NULL);
void initCurvature(FluidModifierData *fmd = NULL);
void initGuiding(FluidModifierData *fmd = NULL);
void initFractions(FluidModifierData *fmd = NULL);
void initInVelocity(FluidModifierData *fmd = NULL);
void initOutflow(FluidModifierData *fmd = NULL);
void initSndParts(FluidModifierData *fmd = NULL);
void initLiquidSndParts(FluidModifierData *fmd = NULL);
// Pointer transfer: Mantaflow -> Blender
void updatePointers();
// Write cache
bool writeConfiguration(FluidModifierData *mmd, int framenr);
bool writeData(FluidModifierData *mmd, int framenr);
bool writeNoise(FluidModifierData *mmd, int framenr);
bool writeConfiguration(FluidModifierData *fmd, int framenr);
bool writeData(FluidModifierData *fmd, int framenr);
bool writeNoise(FluidModifierData *fmd, int framenr);
// write calls for mesh and particles were left in bake calls for now
// Read cache (via Manta save/load)
bool readConfiguration(FluidModifierData *mmd, int framenr);
bool readData(FluidModifierData *mmd, int framenr, bool resumable);
bool readNoise(FluidModifierData *mmd, int framenr, bool resumable);
bool readMesh(FluidModifierData *mmd, int framenr);
bool readParticles(FluidModifierData *mmd, int framenr, bool resumable);
bool readGuiding(FluidModifierData *mmd, int framenr, bool sourceDomain);
bool readConfiguration(FluidModifierData *fmd, int framenr);
bool readData(FluidModifierData *fmd, int framenr, bool resumable);
bool readNoise(FluidModifierData *fmd, int framenr, bool resumable);
bool readMesh(FluidModifierData *fmd, int framenr);
bool readParticles(FluidModifierData *fmd, int framenr, bool resumable);
bool readGuiding(FluidModifierData *fmd, int framenr, bool sourceDomain);
// Read cache (via file read functions in MANTA - e.g. read .bobj.gz meshes, .uni particles)
bool updateMeshStructures(FluidModifierData *mmd, int framenr);
bool updateFlipStructures(FluidModifierData *mmd, int framenr);
bool updateParticleStructures(FluidModifierData *mmd, int framenr);
bool updateSmokeStructures(FluidModifierData *mmd, int framenr);
bool updateNoiseStructures(FluidModifierData *mmd, int framenr);
bool updateVariables(FluidModifierData *mmd);
bool updateMeshStructures(FluidModifierData *fmd, int framenr);
bool updateFlipStructures(FluidModifierData *fmd, int framenr);
bool updateParticleStructures(FluidModifierData *fmd, int framenr);
bool updateSmokeStructures(FluidModifierData *fmd, int framenr);
bool updateNoiseStructures(FluidModifierData *fmd, int framenr);
bool updateVariables(FluidModifierData *fmd);
// Bake cache
bool bakeData(FluidModifierData *mmd, int framenr);
bool bakeNoise(FluidModifierData *mmd, int framenr);
bool bakeMesh(FluidModifierData *mmd, int framenr);
bool bakeParticles(FluidModifierData *mmd, int framenr);
bool bakeGuiding(FluidModifierData *mmd, int framenr);
bool bakeData(FluidModifierData *fmd, int framenr);
bool bakeNoise(FluidModifierData *fmd, int framenr);
bool bakeMesh(FluidModifierData *fmd, int framenr);
bool bakeParticles(FluidModifierData *fmd, int framenr);
bool bakeGuiding(FluidModifierData *fmd, int framenr);
// IO for Mantaflow scene script
void exportSmokeScript(struct FluidModifierData *mmd);
void exportLiquidScript(struct FluidModifierData *mmd);
void exportSmokeScript(struct FluidModifierData *fmd);
void exportLiquidScript(struct FluidModifierData *fmd);
// Check cache status by frame
bool hasConfig(FluidModifierData *mmd, int framenr);
bool hasData(FluidModifierData *mmd, int framenr);
bool hasNoise(FluidModifierData *mmd, int framenr);
bool hasMesh(FluidModifierData *mmd, int framenr);
bool hasParticles(FluidModifierData *mmd, int framenr);
bool hasGuiding(FluidModifierData *mmd, int framenr, bool sourceDomain);
bool hasConfig(FluidModifierData *fmd, int framenr);
bool hasData(FluidModifierData *fmd, int framenr);
bool hasNoise(FluidModifierData *fmd, int framenr);
bool hasMesh(FluidModifierData *fmd, int framenr);
bool hasParticles(FluidModifierData *fmd, int framenr);
bool hasGuiding(FluidModifierData *fmd, int framenr, bool sourceDomain);
inline size_t getTotalCells()
{
@@ -739,7 +739,7 @@ struct MANTA {
float getTimestep();
void adaptTimestep();
bool needsRealloc(FluidModifierData *mmd);
bool needsRealloc(FluidModifierData *fmd);
private:
// simulation constants
@@ -874,20 +874,20 @@ struct MANTA {
vector<pVel> *mSndParticleVelocity;
vector<float> *mSndParticleLife;
void initializeRNAMap(struct FluidModifierData *mmd = NULL);
void initDomain(struct FluidModifierData *mmd = NULL);
void initNoise(struct FluidModifierData *mmd = NULL);
void initMesh(struct FluidModifierData *mmd = NULL);
void initSmoke(struct FluidModifierData *mmd = NULL);
void initSmokeNoise(struct FluidModifierData *mmd = NULL);
void initializeRNAMap(struct FluidModifierData *fmd = NULL);
void initDomain(struct FluidModifierData *fmd = NULL);
void initNoise(struct FluidModifierData *fmd = NULL);
void initMesh(struct FluidModifierData *fmd = NULL);
void initSmoke(struct FluidModifierData *fmd = NULL);
void initSmokeNoise(struct FluidModifierData *fmd = NULL);
void initializeMantaflow();
void terminateMantaflow();
bool runPythonString(vector<string> commands);
string getRealValue(const string &varName);
string parseLine(const string &line);
string parseScript(const string &setup_string, FluidModifierData *mmd = NULL);
string getDirectory(struct FluidModifierData *mmd, string subdirectory);
string getFile(struct FluidModifierData *mmd,
string parseScript(const string &setup_string, FluidModifierData *fmd = NULL);
string getDirectory(struct FluidModifierData *fmd, string subdirectory);
string getFile(struct FluidModifierData *fmd,
string subdirectory,
string fname,
string extension,

View File

@@ -27,9 +27,9 @@
#include "manta_fluid_API.h"
/* Fluid functions */
MANTA *manta_init(int *res, struct FluidModifierData *mmd)
MANTA *manta_init(int *res, struct FluidModifierData *fmd)
{
return new MANTA(res, mmd);
return new MANTA(res, fmd);
}
void manta_free(MANTA *fluid)
{
@@ -37,173 +37,173 @@ void manta_free(MANTA *fluid)
fluid = nullptr;
}
void manta_ensure_obstacle(MANTA *fluid, struct FluidModifierData *mmd)
void manta_ensure_obstacle(MANTA *fluid, struct FluidModifierData *fmd)
{
if (!fluid)
return;
fluid->initObstacle(mmd);
fluid->initObstacle(fmd);
fluid->updatePointers();
}
void manta_ensure_guiding(MANTA *fluid, struct FluidModifierData *mmd)
void manta_ensure_guiding(MANTA *fluid, struct FluidModifierData *fmd)
{
if (!fluid)
return;
fluid->initGuiding(mmd);
fluid->initGuiding(fmd);
fluid->updatePointers();
}
void manta_ensure_invelocity(MANTA *fluid, struct FluidModifierData *mmd)
void manta_ensure_invelocity(MANTA *fluid, struct FluidModifierData *fmd)
{
if (!fluid)
return;
fluid->initInVelocity(mmd);
fluid->initInVelocity(fmd);
fluid->updatePointers();
}
void manta_ensure_outflow(MANTA *fluid, struct FluidModifierData *mmd)
void manta_ensure_outflow(MANTA *fluid, struct FluidModifierData *fmd)
{
if (!fluid)
return;
fluid->initOutflow(mmd);
fluid->initOutflow(fmd);
fluid->updatePointers();
}
int manta_write_config(MANTA *fluid, FluidModifierData *mmd, int framenr)
int manta_write_config(MANTA *fluid, FluidModifierData *fmd, int framenr)
{
if (!fluid || !mmd)
if (!fluid || !fmd)
return 0;
return fluid->writeConfiguration(mmd, framenr);
return fluid->writeConfiguration(fmd, framenr);
}
int manta_write_data(MANTA *fluid, FluidModifierData *mmd, int framenr)
int manta_write_data(MANTA *fluid, FluidModifierData *fmd, int framenr)
{
if (!fluid || !mmd)
if (!fluid || !fmd)
return 0;
return fluid->writeData(mmd, framenr);
return fluid->writeData(fmd, framenr);
}
int manta_write_noise(MANTA *fluid, FluidModifierData *mmd, int framenr)
int manta_write_noise(MANTA *fluid, FluidModifierData *fmd, int framenr)
{
if (!fluid || !mmd)
if (!fluid || !fmd)
return 0;
return fluid->writeNoise(mmd, framenr);
return fluid->writeNoise(fmd, framenr);
}
int manta_read_config(MANTA *fluid, FluidModifierData *mmd, int framenr)
int manta_read_config(MANTA *fluid, FluidModifierData *fmd, int framenr)
{
if (!fluid || !mmd)
if (!fluid || !fmd)
return 0;
return fluid->readConfiguration(mmd, framenr);
return fluid->readConfiguration(fmd, framenr);
}
int manta_read_data(MANTA *fluid, FluidModifierData *mmd, int framenr, bool resumable)
int manta_read_data(MANTA *fluid, FluidModifierData *fmd, int framenr, bool resumable)
{
if (!fluid || !mmd)
if (!fluid || !fmd)
return 0;
return fluid->readData(mmd, framenr, resumable);
return fluid->readData(fmd, framenr, resumable);
}
int manta_read_noise(MANTA *fluid, FluidModifierData *mmd, int framenr, bool resumable)
int manta_read_noise(MANTA *fluid, FluidModifierData *fmd, int framenr, bool resumable)
{
if (!fluid || !mmd)
if (!fluid || !fmd)
return 0;
return fluid->readNoise(mmd, framenr, resumable);
return fluid->readNoise(fmd, framenr, resumable);
}
int manta_read_mesh(MANTA *fluid, FluidModifierData *mmd, int framenr)
int manta_read_mesh(MANTA *fluid, FluidModifierData *fmd, int framenr)
{
if (!fluid || !mmd)
if (!fluid || !fmd)
return 0;
return fluid->readMesh(mmd, framenr);
return fluid->readMesh(fmd, framenr);
}
int manta_read_particles(MANTA *fluid, FluidModifierData *mmd, int framenr, bool resumable)
int manta_read_particles(MANTA *fluid, FluidModifierData *fmd, int framenr, bool resumable)
{
if (!fluid || !mmd)
if (!fluid || !fmd)
return 0;
return fluid->readParticles(mmd, framenr, resumable);
return fluid->readParticles(fmd, framenr, resumable);
}
int manta_read_guiding(MANTA *fluid, FluidModifierData *mmd, int framenr, bool sourceDomain)
int manta_read_guiding(MANTA *fluid, FluidModifierData *fmd, int framenr, bool sourceDomain)
{
if (!fluid || !mmd)
if (!fluid || !fmd)
return 0;
return fluid->readGuiding(mmd, framenr, sourceDomain);
return fluid->readGuiding(fmd, framenr, sourceDomain);
}
int manta_bake_data(MANTA *fluid, FluidModifierData *mmd, int framenr)
int manta_bake_data(MANTA *fluid, FluidModifierData *fmd, int framenr)
{
if (!fluid || !mmd)
if (!fluid || !fmd)
return 0;
return fluid->bakeData(mmd, framenr);
return fluid->bakeData(fmd, framenr);
}
int manta_bake_noise(MANTA *fluid, FluidModifierData *mmd, int framenr)
int manta_bake_noise(MANTA *fluid, FluidModifierData *fmd, int framenr)
{
if (!fluid || !mmd)
if (!fluid || !fmd)
return 0;
return fluid->bakeNoise(mmd, framenr);
return fluid->bakeNoise(fmd, framenr);
}
int manta_bake_mesh(MANTA *fluid, FluidModifierData *mmd, int framenr)
int manta_bake_mesh(MANTA *fluid, FluidModifierData *fmd, int framenr)
{
if (!fluid || !mmd)
if (!fluid || !fmd)
return 0;
return fluid->bakeMesh(mmd, framenr);
return fluid->bakeMesh(fmd, framenr);
}
int manta_bake_particles(MANTA *fluid, FluidModifierData *mmd, int framenr)
int manta_bake_particles(MANTA *fluid, FluidModifierData *fmd, int framenr)
{
if (!fluid || !mmd)
if (!fluid || !fmd)
return 0;
return fluid->bakeParticles(mmd, framenr);
return fluid->bakeParticles(fmd, framenr);
}
int manta_bake_guiding(MANTA *fluid, FluidModifierData *mmd, int framenr)
int manta_bake_guiding(MANTA *fluid, FluidModifierData *fmd, int framenr)
{
if (!fluid || !mmd)
if (!fluid || !fmd)
return 0;
return fluid->bakeGuiding(mmd, framenr);
return fluid->bakeGuiding(fmd, framenr);
}
int manta_has_data(MANTA *fluid, FluidModifierData *mmd, int framenr)
int manta_has_data(MANTA *fluid, FluidModifierData *fmd, int framenr)
{
if (!fluid || !mmd)
if (!fluid || !fmd)
return 0;
return fluid->hasData(mmd, framenr);
return fluid->hasData(fmd, framenr);
}
int manta_has_noise(MANTA *fluid, FluidModifierData *mmd, int framenr)
int manta_has_noise(MANTA *fluid, FluidModifierData *fmd, int framenr)
{
if (!fluid || !mmd)
if (!fluid || !fmd)
return 0;
return fluid->hasNoise(mmd, framenr);
return fluid->hasNoise(fmd, framenr);
}
int manta_has_mesh(MANTA *fluid, FluidModifierData *mmd, int framenr)
int manta_has_mesh(MANTA *fluid, FluidModifierData *fmd, int framenr)
{
if (!fluid || !mmd)
if (!fluid || !fmd)
return 0;
return fluid->hasMesh(mmd, framenr);
return fluid->hasMesh(fmd, framenr);
}
int manta_has_particles(MANTA *fluid, FluidModifierData *mmd, int framenr)
int manta_has_particles(MANTA *fluid, FluidModifierData *fmd, int framenr)
{
if (!fluid || !mmd)
if (!fluid || !fmd)
return 0;
return fluid->hasParticles(mmd, framenr);
return fluid->hasParticles(fmd, framenr);
}
int manta_has_guiding(MANTA *fluid, FluidModifierData *mmd, int framenr, bool domain)
int manta_has_guiding(MANTA *fluid, FluidModifierData *fmd, int framenr, bool domain)
{
if (!fluid || !mmd)
if (!fluid || !fmd)
return 0;
return fluid->hasGuiding(mmd, framenr, domain);
return fluid->hasGuiding(fmd, framenr, domain);
}
void manta_update_variables(MANTA *fluid, FluidModifierData *mmd)
void manta_update_variables(MANTA *fluid, FluidModifierData *fmd)
{
if (!fluid)
return;
fluid->updateVariables(mmd);
fluid->updateVariables(fmd);
}
int manta_get_frame(MANTA *fluid)
@@ -227,11 +227,11 @@ void manta_adapt_timestep(MANTA *fluid)
fluid->adaptTimestep();
}
bool manta_needs_realloc(MANTA *fluid, FluidModifierData *mmd)
bool manta_needs_realloc(MANTA *fluid, FluidModifierData *fmd)
{
if (!fluid)
return false;
return fluid->needsRealloc(mmd);
return fluid->needsRealloc(fmd);
}
/* Fluid accessors */
@@ -361,11 +361,11 @@ float *manta_get_phioutstatic_in(MANTA *fluid)
}
/* Smoke functions */
void manta_smoke_export_script(MANTA *smoke, FluidModifierData *mmd)
void manta_smoke_export_script(MANTA *smoke, FluidModifierData *fmd)
{
if (!smoke || !mmd)
if (!smoke || !fmd)
return;
smoke->exportSmokeScript(mmd);
smoke->exportSmokeScript(fmd);
}
void manta_smoke_export(MANTA *smoke,
@@ -527,31 +527,31 @@ void manta_smoke_turbulence_get_rgba_fixed_color(MANTA *smoke,
get_rgba_fixed_color(color, smoke->getTotalCellsHigh(), data, sequential);
}
void manta_smoke_ensure_heat(MANTA *smoke, struct FluidModifierData *mmd)
void manta_smoke_ensure_heat(MANTA *smoke, struct FluidModifierData *fmd)
{
if (smoke) {
smoke->initHeat(mmd);
smoke->initHeat(fmd);
smoke->updatePointers();
}
}
void manta_smoke_ensure_fire(MANTA *smoke, struct FluidModifierData *mmd)
void manta_smoke_ensure_fire(MANTA *smoke, struct FluidModifierData *fmd)
{
if (smoke) {
smoke->initFire(mmd);
smoke->initFire(fmd);
if (smoke->usingNoise()) {
smoke->initFireHigh(mmd);
smoke->initFireHigh(fmd);
}
smoke->updatePointers();
}
}
void manta_smoke_ensure_colors(MANTA *smoke, struct FluidModifierData *mmd)
void manta_smoke_ensure_colors(MANTA *smoke, struct FluidModifierData *fmd)
{
if (smoke) {
smoke->initColors(mmd);
smoke->initColors(fmd);
if (smoke->usingNoise()) {
smoke->initColorsHigh(mmd);
smoke->initColorsHigh(fmd);
}
smoke->updatePointers();
}
@@ -700,17 +700,17 @@ int manta_smoke_turbulence_get_cells(MANTA *smoke)
}
/* Liquid functions */
void manta_liquid_export_script(MANTA *liquid, FluidModifierData *mmd)
void manta_liquid_export_script(MANTA *liquid, FluidModifierData *fmd)
{
if (!liquid || !mmd)
if (!liquid || !fmd)
return;
liquid->exportLiquidScript(mmd);
liquid->exportLiquidScript(fmd);
}
void manta_liquid_ensure_sndparts(MANTA *liquid, struct FluidModifierData *mmd)
void manta_liquid_ensure_sndparts(MANTA *liquid, struct FluidModifierData *fmd)
{
if (liquid) {
liquid->initLiquidSndParts(mmd);
liquid->initLiquidSndParts(fmd);
liquid->updatePointers();
}
}

View File

@@ -146,19 +146,19 @@ mantaMsg('1 Mantaflow cell is ' + str(ratioMetersToRes_s$ID$) + ' Blender length
ratioResToBLength_s$ID$ = float(res_s$ID$) / float(domainSize_s$ID$) # [cells / blength] (blength: cm, m, or km, ... )\n\
mantaMsg('1 Blender length unit is ' + str(ratioResToBLength_s$ID$) + ' Mantaflow cells long.')\n\
\n\
ratioBTimeToTimstep_s$ID$ = float(1) / float(frameLengthRaw_s$ID$) # the time within 1 blender time unit, see also fluid.c\n\
mantaMsg('1 Blender time unit is ' + str(ratioBTimeToTimstep_s$ID$) + ' Mantaflow time units long.')\n\
ratioBTimeToTimestep_s$ID$ = float(1) / float(frameLengthRaw_s$ID$) # the time within 1 blender time unit, see also fluid.c\n\
mantaMsg('1 Blender time unit is ' + str(ratioBTimeToTimestep_s$ID$) + ' Mantaflow time units long.')\n\
\n\
ratioFrameToFramelength_s$ID$ = float(1) / float(frameLengthUnscaled_s$ID$ ) # the time within 1 frame\n\
mantaMsg('frame / frameLength is ' + str(ratioFrameToFramelength_s$ID$) + ' Mantaflow time units long.')\n\
\n\
scaleAcceleration_s$ID$ = ratioResToBLength_s$ID$ * (ratioBTimeToTimstep_s$ID$**2)# [meters/btime^2] to [cells/timestep^2] (btime: sec, min, or h, ...)\n\
scaleAcceleration_s$ID$ = ratioResToBLength_s$ID$ * (ratioBTimeToTimestep_s$ID$**2)# [meters/btime^2] to [cells/timestep^2] (btime: sec, min, or h, ...)\n\
mantaMsg('scaleAcceleration is ' + str(scaleAcceleration_s$ID$))\n\
\n\
scaleSpeedFrames_s$ID$ = ratioResToBLength_s$ID$ * ratioFrameToFramelength_s$ID$ # [blength/frame] to [cells/frameLength]\n\
mantaMsg('scaleSpeed is ' + str(scaleSpeedFrames_s$ID$))\n\
\n\
scaleSpeedTime_s$ID$ = ratioResToBLength_s$ID$ * ratioBTimeToTimstep_s$ID$ # [blength/btime] to [cells/frameLength]\n\
scaleSpeedTime_s$ID$ = ratioResToBLength_s$ID$ * ratioBTimeToTimestep_s$ID$ # [blength/btime] to [cells/frameLength]\n\
mantaMsg('scaleSpeedTime is ' + str(scaleSpeedTime_s$ID$))\n\
\n\
gravity_s$ID$ *= scaleAcceleration_s$ID$ # scale from world acceleration to cell based acceleration\n\
@@ -461,14 +461,14 @@ if 'fluid_data_dict_resume_s$ID$' in globals(): fluid_data_dict_resume_s$ID$.cle
if 'fluid_guiding_dict_s$ID$' in globals(): fluid_guiding_dict_s$ID$.clear()\n\
if 'fluid_vel_dict_s$ID$' in globals(): fluid_vel_dict_s$ID$.clear()\n\
\n\
# Delete all childs from objects (e.g. pdata for particles)\n\
mantaMsg('Release solver childs childs')\n\
# Delete all children from objects (e.g. pdata for particles)\n\
mantaMsg('Release solver childrens children')\n\
for var in list(globals()):\n\
if var.endswith('_pp$ID$') or var.endswith('_mesh$ID$'):\n\
del globals()[var]\n\
\n\
# Now delete childs from solver objects\n\
mantaMsg('Release solver childs')\n\
# Now delete children from solver objects\n\
mantaMsg('Release solver children')\n\
for var in list(globals()):\n\
if var.endswith('_s$ID$') or var.endswith('_sn$ID$') or var.endswith('_sm$ID$') or var.endswith('_sp$ID$') or var.endswith('_sg$ID$'):\n\
del globals()[var]\n\
@@ -502,10 +502,12 @@ gc.collect()\n";
// BAKE
//////////////////////////////////////////////////////////////////////
/* This has to match the behavior of BLI_path_frame,
* for positive and negative frame numbers. */
const std::string fluid_cache_helper =
"\n\
def fluid_cache_get_framenr_formatted_$ID$(framenr):\n\
return str(framenr).zfill(4) # framenr with leading zeroes\n";
return str(framenr).zfill(4) if framenr >= 0 else str(framenr).zfill(5)\n";
const std::string fluid_bake_multiprocessing =
"\n\

35
intern/sky/CMakeLists.txt Normal file
View File

@@ -0,0 +1,35 @@
# ***** BEGIN GPL LICENSE BLOCK *****
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ***** END GPL LICENSE BLOCK *****
set(INC
include
)
set(INC_SYS
)
set(SRC
source/sky_model.cpp
source/sky_nishita.cpp
)
set(LIB
)
blender_add_lib(bf_intern_sky "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")

View File

@@ -298,14 +298,14 @@ HINT #1: if you want to model the sky of an earth-like planet that orbits
previous paragraph.
*/
#include "util/util_types.h"
#ifndef __SKY_MODEL_H__
#define __SKY_MODEL_H__
CCL_NAMESPACE_BEGIN
#ifdef __cplusplus
extern "C" {
#endif
#ifndef _SKY_MODEL_H_
# define _SKY_MODEL_H_
typedef double ArHosekSkyModelConfiguration[9];
typedef double SKY_ArHosekSkyModelConfiguration[9];
// Spectral version of the model
@@ -335,8 +335,8 @@ typedef double ArHosekSkyModelConfiguration[9];
---------------------------------------------------------------------------- */
typedef struct ArHosekSkyModelState {
ArHosekSkyModelConfiguration configs[11];
typedef struct SKY_ArHosekSkyModelState {
SKY_ArHosekSkyModelConfiguration configs[11];
double radiances[11];
double turbidity;
double solar_radius;
@@ -344,7 +344,7 @@ typedef struct ArHosekSkyModelState {
double emission_correction_factor_sun[11];
double albedo;
double elevation;
} ArHosekSkyModelState;
} SKY_ArHosekSkyModelState;
/* ----------------------------------------------------------------------------
@@ -355,9 +355,9 @@ typedef struct ArHosekSkyModelState {
---------------------------------------------------------------------------- */
ArHosekSkyModelState *arhosekskymodelstate_alloc_init(const double solar_elevation,
const double atmospheric_turbidity,
const double ground_albedo);
SKY_ArHosekSkyModelState *SKY_arhosekskymodelstate_alloc_init(const double solar_elevation,
const double atmospheric_turbidity,
const double ground_albedo);
/* ----------------------------------------------------------------------------
@@ -388,66 +388,68 @@ ArHosekSkyModelState *arhosekskymodelstate_alloc_init(const double solar_elevati
---------------------------------------------------------------------------- */
ArHosekSkyModelState *arhosekskymodelstate_alienworld_alloc_init(
SKY_ArHosekSkyModelState *SKY_arhosekskymodelstate_alienworld_alloc_init(
const double solar_elevation,
const double solar_intensity,
const double solar_surface_temperature_kelvin,
const double atmospheric_turbidity,
const double ground_albedo);
void arhosekskymodelstate_free(ArHosekSkyModelState *state);
void SKY_arhosekskymodelstate_free(SKY_ArHosekSkyModelState *state);
double arhosekskymodel_radiance(ArHosekSkyModelState *state,
double theta,
double gamma,
double wavelength);
double SKY_arhosekskymodel_radiance(SKY_ArHosekSkyModelState *state,
double theta,
double gamma,
double wavelength);
// CIE XYZ and RGB versions
ArHosekSkyModelState *arhosek_xyz_skymodelstate_alloc_init(const double turbidity,
const double albedo,
const double elevation);
SKY_ArHosekSkyModelState *SKY_arhosek_xyz_skymodelstate_alloc_init(const double turbidity,
const double albedo,
const double elevation);
ArHosekSkyModelState *arhosek_rgb_skymodelstate_alloc_init(const double turbidity,
const double albedo,
const double elevation);
SKY_ArHosekSkyModelState *SKY_arhosek_rgb_skymodelstate_alloc_init(const double turbidity,
const double albedo,
const double elevation);
double arhosek_tristim_skymodel_radiance(ArHosekSkyModelState *state,
double theta,
double gamma,
int channel);
double SKY_arhosek_tristim_skymodel_radiance(SKY_ArHosekSkyModelState *state,
double theta,
double gamma,
int channel);
// Delivers the complete function: sky + sun, including limb darkening.
// Please read the above description before using this - there are several
// caveats!
double arhosekskymodel_solar_radiance(ArHosekSkyModelState *state,
double theta,
double gamma,
double wavelength);
#endif // _SKY_MODEL_H_
double SKY_arhosekskymodel_solar_radiance(SKY_ArHosekSkyModelState *state,
double theta,
double gamma,
double wavelength);
/* Nishita improved sky model */
void nishita_skymodel_precompute_texture(float *pixels,
int stride,
int start_y,
int end_y,
int width,
int height,
float sun_elevation,
void SKY_nishita_skymodel_precompute_texture(float *pixels,
int stride,
int start_y,
int end_y,
int width,
int height,
float sun_elevation,
float altitude,
float air_density,
float dust_density,
float ozone_density);
void SKY_nishita_skymodel_precompute_sun(float sun_elevation,
float angular_diameter,
float altitude,
float air_density,
float dust_density,
float ozone_density);
float *r_pixel_bottom,
float *r_pixel_top);
void nishita_skymodel_precompute_sun(float sun_elevation,
float angular_diameter,
float altitude,
float air_density,
float dust_density,
float *pixel_bottom,
float *pixel_top);
#ifdef __cplusplus
}
#endif
CCL_NAMESPACE_END
#endif // __SKY_MODEL_H__

View File

@@ -0,0 +1,157 @@
/*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef __SKY_FLOAT3_H__
#define __SKY_FLOAT3_H__
// minimal float3 + util_math.h implementation for nishita sky model
#include <math.h>
#ifndef M_PI_F
# define M_PI_F (3.1415926535897932f) /* pi */
#endif
#ifndef M_PI_2_F
# define M_PI_2_F (1.5707963267948966f) /* pi/2 */
#endif
#ifndef M_2PI_F
# define M_2PI_F (6.2831853071795864f) /* 2*pi */
#endif
struct float3 {
float x, y, z;
float3() = default;
float3(const float *ptr) : x{ptr[0]}, y{ptr[1]}, z{ptr[2]}
{
}
float3(const float (*ptr)[3]) : float3((const float *)ptr)
{
}
explicit float3(float value) : x(value), y(value), z(value)
{
}
explicit float3(int value) : x(value), y(value), z(value)
{
}
float3(float x, float y, float z) : x{x}, y{y}, z{z}
{
}
operator const float *() const
{
return &x;
}
operator float *()
{
return &x;
}
friend float3 operator*(const float3 &a, float b)
{
return {a.x * b, a.y * b, a.z * b};
}
friend float3 operator*(float b, const float3 &a)
{
return {a.x * b, a.y * b, a.z * b};
}
friend float3 operator-(const float3 &a, const float3 &b)
{
return {a.x - b.x, a.y - b.y, a.z - b.z};
}
friend float3 operator-(const float3 &a)
{
return {-a.x, -a.y, -a.z};
}
float length_squared() const
{
return x * x + y * y + z * z;
}
float length() const
{
return sqrt(length_squared());
}
static float distance(const float3 &a, const float3 &b)
{
return (a - b).length();
}
friend float3 operator+(const float3 &a, const float3 &b)
{
return {a.x + b.x, a.y + b.y, a.z + b.z};
}
void operator+=(const float3 &b)
{
this->x += b.x;
this->y += b.y;
this->z += b.z;
}
friend float3 operator*(const float3 &a, const float3 &b)
{
return {a.x * b.x, a.y * b.y, a.z * b.z};
}
};
inline float sqr(float a)
{
return a * a;
}
inline float3 make_float3(float x, float y, float z)
{
return float3(x, y, z);
}
inline float dot(const float3 &a, const float3 &b)
{
return a.x * b.x + a.y * b.y + a.z * b.z;
}
inline float distance(const float3 &a, const float3 &b)
{
return float3::distance(a, b);
}
inline float len_squared(float3 f)
{
return f.length_squared();
}
inline float len(float3 f)
{
return f.length();
}
inline float reduce_add(float3 f)
{
return f.x + f.y + f.z;
}
#endif /* __SKY_FLOAT3_H__ */

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