Compare commits

...

399 Commits

Author SHA1 Message Date
b3a7e47c9e remove unnecessary mutex 2020-03-22 16:16:19 +01:00
f55198da42 use multithreading for obj parsing 2020-03-22 16:14:02 +01:00
95e71dad88 initial mesh generation 2020-03-22 15:47:51 +01:00
6a61e86b43 count total amounts 2020-03-22 14:57:05 +01:00
7ae5433779 prepare function for object generation 2020-03-22 14:30:46 +01:00
4be9d4541e collect all segments 2020-03-22 14:24:08 +01:00
01416b7e8d cleanup 2020-03-22 14:16:48 +01:00
df984b1dd6 parse face information 2020-03-22 14:12:45 +01:00
a4d1acf1ce parse more stuff 2020-03-22 13:19:12 +01:00
a40bdbb5fc convert stringref to float 2020-03-22 11:33:49 +01:00
0f2147bf52 parse object name 2020-03-22 11:01:38 +01:00
d4a3adf045 strip methods for stringref 2020-03-22 10:56:15 +01:00
c7d9070ccb tests for new stringref functions 2020-03-21 14:04:08 +01:00
3512be55e9 improved file name parsing 2020-03-20 12:41:27 +01:00
4a4a36627e initial obj import experiments 2020-03-19 21:32:40 +01:00
689606887f Cleanup: add extern C 2020-03-19 16:54:09 +01:00
89b0465136 Fix T74908: volume object step size can not be set back to zero 2020-03-19 16:00:40 +01:00
2be14e0ec4 Fix typo in make.bat help for build directory 2020-03-19 15:31:21 +01:00
2982c9ba0a ColorManagement: Incorrect Memory Read for RGB images
When RGB images or BW images are converted to a GPU texture and color
space conversion was needed the images were read incorrectly.

This patch checks the correct amount of channels in the image and uses
that as the correct pixel stride.
2020-03-19 15:26:53 +01:00
9ace7e2439 Fix T74925: Texture Paint Stencil Mask crash
Use first texture if we dont have an ImageUser.

Maniphest Tasks: T74925

Differential Revision: https://developer.blender.org/D7181
2020-03-19 15:18:09 +01:00
42012493a8 Fix T74916: Industry compat keymap: GP Tweak tool acts like the Cursor tool 2020-03-19 14:43:50 +01:00
91c1759956 Fluid: Cleaned up some parts of the fluid modifier UI
Especially when expanding the UI panel horizontally, there were some problems with empty space.
2020-03-19 13:15:39 +01:00
cc516b82ef Fix T74915: Gpencil Tweak tool does not add point to selection holding Shift 2020-03-19 12:11:48 +01:00
885caa4535 Multires: Support "Subdivide" for Simple subdivision type
Is done by considering all base edges infinitely sharp.

In the future can become a different operator option to allow to mix
Catmull-Clark and simple subdivisions. For now just sticking to what
old good Blender versions were doing.

Fixes T74869: Simple subdivision type is not working as it should
2020-03-19 11:59:45 +01:00
e793a47efb Multires: Optimize memory usage further
Avoid storing any loose edges for the propagation process.
Also avoid any edge which crease is zero.
2020-03-19 11:59:45 +01:00
ccb731f2dd Multires: Reduce memory footprint after previous fix
The idea is following: only store information about edges which are

1. Communicated to the OpenSubdiv topology.

   This rules out all loose edges, as they are not needed for the
   propagation process.

2. Correspond to edge from the base mesh.

   This avoids storing edges which are generated between inner face.
   Those are not to have any sharpness to allow smooth propagation.

There is still possible to have memory peak in some obscure case when
mesh contains a lot of loose edges. It can be optimized further by
utilizing knowledge of the non-loose tags.
2020-03-19 11:59:45 +01:00
317a9cf835 Multires: Subdiv, properly support base edge crease
The title says it all actually. The test case is to get default cube,
set some edges to non-zero crease, add multires modifier and hit the
"Subdivide" button few times.

The memory footprint might be optimized by not storing information
about inner generated edges.
2020-03-19 11:59:45 +01:00
6e39445f80 GPencil: Cleanup - Split BKE_gpencil.h geometry functions into BKE_gpencil_geom.h
This split prepare the code for future geometry functions.
2020-03-19 11:38:22 +01:00
e839a25651 RNA: add MetaElem.select & use_scale_stiffness 2020-03-19 21:16:57 +11:00
7e9575f7a1 Fix T74701: Text on Curve Scaling Issue
Both scaling the text itself, as well as scaling the curve wasnt
updating, now added relations for this.

Maniphest Tasks: T74701

Differential Revision: https://developer.blender.org/D7140
2020-03-19 10:43:10 +01:00
b49dbb635a Subdiv: Make Blender crease to OSD sharpness reusable
Makes it so conversion is centralized in a single place.

We might consider removing any conversion, passing value as-is which
will be easier for I/O scripts to match crease. The downside of that
would be loose of control range in certain qualities and values of
crease.

There shouldn't be any functional changes in this commit.
2020-03-19 10:33:51 +01:00
53674fb255 Multires: Add missing context initialization
Might have caused access to uninitialized memory when foreach()
would have failed for some reason.
2020-03-19 10:08:48 +01:00
9dfc480ad1 Multires: Cleanup, typo in type name 2020-03-19 10:01:56 +01:00
ffb95baebe Multires: Store modifier pointer for subdivide
Allows to access its settings during the subdivision process.
2020-03-19 10:01:56 +01:00
2d1cce8331 Cleanup: make format after SortedIncludes change 2020-03-19 09:33:58 +01:00
008aaaa378 Code quality: Enable SortedIncludes
Code quality: Enable SortedIncludes in .clang-format

This patch does not include a `make format`, which will follow suit.

Differential Revision: D6811
2020-03-19 09:33:43 +01:00
Dalai Felinto
473316e246 Cleanup: make format (and adding . to end of comment) 2020-03-19 09:29:47 +01:00
Jeroen Bakker
fd48ff1296 Fix T73931: Stereo Viewport Color Management
Stereoscopic viewport didn't support Color Manangement due recent
changes in the color management pipeline. In order to solve the issue we
will migrate the strereo rendering into the GPUViewport. This will share
some textures and reduce required GPU memory.

Reviewed By: fclem, dfelinto

Differential Revision: https://developer.blender.org/D6922
2020-03-19 08:26:48 +01:00
Jeroen Bakker
fe045b2b77 WindowManager: Remove Stereo Offscreen
Stereo offscreen rendering has been replaced with stereo viewport
rendering. When an offscreen buffer is used it is only used for mono
rendering.

This patch will remove the second offscreen buffer.

Reviewed By: fclem

Differential Revision: https://developer.blender.org/D7153
2020-03-19 08:03:40 +01:00
d68d1da1f3 UI: scale sequence handle by pixelsize 2020-03-19 12:28:59 +11:00
f4a60fd85c Cleanup: rename variables which aren't specific to macOS 2020-03-19 12:28:50 +11:00
326ce2d625 Cleanup: declare & assign variables on the same line
Use less vertical space.
2020-03-19 12:28:50 +11:00
07c4c86049 Theme: update blender light theme
Also correct gizmo_view_align color.
2020-03-19 12:18:41 +11:00
b62e1146e1 UI: add view aligned gizmo color
Was hard coded to white making white backgrounds impractical.

D7162 by @billreynish with edits.
2020-03-19 12:09:53 +11:00
014e569258 Cleanup: use '\' for doxygen commands 2020-03-19 12:09:07 +11:00
ed4c47632f Cleanup: spelling 2020-03-19 12:09:07 +11:00
5bf09bbcdf Cleanup: shadow warning 2020-03-19 12:09:02 +11:00
f3e7c1e8c8 Fix building on Linux as '__time64_t' isn't portable 2020-03-19 11:56:02 +11:00
Robert Guetzkow
f70241deba Fix (unreported): Crash on accessing active sequence in select groupped operator
This patch moves the NULL check of `actseq` to the correct position, which should happen
before the `channel` is assigned. Otherwise an attempt to call the `sequencer_select_grouped_exec`,
when there is no active sequence and `use_active_channel` set to true, results in a crash.

Reviewed By: ISS

Differential Revision: https://developer.blender.org/D7170
2020-03-19 00:49:46 +01:00
271231f58e VSE: Strip drawing improvements
This patch include changes:
- Thicker and clearer selection indication
- Slimmer handles
- More transparent muted strips
- Trim frame number is drawn inside the strip
- Strip text is drawn in upper part of strip
- Color strips now have specific color, with chosen color drawn under strip text
- Transition strip will use color of input strips showing direction of transition
- Selecting effect strip will highlight input strips
- Selecting multicam strips will highlight target channel
- Missing media state is now indicated by a red line drawn on the top part of the strip
- A checkerboard pattern is now drawn on the outsides of the meta range
- Hold still regions are now always drawn if existent, with a darker shade of the strip’s background color

Author: Alessio Monti di Sopra <a.monti>

Reviewed By: ISS

Differential Revision: https://developer.blender.org/D6883
2020-03-19 00:24:09 +01:00
348d2fa09e VSE: Disk cache
This patch implements dumping images from cache to HDD.
The main goal of this system is to provide a means to achieve consistent playback speed mainly for strips that are not possible to preview in real time.

How to use:
Disk cache has own settings in user preferences for path to storage, size limit and compression level.
To use disk cache, you need to check `Use Disk Cache` box, set `Disk Cache Directory`, `Disk Cache Limit` and save or open existing .blend file.
By default sequencer output will be cached only. Manual setting is possible in cache panel.

Uses:
 - Replacement or alternative for proxies. Disk cache will work with any strip type, supports float images as well.
 - Storage for strip thumbnails.
 - Less RAM needs to be allocated for preview cache

How it works:
Disk cache is extension of RAM cache. Every image, that is stored or deleted in RAM will be stored or deleted on HDD as well. Images can be compressed to save space and for use on slower drives. Compressed images are slower to write and read though.
Images are stored in bulk of 100 rendered frames per one file. This is to overcome slow file access time for large amount of files. Drawback is, that if one frame needs to be redrawn, all 100 frames are deleted.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D5524
2020-03-19 00:07:30 +01:00
c8b4b4c0fa Fluid: Fixed issue with intial velocities in liquid domains
The fix for T74762 (bf9c4af9bb) introduced this issue. Initial velocities were not applied to liquids anymore.
2020-03-19 00:04:13 +01:00
99be00fdb1 Cleanup: Prepare XR code for sorted headers 2020-03-18 20:53:02 +01:00
1935cd4027 Fix T74837: GPencil: Mirror over first selected marker crashes
'mirror_gpf_marker()' needs a NULL bGPDframe for initialization [but
still requires a scene to get the marker].

Maniphest Tasks: T74837

Differential Revision: https://developer.blender.org/D7166
2020-03-18 20:46:22 +01:00
a12ae67cf7 UI: Update the Clay Thumb Sculpt icon
The previous icon was identical with the Thumb icon.

New icon designed by Damian Winnichenko
2020-03-18 20:38:28 +01:00
c102dfd43d Cleanup: Prepare for sorted headers on windows
To prepare for D6811 small changes were needed.
we can no longer undefine near/far since the windows
headers use those extensively.

some of the imbuf files need to include the windows
headers explicitly to make sure it builds.
2020-03-18 13:26:38 -06:00
6bfe7c7a02 Fix (harmless) use of uninitialized variables in Cycles 2020-03-18 19:51:54 +01:00
9a116c7c2d Cleanup: 64 bit file IO on windows.
Unlike Linux where fseek/tell will be either 32 or 64 bit
depending on the target platform, it will always be 32 bit
on windows.

We had some macro magic in BLI_winstuff.h that substituted
them for 64 bit versions, but that is upsetting the system
headers if they get included after BLI_winstuff.h which
is problematic for D6811.

This diff adds proper functions in blenlib and updates
all calls that were using the BLI_winstuff.h header to
gain 64 bit file IO.

note: Anything that was using the 32 bit versions (ie not
including BLI_winstuff.h) will still be using the 32 bit
versions, which is perhaps a good code quality Friday project.

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

Reviewers: brecht dfelinto
2020-03-18 12:13:03 -06:00
ac74a843d2 Fix NULL-pointer dereference after error during VR session start 2020-03-18 18:24:11 +01:00
1a502097c7 Cleanup: Fix build warnings on windows.
Two headers define the _USE_MATH_DEFINES symbol now, if both
are included warnings are generated.

Added some guards, all good again.
2020-03-18 11:23:56 -06:00
c9c08dc7c8 Fix compilation error after recent change 2020-03-18 18:16:18 +01:00
805c4ab6bc UI: Make sure theme UI names are correctly capitalized
Also removed redundant use of 'color' in some instances.
2020-03-18 18:02:35 +01:00
efb53f5181 Fix T74524: tooltip for smoke dissolve time is backwards 2020-03-18 17:54:17 +01:00
b88ca3e6d1 Cleanup: Resolve HKEY conflict
Both the MS headers and blender headers define the HKEY
which gives all kind of inclusion order issues.

This diff renames all *KEY constants to EVT_*KEY to resolve
this conflict.

Reviewed By: brecht , dfelinto

Differential Revision: http://developer.blender.org/D7164
2020-03-18 10:38:37 -06:00
9e382dd2a3 Fix T74542, T74386: schulpt changes not saving (dyntopo or mutires)
Caused by rB2d423479bdea.
Correct check for stroke being painted.

thx also to brecht checking.
2020-03-18 16:41:41 +01:00
237ef0dcc7 Fix T74842: Remove Vertex Paint hotkeys
There were some conflicts with these keys.
2020-03-18 15:49:58 +01:00
7bde3f63dd GPencil: Fix typo error 2020-03-18 15:33:03 +01:00
19df67cd75 Fix build errors with WITH_HEADLESS or WITH_GHOST_SDL
Disable WITH_XR_OPENXR entirely for these cases. For headless XR
features don't make much sense, for SDL support is not implemented.
2020-03-18 15:19:41 +01:00
82fc81816e Fix openXR building with install_deps in some compilers. 2020-03-18 15:11:03 +01:00
efdc93fcc6 Fix T74876: Crash when snapping to faces
The crash occurs after operators change the amount of editmesh looptris.
The looptris of the evaluated object's editmesh are not updated.
2020-03-18 09:58:24 -03:00
52c0742560 GPencil: Remove Panel Grease Pencil and move Use Lights to Visibility
It was too much to have a panel for that.
2020-03-18 13:48:30 +01:00
d8897bed99 Fix headless and Python module build after recent alert icon changes 2020-03-18 13:31:49 +01:00
0af739ae8a GPencil: Remove duplicated Mode parameter from Color Subpanel in Vertex Paint
This parameter is now at Brush level, so it was duplicated in the Color panel.
2020-03-18 13:16:40 +01:00
e843d4e438 Cleanup: Rename variables 2020-03-18 09:10:39 -03:00
b81b127928 GPencil: Remove background to Dopesheet buttons
This was missing in previous commit.
2020-03-18 13:06:09 +01:00
dd416681fb Fix BPY enum property definiton failing if items contain spaces
Mistake in 03a4d3c33f, turns out this actually is called from BPY
(which I didn't think it was). So only error out during makesrna, not at
runtime.
2020-03-18 12:53:36 +01:00
406026abba Cleanup: spelling 2020-03-18 22:28:54 +11:00
c3651adf89 Tests: add OpenVDB volume tests 2020-03-18 11:23:05 +01:00
7537cad576 Volumes: add render settings for volume datablock
* Space: volume density and step size in object or world space
* Step Size: override automatic step size
* Clipping: values below this are ignored for tighter volume bounds

The last two are Cycles only currently.

Ref T73201
2020-03-18 11:23:05 +01:00
Brecht Van Lommel
1162ba206d Cycles: change volume step size controls, auto adjust based on voxel size
By default it will now set the step size to the voxel size for smoke and
volume objects, and 1/10th the bounding box for procedural volume shaders.

New settings are:
* Scene render/preview step rate: to globally adjust detail and performance
* Material step rate: multiplied with auto detected per-object step size
* World step size: distance to steo for world shader

Differential Revision: https://developer.blender.org/D1777
2020-03-18 11:23:05 +01:00
9d20f170c7 Cycles: support for rendering of new Hair object prototype
Ref T68981
2020-03-18 11:23:05 +01:00
994eb1ec17 Cycles: support rendering new Volume object type
Voxels are loaded directly from the OpenVDB grid. Rendering still only supports
dense grid, so memory usage is not great for sparse volumes, this is to be
addressed in the future.

Ref T73201
2020-03-18 11:23:05 +01:00
006025ead0 Cycles: support for different 3D transform per volume grid
This is not yet fully supported by automatic volume bounds but works fine in
most cases that will have mostly matching bounds.

Ref T73201
2020-03-18 11:23:05 +01:00
fd53b72871 Objects: Eevee and workbench rendering of new Volume, Hair, PointCloud
Only the volume drawing part is really finished and exposed to the user. Hair
plugs into the existing hair rendering code and is fairly straightforward. The
pointcloud drawing is a hack using overlays rather than Eevee and workbench.

The most tricky part for volume rendering is the case where each volume grid
has a different transform, which requires an additional matrix in the shader
and non-trivial logic in Eevee volume drawing. In the common case were all the
transforms match we don't use the additional per-grid matrix in the shader.

Ref T73201, T68981

Differential Revision: https://developer.blender.org/D6955
2020-03-18 11:23:05 +01:00
b0a1cf2c9a Objects: add Volume object type, and prototypes for Hair and PointCloud
Only the volume object is exposed in the user interface. It is based on OpenVDB
internally. Drawing and rendering code will follow in another commit.
https://wiki.blender.org/wiki/Source/Objects/Volume
https://wiki.blender.org/wiki/Reference/Release_Notes/2.83/Volumes

Hair and PointCloud object types are hidden behind a WITH_NEW_OBJECT_TYPES
build option. These are unfinished, and included only to make it easier to
cooperate on development in the future and avoid tricky merges.
https://wiki.blender.org/wiki/Source/Objects/New_Object_Types

Ref T73201, T68981

Differential Revision: https://developer.blender.org/D6945
2020-03-18 11:23:05 +01:00
8dcfd392e4 UI: add new icons for Volume, Hair and PointCloud 2020-03-18 11:23:05 +01:00
12720d8b9b GPencil: Cleanup int comparisons 2020-03-18 11:12:11 +01:00
35019443c0 GPencil: Invert Dopesheet icons to same order than properties panel 2020-03-18 10:19:54 +01:00
084bf7daee Weight Paint: Implement a new Lock-Relative mode.
This check box alters how weights are displayed and painted,
similar to Multi Paint, but in a different way. Specifically,
weights are presented as if all locked vertex groups were
deleted, and the remaining deform groups normalized.

The new feature is intended for use when balancing weights within
a group of bones while all others are locked. Enabling the option
presents weight as if the locked bones didn't exist, and their
weight was proportionally redistributed to the editable bones.

Conversely, the Multi-Paint feature allows balancing a group of
bones as a whole against all unselected bones, while ignoring
weight distribution within the selected group.

This mode also allows temporarily viewing non-normalized weights
as if they were normalized, without actually changing the values.

Differential Revision: https://developer.blender.org/D3837
2020-03-18 11:55:44 +03:00
82c51d0edb Modifier: skip calling MOD_deform_mesh_eval_get
This is only needed in certain cases.

When testing performance improvements to the modifier stack
it's useful to bypass this function.
2020-03-18 14:21:40 +11:00
7ba403dc94 Fix typo causing compile error with WITH_XR_OPENXR disabled 2020-03-17 22:23:02 +01:00
dc2df8307f VR: Initial Virtual Reality support - Milestone 1, Scene Inspection
NOTE: While most of the milestone 1 goals are there, a few smaller features and
improvements are still to be done.

Big picture of this milestone: Initial, OpenXR-based virtual reality support
for users and foundation for advanced use cases.
Maniphest Task: https://developer.blender.org/T71347
The tasks contains more information about this milestone.

To be clear: This is not a feature rich VR implementation, it's focused on the
initial scene inspection use case. We intentionally focused on that, further
features like controller support are part of the next milestone.

- How to use?
Instructions on how to use this are here:
https://wiki.blender.org/wiki/User:Severin/GSoC-2019/How_to_Test
These will be updated and moved to a more official place (likely the manual) soon.

Currently Windows Mixed Reality and Oculus devices are usable. Valve/HTC
headsets don't support the OpenXR standard yet and hence, do not work with this
implementation.

---------------

This is the C-side implementation of the features added for initial VR
support as per milestone 1. A "VR Scene Inspection" Add-on will be
committed separately, to expose the VR functionality in the UI. It also
adds some further features for milestone 1, namely a landmarking system
(stored view locations in the VR space)

Main additions/features:
* Support for rendering viewports to an HMD, with good performance.
* Option to sync the VR view perspective with a fully interactive,
  regular 3D View (VR-Mirror).
* Option to disable positional tracking. Keeps the current position (calculated
  based on the VR eye center pose) when enabled while a VR session is running.
* Some regular viewport settings for the VR view
* RNA/Python-API to query and set VR session state information.
* WM-XR: Layer tying Ghost-XR to the Blender specific APIs/data
* wmSurface API: drawable, non-window container (manages Ghost-OpenGL and GPU
  context)
* DNA/RNA for management of VR session settings
* `--debug-xr` and `--debug-xr-time` commandline options
* Utility batch & config file for using the Oculus runtime on Windows.
* Most VR data is runtime only. The exception is user settings which are saved
  to files (`XrSessionSettings`).
* VR support can be disabled through the `WITH_XR_OPENXR` compiler flag.

For architecture and code documentation, see
https://wiki.blender.org/wiki/Source/Interface/XR.

---------------

A few thank you's:
* A huge shoutout to Ray Molenkamp for his help during the project - it would
  have not been that successful without him!
* Sebastian Koenig and Simeon Conzendorf for testing and feedback!
* The reviewers, especially Brecht Van Lommel!
* Dalai Felinto for pushing and managing me to get this done ;)
* The OpenXR working group for providing an open standard. I think we're the
  first bigger application to adopt OpenXR. Congratulations to them and
  ourselves :)

This project started as a Google Summer of Code 2019 project - "Core Support of
Virtual Reality Headsets through OpenXR" (see
https://wiki.blender.org/wiki/User:Severin/GSoC-2019/).
Some further information, including ideas for further improvements can be found
in the final GSoC report:
https://wiki.blender.org/wiki/User:Severin/GSoC-2019/Final_Report

Differential Revisions: D6193, D7098

Reviewed by: Brecht Van Lommel, Jeroen Bakker
2020-03-17 21:42:44 +01:00
406bfd4304 Ghost: Ghost-XR API to abstract away and access OpenXR functionality
Extends Ghost to include an abstraction for OpenXR, which I refer to as
Ghost-XR. Such an API is the base for the following commit, which introduces VR
support to Blender.

Main features:
* Simple and high-level interface for Blender specific code to call.
* Extensible for muliple graphics backends, currently OpenGL and a DirectX
  compatibility layer are supported.
* Carefully designed error handling strategy allowing Blender to handle errors
  gracefully and with useful error messages.
* OpenXR extension and API-layer management.
* OpenXR session management.
* Basic OpenXR event management.
* Debug utilities for Ghost-XR and OpenXR

For more information on this API, check
https://wiki.blender.org/wiki/Source/Interface/XR.

Reviewed by: Brecht Van Lommel

Differential Revision: https://developer.blender.org/D6188
2020-03-17 21:39:59 +01:00
c9a8de1d70 Fluid: Correct Tooltip 2020-03-17 16:32:56 -04:00
3af51cacbf Online Manual Reference: Update 2020-03-17 16:28:58 -04:00
a7c660fe61 Cleanup: Fix warnings about function signature of register pass
RE_engine_register_pass is sometimes in the headers with type
as an integer parameter, sometimes as eNodeSocketDatatype.

This caused warnings, the root cause was makesrna was not able
to generate the proper type for enums and defaulted to int.

makesrna has been extended with the RNA_def_property_enum_native_type
that allows telling makesrna the native type of an enum, if set it
will be used otherwise it will still fall back to int.

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

Reviewed By: brecht
2020-03-17 13:45:35 -06:00
e09f0caff3 GPencil: Fix crash joining objects
The weights array can be NULL.
2020-03-17 19:02:10 +01:00
blender
ba3d49225c make deps: Fixes to make OpenXR to work on CentOS Linux
- Harvest to a proper location.
- Disable STD's filesystem which is experimental and caused
  linking errors when OpenXR is usedi n Blender.
2020-03-17 18:35:29 +01:00
f1eb86c458 GPencil: Rename old color operators to material
The color was used in old version when palettes were used, but now all are materials
2020-03-17 18:29:34 +01:00
bf9c4af9bb Fix T74762: Mantaflow: Non emmiting flow source affects simulation 2020-03-17 18:21:01 +01:00
07d5b8b023 Fix T74322: Wrong object bundles with scaled camera
Camera scale was not handled correctly when drawing 3d bundles for
reconstructed objects (caused by normalization of the matrix).
2020-03-17 17:48:55 +01:00
6a0ddb4bb1 Cleanup: Remove unused function
Was introduced earlier today and did not turn out to be very useful
and clear.
2020-03-17 17:40:54 +01:00
f958560a99 Multires: Properly support virtual modifiers for Apply Base
The initial code from earlier from today didn't really work reliable
since it is not possible to apply virtual modifiers but not the real
multires one (in a situation like mesh with shapekeys and multires).

New code uses less memory and has better performance for the case
when there are actual modifiers leading the multires. The case when
there is only multires will not be as performant as possible at this
moment.
2020-03-17 17:40:54 +01:00
1504cb26b0 Cleanup: process colorspace conversion with a 1D pixel array
No need to assume it's 2D or 3D.
2020-03-17 17:33:08 +01:00
2518f60109 GPencil: Fix Parent layer not working
The parenting was using the old logic, but with new engine the draw is done using eval data.

Fixed the depsgraph relationship missing with bones to get an update when the bone is transformed.

Also fixed Snap cursor to Selected
2020-03-17 17:28:49 +01:00
964375e36a Cleanup: blenkernel proper header inclusion for BKE_ocean.h
BKE_ocean.h uses the bool type without including stdbool.h
counting on someone else including that before it.

With D6811 enabling automatic sorting of the includes
this can no longer be counted on. This changes includes
stdbool.h in BKE_ocean.h so it can build without being
depended on others including the right headers before it.
2020-03-17 10:12:47 -06:00
Robert Guetzkow
d374237d43 Fix T74838: fix dereferencing of NULL in sculpt_no_multires_poll when no active object exists
Fix crash when the operator search is used while no active object exists. The cause of the issue is an attempt to dereference `ob` when it is `NULL`. Therefore this patch checks the return value of `SCULPT_mode_poll()` first, to ensure that `ob` isn't `NULL`.

Reviewed By: pablodp606

Maniphest Tasks: T74838

Differential Revision: https://developer.blender.org/D7156
2020-03-17 16:46:55 +01:00
24e44143a1 Multires: Fix Apply Base when there are deform modifiers
Their effect was applied twice after hitting Apply Base since the
operator was also applying deformation caused by those modifiers.
2020-03-17 16:41:43 +01:00
628d799c85 Multires: Add utility to create deformed base mesh
The new function will use original object as a starting point
and apply all enabled deformation modifiers prior to the multires.
2020-03-17 16:41:43 +01:00
c76d390c92 Mesh: Fix applying deform modifier up to index
The code would have break the first (deform only) modifiers
once the index is reached, but it will not prevent second
loop (over remaining modifiers) from run.

This was applying deform modifier twice in some conditions:
having single deform modifier and calculating deformed mesh
up to the first modifier (index=0).
2020-03-17 16:41:43 +01:00
bf5151b2d2 Mesh: Add utility to calculate deform modifier up to index
Intention is to be used to create mesh at the state which is an input
to the multires modifier.
2020-03-17 16:41:43 +01:00
a45c34ae8e Multires: Cleanup, argument naming and order
Use full argument name.

Also order arguments in the generosity order: from depsgraph
(which has everything) to object (which contains multires)
specific multires modifier.
2020-03-17 16:41:43 +01:00
17abae45f1 Multires: Cleanup, remove redundant argument
Scene can be queried from the dependency graph.
2020-03-17 16:41:43 +01:00
20456b52b4 Fluid: Fixes for new abort bake faster feature
In addition to previous commit that made it possible to abort bakes faster.
2020-03-17 16:12:46 +01:00
b852db57ba Add experimental global undo speedup.
The feature is hidden behind an experimental option, you'll have to
enable it in the preferences to try it.

This feature is not yet considered fully stable, crashes may happen, as
well as .blend file corruptions (very unlikely, but still possible).

In a nutshell, the ideas behind this code are to:
* Detect unchanged IDs across an undo step.
* Reuse as much as possible existing IDs memory, even when its content
  did change.
* Re-use existing depsgraphs instead of building new ones from scratch.
* Store accumulated recalc flags, to avoid needless re-compute of things
  that did not change, when the ID itself is detected as modified.

See T60695 and D6580 for more technical details.
2020-03-17 15:02:05 +01:00
Mateusz Grzeliński
9ce3890950 Cleanup: rename function
This function was missed in rBec471a9b1c1.

Differential Revision: https://developer.blender.org/D7155
2020-03-17 14:46:50 +01:00
8cb463f4ff OverlayEngine: crash when using hidden faces
Unreported Crash. When hidden faces are active (retopology) the depth
test could fail as the default framebuffers aren't set. This patch will
check if we are rendering a depth only and skip the clearing of the
buffer.
2020-03-17 13:56:25 +01:00
3c1433b6f3 Revert "Cleanup: use doxy sections"
This reverts commit 626b2bd071.

Sergey prefers not to use doxy sections for this code.

Revert pending a decision on T74845
2020-03-17 23:53:36 +11:00
b2851dbe78 Fluid: Abort baking jobs faster
With this change baking jobs will be aborted faster. The user will not have to wait for the current frame to finish baking. The bake job will exit early and discard the incomplete frame.
2020-03-17 13:49:57 +01:00
54c8770692 Fix error using CUDA in plug-ins on Linux/macOS, hide our CUDA symbols
Better solution will be to hide all symbols by default, but this works for now.
2020-03-17 12:23:36 +01:00
0b7841679e Multires: Cleanup, naming, make it more consistent
The coarse mesh is an input to generic Subdiv, and exact meaning is
ambiguous.

The input to Multires is a base mesh, which owns CD_MDISPS.
2020-03-17 12:23:02 +01:00
b02a25b7e1 Add accumulated recalc flags to IDs.
Those accumulated flags get cleared every time an undo step is written
to memfile.

Preliminary work for undo-speedup.

Part of T60695/D6580.
2020-03-17 12:10:52 +01:00
055863d9c1 Cleanup: minor changes. 2020-03-17 12:10:52 +01:00
20d7c04305 Fluid: Re-dded Empty Space option in the UI
This option existed already and was just hidden in the UI. With the new fluids system though, it will only be used for rendering - and not to optimize the cache.
2020-03-17 11:57:04 +01:00
7f3e84deb5 Fluid: Updated manta pp files
Includes only a rename. The name PyInit_Main was a bit confusing as it just belongs to Manta.
2020-03-17 11:57:04 +01:00
2ba3e6a02e Depsgraph: Adds helpers to extract/restore despgraphs in a given Main.
Extract will steal all depsgraphs currently stored in given bmain, and
restore will put them back in place, using scene and viewlayers as keys.

Preliminary work for undo-speedup.

Part of T60695/D6580.
2020-03-17 11:24:37 +01:00
90ce708ef0 BKE_lib_id: Add helper to swap full ID content and use proper naming.
Preliminary work for undo-speedup.

Part of T60695/D6580.
2020-03-17 11:13:14 +01:00
b87997f59b Cleanup: rename 'centre' to 'center' in View3D 2020-03-17 11:34:11 +11:00
ab430cfdfe Cleanup: sort DNA renaming 2020-03-17 11:29:54 +11:00
67307e72ea Cleanup: use more descriptive variable name for the data-mask
Make it explicit this data mask is added to the default mask.
2020-03-17 11:04:50 +11:00
47af235ba9 Revert "UI: Add 7 new community themes"
This reverts commit d89e5fcaef.

This was meant to be committed to the add-ons repo.
2020-03-17 10:41:40 +11:00
120a38ccbe Nodes: Display bl_icon of custom nodes in node header
This is D1578 by Philipp Oeser with small modifications.
2020-03-16 18:25:23 +01:00
e42f61dda8 Fix incorrect Face Sets when using mask extract
Mask extract modifies the topology when adding the boundary loop, so
previous face sets may not be correct in the new mesh. Remove the face
sets datalayer and let sculpt mode rebuild it when entering sculpt mode
in the new object.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D7129
2020-03-16 17:53:03 +01:00
bab0fd1308 Fix visual artifacts with partially hidden meshes and mask extract
The previous behaivour didn't make sense as sculpt mode was still active
when switching to the new object, so it was rendering inconrrectly.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D7130
2020-03-16 17:45:22 +01:00
e4077ea69d Fix T74626: Wrong Face Sets overlay rendering in smooth shading
The face set color variable needs to be declared inside of the loop in
order to reset it per iteration.

Reviewed By: jbakker

Maniphest Tasks: T74626

Differential Revision: https://developer.blender.org/D7096
2020-03-16 17:43:54 +01:00
7941ea02f8 Update viewport rotation origin when changing Face Set visibility
Small UX fix. When hidding everything but the active face set with H,
the last stroke lotation center can be in a part of the model that is
hidden, so viewport navigation becomes confusing until you start a new
stroke on the visible face set. Now the viewport navigation rotation
center is updated to the active vertex when using a visibility operation
that uses it, so it always rotates using the visible face set as the
origin.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D7137
2020-03-16 17:42:52 +01:00
ba26adee0c Fix T61234 Mirroring Grease Pencil keyframes in the Dopesheet fails
`ANIM_animdata_update()` did not sort grease pencil frames. A
pre-existing comment stated this wouldn't be necessary as
`posttrans_gpd_clean()` already does this. However, this is only
applicable when the change is performed via the transform system. The
mirror operator doesn't call `posttrans_gpd_clean()`, invalidating the
assumption in the comment.

I moved the sorting code into `BKE_gpencil_layer_frames_sort()`, which
is now called from both `ANIM_animdata_update()` and
`posttrans_gpd_clean()`.
2020-03-16 16:23:12 +01:00
f0856b1fda Cycles: Fix bad escape character used for dot 2020-03-16 16:17:13 +01:00
215e474a99 Fix T74776: Cycles crash with missing image texture after recent changes 2020-03-16 16:02:06 +01:00
20f6700c88 UI: Show decorators for lights when using Cycles
This matches Eevee, and also the rest of Blender.
2020-03-16 14:32:09 +01:00
d89e5fcaef UI: Add 7 new community themes
This commit adds 7 themes submitted by the community on Devtalk. These themes both serve specific purposes, provide a greater variety in look & feel, and serve as welcoming homes for users coming on board from other packages. This is the initial commit, but these themes can be continuously updated over time to fix issues and keep them up to date with changes.

Thanks to all contributors, and in particular the makes of the picked themes: Pierre Schiller, Edward Agwi, Vojtěch Lacina, Michail Soluyanov, Jason van Gumster, Mr Wax Police & Jonathan Lampel.

An overview is here: https://developer.blender.org/T74360
2020-03-16 14:25:47 +01:00
37e7e1e77c Cleanup: Typo in comment 2020-03-16 12:43:05 +01:00
a69c364746 UI: fix backdrop and alignment in anim channels
This patch fixes various problems of alignment and element backdrops for
the animation channels drawing, mainly in the Graph editor but also for
grease pencil and mask layers in the Dope Sheet.

Reviewed By: billreynish, sybren

Differential Revision: https://developer.blender.org/D5204
2020-03-16 12:18:33 +01:00
5a664c6e98 Fix another implicit cast of boot to int
Use proper comparison to nullptr.

It is important to use nullptr since NULL is actually an integer,
which leads to another type of warnings.
2020-03-16 12:15:16 +01:00
35a29befb3 Fluid: Updated Manta pp files
Includes additional minmax check for Windows
2020-03-16 11:52:18 +01:00
7df435325b Fix implicit cast from bool to int in path tests 2020-03-16 10:53:46 +01:00
01377fd229 Workbench: Crash When Rendering With Stereo 2020-03-16 10:42:03 +01:00
868573451f Cleanup: use unsigned char for UI_view2d_text_cache_add
Avoids casts when used with other UI code
where the color is often unsigned.
2020-03-16 11:53:08 +11:00
f06a6e92bc Cleanup: misleading memset use
This call to memset relied on PassList having a single,
zero sized struct member.

Pass the passes array instead for readability.
2020-03-16 09:43:07 +11:00
Yevgeny Makarov
ac1dcdbf06 UI: Add an Outline to the Popover Arrows
Reviewed By: billreynish, fclem

Differential Revision: https://developer.blender.org/D5873
2020-03-15 23:19:01 +01:00
7a19a99675 Workbench: Fix default view not reset after drawing
This fix jitter of overlay and GPencil. But I'm not sure this should
be the responsibility of the subsequent draw engines or the responsibility
of the current engine to reset the view.
2020-03-15 22:50:07 +01:00
cebff2ff30 Fix a syntax error in test spec for BLI_delaunay_2d_test.
Test specs are read from strings, and there was a comma instead
of a decimal point, and then an extra decimal point in the Quad0 test.
This test has been flaky on Windows buildbot. Perhaps this is why.
2020-03-15 17:14:04 -04:00
7a7b392b54 GPencil: Reduce factor to 5 in previous commit
10 decimals is too high
2020-03-15 19:40:21 +01:00
22925d0dd3 GPencil: Remove Keep parameter from Select Vertex Color
Also changed range of threshold from 0 to 10
2020-03-15 19:22:33 +01:00
8022fc3220 Fix Blender building after recent 'cleanup'.
Caused by rB4be4c0667155. Please ensure at least affected code does
still build...
2020-03-15 16:11:35 +01:00
e53e17b8d6 Fix outliner edit-mode check 2020-03-15 22:04:08 +11:00
b435bd2f31 Fix potential draw manager assignment to negative index
While there is an assert here, the run-time code would perform the assignment.
2020-03-15 22:03:59 +11:00
59f5194265 Fix potential NULL pointer de-reference creating liquid geometry 2020-03-15 22:03:49 +11:00
b8feef59c8 Cleanup: add parens for clarity 2020-03-15 21:53:57 +11:00
5029b97d02 Cleanup: add NULL check for RNA filename argument
Currently some of the code supports a NULL filename,
add the NULL check so RNAProcessItem's with a NULL filename
don't crash in the future.
2020-03-15 21:53:20 +11:00
ecfb89280e Cleanup: use 'r_' prefix for return args 2020-03-15 21:51:22 +11:00
37419bb3f6 Cleanup: avoid setting float values by bit-pattern
Replace memset with copy_vn_fl, note that the exact values are slightly
different in this case. The value being set was close to FLT_MAX.
2020-03-15 21:51:02 +11:00
4be4c06671 Cleanup: redundant checks
In some cases moved the checks into asserts,
to ensure changes in the future don't cause
the checks to become necessary again.
2020-03-15 21:48:35 +11:00
80edc0e972 Cleanup: redundant assignments 2020-03-15 21:46:18 +11:00
aa60b9338a Cleanup: use 'const' style argument 2020-03-15 21:42:06 +11:00
b037816980 Cleanup: shadow warning, clang-format 2020-03-15 21:42:06 +11:00
4031d8bcb7 UI: Fix capitalization in the macOS app menu 2020-03-15 11:16:08 +01:00
a210b8297f UI: Larger Alert Icons
Adding a set of larger icons for use in informational dialogs.

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

Reviewed by Campbell Barton
2020-03-14 11:05:09 -07:00
a816a067ed GPencil: Change Select Vertex Color to similar selection
Now, instead to use the Brush color as selection patron, now it uses any previous selected color.
2020-03-14 16:26:56 +01:00
b7160f2f0a IC keymap: Fixes for GP
- Remove Shift for drawing poly-lines, just as in the default keymap
  - Use consistent hotkeys for size and strength radial controls
  - Fix some bugs/missing items from the GP merge
2020-03-14 14:00:28 +01:00
94bad2f30d GPencil: Fix missing context wheel color in Tint tool 2020-03-14 11:58:22 +01:00
cc53900baf GPencil: Add option to keep selected in Select Vertex Color 2020-03-14 11:07:35 +01:00
428e65256e GPencil: Use Linear color instead of sRGB for Select Vertex Color
The brush color is sRGB but the Vertex Color is linear.
2020-03-14 10:46:28 +01:00
b8211a4d7c GPencil: Add Select Vertex Color to menu
This option was missing
2020-03-14 10:45:23 +01:00
466171d0ef GPencil: Rename operator select_color to select_vertex_color 2020-03-14 10:33:33 +01:00
d50d410a70 GPencil: Rename operator color_select to select_material
The old name was related to the old palettes.
2020-03-14 10:30:59 +01:00
bb89cc51ec Fix T67446: UV Editor: support island select mode for box/circle/lasso
selections

Previously this was only supported in single click selections, doing an
island selection with box/circle/lasso would just select individual
vertices instead. Now selects islands properly.

This also unifys some logic between box/circle/lasso:
- use early selection test from lasso [makes things faster] in box/
circle
- circle wasnt checking visible face
2020-03-14 08:16:08 +01:00
f0b0524c5f Cleanup: spelling 2020-03-14 15:43:21 +11:00
117ccb56ad Cleanup: remove unused ARegion from bGPdata_Runtime 2020-03-14 15:39:59 +11:00
4b38eac4da CMake: use spaces instead of tabs for icon updating script 2020-03-14 15:39:59 +11:00
60e3f690cb Cleanup: sort file lists & struct declatations 2020-03-14 15:39:59 +11:00
626b2bd071 Cleanup: use doxy sections 2020-03-14 15:39:53 +11:00
acab745078 UI: Toolbar icons
- Add icons for Sculpt Cloth, Clay Thumb and Draw Face Sets, as well as GP Tint, Replace and Transform Fill tools
  - Tweak icons for Sculpt Rotate, Pinch, Multiplane Scrape, Inflate, Blob, Draw Sharp, based on feedback on Devtalk
2020-03-14 01:31:28 +01:00
5260aaf3b1 Fix T73921: Eevee volume render test memory leak in Mantaflow
Fixed memory leak that showed up after the original issue (crash) had been fixed in 93ac4709eb. The fix ensures that light cache bakes free up GPU smoke textures and the smoke domain list correctly.

This commit also removes the workaround (f3a33a9298) that disabled light cache bakes for fluid objects.
2020-03-14 00:30:55 +01:00
7d56c425f8 GPencil: Don'r Replace color if vertex color is empty
The replace tools only must work over previously vertex painted.
2020-03-13 21:54:54 +01:00
dc99c3532a Cleanup: USD, move some common code to an abstract superclass
The `check_is_animated()` function will be used by the upcoming Alembic
exporter as well. There is nothing USD-specific in the function.

No functional changes.
2020-03-13 18:17:51 +01:00
ebf3c87912 Fix T74699: File browser closing while loading crash.
Owner of filelisting job was changed, without proper update of all
access/usages of that owner to reach the job, leading to failure of
timer removal from the WM, and attempt to double-free the job...

Caused by rB2c4dfbb00246ff.
2020-03-13 17:34:21 +01:00
5ad16e6a11 Cleanup: BKE_mesh_nomain_to_mesh: Add assert that source mesh is indeed not in Main. 2020-03-13 17:17:26 +01:00
4e26afe0ae Cleanup: Comments of wmJobs callbacks. 2020-03-13 17:17:26 +01:00
110a35ef5a Fix T74397: Crash after undoing quadriflow remesh on duplicate with armature deform
The issue was that we were creating temporary mesh copies and storing
them in bmain and then later using BKE_mesh_nomain_to_mesh which would
add them to bmain once more (duplicates).

This would lead to crashes later as the custom data of the mesh could be
trashed quite easily.
2020-03-13 16:29:30 +01:00
de30fda04e Fix T74686: Loading btx file in multires modifier is not working
Was happening when object does not have CD_MDISPS allocated yet.
Need to make sure totdisp and level is specified on CD_MDISPS data
prior to loading (as the load expects them to be properly set).
2020-03-13 16:15:31 +01:00
67704cb8aa Multires: Fix loosing sculpt data when using external BTX file 2020-03-13 16:15:31 +01:00
6bcb6a0ea6 Fix stereoscopy reference image drawing in the viewport
Note: Without D6922 stereo is too broken to even test this patch.
With D6922 + this patch the fullscreen modes work (anaglyph/interlace not yet).
2020-03-13 16:07:19 +01:00
be76a37c91 GPencil: Fix UI typo 2020-03-13 15:50:26 +01:00
5593efec01 Fix stereoscopy drawing for camera background
Part of the fix was to get gputexture to use an array to accomodate each
eye. This takes care of viewports showing individual Left or Right
views.

For the combined view the fix was in overlay_image.c:camera_background_images_stereo_setup.

Note 1: Referece images are still not supporting stereo.

Note 2: For painting, and getting image bindcode I'm hardcording a
single-view experience.

Note 3: Without D6922 stereo is too broken to even test this patch.
With D6922 + this patch the fullscreen modes work (anaglyph/interlace
not yet).

Differential Revision: D7143
2020-03-13 15:40:20 +01:00
93ac4709eb Fluid: Potential fix for Eevee tests crashing with Mantaflow
Belongs to T73921. This commit fixes the crashes with light baking (disabled in f3a33a9298). There is still a memory leak to be fixed though.
2020-03-13 15:34:07 +01:00
525bd62557 Potential fix for T74609: File Selector Crashes Showing Thumbnails.
Existing code was definitively giving possibility to access freed
memory, although probably not on a super-common basis...
2020-03-13 14:37:28 +01:00
bc0a0cdf17 Multires: Fix Subdivide, Reshape and Apply Base
This change fixes artifacts produced by these operations.

On a technical aspect this is done by porting all of the operations
to the new subdivision surface implementation which ensures that
tangent space used to evaluate modifier and those operations is
exactly the same (before modifier will use new code and the operations
will still use an old one).

The next step is to get sculpting on a non-top level to work, and
that actually requires fixes in the undo system.
2020-03-13 14:14:56 +01:00
b0a1af4eb1 Multires: Increase default quality to 4
Makes it work better "out of the box" for irregular topology like
Suzanne mesh.

There might be some performance impact on non-regular meshes, but
those are not very common usecase for multires and for those its
always possible to lower the quality if needed.
2020-03-13 14:13:37 +01:00
f36d98bb1d Subdiv: Fix loose geometry callbacks in certain conditions
Loose vertices and vertices of loose edges callback was not working
correct if some of other callbacks were set to NULL.

Was caused by missing bitmask set in the callbacks which were set
to NULL.
2020-03-13 14:07:44 +01:00
8622372256 OpenSubdiv: Make non-full geometry less strict for sharpness
Allow to mark individual vertices as infinitely sharp even if there is
no full topology and no access to edges: infinite sharp vertices do not
need connectivity information.
2020-03-13 14:07:44 +01:00
48e0af52e6 GPencil: Fix typo error 2020-03-13 13:08:45 +01:00
4326d162ba GPencil: Enable Lights ON to default object in 2D template 2020-03-13 13:06:02 +01:00
Bogdan Nagirniak
9075ec8269 Python: add foreach_get and foreach_set methods to pyrna_prop_array
This allows fast access to various arrays in the Python API.
Most notably, `image.pixels` can be accessed much more efficiently now.

**Benchmark**

Below are the results of a benchmark that compares different ways to
set/get all pixel values. I do the tests on 2048x2048 rgba images.
The benchmark tests the following dimensions:
- Byte vs. float per color channel
- Python list vs. numpy array containing floats
- `foreach_set` (new) vs. `image.pixels = ...` (old)

```
Pixel amount: 2048 * 2048 = 4.194.304
Byte buffer size:  16.8 mb
Float buffer size: 67.1 mb

Set pixel colors:
    byte  - new - list:    271 ms
    byte  - new - buffer:   29 ms
    byte  - old - list:    350 ms
    byte  - old - buffer: 2900 ms

    float - new - list:    249 ms
    float - new - buffer:    8 ms
    float - old - list:    330 ms
    float - old - buffer: 2880 ms

Get pixel colors:
    byte - list:   128 ms
    byte - buffer:   9 ms
    float - list:  125 ms
    float - buffer:  8 ms
```

**Observations**

The best set and get speed can be achieved with buffers and a float image,
at the cost of higher memory consumption. Furthermore, using buffers when
using `pixels = ...` is incredibly slow, because it is not optimized.
Optimizing this is possible, but might not be trivial (there were multiple
attempts afaik).

Float images are faster due to overhead introduced by the api for byte images.
If I profiled it correctly, a lot of time is spend in the `[0, 1] -> {0, ..., 255}`
conversion. The functions doing that conversion is `unit_float_to_uchar_clamp`.
While I have an idea on how it can be optimized, I do not know if it can be done
without changing its functionality slightly. Performance wise the best solution
would be to not do this conversion at all and accept byte input from the api
user directly, but that seems to be a more involved task as well.

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

Reviewers: JacquesLucke, mont29
2020-03-13 12:59:36 +01:00
db4298c6be GPencil: Avoid segment fault when use Simplify modifier
The number of points of the evaluated stroke can be less than original or the original can use less points that evaluated.
2020-03-13 12:57:59 +01:00
cb19bb7f57 Cleanup: USD, removed unused export job data
The code was copied from the Alembic exporter, and some of the options are
no longer used.

Not updating the Alembic exporter itself, as this will be done in a much
larger rewrite.
2020-03-13 12:34:03 +01:00
cf9b3310c0 GPencil: Fix Noise modifier versioning
The versioning was setting the factor for all modes without checking flags.

Also cleanup some unused code.
2020-03-13 12:24:49 +01:00
91ca3c3c0b Fix T74696: Segment fault in Noise modifier using Vertex Groups 2020-03-13 12:07:36 +01:00
1ca582c651 Fix IDTypeInfo not having enough bits for ID filter flag 2020-03-13 12:06:29 +01:00
3652870483 GPencil: Cleanup unneeded check 2020-03-13 11:16:02 +01:00
de9c7bae7b GPencil: Join Tint and Vertex Color modifier
Both are doing almost the same and can be merged. This reduce complexity for user and less code to maintain.

Reviewed By: mendio, pepeland, fclem

Differential Revision: https://developer.blender.org/D7134
2020-03-13 10:28:59 +01:00
df032580c1 Fix info showing multi-line reports reversed (upside-down)
Also, only show the icon once per report.
2020-03-13 20:14:33 +11:00
Jeroen Bakker
54743dbf09 DeformMod: Performance by reusing buffers
The Deform modifiers was reallocating buffers that only fit the vertices
of the inner loop. This patch first counts the maximum needed buffer and
allocates one.

When using the daily dweebs animation file the playback performance went
from 0.66 fps to 0.93 fps.

Reviewed By: sybren

Differential Revision: https://developer.blender.org/D7132
2020-03-13 09:28:58 +01:00
1f0b21e713 Cleanup: pass const args (mostly Scene & RenderData) 2020-03-13 17:27:11 +11:00
fa823f0af8 Fix boundary edges detection ignoring Face Set visibility
If one of the faces connected to a vertex is hidden in the face sets, we
can assume that the vertex is part of a boundary edge, so it should be
cosidered like that in all automasking and edge detection functions.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D7126
2020-03-12 20:47:31 +01:00
69eaa19340 Fix flood fill operation not taking into account hidden vertices
The idea of the visibility system is that tools should behave like
hidden vertices do not exist, so the flood fill operation should ignore
hidden vertices for all operators.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D7125
2020-03-12 20:45:06 +01:00
b0271c6e40 Use golden ratio conjugate for Face Sets hue generation
The face set ID is sequential, so implementing this was straightforward.
Suggested by Jeroen Bakker

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D7123
2020-03-12 20:43:38 +01:00
53c03d4679 Fix Face Set operators not modifying sigle poly Face Sets
The face_set_set function which sets a face sets given a vertex index
can ignore all modifications to hidden face sets, so we can skip all
vertex visibility checks outside that function. This makes the code
faster, simpler and fixes multiple bugs.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D7122
2020-03-12 20:38:57 +01:00
9dcd6ba3eb Fix T74646: Pick a random face set to be rendered white when randomizing the colors
The previous solution was also working fine as the white face set has no
meaning, but now it is a little bit more random. Also, bigger face sets
have more chance of getting the white color.

Reviewed By: jbakker

Maniphest Tasks: T74646

Differential Revision: https://developer.blender.org/D7111
2020-03-12 20:37:49 +01:00
88fd2b1dd5 Fix T74648: Do not relax with 0 neighbors or no vertex normal
The mesh provided in the report has 0 area faces and overlapping
vertices, causing the relax code to fail when calculating the plane to
constraint the vertex movement. Now it works fine both in the brush and
in the mesh filter.

Reviewed By: jbakker

Maniphest Tasks: T74648

Differential Revision: https://developer.blender.org/D7109
2020-03-12 20:36:49 +01:00
088b92b92c Fix mesh shrinking when using the relax mesh filter.
If the relax mesh filter was used on a non manifold mesh with open
boundaries, all the vertices were relaxed and the mesh was shrinking.
This was an unintended behavior that was making the filter unusable with
these meshes.

The mesh filter is now initializing an automasking buffer using the same
boundary automasking function from the brush code. Now edges are
preserved and the relax filter works as it should.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D7097
2020-03-12 20:35:52 +01:00
472534d16e Fix memory leak in recent Cycles image texture refactor 2020-03-12 20:30:49 +01:00
2050baa139 GPencil: Move Vertex Paint mode to topbar
It's more easy to find in the topbar
2020-03-12 20:29:04 +01:00
c1290a1d1f GPencil: Fix color management in Vertex Paint tools
The brush is using sRGB and need to be Linear
2020-03-12 19:39:10 +01:00
649fdc7938 Fix T73049: Drag & drop on overlapping panels behaves incorrectly
Reviewers: brecht, Severin

Differential Revision: https://developer.blender.org/D7024
2020-03-12 19:36:13 +01:00
11e4827738 Fix T74670: crash during copy paste of objects.
Embedded data should always be considered as outside of Main database
here.

Note that it's a bit of an edge case to decide whether those should
always have their `LIB_TAG_NOMAIN` set too, or not? For now, let's keep
things as they are here.
2020-03-12 18:08:11 +01:00
4669dfe2cc Expose 'is embedded data' ID flag to RNA.
Relevant currently for root node trees and master collections.
2020-03-12 18:08:11 +01:00
38ba022858 Fix T66505: Dope Sheet shows empty Grease Pencil/Annotation layers
The behaviour of GP layers is the same as annotation layers: they show
in the dope sheet regardless of whether they have frames or not. This is
easily resolved by adding some extra filtering.
2020-03-12 17:33:48 +01:00
741888ce08 Cleanup: simplified Grease Pencil animdata filter
Part of the function was following an "if-ok: do-this" pattern, and then
mid-function switched to a "if-bad: skip" pattern. The function now just
uses the latter.

No functional changes.
2020-03-12 17:33:48 +01:00
26bea849cf Cleanup: add device_texture for images, distinct from other global memory
There was too much image texture specific stuff in device_memory, and too
much code duplication between devices.
2020-03-12 17:28:55 +01:00
75be60a667 Fix build error with recent OpenImageIO versions 2020-03-12 17:19:57 +01:00
f130c5ddb6 EEVEE: Update Preview file with new lightcache 2020-03-12 17:03:58 +01:00
5c427f4b17 GPencil: Fix unreliable comparison 2020-03-12 16:34:05 +01:00
63ee3db961 Fix T73228: UI shows settings of wrong marker when movie clip is offset 2020-03-12 15:53:52 +01:00
5929dd7129 Fix T73212: Gizmo's are still interactive when behind nodes 2020-03-13 01:29:06 +11:00
85ea7dfc54 Cleanup: move gizmo handling into a function 2020-03-13 01:29:06 +11:00
fe5933a972 Fix T71961: Soft body behavior is incorrect when CTRL + F12 animation is rendered.
The softbody modifier was missing the transform depsgraph relation and
thus the object matrix would not get updated during animation render.
2020-03-12 15:29:50 +01:00
37a07f812b Cleanup: remove unused node tree user counting functions 2020-03-12 13:23:02 +01:00
16ed7aebf2 Bug report preset update (last worked version)
I updated the "Worked" field in the online form but forgot to do it for
the oeprator from within Blender.
2020-03-12 11:14:53 +01:00
6c707aad6a Fix T74605 Key Indicator for motion paths not updating for objects
This fixes a functional change in 4db2a08281,
which was marked as 'should have non-functional changes only'.
2020-03-12 11:08:45 +01:00
4ba6a00afc GPencil: Change Build modifier UI layout for Influence Filters
The layer filter was not following the standard layout
2020-03-12 10:39:41 +01:00
8363e10ccc Fix T74659: Seaching for operator crashes Blender
The poll function was not checking the paint pointer.
2020-03-12 10:17:48 +01:00
21f016f010 DrawManager: Pack Draw State Bits
Some draw state bits are mutual exclusive. This patch will free some
draw state bits by packing the mutual exclusive bits in a mask.

Reviewed By: fclem

Differential Revision: https://developer.blender.org/D7088
2020-03-12 09:35:27 +01:00
456595fd39 Fix T74392: HDRI preview spheres appear in render passes and reflections
Do not render HDRI Previews when a renderpass is active

Reviewed By: fclem

Differential Revision: https://developer.blender.org/D7005
2020-03-12 09:27:28 +01:00
0c0895e3e6 Fix move-3D gizmo in use 2D spaces
This fixes node corner-pin and sun-beam gizmo's cursor offsets.
2020-03-12 19:17:39 +11:00
d4d9ded09b Cleanup: text view API
- Use typed enum for line_data callback.
- Pass in 'const' arguments where possible.
- Use 'r_' prefix for return arguments.
- Remove unused return value from line_get callback.
- Remove redundant casts.
2020-03-12 16:18:38 +11:00
Phil Stopford
6ce709dceb Ocean: add new spectra modes to the ocean modifier
This extends the ocean modifier to add new spectra
(Pierson-Moskowitz, Jonswap, TMA).

These models are very different to the Phillips spectrum.
They are intended for more established,
large area, oceans and/or shallow water situations.
2020-03-12 15:48:20 +11:00
1aebcdbb3a Cleanup: spelling, clang-format 2020-03-12 12:34:54 +11:00
74855969e7 Cleanup: use term suppress instead of repress
Also check MSVC instead of WIN32, for setting MSVC flags.
2020-03-12 12:13:41 +11:00
8751af6d19 EEVEE: Bump minimum probe level to make rough reflection more precise 2020-03-12 01:33:56 +01:00
27e0998a8a EEVEE: Hair: Fix wrong color when using color attribute without actual data 2020-03-12 00:43:09 +01:00
72461c09b4 Windows: Clean-up warnings originating from bullet
Bullet currently generates the majority of the warnings
on windows all of them are silly. This patch disables
all warns from bullet for now.

We should revisit this if/when we update bullet
to a newer version.

Reviewed By: sergey brecht

Differential Revision: https://developer.blender.org/D7118
2020-03-11 14:11:19 -06:00
372dcacbe4 Windows: Cleanup warning about non returning dtor
`google::LogMessageFatal::~LogMessageFatal` calls `abort`
which MSVC correctly identifies as 'not returning'
and warns about a potential memory leak.

Given this is intended behaviour and glog is not overly
concerned with shutting down the process nicely, we
can safely ignore this warning.
2020-03-11 14:07:47 -06:00
e6d0a438ab Fix T73626: crash scrubbing timeline with Cycles viewport and smoke/fire 2020-03-11 20:45:39 +01:00
6cf4861c3a Cleanup: refactor image loading to use abstract ImageLoader base class
Rather than passing around void pointers, various Blender image sources now
subclass this. OIIO is also just another type of image loader.

Also fixes T67718: Cycles viewport render crash editing point density settings
2020-03-11 20:45:39 +01:00
d8aa613d94 Cleanup: add ImageHandle to centralize image ownership logic 2020-03-11 20:35:38 +01:00
ec3eeee46b Cycles: add internal default volume shader, to be used for new volume object
This is mostly straightforward, but required some refactoring to ensure that
the default volume material does not always turn on the volume feature for GPU
rendering.
2020-03-11 20:35:38 +01:00
5a169ae2f3 Cleanup: remove foreach include from header, conflicts with OpenVDB 2020-03-11 20:35:38 +01:00
21821601f2 Fix Optix build error on Linux with some compilers 2020-03-11 20:35:38 +01:00
cbb854a98f Cleanup: Fix build warning on windows.
printf is called for a size_t (64 bit on x64) type
but the formatter is `%lu` (32 bit) leading to a
warning with MSVC.

`%zu` is the appropriate formatter.
2020-03-11 13:26:09 -06:00
33c6b269d1 EEVEE: Fix test crashing
Probe counting now needs to have proper gl capabilities initialised to run
correctly.
2020-03-11 18:52:16 +01:00
12e64e5ec1 Cleanup: Fix unused debug var warning. 2020-03-11 18:50:48 +01:00
366d951b0c GPencil: Change default hardeness for Airbrush 2020-03-11 18:02:05 +01:00
e9220d5cd0 Depsgraph: Fix crash deleting Viewer image from Outliner
Was happening when having compositor open with Viewer node attached
directly to Render Layers output.

There were two things involved here:

1. The code which was storing CoW-ed versions of IDs was checking all
   IDs for whether they are expanded or not. This was causing access
   of freed memory for deleted IDs which do not need CoW (such as IM).

   Simple fix: store ID type as a scalar and use early check before
   doing more elaborate check based on accessing fields of id_cow.

2. The code which was ensuring view layer pointer is doing CoW for
   scene. This isn't an issue on its own, but scene might have an
   embedded ID such as compositor which was actually traversed by the
   ID remap routines. This was causing remapping procedure to go into
   non-updated copy of compositor, accessing freed Viewer image ID.

   Solved by not recursing into embedded IDs for datablocks as those
   are supposed to have own copy-on-write operations which takes care
   of re-mapping.

Reported my Bastien, and also pair-coded with him.
2020-03-11 17:38:42 +01:00
Giovanni Remigi
19b46b2fca Fix Cycles crash in BVH8 build due to out of bounds memory access
Differential Revision: https://developer.blender.org/D7114
2020-03-11 17:35:11 +01:00
200695dd89 Windows: Clean-up linker warnings regarding MSVCRT.lib
For debug builds we link the against the release mode libs
for C based libraries, which are technically linked against
a different CRT, which the linker will implicitly try to link.

Which results in a linker warning about mixing the debug/release CRT.

This patch prevents the implicit linking of the release
CRT in debug configurations for sub projects that had issues
with it.
2020-03-11 10:33:12 -06:00
a9c0ad53e2 Cleanup: Typo in comments. 2020-03-11 17:29:20 +01:00
a54e17e52d LibQuery: Add option to NOT process embedded IDs.
Request from depsgraph department, which does basically consider those
embedded IDs as any other data-block (unlike any BKE ID management code).
2020-03-11 17:26:58 +01:00
7dd0be9554 EEVEE: Replace octahedron reflection probe by cubemap array
We implement cubemap array support for EEVEE's lightcache reflection probes.
This removes stretched texels and bottom hemisphere seams artifacts caused
by the octahedral projection previously used.

This introduce versioning code for the lightcache which will discard any
lightcache version that is not compatible.

Differential Revision: https://developer.blender.org/D7066
2020-03-11 17:12:16 +01:00
c476c36e40 Workbench Simplification Refactor
This patch is (almost) a complete rewrite of workbench engine.
The features remain unchanged but the code quality is greatly improved.
Hair shading is brighter but also more correct.

This also introduce the concept of `DRWShaderLibrary` to make a simple
include system inside the GLSL files.

Differential Revision: https://developer.blender.org/D7060
2020-03-11 17:12:16 +01:00
f01bc597a8 Cleanup: stop encoding image data type in slot index
This is legacy code from when we had a fixed number of textures.
2020-03-11 17:07:17 +01:00
9910803574 Fix Cycles link error with debug + asan after RTTI changes 2020-03-11 17:05:15 +01:00
9ef7759bf0 Fix (unreported) bad user refcounting of viewer image ID.
This is typical case where you do not want to use actual ID refcounting,
but only the shallow 'user real' (aka 'user one') system...
2020-03-11 16:51:53 +01:00
e1698e3750 Windows: Clean-up warning while building blendthumb
Casting a 64 bit pointer to a 32 bit DWORD gave 2 warnings.
Solved by storing the actual DWORD in the registry table.

Would have preferred to use a union, but C++ doesn't let you
initialize anything other than the first field, and C99 style
initializers are not supported until C++20, so this solution
will have to do until then.
2020-03-11 09:27:35 -06:00
6a632f11c8 GPencil: Add missing Layer buttons in Dopesheet header and remove unneeded options
Update Dopesheet header to include missing buttons, remove Scene Active only buttton and also removed duplicated search box.

The removed options come from old 2.7x version and they are not required now.

Reviewed By: mendio, pepeland

Differential Revision: https://developer.blender.org/D7107
2020-03-11 16:10:47 +01:00
b198cef89f Fix T74516: Armature Crash on Select Similar Group
Select Similar Group and Select Similar Shape had this issue since they
were added. Basically it assumes there is pose data which in some cases
it does not.
2020-03-11 15:32:21 +01:00
Brecht Van Lommel
b9f6d033be Eevee: internal support for arbitrary number of volume grids
This has no user visible impact yet since smoke volumes only support a fixed
set of attributes, but will become important with the new volume object.

For GPU shader compilation, volume grids are now handled separately from
image textures. They are somewhere between a vertex attribute and an image
texture, basically an attribute that is stored as a texture.

Differential Revision: https://developer.blender.org/D6952
2020-03-11 14:59:05 +01:00
e1e772a802 Cleanup: add comment explaining reason for volume texture swizzling 2020-03-11 14:52:55 +01:00
c4beb518de Cycles: disable RTTI only for OSL files, other libraries like OpenVDB need it
This is a bit weak since it's not entirely clear where the boundary is, but
tested to build and pass tests on all platforms.
2020-03-11 14:42:46 +01:00
Brecht Van Lommel
c8acb6dd6c Smoke: put density/color in separate textures, fixes for workbench shader
This is more in line with standard grids and means we don't have to make
many special exceptions in the upcoming change for arbitrary number of volume
grids support in Eevee.

The workbench shader was also changed to fix bugs where squared density was
used, and the smoke color would affect the density so that black smoke would
be invisible. This can change the look of smoke in workbench significantly.

When using the color grid when smoke has a constant color, the color grid
will no longer be premultiplied by the density. If the color is constant
we want to be able not to store a grid at all. This breaks one test for
Cycles and Eevee, but the setup in that test using a color without density
does not make sense. It suffers from artifacts since the unpremultiplied
color grid by itself will not have smooth boundaries.

Differential Revision: https://developer.blender.org/D6951
2020-03-11 14:42:46 +01:00
f3a33a9298 Fix/workaround Eevee tests crashing with Mantaflow
Skip light cache baking until T73921 is fixed. This should be fixed properly
but being able to run the tests at all is important now.
2020-03-11 14:42:46 +01:00
4bee1e1c8c Fix broken logic in lib_query that could lead to NULL id_owner pointer.
Issue revealed by own recent cleanup in rB8820ab4, and moticed by
@brecht, thanks.

Note that am not 100% sure whether we should allow call on lib_query
without a proper valid owner_id, for embedded data-blocks. But this can
be investifated later, so far things have been working like that.
2020-03-11 14:37:38 +01:00
836b99ce49 Fix T74296: Free depsgraph when view layer is removed
Reviewers: sergey

Differential Revision: https://developer.blender.org/D7110
2020-03-11 14:18:22 +01:00
6eeaecdd67 Cloth: Copy point cache settings when copying cloth modifier
This fixes the issue mentioned in the comment in T74515.

Reviewers: mont29

Differential Revision: https://developer.blender.org/D7104
2020-03-11 13:43:58 +01:00
5cb2861420 Fix Cycles incorrect result when compressing some 8 bit log colorspace images
Don't clamp and do premultiply after color space conversion.
2020-03-11 12:59:29 +01:00
68c0d77b0c Cleanup: rename 'private' to 'embedded' for sub-data IDs.
'Private' can be a rather confusing term, especially when considering
its meaning in programming languages.

So now root node trees and master collections are 'embedded' IDs
instead.
2020-03-11 12:53:10 +01:00
8820ab41bd Cleanup in ID remapping code re owner_id vs. self_id.
The former is always a real, in-Main data-block, while the later, when
different, should be one of those embedded 'private' IDs (like root node
ree or master collection).
2020-03-11 12:53:10 +01:00
8b2072868d Cleanup: spelling 2020-03-11 21:39:56 +11:00
796683db8e Cycles: add view layer setting to exclude volumes, like hair and surfaces 2020-03-11 11:25:57 +01:00
b70a13fb66 UI: show more digits for adaptive sampling noise threshold 2020-03-11 10:54:28 +01:00
476c0eab4a Fix T74315: Cloth brush breaks orbit around selection
Reviewers: pablodp606

Differential Revision: https://developer.blender.org/D7095
2020-03-11 10:30:52 +01:00
e1b70e9f9c Fix T74635: GPencil RMB-menu brush settings not working in Sculpt and Weight Paint modes 2020-03-11 10:14:42 +01:00
f2c64517b5 Fix T74607: Modifier key click events ignore mouse wheel
Alt-Wheel would sent Alt-Click event, prompting to switch tools.
2020-03-11 20:09:37 +11:00
d195deef5c Cleanup: clang-format 2020-03-11 19:23:52 +11:00
Greg Neumiller
d0618570eb UI: edit modifier messages to clarify where auto-smooth is set 2020-03-11 19:19:29 +11:00
1c9829f351 GHOST: tests now build again
GLX gears work as expected, multitest_c only creates windows
but misses font drawing still.
2020-03-11 15:17:27 +11:00
15983243a4 Cleanup: remove bitmap font drawing ifdef from MultiTest.c 2020-03-11 15:01:14 +11:00
4184f890fd GPU: minor changes to support standalone GHOST builds
- Move gpuPush/Pop from GPU_draw.h into GPU_state.h
  as this is for pushing/popping state.
- Add 'GPU_STANDALONE' define, to bypass use of user-preferences
  for theme colors and pixelsize, as well as pbvh init/free functions.

Needed to get GHOST tests working again.
2020-03-11 14:52:57 +11:00
f9cca12886 Fix T74596: Gpencil invert button was not working for Sculpt brushes
The button was not checked, only the pen position or the control key.
2020-03-10 20:12:11 +01:00
9c5a120ba2 GPencil: Use high precision float buffer for final rendering
This avoid color drifting due to R11G11B10 buffers.
2020-03-10 18:17:42 +01:00
fa09b900c2 Fix T74625 GPencil: Airbrush doesn't paint anything 2020-03-10 18:11:25 +01:00
0f1f751785 Fix T74525: Fluid caches overwrite each other by default
Reviewers: sebbas

Differential Revision: https://developer.blender.org/D7093
2020-03-10 17:33:05 +01:00
a6d7280b8e Fix T74200: Alembic import crashes Blender
I've added a very minimal mesh validation before the Alembic mesh is actually
converted to a Blender mesh. This prevents a specific crash with an example
file attached to T74200.
2020-03-10 17:16:12 +01:00
7c027f9480 Cycles: Fixed Shadow and Mist passes with adaptive sampling.
This also fixes a side-effect where turning on UV pass but leaving
Shadow pass turned off destroyed the Combined pass.
2020-03-10 16:50:51 +01:00
be20bf2fc0 Fix T74617: Gpencil Sculpt Strength brush gets wonky results
Changed how the strength is calculñated and reduce the factor to get a smoother result.
2020-03-10 16:45:51 +01:00
1619a5d8e9 Fix rendering artifacts when changing Face Sets visibility
All sculpt operators and brushes need to use ID_RECALC_SHADING even when
PBVH rendering is not used.
2020-03-10 16:32:09 +01:00
dc8bb3f3a0 Cleanup: Clarify places to look for subversion bump 2020-03-10 16:17:49 +01:00
b37482bc3d Fix T74613: Assign the default face set color in the versioning code
A default face set color was not being set in previously saved meshes,
so it will always render the default face set with a random color until
the colors were recalculated.

Bump subversion to 283.8

Reviewed By: dfelinto

Maniphest Tasks: T74613

Differential Revision: https://developer.blender.org/D7094
2020-03-10 15:55:50 +01:00
e06888cf89 Cleanup: Add comment explaining DPI influence on RNA pixel-properties
Good to be explicit about the fact that we may still use the pixel
property sub-type when DPI will be applied.
See comments in https://developer.blender.org/D7077.
2020-03-10 15:19:22 +01:00
d55231e5a1 UI: Clarify 3D View Grid Size Tooltip
The 3D view grid size property is a multiplier, not the size of the grid itself.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D7085
2020-03-10 08:44:30 -05:00
a52f6d7a31 Fix T66269: Menu for Extrapolation Mode is disabled in Graph Editor
The Extrapolation Mode menu in the graph editor channel list was
incorrectly using the operator for the Action/Dopesheet editor. The
operator was even missing in the generic dopesheet hotkeys, so
{key Shift E} was listed as hotkey but didn't work. This is now all
fixed.
2020-03-10 14:18:19 +01:00
a801487ef5 Fix T65076: Missing EasingType implementation on the Dopesheet
EasingType was implemented rBdaccaa713b6e for the GraphEditor (but never
made it to the Dopesheet). If you can select Easing Mode in the
DopeSheet, then you should also be able to select the associated Easing
Type.

Thanks @lichtwerk for the initial implementation.

Maniphest Tasks: T65076

Differential Revision: https://developer.blender.org/D6094
2020-03-10 14:02:40 +01:00
ca717f0489 Fix T74425: Cannot texture paint an images sequence anymore
Caused by the introduction of UDIM (rBc30d6571bb47).

We need to make sure the tiles ImageUser is set up correctly [especially
the framenr], otherwise BKE_image_acquire_ibuf() and friends will fail
to find the correct ImBuf.

Also instead of initializing a minimal BKE_imageuser_default, now use
an appropriate ImageUser if avaliable and pass this around (instead of
just the tile_number). 2D painting can reuse the Image Editor ImageUser,
for 3D painting we still rely on a default ImageUser in most places, but
at least set the framenr correctly].

This also fixes crashes when doing image operations such as inverting or
resizing on images in a sequence in the Image Editor.

This also fixes color sampling (S) from the 3DView going wrong for image
sequences (would fallback to OpenGL sampling because an ImBuf could not
be found).

Maniphest Tasks: T74425

Differential Revision: https://developer.blender.org/D7022
2020-03-10 13:47:33 +01:00
212660f467 Fix T73369: corner pin & sun-beam nodes gizmos are too big
Note that dragging isn't working well,
however this was an issue in previous releases.
2020-03-10 23:30:59 +11:00
85cdf9a1b9 Fix T74612: file browser thumbnails not showing and using CPU continuously
This started happening after changing filter ID to 64 bit in rB2841b2be3949,
however there was a pre-existing error here in the comparison to detect updates
to filter flags.
2020-03-10 13:11:32 +01:00
Lucas Veber
915998111b Modifiers: Corrective Smooth modifier, new Scale parameter
When scaling the root bone of a rig to apply a global scale, the
corrective smooth modifier results in wrong deformation due to incorrect
scaling. The delta calculations are not taking into account any scale
value.

To fix it, a scale property is added to the modifier, allowing to set
manually the scale value for the deltas by simply multiplying the
vectors by this value. There is a similar implementation in Maya's Delta
Mush deformer. This property can be for example driven by the scale of
the root bone of the rig, to dynamically update when the animator scale
this bone.

Reviewed By: brecht, sybren

Differential Revision: https://developer.blender.org/D6622
2020-03-10 12:49:08 +01:00
982b498c22 OVERLAY: Viewport Background Color visible in Material Preview Mode
When user used a custom background color, this color was also visible in
material preview mode, when the world opacity was less than 1. This
patch will draw the theme color as it was used to.
2020-03-10 11:36:39 +01:00
dc3ff1db3f Fix T74585: Crash when scrolling viewport shading pop-up
Was dereferencing NULL pointer. Mistake from d5572eacc5.
2020-03-10 11:21:00 +01:00
9f48852ba4 Buildbot: Enable version character for development builds
Allows to have 2.82a as a beta version on buildbot.
2020-03-10 10:23:28 +01:00
1aa7c4c28a GPencil: Cleanup float indicator 2020-03-10 08:58:25 +01:00
Stefan Werner
811569dc11 Cycles: Using OpenCL popcount() in PMJ sampler. 2020-03-10 08:53:30 +01:00
7b8ac04d86 Fix T74601: Cut Particles to Shape fails for transformed object 2020-03-10 16:55:41 +11:00
5aa54207e1 Fix sequencer Slip tool skipping offset=0 case
The slip tool wasn't being applied when the offset was zero.

This caused modal operation to skip applying this offset while dragging.
2020-03-10 16:09:57 +11:00
5184328991 Cleanup: replace term 'terrible' from sequence slip
Joke from branch name, makes comments unclear.
2020-03-10 15:53:18 +11:00
94a5b7a2e2 Fix vertex slide deselecting faces
Regression from 9a5df92c1b
2020-03-10 15:15:52 +11:00
163e6b348f Cleanup: GPencil: Remove uneeded cast 2020-03-10 05:01:13 +01:00
71712d828d GPencil: Fix RNA range for uv_rotation 2020-03-10 04:47:37 +01:00
c971e812d5 Fix T74536: Grease pencil immediately crashes on macOS
It seems like OSX drivers are using standard attributes for passing
gl_VertexID and gl_InstanceID to the vertex shader, and count them in the
limit of MAX_VERTEX_ATTRIBS.

This patch make sure to never use more than 13 attributes by packing some
attributes together.
2020-03-10 04:47:37 +01:00
bf1b323b15 DRW: Fix wrong test condition
Fixes the warning: address of array 'cmd->draw.batch->inst' will
always evaluate to 'true'
2020-03-10 04:47:37 +01:00
ec9b836d3b Fix T74579: Filename with '\' causes assert when browsing files 2020-03-10 12:29:37 +11:00
fbe81db29a Fix IC keymap after recent GP merge
Just a simple fix here for now to keep the keymap working. Will revisit these areas to make them fit in properly with the keymap.
2020-03-09 23:23:06 +01:00
9c5522f7c8 Cleanup: compiler warnings 2020-03-09 21:58:55 +01:00
0133d66ada Fix error in grease pencil vertex paint levels operator 2020-03-09 21:58:55 +01:00
Pablo Dobarro
4652f23fa3 Fix T74354: Avoid division by 0 when calculating hardness
I could not reproduce the issue, but it looks like it was produced by
this division by 0. In any case, the code here was wrong.

Reviewed By: jbakker

Maniphest Tasks: T74354

Differential Revision: https://developer.blender.org/D6987
2020-03-09 21:19:55 +01:00
84b94f9e7b Sculpt: Edge Automasking
This automasking option protects the open boundary edges of the mesh from the brush deformation. This is needed to sculpt cloths and it works nicely with the cloth brush.
It has a Propagation Steps property that controls the falloff of the mask from the edge.

Limitations:
- The automask is recalculated at the beginning of each stroke, creating a little bit of lag in high poly meshes, but it is not necessary. This can be fixed in the future by caching the edge distances, increasing a little bit the complexity of the code.
- The boundary vertex detection in meshes is not ideal and it fails with triangulated geometry, but it is the same as in the smooth brush. After fixing this, we should refactor the smooth brush to use the API and let the automasking option manually control the affected vertices.
- It does not work in Multires (it needs to be implemented in the API). The smooth brush in Multires is also not making boundary vertices.
- The falloff has a visible line artifact on grid patterns. We can smooth the final automasking factors several iterations, but it will make the initialization much slower. This can also be added in the future if we decided to cache the distances.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D6705
2020-03-09 21:16:02 +01:00
Yevgeny Makarov
04e9ba7169 UI: add menus for preferences editor
This only applies to the case where preferences are opened as an editor in
a workspace, not with Edit > Preferences in a new window.

Differential Revision: https://developer.blender.org/D7001
2020-03-09 20:18:11 +01:00
Adrian Newton
2d8d30e17b UI: make workbench viewport samples label consistent with Cycles and Eevee
Differential Revision: https://developer.blender.org/D7082
2020-03-09 20:18:11 +01:00
Adrian Newton
848a4f002d UI: add "Samples" text to audio mixing buffer size preference for clarity
Differential Revision: https://developer.blender.org/D7076
2020-03-09 20:18:11 +01:00
18e3615a68 Face Sets: Use white color for a default Face Set to enable the overlay
This introduces a variable to store a face set ID which is going to be
rendered white. When initializing a mesh or randomizing the colors, this
variable gets updated to always render a white face set. This way the
face set overlay can be enabled without adding colors to the mesh if
face sets are not in use. After creating the first face set, new colors
are generated randomly like usual.

The face set stored as default does not have any special meaning for
tools or brushes, it just affects the rendering color.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D7035
2020-03-09 20:11:18 +01:00
0dfb4ac1ff Face Sets: Add relax support to Mesh Filter and Draw Face Sets
This enables a relax operation that works only on face sets boundaries,
which smooths the jagged edges that are produced when painting or
expanding face sets by sliding the topology without affecting the shape
of the mesh. This has many uses in hard surface sculpting for things
like sculpting panels or smoothing surfaces. It can also help when
working with remeshed topology as it makes the face sets looks better
and more organized if needed.

The operation is implemented as an Shift smooth in the Draw Face sets
tool, similar to the Slide/Relax tool.

The same operation is also available in the mesh filter to smooth all
the face sets boundaries uniformly or to smooth the face set under the
cursor with the Use Face Sets option.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D7034
2020-03-09 20:04:05 +01:00
e702c9a700 Fix Cloth Brush not working with automasking
The cloth brush was not using the automasking values when calculating
the mask value on each vertex.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D7083
2020-03-09 19:43:00 +01:00
0030e6a2fc Fix T74500: Rebuild the Face Sets datalayer after slicing the geometry
Was crashing SculptSession data will not longer be valid if the total
number of polys is modified when rendering the mesh again.
This deletes all face sets in the mesh when slicing the mask. I'll try
to add code to generate a new face set in with faces that are created
when filling the holes, but for now this avoids the crash.

Reviewed By: brecht

Maniphest Tasks: T74500

Differential Revision: https://developer.blender.org/D7049
2020-03-09 19:39:57 +01:00
503d5c0c65 Fix T74499: Add visibility checks to Face Sets creation operations
Create face sets by visibility needs to check if all face sets of a
vertex are visible to set the new face set. I renamed the functions to
make this more cleare in the API.

I also added a visibility check when creating by mask to avoid modifying
hidden areas.

Reviewed By: brecht

Maniphest Tasks: T74499

Differential Revision: https://developer.blender.org/D7048
2020-03-09 19:33:22 +01:00
c65b9fb825 Sculpt: Remove hardcoded hardness from Clay brush
Hardness is now a property implemented for all brushes, so this is no
longer needed.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D7078
2020-03-09 19:29:18 +01:00
6eb76f6430 Fix T74492: Reset Face Set data when cancelling the expand operator
The operator was resetting the mask data when cancelling instead of the
face set data, so it was crashing because mask data was not available
when starting the operator in expand face set mode.

Reviewed By: brecht

Maniphest Tasks: T74492

Differential Revision: https://developer.blender.org/D7043
2020-03-09 19:25:38 +01:00
a540d16ee8 Cleanup: Move Face Sets random color generation to its own function
This way we can change the color generation easily if we want to improve
it in the future. I also added more values to randomize a little bit the
saturation and value of the colors, as previously it was too easy to get
similar colors when creating new faces, forcing you to use the randomize
colors more than necessary.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D7042
2020-03-09 19:14:18 +01:00
1131e33026 Fix T74438: Vertex-only meshes disappear in wireframe mode
The problem happens because, in wireframe mode, `bool use_wire` is
always `true`, so the function that draws all edges is the called.

The solution is set `use_wire` as `false` when the mesh has no edges.

This matches the behavior of blender 2.79.

Reviewed By: fclem, brecht

Differential Revision: https://developer.blender.org/D7041
2020-03-09 15:09:26 -03:00
Adrian Newton
a468368540 UI: use pixel units for tile sizes and node auto-offset margin
Differential Revision: https://developer.blender.org/D7077
2020-03-09 18:49:42 +01:00
be2e41c397 Cleanup: Move BKE_animdata_free() call out of each IDType free data.
This has been long standing TODO...

Note that remaining usages of BKE_xxx_delete should all be carefully
checked for and utilmately nuked in favor of `BKE_id_delete()`, think we
still have quiet a few bugs hidden in those (code seems to usually
assume those functions do a full ID deletion, which is not the case).
2020-03-09 18:43:11 +01:00
6472a721f0 Cleanup: Remove unused switch/case from BKE_lib_id.
Only covers direct usages of new callbacks from IDTypeInfo.

We still have a lot of those switch/case, many can probably go away
with minimal refactor now, but that will be for later.
2020-03-09 18:43:11 +01:00
b080de79db Alembic: constraint for transform animation is using world matrix again
In rB7c5a44c71f13 I changed the way transform matrices are loaded from
Alembic. Instead of having the Alembic importer convert matrices from
local (in the Alembic file) to World (to pass to the constraint handling
the animation of transforms), I set the constraint space to
`CONSTRAINT_SPACE_LOCAL`.

This worked thanks to rB7728bfd4c45c. However, that commit was reverted,
which meant that for parentless objects `CONSTRAINT_SPACE_LOCAL` no
longer means "local space".

The situation is resolved by setting the constraint to world space
again, and computing the world matrix in the Alembic importer.
2020-03-09 18:27:18 +01:00
e672cf11c3 Cleanup: palette: Move to IDTypeInfo and remove unused BKE API. 2020-03-09 18:09:23 +01:00
3e9dbe7f62 Cleanup: GreasePencil: Move to IDTypeInfo and remove unused BKE API. 2020-03-09 18:09:23 +01:00
c010290e75 Cleanup: Ipo: Move to IDTypeInfo and remove unused BKE API. 2020-03-09 18:09:23 +01:00
214cc3c245 Fix failing assert because of invalid region coordinates
Steps to reproduce were:
* Disable tool settings region in 3D View (View > Tool Settings)
* Split the 3D View and drag all the way down

The removed code doesn't seem to be needed anymore. Tested this on hiDPI
too, seems fine.

These kind of fixes are always tricky, so I wouldn't be surprised if
there are any issues caused by this.
2020-03-09 18:02:08 +01:00
32fc22db56 Fix T72253: Mantaflow adaptive domain cuts off
The issue of T72253 was that the density threshold (RNA adapt_threshold) was considering cells as empty cells too early and thus also shrinking the domain too early. The fix for this is to use smaller threshold values for the adaptive domain. This fix gives more flexibility in the UI to do just that.
2020-03-09 17:42:38 +01:00
Yevgeny Makarov
07bdbeda84 UI: avoid blurring of view navigation widgets at some UI scales
Differential Revision: https://developer.blender.org/D6734
2020-03-09 17:11:24 +01:00
Ulysse Martin
aca222c3da Fix unnecessary grease pencil drawing when there are no grease pencil objects
Differential Revision: https://developer.blender.org/D6551
2020-03-09 17:11:24 +01:00
Yevgeny Makarov
bada2dcafd UI: improve layout of keymap preferences, more consistent with other areas
Differential Revision: https://developer.blender.org/D6592
2020-03-09 17:11:24 +01:00
Kai Jægersen
6f4612a7cc Python API: allow overriding context.workspace for workspace operators
Differential Revision: https://developer.blender.org/D6867
2020-03-09 17:11:24 +01:00
Yevgeny Makarov
da101eddef UI: input preferences layout tweaks for keymap search and zoom settings
Differential Revision: https://developer.blender.org/D6979
2020-03-09 17:11:24 +01:00
Johan Walles
8bc8713beb Cleanup: avoid (harmless) race condition reported by Helgrind
Differential Revision: https://developer.blender.org/D7058
2020-03-09 17:11:24 +01:00
Adrian Newton
58e6306b15 UI: reorder viewport/render toggle in particles for consistency with modifiers
Differential Revision: https://developer.blender.org/D7069
2020-03-09 17:11:24 +01:00
Adrian Newton
5543572cd2 Cleanup: remove unnecessary space at end of label
Differential Revision: https://developer.blender.org/D7070
2020-03-09 17:11:24 +01:00
Adrian Newton
1276380fd2 UI: add space before px unit in Eevee properties for consistency
Differential Revision: https://developer.blender.org/D7072
2020-03-09 17:11:24 +01:00
Eitan
3923738c8f UI: rename View Frame to Go to Current Frame in video sequencer
For consistency with other editors.

Differential Revision: https://developer.blender.org/D7025
2020-03-09 17:11:24 +01:00
324e24ee38 Fix layout.prop invert_checkbox not working combined with icons
Contributed by Valentin (Poulpator).

Differential Revision: https://developer.blender.org/D7027
2020-03-09 17:11:24 +01:00
81c18c2507 Fix part of T73921: hang with Eevee light baking and Mantaflow
Now it crashes instead.
2020-03-09 17:11:24 +01:00
29b405a327 Overlay: Add antialiasing to particle sprites 2020-03-09 17:09:32 +01:00
3912a2a227 Fix T74438: Overlay: Loose verts and particle not draw in some conditions
This was caused by a missing output variable for lineOutput.
This triggered some undefined behavior.
2020-03-09 17:09:32 +01:00
4d0d43ce8e Cleanup: FreestyleLineStyle: Move to IDTypeInfo and remove unused BKE API. 2020-03-09 16:56:53 +01:00
dab1d14a51 Cleanup: Mask: Move to IDTypeInfo and remove unused BKE API. 2020-03-09 16:56:53 +01:00
6965bcc0c9 Cleanup: MovieClip: Move to IDTypeInfo and remove unused BKE API. 2020-03-09 16:56:53 +01:00
d43fbbb307 Cleanup: Silence warnings 2020-03-09 16:34:55 +01:00
29f3af9527 GPencil: Refactor of Draw Engine, Vertex Paint and all internal functions
This commit is a full refactor of the grease pencil modules including Draw Engine, Modifiers, VFX, depsgraph update, improvements in operators and conversion of Sculpt and Weight paint tools to real brushes.

Also, a huge code cleanup has been done at all levels.

Thanks to @fclem for his work and yo @pepeland and @mendio for the testing and help in the development.

Differential Revision: https://developer.blender.org/D6293
2020-03-09 16:27:24 +01:00
dcb9312687 Depsgraph: fix crash caused by removing too many NO-OP nodes
Unused no-op operation nodes are not bound to a callback function, and
have no outgoing relations. Incoming relations of such nodes are removed
since ff60dd8b18. However, this was done
too broadly, causing too many relations to be lost and indirectly linked
objects to be unevaluated.

This commit introduces a `DEPSOP_FLAG_FAKE_USER` flag for operation
nodes, which indicates they are not to be removed, even when they appear
to be unused.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D7074
2020-03-09 16:05:33 +01:00
93f6369573 Fix T74533: Crash when entering sculpt mode
Apparently this happened when the object is in a flat view and has
customdata `CD_SCULPT_FACE_SETS`

Differential Revision: https://developer.blender.org/D7073
2020-03-09 12:00:11 -03:00
598ab525da Cleanup: Replace ABS/SQUARE/CUBE with function calls
While it might be handy to have type-less functionality which is
similar to how C++ math is implemented it can not be easily achieved
with just preprocessor in a way which does not have side-effects on
wrong usage.

There macros where often used on a non-trivial expression, and there
was at least one usage where it was causing an actual side effect/bug
on Windows (see change around square_f(sh[index++]) in studiolight.c).

For such cases it is handy to have a function which is guaranteed to
have zero side-effects. The motivation behind actually removing the
macros is that there is already a way to do similar calculation. Also,
not having such macros is a way to guarantee that its usage is not
changed in a way which have side-effects and that it's not used as an
inspiration for cases where it should not be used.

Differential Revision: https://developer.blender.org/D7051
2020-03-09 14:47:59 +01:00
ee5d7bc16b Cleanup: clang-format 2020-03-09 10:11:31 -03:00
a922a097ef Transform Snap Object: Remove depsgraph when creating context
Currently, this change does not bring functional changes.
But it is necessary to extend the use of the snap system for gizmos,
since, after a Undo, the `depsgraph` pointed by the `snap_context`
has its memory invalidated.

Reviewed By: campbellbarton

Differential Revision: https://developer.blender.org/D7013
2020-03-09 10:02:11 -03:00
3a10c61a7d Cleanup: ParticleSettings: Move to IDTypeInfo and remove unused BKE API. 2020-03-09 12:49:04 +01:00
b9d1026ce0 Cleanup: PaintCurve: Move to IDTypeInfo and remove unused BKE API. 2020-03-09 12:49:04 +01:00
b57d3afb76 Cleanup: CacheFile: Move to IDTypeInfo and remove unused BKE API. 2020-03-09 12:49:04 +01:00
613148ce5b Cleanup: WorkSpace: Move to IDTypeInfo and remove unused BKE API. 2020-03-09 12:49:04 +01:00
0de5156a24 Cleanup: WindowManager: Move to IDTypeInfo and remove unused WM API.
Getting rid of one static 'registered' callback in BKE, yeah!
2020-03-09 12:49:04 +01:00
f881162f81 Revert "Constraints: remove special meaning of Local Space for parentless Objects."
This reverts commit 7728bfd4c4.

Although this brings back an inconsistency in the behaviour of
constraints on objects and bones, people were relying on the old
behaviour, and the new behaviour broke their files.

It is still desired to remove this inconsistency, but it will happen
more gradually.
2020-03-09 10:44:55 +01:00
Stefan Werner
bc6bbe5fac Fix T74537: Fixed out of bounds memory access in Cycles' PMJ sampler. 2020-03-08 21:31:47 +01:00
668b64380a Cleanup: Sound: Move to IDTypeInfo and remove unused BKE API. 2020-03-08 20:45:00 +01:00
014f78b5b5 Cleanup: Speaker: Move to IDTypeInfo and remove unused BKE API. 2020-03-08 20:10:07 +01:00
0d05fd9b4c Install_deps: fix wrong XR_OPENXR_ROOT_DIR parameter for CMake.
Should be `XR_OPENXR_SDK_ROOT_DIR`.`
2020-03-08 17:14:58 +01:00
7f404f1c74 Fix T74395: Box interpolation does not support repeat extrapolation
Reviewers: fclem

Differential Revision: https://developer.blender.org/D7009
2020-03-08 14:43:06 +01:00
bc2343d5c3 Cleanup: comments in main()
Clarify references to functions.
2020-03-08 13:48:52 +11:00
52dc1ddaa0 Revert "Outliner: Allow deleting entire selection"
This reverts commit 62f238a65e.

This prevents undo steps from being stored.
2020-03-08 13:48:21 +11:00
62f238a65e Outliner: Allow deleting entire selection
This allows deleting both collections and objects in the outliner
selection at the same time. This only works using the keyboard shortcuts
(X or Delete).

While this works, a more robust solution should be implemented later to
allow deleting the whole selection from the context menu as well.
2020-03-07 14:46:22 -07:00
5539b68009 Fluid: Optimization for smoke simulation (multigrid)
The solver will now automatically detect static scenes (no moving obstacles) and use a slightly faster pressure solve in those cases.
2020-03-07 19:57:06 +01:00
9867a82072 Cleanup: Outliner: Remove unused parameter
Searching back in the outliner did not require the unused SpaceOutliner
parameter.
2020-03-07 11:26:02 -07:00
6b49a9db52 Fix T74513: Wrong naming in some Face Set comments and operators
Missing changes from one of the renamings of the initial face sets
patch.

Reviewed By: brecht

Maniphest Tasks: T74513

Differential Revision: https://developer.blender.org/D7054
2020-03-07 16:42:28 +01:00
db1d711458 Fix T74501: Wrong initial iteration when using mask expand
The initial iteration for all symmetry areas is always 0. We were using
1 for the main stroke, so it was 1 step behind.

This was broken for expanding masks and face sets, but with face sets it
is more noticeable.

Reviewed By: brecht

Maniphest Tasks: T74501

Differential Revision: https://developer.blender.org/D7050
2020-03-07 16:41:41 +01:00
7760cec5dc Fix T74498: Do not iterate over hidden vertices when using the transform tool
By using PBVH_ITER_UNIQUE hidden vertices are skipped, like in the rest of
the brushes and tools.

Reviewed By: brecht

Maniphest Tasks: T74498

Differential Revision: https://developer.blender.org/D7047
2020-03-07 16:40:19 +01:00
2261 changed files with 64866 additions and 37826 deletions

View File

@@ -132,9 +132,7 @@ PenaltyBreakAssignment: 100
AllowShortFunctionsOnASingleLine: None
# Disable for now since it complicates initial migration tests,
# TODO: look into enabling this in the future.
SortIncludes: false
SortIncludes: true
# Don't right align escaped newlines to the right because we have a wide default
AlignEscapedNewlines: DontAlign

View File

@@ -186,8 +186,7 @@ if(APPLE)
option(WITH_XR_OPENXR "Enable VR features through the OpenXR specification" OFF)
mark_as_advanced(WITH_XR_OPENXR)
else()
# Disabled until there's more than just the build system stuff. Should be enabled soon.
option(WITH_XR_OPENXR "Enable VR features through the OpenXR specification" OFF)
option(WITH_XR_OPENXR "Enable VR features through the OpenXR specification" ON)
endif()
# Compositor
@@ -320,6 +319,10 @@ mark_as_advanced(WITH_SYSTEM_GLOG)
# Freestyle
option(WITH_FREESTYLE "Enable Freestyle (advanced edges rendering)" ON)
# New object types
option(WITH_NEW_OBJECT_TYPES "Enable new hair and pointcloud objects (use for development only, don't save in files)" OFF)
mark_as_advanced(WITH_NEW_OBJECT_TYPES)
# Misc
if(WIN32)
option(WITH_INPUT_IME "Enable Input Method Editor (IME) for complex Asian character input" ON)
@@ -681,6 +684,7 @@ if(WITH_GHOST_SDL OR WITH_HEADLESS)
set(WITH_X11_ALPHA OFF)
set(WITH_GHOST_XDND OFF)
set(WITH_INPUT_IME OFF)
set(WITH_XR_OPENXR OFF)
endif()
if(WITH_CPU_SSE)

View File

@@ -162,7 +162,7 @@ harvest(opensubdiv/lib opensubdiv/lib "*.a")
harvest(openvdb/include/openvdb openvdb/include/openvdb "*.h")
harvest(openvdb/lib openvdb/lib "*.a")
harvest(xr_openxr_sdk/include/openxr xr_openxr_sdk/include/openxr "*.h")
harvest(xr_openxr_sdk/lib xr_openxr_sdk/src/loader "*.a")
harvest(xr_openxr_sdk/lib xr_openxr_sdk/lib "*.a")
harvest(osl/bin osl/bin "oslc")
harvest(osl/include osl/include "*.h")
harvest(osl/lib osl/lib "*.a")

View File

@@ -29,6 +29,7 @@ if(UNIX AND NOT APPLE)
-DBUILD_WITH_WAYLAND_HEADERS=OFF
-DBUILD_WITH_XCB_HEADERS=OFF
-DBUILD_WITH_XLIB_HEADERS=ON
-DCMAKE_CXX_FLAGS=-DDISABLE_STD_FILESYSTEM=1
)
endif()

View File

@@ -3128,7 +3128,7 @@ compile_XR_OpenXR_SDK() {
fi
# To be changed each time we make edits that would modify the compiled result!
xr_openxr_magic=0
xr_openxr_magic=1
_init_xr_openxr_sdk
# Clean install if needed!
@@ -3186,7 +3186,7 @@ compile_XR_OpenXR_SDK() {
cmake_d="$cmake_d -D BUILD_WITH_XCB_HEADERS=OFF"
cmake_d="$cmake_d -D BUILD_WITH_XLIB_HEADERS=ON"
cmake $cmake_d ..
cmake $cmake_d "-DCMAKE_CXX_FLAGS=-DDISABLE_STD_FILESYSTEM=1" ..
make -j$THREADS && make install
make clean
@@ -5377,7 +5377,7 @@ print_info() {
PRINT " $_1"
_buildargs="$_buildargs $_1"
if [ -d $INST/xr-openxr-sdk ]; then
_1="-D XR_OPENXR_ROOT_DIR=$INST/xr-openxr-sdk"
_1="-D XR_OPENXR_SDK_ROOT_DIR=$INST/xr-openxr-sdk"
PRINT " $_1"
_buildargs="$_buildargs $_1"
fi

View File

@@ -98,7 +98,7 @@ class VersionInfo:
self.is_development_build = False
else:
# Development build
self.full_version = self.version + '-' + self.hash
self.full_version = self.version + self.version_char + '-' + self.hash
self.is_development_build = True
def _parse_header_file(self, filename, define):

View File

@@ -23,7 +23,7 @@ echo - with_tests ^(enable building unit tests^)
echo - nobuildinfo ^(disable buildinfo^)
echo - debug ^(Build an unoptimized debuggable build^)
echo - packagename [newname] ^(override default cpack package name^)
echo - buildir [newdir] ^(override default build folder^)
echo - builddir [newdir] ^(override default build folder^)
echo - 2017 ^(build with visual studio 2017^)
echo - 2017pre ^(build with visual studio 2017 pre-release^)
echo - 2017b ^(build with visual studio 2017 Build Tools^)

View File

@@ -415,4 +415,11 @@ if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive")
endif()
if(MSVC)
# bullet is responsible for quite a few silly warnings
# suppress all of them. Not great, but they really needed
# to sort that out themselves.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W0")
endif()
blender_add_lib(extern_bullet "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")

View File

@@ -77,6 +77,11 @@ if(WIN32)
list(APPEND INC
src/windows
)
if(MSVC)
# Suppress warning about google::LogMessageFatal::~LogMessageFatal
# not returning.
add_definitions("/wd4722")
endif()
else()
list(APPEND INC
include

View File

@@ -192,7 +192,7 @@ int cbDisableConstructor(PyObject *self, PyObject *args, PyObject *kwds)
return -1;
}
PyMODINIT_FUNC PyInit_Main(void)
PyMODINIT_FUNC PyInit_manta_main(void)
{
MantaEnsureRegistration();
#if PY_MAJOR_VERSION >= 3
@@ -567,7 +567,7 @@ void WrapperRegistry::construct(const string &scriptname, const vector<string> &
registerDummyTypes();
// work around for certain gcc versions, cast to char*
PyImport_AppendInittab((char *)gDefaultModuleName.c_str(), PyInit_Main);
PyImport_AppendInittab((char *)gDefaultModuleName.c_str(), PyInit_manta_main);
}
inline PyObject *castPy(PyTypeObject *p)

View File

@@ -62,7 +62,7 @@ void MantaEnsureRegistration();
#ifdef BLENDER
# ifdef PyMODINIT_FUNC
PyMODINIT_FUNC PyInit_Main(void);
PyMODINIT_FUNC PyInit_manta_main(void);
# endif
#endif

View File

@@ -15,7 +15,7 @@
#define _VECTORBASE_H
// get rid of windos min/max defines
#if defined(WIN32) || defined(_WIN32)
#if (defined(WIN32) || defined(_WIN32)) && !defined(NOMINMAX)
# define NOMINMAX
#endif

View File

@@ -1,3 +1,3 @@
#define MANTA_GIT_VERSION "commit 1d52e96ad602f1974dfee75bef293bc397e4b41b"
#define MANTA_GIT_VERSION "commit 5fbd3d04381b21afce4a593d1fe2d9bc7bef5424"

View File

@@ -1171,6 +1171,11 @@ void solvePressureSystem(Grid<Real> &rhs,
maxIter = 100;
pmg = gMapMG[parent];
// Release MG from previous step if present (e.g. if previous solve was with MGStatic)
if (pmg && preconditioner == PcMGDynamic) {
releaseMG(parent);
pmg = nullptr;
}
if (!pmg) {
pmg = new GridMg(pressure.getSize());
gMapMG[parent] = pmg;

View File

@@ -37,8 +37,8 @@
#endif
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <intrin.h>
#include <windows.h>
#if defined(__clang__)
# pragma GCC diagnostic push

View File

@@ -47,10 +47,10 @@
#ifndef __ATOMIC_OPS_UTILS_H__
#define __ATOMIC_OPS_UTILS_H__
#include <stdint.h>
#include <stddef.h>
#include <stdlib.h>
#include <limits.h>
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include <assert.h>

View File

@@ -25,8 +25,8 @@
#include "AUD_PyInit.h"
#include <AUD_Sound.h>
#include <python/PySound.h>
#include <python/PyAPI.h>
#include <python/PySound.h>
extern "C" {
extern void *BKE_sound_get_factory(void *sound);

View File

@@ -18,23 +18,23 @@
* \ingroup clog
*/
#include <assert.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <assert.h>
/* Disable for small single threaded programs
* to avoid having to link with pthreads. */
#ifdef WITH_CLOG_PTHREADS
# include <pthread.h>
# include "atomic_ops.h"
# include <pthread.h>
#endif
/* For 'isatty' to check for color. */
#if defined(__unix__) || defined(__APPLE__) || defined(__HAIKU__)
# include <unistd.h>
# include <sys/time.h>
# include <unistd.h>
#endif
#if defined(_MSC_VER)

View File

@@ -177,14 +177,11 @@ if(CXX_HAS_AVX2)
add_definitions(-DWITH_KERNEL_AVX2)
endif()
if(WITH_CYCLES_OSL)
# LLVM and OSL need to build without RTTI
if(WIN32 AND MSVC)
set(RTTI_DISABLE_FLAGS "/GR- -DBOOST_NO_RTTI -DBOOST_NO_TYPEID")
elseif(CMAKE_COMPILER_IS_GNUCC OR (CMAKE_C_COMPILER_ID MATCHES "Clang"))
set(RTTI_DISABLE_FLAGS "-fno-rtti -DBOOST_NO_RTTI -DBOOST_NO_TYPEID")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${RTTI_DISABLE_FLAGS}")
# LLVM and OSL need to build without RTTI
if(WIN32 AND MSVC)
set(RTTI_DISABLE_FLAGS "/GR- -DBOOST_NO_RTTI -DBOOST_NO_TYPEID")
elseif(CMAKE_COMPILER_IS_GNUCC OR (CMAKE_C_COMPILER_ID MATCHES "Clang"))
set(RTTI_DISABLE_FLAGS "-fno-rtti -DBOOST_NO_RTTI -DBOOST_NO_TYPEID")
endif()
# Definitions and Includes
@@ -353,17 +350,6 @@ if(WITH_CYCLES_NETWORK)
add_definitions(-DWITH_NETWORK)
endif()
if(WITH_OPENCOLORIO)
add_definitions(-DWITH_OCIO)
include_directories(
SYSTEM
${OPENCOLORIO_INCLUDE_DIRS}
)
if(WIN32)
add_definitions(-DOpenColorIO_STATIC)
endif()
endif()
if(WITH_CYCLES_STANDALONE OR WITH_CYCLES_NETWORK OR WITH_CYCLES_CUBIN_COMPILER)
add_subdirectory(app)
endif()

View File

@@ -60,6 +60,7 @@ link_directories(
${TIFF_LIBPATH}
${OPENEXR_LIBPATH}
${OPENJPEG_LIBPATH}
${OPENVDB_LIBPATH}
)
if(WITH_OPENCOLORIO)

View File

@@ -14,8 +14,8 @@
* limitations under the License.
*/
#include <stdio.h>
#include <stdint.h>
#include <stdio.h>
#include <string>
#include <vector>

View File

@@ -20,11 +20,11 @@
#include "util/util_args.h"
#include "util/util_foreach.h"
#include "util/util_logging.h"
#include "util/util_path.h"
#include "util/util_stats.h"
#include "util/util_string.h"
#include "util/util_task.h"
#include "util/util_logging.h"
using namespace ccl;

View File

@@ -16,12 +16,12 @@
#include <stdio.h>
#include "device/device.h"
#include "render/buffers.h"
#include "render/camera.h"
#include "device/device.h"
#include "render/integrator.h"
#include "render/scene.h"
#include "render/session.h"
#include "render/integrator.h"
#include "util/util_args.h"
#include "util/util_foreach.h"

View File

@@ -16,9 +16,9 @@
#include <stdio.h>
#include <sstream>
#include <algorithm>
#include <iterator>
#include <sstream>
#include "graph/node_xml.h"
@@ -32,8 +32,8 @@
#include "render/nodes.h"
#include "render/object.h"
#include "render/osl.h"
#include "render/shader.h"
#include "render/scene.h"
#include "render/shader.h"
#include "subd/subd_patch.h"
#include "subd/subd_split.h"
@@ -292,7 +292,7 @@ static void xml_read_shader_graph(XMLReadState &state, Shader *shader, xml_node
filepath = path_join(state.base, filepath);
}
snode = ((OSLShaderManager *)manager)->osl_node(filepath);
snode = OSLShaderManager::osl_node(manager, filepath);
if (!snode) {
fprintf(stderr, "Failed to create OSL node from \"%s\".\n", filepath.c_str());

View File

@@ -38,6 +38,7 @@ set(SRC
CCL_api.h
blender_device.h
blender_id_map.h
blender_image.h
blender_object_cull.h
blender_sync.h
blender_session.h
@@ -91,6 +92,20 @@ if(WITH_MOD_FLUID)
add_definitions(-DWITH_FLUID)
endif()
if(WITH_NEW_OBJECT_TYPES)
add_definitions(-DWITH_NEW_OBJECT_TYPES)
endif()
if(WITH_OPENVDB)
add_definitions(-DWITH_OPENVDB ${OPENVDB_DEFINITIONS})
list(APPEND INC_SYS
${OPENVDB_INCLUDE_DIRS}
)
list(APPEND LIB
${OPENVDB_LIBRARIES}
)
endif()
blender_add_lib(bf_intern_cycles "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
# avoid link failure with clang 3.4 debug

View File

@@ -33,7 +33,7 @@ def _is_using_buggy_driver():
# in the version string, but those cards do not quite work and
# causing crashes.
return True
regex = re.compile(".*Compatibility Profile Context ([0-9]+(\.[0-9]+)+)$")
regex = re.compile(".*Compatibility Profile Context ([0-9]+(\\.[0-9]+)+)$")
if not regex.match(version):
# Skip cards like FireGL
return False

View File

@@ -361,6 +361,7 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
description="Noise level step to stop sampling at, lower values reduce noise the cost of render time. Zero for automatic setting based on number of AA samples",
min=0.0, max=1.0,
default=0.0,
precision=4,
)
adaptive_min_samples: IntProperty(
name="Adaptive Min Samples",
@@ -443,13 +444,20 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
default=8,
)
volume_step_size: FloatProperty(
name="Step Size",
description="Distance between volume shader samples when rendering the volume "
"(lower values give more accurate and detailed results, but also increased render time)",
default=0.1,
min=0.0000001, max=100000.0, soft_min=0.01, soft_max=1.0, precision=4,
unit='LENGTH'
volume_step_rate: FloatProperty(
name="Step Rate",
description="Globally adjust detail for volume rendering, on top of automatically estimated step size. "
"Higher values reduce render time, lower values render with more detail",
default=1.0,
min=0.01, max=100.0, soft_min=0.1, soft_max=10.0, precision=2
)
volume_preview_step_rate: FloatProperty(
name="Step Rate",
description="Globally adjust detail for volume rendering, on top of automatically estimated step size. "
"Higher values reduce render time, lower values render with more detail",
default=1.0,
min=0.01, max=100.0, soft_min=0.1, soft_max=10.0, precision=2
)
volume_max_steps: IntProperty(
@@ -933,6 +941,14 @@ class CyclesMaterialSettings(bpy.types.PropertyGroup):
default='LINEAR',
)
volume_step_rate: FloatProperty(
name="Step Rate",
description="Scale the distance between volume shader samples when rendering the volume "
"(lower values give more accurate and detailed results, but also increased render time)",
default=1.0,
min=0.001, max=1000.0, soft_min=0.1, soft_max=10.0, precision=4
)
displacement_method: EnumProperty(
name="Displacement Method",
description="Method to use for the displacement",
@@ -1043,6 +1059,13 @@ class CyclesWorldSettings(bpy.types.PropertyGroup):
items=enum_volume_interpolation,
default='LINEAR',
)
volume_step_size: FloatProperty(
name="Step Size",
description="Distance between volume shader samples when rendering the volume "
"(lower values give more accurate and detailed results, but also increased render time)",
default=1.0,
min=0.0000001, max=100000.0, soft_min=0.1, soft_max=100.0, precision=4
)
@classmethod
def register(cls):

View File

@@ -373,7 +373,7 @@ class CYCLES_RENDER_PT_subdivision(CyclesButtonsPanel, Panel):
col = layout.column()
sub = col.column(align=True)
sub.prop(cscene, "dicing_rate", text="Dicing Rate Render")
sub.prop(cscene, "preview_dicing_rate", text="Preview")
sub.prop(cscene, "preview_dicing_rate", text="Viewport")
col.separator()
@@ -428,9 +428,11 @@ class CYCLES_RENDER_PT_volumes(CyclesButtonsPanel, Panel):
scene = context.scene
cscene = scene.cycles
col = layout.column()
col.prop(cscene, "volume_step_size", text="Step Size")
col.prop(cscene, "volume_max_steps", text="Max Steps")
col = layout.column(align=True)
col.prop(cscene, "volume_step_rate", text="Step Rate Render")
col.prop(cscene, "volume_preview_step_rate", text="Viewport")
layout.prop(cscene, "volume_max_steps", text="Max Steps")
class CYCLES_RENDER_PT_light_paths(CyclesButtonsPanel, Panel):
@@ -770,6 +772,8 @@ class CYCLES_RENDER_PT_filter(CyclesButtonsPanel, Panel):
col.prop(view_layer, "use_solid", text="Surfaces")
col = flow.column()
col.prop(view_layer, "use_strand", text="Hair")
col = flow.column()
col.prop(view_layer, "use_volumes", text="Volumes")
if with_freestyle:
col = flow.column()
col.prop(view_layer, "use_freestyle", text="Freestyle")
@@ -1413,8 +1417,6 @@ class CYCLES_LIGHT_PT_light(CyclesButtonsPanel, Panel):
light = context.light
clamp = light.cycles
layout.use_property_decorate = False
if self.bl_space_type == 'PROPERTIES':
layout.row().prop(light, "type", expand=True)
layout.use_property_split = True
@@ -1696,6 +1698,9 @@ class CYCLES_WORLD_PT_settings_volume(CyclesButtonsPanel, Panel):
sub.prop(cworld, "volume_sampling", text="Sampling")
col.prop(cworld, "volume_interpolation", text="Interpolation")
col.prop(cworld, "homogeneous_volume", text="Homogeneous")
sub = col.column()
sub.active = not cworld.homogeneous_volume
sub.prop(cworld, "volume_step_size")
class CYCLES_MATERIAL_PT_preview(CyclesButtonsPanel, Panel):
@@ -1827,6 +1832,9 @@ class CYCLES_MATERIAL_PT_settings_volume(CyclesButtonsPanel, Panel):
sub.prop(cmat, "volume_sampling", text="Sampling")
col.prop(cmat, "volume_interpolation", text="Interpolation")
col.prop(cmat, "homogeneous_volume", text="Homogeneous")
sub = col.column()
sub.active = not cmat.homogeneous_volume
sub.prop(cmat, "volume_step_rate")
def draw(self, context):
self.draw_shared(self, context, context.material)

View File

@@ -595,40 +595,6 @@ static void ExportCurveTriangleGeometry(Mesh *mesh, ParticleCurveData *CData, in
/* texture coords still needed */
}
static void export_hair_motion_validate_attribute(Hair *hair,
int motion_step,
int num_motion_keys,
bool have_motion)
{
Attribute *attr_mP = hair->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
const int num_keys = hair->curve_keys.size();
if (num_motion_keys != num_keys || !have_motion) {
/* No motion or hair "topology" changed, remove attributes again. */
if (num_motion_keys != num_keys) {
VLOG(1) << "Hair topology changed, removing attribute.";
}
else {
VLOG(1) << "No motion, removing attribute.";
}
hair->attributes.remove(ATTR_STD_MOTION_VERTEX_POSITION);
}
else if (motion_step > 0) {
VLOG(1) << "Filling in new motion vertex position for motion_step " << motion_step;
/* Motion, fill up previous steps that we might have skipped because
* they had no motion, but we need them anyway now. */
for (int step = 0; step < motion_step; step++) {
float4 *mP = attr_mP->data_float4() + step * num_keys;
for (int key = 0; key < num_keys; key++) {
mP[key] = float3_to_float4(hair->curve_keys[key]);
mP[key].w = hair->curve_radius[key];
}
}
}
}
static void ExportCurveSegments(Scene *scene, Hair *hair, ParticleCurveData *CData)
{
int num_keys = 0;
@@ -748,6 +714,40 @@ static float4 LerpCurveSegmentMotionCV(ParticleCurveData *CData, int sys, int cu
return lerp(mP, mP2, remainder);
}
static void export_hair_motion_validate_attribute(Hair *hair,
int motion_step,
int num_motion_keys,
bool have_motion)
{
Attribute *attr_mP = hair->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
const int num_keys = hair->curve_keys.size();
if (num_motion_keys != num_keys || !have_motion) {
/* No motion or hair "topology" changed, remove attributes again. */
if (num_motion_keys != num_keys) {
VLOG(1) << "Hair topology changed, removing attribute.";
}
else {
VLOG(1) << "No motion, removing attribute.";
}
hair->attributes.remove(ATTR_STD_MOTION_VERTEX_POSITION);
}
else if (motion_step > 0) {
VLOG(1) << "Filling in new motion vertex position for motion_step " << motion_step;
/* Motion, fill up previous steps that we might have skipped because
* they had no motion, but we need them anyway now. */
for (int step = 0; step < motion_step; step++) {
float4 *mP = attr_mP->data_float4() + step * num_keys;
for (int key = 0; key < num_keys; key++) {
mP[key] = float3_to_float4(hair->curve_keys[key]);
mP[key].w = hair->curve_radius[key];
}
}
}
}
static void ExportCurveSegmentsMotion(Hair *hair, ParticleCurveData *CData, int motion_step)
{
VLOG(1) << "Exporting curve motion segments for hair " << hair->name << ", motion step "
@@ -817,7 +817,7 @@ static void ExportCurveSegmentsMotion(Hair *hair, ParticleCurveData *CData, int
}
}
/* in case of new attribute, we verify if there really was any motion */
/* In case of new attribute, we verify if there really was any motion. */
if (new_attribute) {
export_hair_motion_validate_attribute(hair, motion_step, i, have_motion);
}
@@ -1154,6 +1154,194 @@ void BlenderSync::sync_particle_hair(
}
}
#ifdef WITH_NEW_OBJECT_TYPES
static float4 hair_point_as_float4(BL::HairPoint b_point)
{
float4 mP = float3_to_float4(get_float3(b_point.co()));
mP.w = b_point.radius();
return mP;
}
static float4 interpolate_hair_points(BL::Hair b_hair,
const int first_point_index,
const int num_points,
const float step)
{
const float curve_t = step * (num_points - 1);
const int point_a = clamp((int)curve_t, 0, num_points - 1);
const int point_b = min(point_a + 1, num_points - 1);
const float t = curve_t - (float)point_a;
return lerp(hair_point_as_float4(b_hair.points[first_point_index + point_a]),
hair_point_as_float4(b_hair.points[first_point_index + point_b]),
t);
}
static void export_hair_curves(Scene *scene, Hair *hair, BL::Hair b_hair)
{
/* TODO: optimize so we can straight memcpy arrays from Blender? */
/* Add requested attributes. */
Attribute *attr_intercept = NULL;
Attribute *attr_random = NULL;
if (hair->need_attribute(scene, ATTR_STD_CURVE_INTERCEPT)) {
attr_intercept = hair->attributes.add(ATTR_STD_CURVE_INTERCEPT);
}
if (hair->need_attribute(scene, ATTR_STD_CURVE_RANDOM)) {
attr_random = hair->attributes.add(ATTR_STD_CURVE_RANDOM);
}
/* Reserve memory. */
const int num_keys = b_hair.points.length();
const int num_curves = b_hair.curves.length();
if (num_curves > 0) {
VLOG(1) << "Exporting curve segments for hair " << hair->name;
}
hair->reserve_curves(num_curves, num_keys);
/* Export curves and points. */
vector<float> points_length;
BL::Hair::curves_iterator b_curve_iter;
for (b_hair.curves.begin(b_curve_iter); b_curve_iter != b_hair.curves.end(); ++b_curve_iter) {
BL::HairCurve b_curve = *b_curve_iter;
const int first_point_index = b_curve.first_point_index();
const int num_points = b_curve.num_points();
float3 prev_co = make_float3(0.0f, 0.0f, 0.0f);
float length = 0.0f;
if (attr_intercept) {
points_length.clear();
points_length.reserve(num_points);
}
/* Position and radius. */
for (int i = 0; i < num_points; i++) {
BL::HairPoint b_point = b_hair.points[first_point_index + i];
const float3 co = get_float3(b_point.co());
const float radius = b_point.radius();
hair->add_curve_key(co, radius);
if (attr_intercept) {
if (i > 0) {
length += len(co - prev_co);
points_length.push_back(length);
}
prev_co = co;
}
}
/* Normalized 0..1 attribute along curve. */
if (attr_intercept) {
for (int i = 0; i < num_points; i++) {
attr_intercept->add((length == 0.0f) ? 0.0f : points_length[i] / length);
}
}
/* Random number per curve. */
if (attr_random != NULL) {
attr_random->add(hash_uint2_to_float(b_curve.index(), 0));
}
/* Curve. */
const int shader_index = 0;
hair->add_curve(first_point_index, shader_index);
}
}
static void export_hair_curves_motion(Hair *hair, BL::Hair b_hair, int motion_step)
{
VLOG(1) << "Exporting curve motion segments for hair " << hair->name << ", motion step "
<< motion_step;
/* Find or add attribute. */
Attribute *attr_mP = hair->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
bool new_attribute = false;
if (!attr_mP) {
VLOG(1) << "Creating new motion vertex position attribute";
attr_mP = hair->attributes.add(ATTR_STD_MOTION_VERTEX_POSITION);
new_attribute = true;
}
/* Export motion keys. */
const int num_keys = hair->curve_keys.size();
float4 *mP = attr_mP->data_float4() + motion_step * num_keys;
bool have_motion = false;
int num_motion_keys = 0;
int curve_index = 0;
BL::Hair::curves_iterator b_curve_iter;
for (b_hair.curves.begin(b_curve_iter); b_curve_iter != b_hair.curves.end(); ++b_curve_iter) {
BL::HairCurve b_curve = *b_curve_iter;
const int first_point_index = b_curve.first_point_index();
const int num_points = b_curve.num_points();
Hair::Curve curve = hair->get_curve(curve_index);
curve_index++;
if (num_points == curve.num_keys) {
/* Number of keys matches. */
for (int i = 0; i < num_points; i++) {
int point_index = first_point_index + i;
if (point_index < num_keys) {
mP[num_motion_keys] = hair_point_as_float4(b_hair.points[point_index]);
num_motion_keys++;
if (!have_motion) {
/* TODO: use epsilon for comparison? Was needed for particles due to
* transform, but ideally should not happen anymore. */
float4 curve_key = float3_to_float4(hair->curve_keys[i]);
curve_key.w = hair->curve_radius[i];
have_motion = !(mP[i] == curve_key);
}
}
}
}
else {
/* Number of keys has changed. Generate an interpolated version
* to preserve motion blur. */
const float step_size = curve.num_keys > 1 ? 1.0f / (curve.num_keys - 1) : 0.0f;
for (int i = 0; i < curve.num_keys; i++) {
const float step = i * step_size;
mP[num_motion_keys] = interpolate_hair_points(b_hair, first_point_index, num_points, step);
num_motion_keys++;
}
have_motion = true;
}
}
/* In case of new attribute, we verify if there really was any motion. */
if (new_attribute) {
export_hair_motion_validate_attribute(hair, motion_step, num_motion_keys, have_motion);
}
}
#endif /* WITH_NEW_OBJECT_TYPES */
/* Hair object. */
void BlenderSync::sync_hair(Hair *hair, BL::Object &b_ob, bool motion, int motion_step)
{
#ifdef WITH_NEW_OBJECT_TYPES
/* Convert Blender hair to Cycles curves. */
BL::Hair b_hair(b_ob.data());
if (motion) {
export_hair_curves_motion(hair, b_hair, motion_step);
}
else {
export_hair_curves(scene, hair, b_hair);
}
#else
(void)hair;
(void)b_ob;
(void)motion;
(void)motion_step;
#endif /* WITH_NEW_OBJECT_TYPES */
}
void BlenderSync::sync_hair(BL::Depsgraph b_depsgraph,
BL::Object b_ob,
Geometry *geom,
@@ -1179,14 +1367,24 @@ void BlenderSync::sync_hair(BL::Depsgraph b_depsgraph,
geom->used_shaders = used_shaders;
if (view_layer.use_hair && scene->curve_system_manager->use_curves) {
/* Particle hair. */
bool need_undeformed = geom->need_attribute(scene, ATTR_STD_GENERATED);
BL::Mesh b_mesh = object_to_mesh(
b_data, b_ob, b_depsgraph, need_undeformed, Mesh::SUBDIVISION_NONE);
#ifdef WITH_NEW_OBJECT_TYPES
if (b_ob.type() == BL::Object::type_HAIR) {
/* Hair object. */
sync_hair(hair, b_ob, false);
assert(mesh == NULL);
}
else
#endif
{
/* Particle hair. */
bool need_undeformed = geom->need_attribute(scene, ATTR_STD_GENERATED);
BL::Mesh b_mesh = object_to_mesh(
b_data, b_ob, b_depsgraph, need_undeformed, Mesh::SUBDIVISION_NONE);
if (b_mesh) {
sync_particle_hair(geom, b_mesh, b_ob, false);
free_object_to_mesh(b_data, b_ob, b_mesh);
if (b_mesh) {
sync_particle_hair(geom, b_mesh, b_ob, false);
free_object_to_mesh(b_data, b_ob, b_mesh);
}
}
}
@@ -1213,13 +1411,24 @@ void BlenderSync::sync_hair_motion(BL::Depsgraph b_depsgraph,
/* Export deformed coordinates. */
if (ccl::BKE_object_is_deform_modified(b_ob, b_scene, preview)) {
/* Particle hair. */
BL::Mesh b_mesh = object_to_mesh(b_data, b_ob, b_depsgraph, false, Mesh::SUBDIVISION_NONE);
if (b_mesh) {
sync_particle_hair(geom, b_mesh, b_ob, true, motion_step);
free_object_to_mesh(b_data, b_ob, b_mesh);
#ifdef WITH_NEW_OBJECT_TYPES
if (b_ob.type() == BL::Object::type_HAIR) {
/* Hair object. */
sync_hair(hair, b_ob, true, motion_step);
assert(mesh == NULL);
return;
}
else
#endif
{
/* Particle hair. */
BL::Mesh b_mesh = object_to_mesh(b_data, b_ob, b_depsgraph, false, Mesh::SUBDIVISION_NONE);
if (b_mesh) {
sync_particle_hair(geom, b_mesh, b_ob, true, motion_step);
free_object_to_mesh(b_data, b_ob, b_mesh);
return;
}
}
}
/* No deformation on this frame, copy coordinates if other frames did have it. */

View File

@@ -17,6 +17,8 @@
#include "blender/blender_device.h"
#include "blender/blender_util.h"
#include "util/util_foreach.h"
CCL_NAMESPACE_BEGIN
enum DenoiserType {

View File

@@ -18,9 +18,9 @@
#define __BLENDER_DEVICE_H__
#include "MEM_guardedalloc.h"
#include "RNA_types.h"
#include "RNA_access.h"
#include "RNA_blender_cpp.h"
#include "RNA_types.h"
#include "device/device.h"

View File

@@ -23,6 +23,8 @@
#include "blender/blender_sync.h"
#include "blender/blender_util.h"
#include "util/util_foreach.h"
CCL_NAMESPACE_BEGIN
Geometry *BlenderSync::sync_geometry(BL::Depsgraph &b_depsgraph,
@@ -36,11 +38,19 @@ Geometry *BlenderSync::sync_geometry(BL::Depsgraph &b_depsgraph,
BL::ID b_key_id = (BKE_object_is_modified(b_ob)) ? b_ob_instance : b_ob_data;
GeometryKey key(b_key_id.ptr.data, use_particle_hair);
BL::Material material_override = view_layer.material_override;
Shader *default_shader = scene->default_surface;
Geometry::Type geom_type = (use_particle_hair &&
Shader *default_shader = (b_ob.type() == BL::Object::type_VOLUME) ? scene->default_volume :
scene->default_surface;
#ifdef WITH_NEW_OBJECT_TYPES
Geometry::Type geom_type = ((b_ob.type() == BL::Object::type_HAIR || use_particle_hair) &&
(scene->curve_system_manager->primitive != CURVE_TRIANGLES)) ?
Geometry::HAIR :
Geometry::MESH;
#else
Geometry::Type geom_type = ((use_particle_hair) &&
(scene->curve_system_manager->primitive != CURVE_TRIANGLES)) ?
Geometry::HAIR :
Geometry::MESH;
#endif
/* Find shader indices. */
vector<Shader *> used_shaders;
@@ -119,10 +129,14 @@ Geometry *BlenderSync::sync_geometry(BL::Depsgraph &b_depsgraph,
geom->name = ustring(b_ob_data.name().c_str());
#ifdef WITH_NEW_OBJECT_TYPES
if (b_ob.type() == BL::Object::type_HAIR || use_particle_hair) {
#else
if (use_particle_hair) {
#endif
sync_hair(b_depsgraph, b_ob, geom, used_shaders);
}
else if (object_fluid_gas_domain_find(b_ob)) {
else if (b_ob.type() == BL::Object::type_VOLUME || object_fluid_gas_domain_find(b_ob)) {
Mesh *mesh = static_cast<Mesh *>(geom);
sync_volume(b_ob, mesh, used_shaders);
}
@@ -159,10 +173,14 @@ void BlenderSync::sync_geometry_motion(BL::Depsgraph &b_depsgraph,
return;
}
#ifdef WITH_NEW_OBJECT_TYPES
if (b_ob.type() == BL::Object::type_HAIR || use_particle_hair) {
#else
if (use_particle_hair) {
#endif
sync_hair_motion(b_depsgraph, b_ob, geom, motion_step);
}
else if (object_fluid_gas_domain_find(b_ob)) {
else if (b_ob.type() == BL::Object::type_VOLUME || object_fluid_gas_domain_find(b_ob)) {
/* No volume motion blur support yet. */
}
else {

View File

@@ -14,206 +14,71 @@
* limitations under the License.
*/
#include "render/image.h"
#include "MEM_guardedalloc.h"
#include "blender/blender_sync.h"
#include "blender/blender_image.h"
#include "blender/blender_session.h"
#include "blender/blender_util.h"
CCL_NAMESPACE_BEGIN
/* builtin image file name is actually an image datablock name with
* absolute sequence frame number concatenated via '@' character
*
* this function splits frame from builtin name
*/
int BlenderSession::builtin_image_frame(const string &builtin_name)
/* Packed Images */
BlenderImageLoader::BlenderImageLoader(BL::Image b_image, int frame)
: b_image(b_image), frame(frame), free_cache(!b_image.has_data())
{
int last = builtin_name.find_last_of('@');
return atoi(builtin_name.substr(last + 1, builtin_name.size() - last - 1).c_str());
}
void BlenderSession::builtin_image_info(const string &builtin_name,
void *builtin_data,
ImageMetaData &metadata)
bool BlenderImageLoader::load_metadata(ImageMetaData &metadata)
{
/* empty image */
metadata.width = 1;
metadata.height = 1;
metadata.width = b_image.size()[0];
metadata.height = b_image.size()[1];
metadata.depth = 1;
metadata.channels = b_image.channels();
if (!builtin_data)
return;
/* recover ID pointer */
PointerRNA ptr;
RNA_id_pointer_create((ID *)builtin_data, &ptr);
BL::ID b_id(ptr);
if (b_id.is_a(&RNA_Image)) {
/* image data */
BL::Image b_image(b_id);
metadata.builtin_free_cache = !b_image.has_data();
metadata.is_float = b_image.is_float();
metadata.width = b_image.size()[0];
metadata.height = b_image.size()[1];
metadata.depth = 1;
metadata.channels = b_image.channels();
if (metadata.is_float) {
/* Float images are already converted on the Blender side,
* no need to do anything in Cycles. */
metadata.colorspace = u_colorspace_raw;
if (b_image.is_float()) {
if (metadata.channels == 1) {
metadata.type = IMAGE_DATA_TYPE_FLOAT;
}
}
else if (b_id.is_a(&RNA_Object)) {
/* smoke volume data */
BL::Object b_ob(b_id);
BL::FluidDomainSettings b_domain = object_fluid_gas_domain_find(b_ob);
metadata.is_float = true;
metadata.depth = 1;
metadata.channels = 1;
if (!b_domain)
return;
if (builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_DENSITY) ||
builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_FLAME) ||
builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_HEAT) ||
builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_TEMPERATURE))
metadata.channels = 1;
else if (builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_COLOR))
metadata.channels = 4;
else if (builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_VELOCITY))
metadata.channels = 3;
else
return;
int3 resolution = get_int3(b_domain.domain_resolution());
int amplify = (b_domain.use_noise()) ? b_domain.noise_scale() : 1;
/* Velocity and heat data is always low-resolution. */
if (builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_VELOCITY) ||
builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_HEAT)) {
amplify = 1;
}
metadata.width = resolution.x * amplify;
metadata.height = resolution.y * amplify;
metadata.depth = resolution.z * amplify;
}
else {
/* TODO(sergey): Check we're indeed in shader node tree. */
PointerRNA ptr;
RNA_pointer_create(NULL, &RNA_Node, builtin_data, &ptr);
BL::Node b_node(ptr);
if (b_node.is_a(&RNA_ShaderNodeTexPointDensity)) {
BL::ShaderNodeTexPointDensity b_point_density_node(b_node);
metadata.channels = 4;
metadata.width = b_point_density_node.resolution();
metadata.height = metadata.width;
metadata.depth = metadata.width;
metadata.is_float = true;
}
}
}
bool BlenderSession::builtin_image_pixels(const string &builtin_name,
void *builtin_data,
int tile,
unsigned char *pixels,
const size_t pixels_size,
const bool associate_alpha,
const bool free_cache)
{
if (!builtin_data) {
return false;
}
const int frame = builtin_image_frame(builtin_name);
PointerRNA ptr;
RNA_id_pointer_create((ID *)builtin_data, &ptr);
BL::Image b_image(ptr);
const int width = b_image.size()[0];
const int height = b_image.size()[1];
const int channels = b_image.channels();
unsigned char *image_pixels = image_get_pixels_for_frame(b_image, frame, tile);
const size_t num_pixels = ((size_t)width) * height;
if (image_pixels && num_pixels * channels == pixels_size) {
memcpy(pixels, image_pixels, pixels_size * sizeof(unsigned char));
}
else {
if (channels == 1) {
memset(pixels, 0, pixels_size * sizeof(unsigned char));
else if (metadata.channels == 4) {
metadata.type = IMAGE_DATA_TYPE_FLOAT4;
}
else {
const size_t num_pixels_safe = pixels_size / channels;
unsigned char *cp = pixels;
for (size_t i = 0; i < num_pixels_safe; i++, cp += channels) {
cp[0] = 255;
cp[1] = 0;
cp[2] = 255;
if (channels == 4) {
cp[3] = 255;
}
}
return false;
}
/* Float images are already converted on the Blender side,
* no need to do anything in Cycles. */
metadata.colorspace = u_colorspace_raw;
}
else {
if (metadata.channels == 1) {
metadata.type = IMAGE_DATA_TYPE_BYTE;
}
else if (metadata.channels == 4) {
metadata.type = IMAGE_DATA_TYPE_BYTE4;
}
else {
return false;
}
}
if (image_pixels) {
MEM_freeN(image_pixels);
}
/* Free image buffers to save memory during render. */
if (free_cache) {
b_image.buffers_free();
}
if (associate_alpha) {
/* Premultiply, byte images are always straight for Blender. */
unsigned char *cp = pixels;
for (size_t i = 0; i < num_pixels; i++, cp += channels) {
cp[0] = (cp[0] * cp[3]) >> 8;
cp[1] = (cp[1] * cp[3]) >> 8;
cp[2] = (cp[2] * cp[3]) >> 8;
}
}
return true;
}
bool BlenderSession::builtin_image_float_pixels(const string &builtin_name,
void *builtin_data,
int tile,
float *pixels,
const size_t pixels_size,
const bool,
const bool free_cache)
bool BlenderImageLoader::load_pixels(const ImageMetaData &metadata,
void *pixels,
const size_t pixels_size,
const bool associate_alpha)
{
if (!builtin_data) {
return false;
}
const size_t num_pixels = ((size_t)metadata.width) * metadata.height;
const int channels = metadata.channels;
const int tile = 0; /* TODO(lukas): Support tiles here? */
PointerRNA ptr;
RNA_id_pointer_create((ID *)builtin_data, &ptr);
BL::ID b_id(ptr);
if (b_id.is_a(&RNA_Image)) {
if (b_image.is_float()) {
/* image data */
BL::Image b_image(b_id);
int frame = builtin_image_frame(builtin_name);
const int width = b_image.size()[0];
const int height = b_image.size()[1];
const int channels = b_image.channels();
float *image_pixels;
image_pixels = image_get_float_pixels_for_frame(b_image, frame, tile);
const size_t num_pixels = ((size_t)width) * height;
if (image_pixels && num_pixels * channels == pixels_size) {
memcpy(pixels, image_pixels, pixels_size * sizeof(float));
@@ -224,7 +89,7 @@ bool BlenderSession::builtin_image_float_pixels(const string &builtin_name,
}
else {
const size_t num_pixels_safe = pixels_size / channels;
float *fp = pixels;
float *fp = (float *)pixels;
for (int i = 0; i < num_pixels_safe; i++, fp += channels) {
fp[0] = 1.0f;
fp[1] = 0.0f;
@@ -239,107 +104,91 @@ bool BlenderSession::builtin_image_float_pixels(const string &builtin_name,
if (image_pixels) {
MEM_freeN(image_pixels);
}
/* Free image buffers to save memory during render. */
if (free_cache) {
b_image.buffers_free();
}
return true;
}
else if (b_id.is_a(&RNA_Object)) {
/* smoke volume data */
BL::Object b_ob(b_id);
BL::FluidDomainSettings b_domain = object_fluid_gas_domain_find(b_ob);
if (!b_domain) {
return false;
}
#ifdef WITH_FLUID
int3 resolution = get_int3(b_domain.domain_resolution());
int length, amplify = (b_domain.use_noise()) ? b_domain.noise_scale() : 1;
/* Velocity and heat data is always low-resolution. */
if (builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_VELOCITY) ||
builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_HEAT)) {
amplify = 1;
}
const int width = resolution.x * amplify;
const int height = resolution.y * amplify;
const int depth = resolution.z * amplify;
const size_t num_pixels = ((size_t)width) * height * depth;
if (builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_DENSITY)) {
FluidDomainSettings_density_grid_get_length(&b_domain.ptr, &length);
if (length == num_pixels) {
FluidDomainSettings_density_grid_get(&b_domain.ptr, pixels);
return true;
}
}
else if (builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_FLAME)) {
/* this is in range 0..1, and interpreted by the OpenGL smoke viewer
* as 1500..3000 K with the first part faded to zero density */
FluidDomainSettings_flame_grid_get_length(&b_domain.ptr, &length);
if (length == num_pixels) {
FluidDomainSettings_flame_grid_get(&b_domain.ptr, pixels);
return true;
}
}
else if (builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_COLOR)) {
/* the RGB is "premultiplied" by density for better interpolation results */
FluidDomainSettings_color_grid_get_length(&b_domain.ptr, &length);
if (length == num_pixels * 4) {
FluidDomainSettings_color_grid_get(&b_domain.ptr, pixels);
return true;
}
}
else if (builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_VELOCITY)) {
FluidDomainSettings_velocity_grid_get_length(&b_domain.ptr, &length);
if (length == num_pixels * 3) {
FluidDomainSettings_velocity_grid_get(&b_domain.ptr, pixels);
return true;
}
}
else if (builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_HEAT)) {
FluidDomainSettings_heat_grid_get_length(&b_domain.ptr, &length);
if (length == num_pixels) {
FluidDomainSettings_heat_grid_get(&b_domain.ptr, pixels);
return true;
}
}
else if (builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_TEMPERATURE)) {
FluidDomainSettings_temperature_grid_get_length(&b_domain.ptr, &length);
if (length == num_pixels) {
FluidDomainSettings_temperature_grid_get(&b_domain.ptr, pixels);
return true;
}
}
else {
fprintf(
stderr, "Cycles error: unknown volume attribute %s, skipping\n", builtin_name.c_str());
pixels[0] = 0.0f;
return false;
}
#endif
fprintf(stderr, "Cycles error: unexpected smoke volume resolution, skipping\n");
}
else {
/* We originally were passing view_layer here but in reality we need a
* a depsgraph to pass to the RE_point_density_minmax() function.
*/
/* TODO(sergey): Check we're indeed in shader node tree. */
PointerRNA ptr;
RNA_pointer_create(NULL, &RNA_Node, builtin_data, &ptr);
BL::Node b_node(ptr);
if (b_node.is_a(&RNA_ShaderNodeTexPointDensity)) {
BL::ShaderNodeTexPointDensity b_point_density_node(b_node);
int length;
b_point_density_node.calc_point_density(b_depsgraph, &length, &pixels);
unsigned char *image_pixels = image_get_pixels_for_frame(b_image, frame, tile);
if (image_pixels && num_pixels * channels == pixels_size) {
memcpy(pixels, image_pixels, pixels_size * sizeof(unsigned char));
}
else {
if (channels == 1) {
memset(pixels, 0, pixels_size * sizeof(unsigned char));
}
else {
const size_t num_pixels_safe = pixels_size / channels;
unsigned char *cp = (unsigned char *)pixels;
for (size_t i = 0; i < num_pixels_safe; i++, cp += channels) {
cp[0] = 255;
cp[1] = 0;
cp[2] = 255;
if (channels == 4) {
cp[3] = 255;
}
}
}
}
if (image_pixels) {
MEM_freeN(image_pixels);
}
if (associate_alpha) {
/* Premultiply, byte images are always straight for Blender. */
unsigned char *cp = (unsigned char *)pixels;
for (size_t i = 0; i < num_pixels; i++, cp += channels) {
cp[0] = (cp[0] * cp[3]) >> 8;
cp[1] = (cp[1] * cp[3]) >> 8;
cp[2] = (cp[2] * cp[3]) >> 8;
}
}
}
return false;
/* Free image buffers to save memory during render. */
if (free_cache) {
b_image.buffers_free();
}
return true;
}
string BlenderImageLoader::name() const
{
return BL::Image(b_image).name();
}
bool BlenderImageLoader::equals(const ImageLoader &other) const
{
const BlenderImageLoader &other_loader = (const BlenderImageLoader &)other;
return b_image == other_loader.b_image && frame == other_loader.frame;
}
/* Point Density */
BlenderPointDensityLoader::BlenderPointDensityLoader(BL::Depsgraph b_depsgraph,
BL::ShaderNodeTexPointDensity b_node)
: b_depsgraph(b_depsgraph), b_node(b_node)
{
}
bool BlenderPointDensityLoader::load_metadata(ImageMetaData &metadata)
{
metadata.channels = 4;
metadata.width = b_node.resolution();
metadata.height = metadata.width;
metadata.depth = metadata.width;
metadata.type = IMAGE_DATA_TYPE_FLOAT4;
return true;
}
bool BlenderPointDensityLoader::load_pixels(const ImageMetaData &,
void *pixels,
const size_t,
const bool)
{
int length;
b_node.calc_point_density(b_depsgraph, &length, (float **)&pixels);
return true;
}
void BlenderSession::builtin_images_load()
@@ -357,4 +206,15 @@ void BlenderSession::builtin_images_load()
manager->device_load_builtin(device, session->scene, session->progress);
}
string BlenderPointDensityLoader::name() const
{
return BL::ShaderNodeTexPointDensity(b_node).name();
}
bool BlenderPointDensityLoader::equals(const ImageLoader &other) const
{
const BlenderPointDensityLoader &other_loader = (const BlenderPointDensityLoader &)other;
return b_node == other_loader.b_node && b_depsgraph == other_loader.b_depsgraph;
}
CCL_NAMESPACE_END

View File

@@ -0,0 +1,61 @@
/*
* Copyright 2011-2020 Blender Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __BLENDER_IMAGE_H__
#define __BLENDER_IMAGE_H__
#include "RNA_blender_cpp.h"
#include "render/image.h"
CCL_NAMESPACE_BEGIN
class BlenderImageLoader : public ImageLoader {
public:
BlenderImageLoader(BL::Image b_image, int frame);
bool load_metadata(ImageMetaData &metadata) override;
bool load_pixels(const ImageMetaData &metadata,
void *pixels,
const size_t pixels_size,
const bool associate_alpha) override;
string name() const override;
bool equals(const ImageLoader &other) const override;
BL::Image b_image;
int frame;
bool free_cache;
};
class BlenderPointDensityLoader : public ImageLoader {
public:
BlenderPointDensityLoader(BL::Depsgraph depsgraph, BL::ShaderNodeTexPointDensity b_node);
bool load_metadata(ImageMetaData &metadata) override;
bool load_pixels(const ImageMetaData &metadata,
void *pixels,
const size_t pixels_size,
const bool associate_alpha) override;
string name() const override;
bool equals(const ImageLoader &other) const override;
BL::Depsgraph b_depsgraph;
BL::ShaderNodeTexPointDensity b_node;
};
CCL_NAMESPACE_END
#endif /* __BLENDER_IMAGE_H__ */

View File

@@ -14,25 +14,25 @@
* limitations under the License.
*/
#include "render/camera.h"
#include "render/colorspace.h"
#include "render/mesh.h"
#include "render/object.h"
#include "render/scene.h"
#include "render/camera.h"
#include "blender/blender_sync.h"
#include "blender/blender_session.h"
#include "blender/blender_sync.h"
#include "blender/blender_util.h"
#include "subd/subd_patch.h"
#include "subd/subd_split.h"
#include "util/util_algorithm.h"
#include "util/util_disjoint_set.h"
#include "util/util_foreach.h"
#include "util/util_hash.h"
#include "util/util_logging.h"
#include "util/util_math.h"
#include "util/util_disjoint_set.h"
#include "mikktspace.h"

View File

@@ -15,14 +15,14 @@
*/
#include "render/camera.h"
#include "render/integrator.h"
#include "render/graph.h"
#include "render/integrator.h"
#include "render/light.h"
#include "render/mesh.h"
#include "render/object.h"
#include "render/scene.h"
#include "render/nodes.h"
#include "render/object.h"
#include "render/particles.h"
#include "render/scene.h"
#include "render/shader.h"
#include "blender/blender_object_cull.h"
@@ -67,10 +67,20 @@ bool BlenderSync::object_is_mesh(BL::Object &b_ob)
return false;
}
if (b_ob.type() == BL::Object::type_CURVE) {
BL::Object::type_enum type = b_ob.type();
#ifdef WITH_NEW_OBJECT_TYPES
if (type == BL::Object::type_VOLUME || type == BL::Object::type_HAIR) {
#else
if (type == BL::Object::type_VOLUME) {
#endif
/* Will be exported attached to mesh. */
return true;
}
else if (type == BL::Object::type_CURVE) {
/* Skip exporting curves without faces, overhead can be
* significant if there are many for path animation. */
BL::Curve b_curve(b_ob.data());
BL::Curve b_curve(b_ob_data);
return (b_curve.bevel_object() || b_curve.extrude() != 0.0f || b_curve.bevel_depth() != 0.0f ||
b_curve.dimensions() == BL::Curve::dimensions_2D || b_ob.modifiers.length());

View File

@@ -19,8 +19,8 @@
#include "blender/CCL_api.h"
#include "blender/blender_device.h"
#include "blender/blender_sync.h"
#include "blender/blender_session.h"
#include "blender/blender_sync.h"
#include "blender/blender_util.h"
#include "render/denoising.h"
@@ -38,8 +38,8 @@
#ifdef WITH_OSL
# include "render/osl.h"
# include <OSL/oslquery.h>
# include <OSL/oslconfig.h>
# include <OSL/oslquery.h>
#endif
#ifdef WITH_OPENCL

View File

@@ -41,8 +41,8 @@
#include "util/util_progress.h"
#include "util/util_time.h"
#include "blender/blender_sync.h"
#include "blender/blender_session.h"
#include "blender/blender_sync.h"
#include "blender/blender_util.h"
CCL_NAMESPACE_BEGIN
@@ -138,14 +138,6 @@ void BlenderSession::create_session()
scene = new Scene(scene_params, session->device);
scene->name = b_scene.name();
/* setup callbacks for builtin image support */
scene->image_manager->builtin_image_info_cb = function_bind(
&BlenderSession::builtin_image_info, this, _1, _2, _3);
scene->image_manager->builtin_image_pixels_cb = function_bind(
&BlenderSession::builtin_image_pixels, this, _1, _2, _3, _4, _5, _6, _7);
scene->image_manager->builtin_image_float_pixels_cb = function_bind(
&BlenderSession::builtin_image_float_pixels, this, _1, _2, _3, _4, _5, _6, _7);
session->scene = scene;
/* There is no single depsgraph to use for the entire render.

View File

@@ -157,22 +157,6 @@ class BlenderSession {
bool do_update_only);
void do_write_update_render_tile(RenderTile &rtile, bool do_update_only, bool highlight);
int builtin_image_frame(const string &builtin_name);
void builtin_image_info(const string &builtin_name, void *builtin_data, ImageMetaData &metadata);
bool builtin_image_pixels(const string &builtin_name,
void *builtin_data,
int tile,
unsigned char *pixels,
const size_t pixels_size,
const bool associate_alpha,
const bool free_cache);
bool builtin_image_float_pixels(const string &builtin_name,
void *builtin_data,
int tile,
float *pixels,
const size_t pixels_size,
const bool associate_alpha,
const bool free_cache);
void builtin_images_load();
/* Update tile manager to reflect resumable render settings. */

View File

@@ -23,14 +23,15 @@
#include "render/scene.h"
#include "render/shader.h"
#include "blender/blender_texture.h"
#include "blender/blender_image.h"
#include "blender/blender_sync.h"
#include "blender/blender_texture.h"
#include "blender/blender_util.h"
#include "util/util_debug.h"
#include "util/util_foreach.h"
#include "util/util_string.h"
#include "util/util_set.h"
#include "util/util_string.h"
#include "util/util_task.h"
CCL_NAMESPACE_BEGIN
@@ -619,16 +620,16 @@ static ShaderNode *add_node(Scene *scene,
/* create script node */
BL::ShaderNodeScript b_script_node(b_node);
OSLShaderManager *manager = (OSLShaderManager *)scene->shader_manager;
ShaderManager *manager = scene->shader_manager;
string bytecode_hash = b_script_node.bytecode_hash();
if (!bytecode_hash.empty()) {
node = manager->osl_node("", bytecode_hash, b_script_node.bytecode());
node = OSLShaderManager::osl_node(manager, "", bytecode_hash, b_script_node.bytecode());
}
else {
string absolute_filepath = blender_absolute_path(
b_data, b_ntree, b_script_node.filepath());
node = manager->osl_node(absolute_filepath, "");
node = OSLShaderManager::osl_node(manager, absolute_filepath, "");
}
}
#else
@@ -650,6 +651,18 @@ static ShaderNode *add_node(Scene *scene,
get_tex_mapping(&image->tex_mapping, b_texture_mapping);
if (b_image) {
PointerRNA colorspace_ptr = b_image.colorspace_settings().ptr;
image->colorspace = get_enum_identifier(colorspace_ptr, "name");
image->animated = b_image_node.image_user().use_auto_refresh();
image->alpha_type = get_image_alpha_type(b_image);
image->tiles.clear();
BL::Image::tiles_iterator b_iter;
for (b_image.tiles.begin(b_iter); b_iter != b_image.tiles.end(); ++b_iter) {
image->tiles.push_back(b_iter->number());
}
/* builtin images will use callback-based reading because
* they could only be loaded correct from blender side
*/
@@ -666,34 +679,13 @@ static ShaderNode *add_node(Scene *scene,
*/
int scene_frame = b_scene.frame_current();
int image_frame = image_user_frame_number(b_image_user, scene_frame);
image->filename = b_image.name() + "@" + string_printf("%d", image_frame);
image->builtin_data = b_image.ptr.data;
image->handle = scene->image_manager->add_image(
new BlenderImageLoader(b_image, image_frame), image->image_params());
}
else {
image->filename = image_user_file_path(
b_image_user, b_image, b_scene.frame_current(), true);
image->builtin_data = NULL;
}
PointerRNA colorspace_ptr = b_image.colorspace_settings().ptr;
image->colorspace = get_enum_identifier(colorspace_ptr, "name");
image->animated = b_image_node.image_user().use_auto_refresh();
image->alpha_type = get_image_alpha_type(b_image);
image->tiles.clear();
BL::Image::tiles_iterator b_iter;
for (b_image.tiles.begin(b_iter); b_iter != b_image.tiles.end(); ++b_iter) {
image->tiles.push_back(b_iter->number());
}
/* TODO: restore */
/* TODO(sergey): Does not work properly when we change builtin type. */
#if 0
if (b_image.is_updated()) {
scene->image_manager->tag_reload_image(image->image_key());
}
#endif
}
node = image;
}
@@ -709,6 +701,12 @@ static ShaderNode *add_node(Scene *scene,
get_tex_mapping(&env->tex_mapping, b_texture_mapping);
if (b_image) {
PointerRNA colorspace_ptr = b_image.colorspace_settings().ptr;
env->colorspace = get_enum_identifier(colorspace_ptr, "name");
env->animated = b_env_node.image_user().use_auto_refresh();
env->alpha_type = get_image_alpha_type(b_image);
bool is_builtin = b_image.packed_file() || b_image.source() == BL::Image::source_GENERATED ||
b_image.source() == BL::Image::source_MOVIE ||
(b_engine.is_preview() && b_image.source() != BL::Image::source_SEQUENCE);
@@ -716,28 +714,13 @@ static ShaderNode *add_node(Scene *scene,
if (is_builtin) {
int scene_frame = b_scene.frame_current();
int image_frame = image_user_frame_number(b_image_user, scene_frame);
env->filename = b_image.name() + "@" + string_printf("%d", image_frame);
env->builtin_data = b_image.ptr.data;
env->handle = scene->image_manager->add_image(new BlenderImageLoader(b_image, image_frame),
env->image_params());
}
else {
env->filename = image_user_file_path(
b_image_user, b_image, b_scene.frame_current(), false);
env->builtin_data = NULL;
}
PointerRNA colorspace_ptr = b_image.colorspace_settings().ptr;
env->colorspace = get_enum_identifier(colorspace_ptr, "name");
env->animated = b_env_node.image_user().use_auto_refresh();
env->alpha_type = get_image_alpha_type(b_image);
/* TODO: restore */
/* TODO(sergey): Does not work properly when we change builtin type. */
#if 0
if (b_image.is_updated()) {
scene->image_manager->tag_reload_image(env->image_key());
}
#endif
}
node = env;
}
@@ -881,18 +864,13 @@ static ShaderNode *add_node(Scene *scene,
else if (b_node.is_a(&RNA_ShaderNodeTexPointDensity)) {
BL::ShaderNodeTexPointDensity b_point_density_node(b_node);
PointDensityTextureNode *point_density = new PointDensityTextureNode();
point_density->filename = b_point_density_node.name();
point_density->space = (NodeTexVoxelSpace)b_point_density_node.space();
point_density->interpolation = get_image_interpolation(b_point_density_node);
point_density->builtin_data = b_point_density_node.ptr.data;
point_density->image_manager = scene->image_manager;
point_density->handle = scene->image_manager->add_image(
new BlenderPointDensityLoader(b_depsgraph, b_point_density_node),
point_density->image_params());
/* TODO(sergey): Use more proper update flag. */
if (true) {
point_density->add_image();
b_point_density_node.cache_point_density(b_depsgraph);
scene->image_manager->tag_reload_image(point_density->image_key());
}
b_point_density_node.cache_point_density(b_depsgraph);
node = point_density;
/* Transformation form world space to texture space.
@@ -1282,6 +1260,7 @@ void BlenderSync::sync_materials(BL::Depsgraph &b_depsgraph, bool update_all)
shader->heterogeneous_volume = !get_boolean(cmat, "homogeneous_volume");
shader->volume_sampling_method = get_volume_sampling(cmat);
shader->volume_interpolation_method = get_volume_interpolation(cmat);
shader->volume_step_rate = get_float(cmat, "volume_step_rate");
shader->displacement_method = get_displacement_method(cmat);
shader->set_graph(graph);
@@ -1346,6 +1325,7 @@ void BlenderSync::sync_world(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d,
shader->heterogeneous_volume = !get_boolean(cworld, "homogeneous_volume");
shader->volume_sampling_method = get_volume_sampling(cworld);
shader->volume_interpolation_method = get_volume_interpolation(cworld);
shader->volume_step_rate = get_float(cworld, "volume_step_size");
}
else if (new_viewport_parameters.use_scene_world && b_world) {
BackgroundNode *background = new BackgroundNode();

View File

@@ -16,6 +16,7 @@
#include "render/background.h"
#include "render/camera.h"
#include "render/curves.h"
#include "render/film.h"
#include "render/graph.h"
#include "render/integrator.h"
@@ -25,19 +26,18 @@
#include "render/object.h"
#include "render/scene.h"
#include "render/shader.h"
#include "render/curves.h"
#include "device/device.h"
#include "blender/blender_device.h"
#include "blender/blender_sync.h"
#include "blender/blender_session.h"
#include "blender/blender_sync.h"
#include "blender/blender_util.h"
#include "util/util_debug.h"
#include "util/util_foreach.h"
#include "util/util_opengl.h"
#include "util/util_hash.h"
#include "util/util_opengl.h"
CCL_NAMESPACE_BEGIN
@@ -178,6 +178,11 @@ void BlenderSync::sync_recalc(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d
world_recalc = true;
}
}
/* Volume */
else if (b_id.is_a(&RNA_Volume)) {
BL::Volume b_volume(b_id);
geometry_map.set_recalc(b_volume);
}
}
BlenderViewportParameters new_viewport_parameters(b_v3d);
@@ -257,7 +262,8 @@ void BlenderSync::sync_integrator()
integrator->transparent_max_bounce = get_int(cscene, "transparent_max_bounces");
integrator->volume_max_steps = get_int(cscene, "volume_max_steps");
integrator->volume_step_size = get_float(cscene, "volume_step_size");
integrator->volume_step_rate = (preview) ? get_float(cscene, "volume_preview_step_rate") :
get_float(cscene, "volume_step_rate");
integrator->caustics_reflective = get_boolean(cscene, "caustics_reflective");
integrator->caustics_refractive = get_boolean(cscene, "caustics_refractive");
@@ -405,6 +411,7 @@ void BlenderSync::sync_view_layer(BL::SpaceView3D & /*b_v3d*/, BL::ViewLayer &b_
view_layer.use_background_ao = b_view_layer.use_ao();
view_layer.use_surfaces = b_view_layer.use_solid();
view_layer.use_hair = b_view_layer.use_strand();
view_layer.use_volumes = b_view_layer.use_volumes();
/* Material override. */
view_layer.material_override = b_view_layer.material_override();

View File

@@ -18,9 +18,9 @@
#define __BLENDER_SYNC_H__
#include "MEM_guardedalloc.h"
#include "RNA_types.h"
#include "RNA_access.h"
#include "RNA_blender_cpp.h"
#include "RNA_types.h"
#include "blender/blender_id_map.h"
#include "blender/blender_viewport.h"
@@ -157,6 +157,7 @@ class BlenderSync {
BL::Object b_ob,
Geometry *geom,
int motion_step);
void sync_hair(Hair *hair, BL::Object &b_ob, bool motion, int motion_step = 0);
void sync_particle_hair(
Geometry *geom, BL::Mesh &b_mesh, BL::Object &b_ob, bool motion, int motion_step = 0);
void sync_curve_settings();
@@ -236,6 +237,7 @@ class BlenderSync {
use_background_ao(true),
use_surfaces(true),
use_hair(true),
use_volumes(true),
samples(0),
bound_samples(false)
{
@@ -247,6 +249,7 @@ class BlenderSync {
bool use_background_ao;
bool use_surfaces;
bool use_hair;
bool use_volumes;
int samples;
bool bound_samples;
} view_layer;

View File

@@ -17,8 +17,8 @@
#ifndef __BLENDER_TEXTURE_H__
#define __BLENDER_TEXTURE_H__
#include <stdlib.h>
#include "blender/blender_sync.h"
#include <stdlib.h>
CCL_NAMESPACE_BEGIN

View File

@@ -18,9 +18,9 @@
#define __BLENDER_VIEWPORT_H__
#include "MEM_guardedalloc.h"
#include "RNA_types.h"
#include "RNA_access.h"
#include "RNA_blender_cpp.h"
#include "RNA_types.h"
#include "render/film.h"
#include "util/util_param.h"

View File

@@ -1,4 +1,3 @@
/*
* Copyright 2011-2013 Blender Foundation
*
@@ -16,14 +15,177 @@
*/
#include "render/colorspace.h"
#include "render/image.h"
#include "render/image_vdb.h"
#include "render/mesh.h"
#include "render/object.h"
#include "blender/blender_sync.h"
#include "blender/blender_util.h"
#ifdef WITH_OPENVDB
# include <openvdb/openvdb.h>
openvdb::GridBase::ConstPtr BKE_volume_grid_openvdb_for_read(const struct Volume *volume,
struct VolumeGrid *grid);
#endif
CCL_NAMESPACE_BEGIN
/* TODO: verify this is not loading unnecessary attributes. */
class BlenderSmokeLoader : public ImageLoader {
public:
BlenderSmokeLoader(const BL::Object &b_ob, AttributeStandard attribute)
: b_ob(b_ob), attribute(attribute)
{
}
bool load_metadata(ImageMetaData &metadata) override
{
BL::FluidDomainSettings b_domain = object_fluid_gas_domain_find(b_ob);
if (!b_domain) {
return false;
}
if (attribute == ATTR_STD_VOLUME_DENSITY || attribute == ATTR_STD_VOLUME_FLAME ||
attribute == ATTR_STD_VOLUME_HEAT || attribute == ATTR_STD_VOLUME_TEMPERATURE) {
metadata.type = IMAGE_DATA_TYPE_FLOAT;
metadata.channels = 1;
}
else if (attribute == ATTR_STD_VOLUME_COLOR) {
metadata.type = IMAGE_DATA_TYPE_FLOAT4;
metadata.channels = 4;
}
else if (attribute == ATTR_STD_VOLUME_VELOCITY) {
metadata.type = IMAGE_DATA_TYPE_FLOAT4;
metadata.channels = 3;
}
else {
return false;
}
int3 resolution = get_int3(b_domain.domain_resolution());
int amplify = (b_domain.use_noise()) ? b_domain.noise_scale() : 1;
/* Velocity and heat data is always low-resolution. */
if (attribute == ATTR_STD_VOLUME_VELOCITY || attribute == ATTR_STD_VOLUME_HEAT) {
amplify = 1;
}
metadata.width = resolution.x * amplify;
metadata.height = resolution.y * amplify;
metadata.depth = resolution.z * amplify;
/* Create a matrix to transform from object space to mesh texture space.
* This does not work with deformations but that can probably only be done
* well with a volume grid mapping of coordinates. */
BL::Mesh b_mesh(b_ob.data());
float3 loc, size;
mesh_texture_space(b_mesh, loc, size);
metadata.transform_3d = transform_translate(-loc) * transform_scale(size);
metadata.use_transform_3d = true;
return true;
}
bool load_pixels(const ImageMetaData &, void *pixels, const size_t, const bool) override
{
/* smoke volume data */
BL::FluidDomainSettings b_domain = object_fluid_gas_domain_find(b_ob);
if (!b_domain) {
return false;
}
#ifdef WITH_FLUID
int3 resolution = get_int3(b_domain.domain_resolution());
int length, amplify = (b_domain.use_noise()) ? b_domain.noise_scale() : 1;
/* Velocity and heat data is always low-resolution. */
if (attribute == ATTR_STD_VOLUME_VELOCITY || attribute == ATTR_STD_VOLUME_HEAT) {
amplify = 1;
}
const int width = resolution.x * amplify;
const int height = resolution.y * amplify;
const int depth = resolution.z * amplify;
const size_t num_pixels = ((size_t)width) * height * depth;
float *fpixels = (float *)pixels;
if (attribute == ATTR_STD_VOLUME_DENSITY) {
FluidDomainSettings_density_grid_get_length(&b_domain.ptr, &length);
if (length == num_pixels) {
FluidDomainSettings_density_grid_get(&b_domain.ptr, fpixels);
return true;
}
}
else if (attribute == ATTR_STD_VOLUME_FLAME) {
/* this is in range 0..1, and interpreted by the OpenGL smoke viewer
* as 1500..3000 K with the first part faded to zero density */
FluidDomainSettings_flame_grid_get_length(&b_domain.ptr, &length);
if (length == num_pixels) {
FluidDomainSettings_flame_grid_get(&b_domain.ptr, fpixels);
return true;
}
}
else if (attribute == ATTR_STD_VOLUME_COLOR) {
/* the RGB is "premultiplied" by density for better interpolation results */
FluidDomainSettings_color_grid_get_length(&b_domain.ptr, &length);
if (length == num_pixels * 4) {
FluidDomainSettings_color_grid_get(&b_domain.ptr, fpixels);
return true;
}
}
else if (attribute == ATTR_STD_VOLUME_VELOCITY) {
FluidDomainSettings_velocity_grid_get_length(&b_domain.ptr, &length);
if (length == num_pixels * 3) {
FluidDomainSettings_velocity_grid_get(&b_domain.ptr, fpixels);
return true;
}
}
else if (attribute == ATTR_STD_VOLUME_HEAT) {
FluidDomainSettings_heat_grid_get_length(&b_domain.ptr, &length);
if (length == num_pixels) {
FluidDomainSettings_heat_grid_get(&b_domain.ptr, fpixels);
return true;
}
}
else if (attribute == ATTR_STD_VOLUME_TEMPERATURE) {
FluidDomainSettings_temperature_grid_get_length(&b_domain.ptr, &length);
if (length == num_pixels) {
FluidDomainSettings_temperature_grid_get(&b_domain.ptr, fpixels);
return true;
}
}
else {
fprintf(stderr,
"Cycles error: unknown volume attribute %s, skipping\n",
Attribute::standard_name(attribute));
fpixels[0] = 0.0f;
return false;
}
#else
(void)pixels;
#endif
fprintf(stderr, "Cycles error: unexpected smoke volume resolution, skipping\n");
return false;
}
string name() const override
{
return Attribute::standard_name(attribute);
}
bool equals(const ImageLoader &other) const override
{
const BlenderSmokeLoader &other_loader = (const BlenderSmokeLoader &)other;
return b_ob == other_loader.b_ob && attribute == other_loader.attribute;
}
BL::Object b_ob;
AttributeStandard attribute;
};
static void sync_smoke_volume(Scene *scene, BL::Object &b_ob, Mesh *mesh, float frame)
{
BL::FluidDomainSettings b_domain = object_fluid_gas_domain_find(b_ob);
@@ -31,7 +193,6 @@ static void sync_smoke_volume(Scene *scene, BL::Object &b_ob, Mesh *mesh, float
return;
}
ImageManager *image_manager = scene->image_manager;
AttributeStandard attributes[] = {ATTR_STD_VOLUME_DENSITY,
ATTR_STD_VOLUME_COLOR,
ATTR_STD_VOLUME_FLAME,
@@ -46,47 +207,172 @@ static void sync_smoke_volume(Scene *scene, BL::Object &b_ob, Mesh *mesh, float
continue;
}
mesh->volume_isovalue = b_domain.clipping();
mesh->volume_clipping = b_domain.clipping();
Attribute *attr = mesh->attributes.add(std);
VoxelAttribute *volume_data = attr->data_voxel();
ImageMetaData metadata;
ImageKey key;
key.filename = Attribute::standard_name(std);
key.builtin_data = b_ob.ptr.data;
ImageLoader *loader = new BlenderSmokeLoader(b_ob, std);
ImageParams params;
params.frame = frame;
volume_data->manager = image_manager;
volume_data->slot = image_manager->add_image(key, frame, metadata);
attr->data_voxel() = scene->image_manager->add_image(loader, params);
}
}
class BlenderVolumeLoader : public VDBImageLoader {
public:
BlenderVolumeLoader(BL::Volume b_volume, const string &grid_name)
: VDBImageLoader(grid_name),
b_volume(b_volume),
b_volume_grid(PointerRNA_NULL),
unload(false)
{
#ifdef WITH_OPENVDB
/* Find grid with matching name. */
BL::Volume::grids_iterator b_grid_iter;
for (b_volume.grids.begin(b_grid_iter); b_grid_iter != b_volume.grids.end(); ++b_grid_iter) {
if (b_grid_iter->name() == grid_name) {
b_volume_grid = *b_grid_iter;
}
}
#endif
}
/* Create a matrix to transform from object space to mesh texture space.
* This does not work with deformations but that can probably only be done
* well with a volume grid mapping of coordinates. */
if (mesh->need_attribute(scene, ATTR_STD_GENERATED_TRANSFORM)) {
Attribute *attr = mesh->attributes.add(ATTR_STD_GENERATED_TRANSFORM);
Transform *tfm = attr->data_transform();
bool load_metadata(ImageMetaData &metadata) override
{
if (!b_volume_grid) {
return false;
}
BL::Mesh b_mesh(b_ob.data());
float3 loc, size;
mesh_texture_space(b_mesh, loc, size);
unload = !b_volume_grid.is_loaded();
*tfm = transform_translate(-loc) * transform_scale(size);
#ifdef WITH_OPENVDB
Volume *volume = (Volume *)b_volume.ptr.data;
VolumeGrid *volume_grid = (VolumeGrid *)b_volume_grid.ptr.data;
grid = BKE_volume_grid_openvdb_for_read(volume, volume_grid);
#endif
return VDBImageLoader::load_metadata(metadata);
}
bool load_pixels(const ImageMetaData &metadata,
void *pixels,
const size_t pixel_size,
const bool associate_alpha) override
{
if (!b_volume_grid) {
return false;
}
return VDBImageLoader::load_pixels(metadata, pixels, pixel_size, associate_alpha);
}
bool equals(const ImageLoader &other) const override
{
/* TODO: detect multiple volume datablocks with the same filepath. */
const BlenderVolumeLoader &other_loader = (const BlenderVolumeLoader &)other;
return b_volume == other_loader.b_volume && b_volume_grid == other_loader.b_volume_grid;
}
void cleanup() override
{
VDBImageLoader::cleanup();
if (b_volume_grid && unload) {
b_volume_grid.unload();
}
}
BL::Volume b_volume;
BL::VolumeGrid b_volume_grid;
bool unload;
};
static void sync_volume_object(BL::BlendData &b_data, BL::Object &b_ob, Scene *scene, Mesh *mesh)
{
BL::Volume b_volume(b_ob.data());
b_volume.grids.load(b_data.ptr.data);
BL::VolumeRender b_render(b_volume.render());
mesh->volume_clipping = b_render.clipping();
mesh->volume_step_size = b_render.step_size();
mesh->volume_object_space = (b_render.space() == BL::VolumeRender::space_OBJECT);
/* Find grid with matching name. */
BL::Volume::grids_iterator b_grid_iter;
for (b_volume.grids.begin(b_grid_iter); b_grid_iter != b_volume.grids.end(); ++b_grid_iter) {
BL::VolumeGrid b_grid = *b_grid_iter;
ustring name = ustring(b_grid.name());
AttributeStandard std = ATTR_STD_NONE;
if (name == Attribute::standard_name(ATTR_STD_VOLUME_DENSITY)) {
std = ATTR_STD_VOLUME_DENSITY;
}
else if (name == Attribute::standard_name(ATTR_STD_VOLUME_COLOR)) {
std = ATTR_STD_VOLUME_COLOR;
}
else if (name == Attribute::standard_name(ATTR_STD_VOLUME_FLAME)) {
std = ATTR_STD_VOLUME_FLAME;
}
else if (name == Attribute::standard_name(ATTR_STD_VOLUME_HEAT)) {
std = ATTR_STD_VOLUME_HEAT;
}
else if (name == Attribute::standard_name(ATTR_STD_VOLUME_TEMPERATURE)) {
std = ATTR_STD_VOLUME_TEMPERATURE;
}
else if (name == Attribute::standard_name(ATTR_STD_VOLUME_VELOCITY)) {
std = ATTR_STD_VOLUME_VELOCITY;
}
if ((std != ATTR_STD_NONE && mesh->need_attribute(scene, std)) ||
mesh->need_attribute(scene, name)) {
Attribute *attr = (std != ATTR_STD_NONE) ?
mesh->attributes.add(std) :
mesh->attributes.add(name, TypeDesc::TypeFloat, ATTR_ELEMENT_VOXEL);
ImageLoader *loader = new BlenderVolumeLoader(b_volume, name.string());
ImageParams params;
params.frame = b_volume.grids.frame();
attr->data_voxel() = scene->image_manager->add_image(loader, params);
}
}
}
/* If the voxel attributes change, we need to rebuild the bounding mesh. */
static vector<int> get_voxel_image_slots(Mesh *mesh)
{
vector<int> slots;
for (const Attribute &attr : mesh->attributes.attributes) {
if (attr.element == ATTR_ELEMENT_VOXEL) {
slots.push_back(attr.data_voxel().svm_slot());
}
}
return slots;
}
void BlenderSync::sync_volume(BL::Object &b_ob, Mesh *mesh, const vector<Shader *> &used_shaders)
{
bool old_has_voxel_attributes = mesh->has_voxel_attributes();
vector<int> old_voxel_slots = get_voxel_image_slots(mesh);
mesh->clear();
mesh->used_shaders = used_shaders;
/* Smoke domain. */
sync_smoke_volume(scene, b_ob, mesh, b_scene.frame_current());
if (view_layer.use_volumes) {
if (b_ob.type() == BL::Object::type_VOLUME) {
/* Volume object. Create only attributes, bounding mesh will then
* be automatically generated later. */
sync_volume_object(b_data, b_ob, scene, mesh);
}
else {
/* Smoke domain. */
sync_smoke_volume(scene, b_ob, mesh, b_scene.frame_current());
}
}
/* Tag update. */
bool rebuild = (old_has_voxel_attributes != mesh->has_voxel_attributes());
bool rebuild = (old_voxel_slots != get_voxel_image_slots(mesh));
mesh->tag_update(scene, rebuild);
}

View File

@@ -535,8 +535,9 @@ void BVH::pack_instances(size_t nodes_size, size_t leaf_nodes_size)
/* Modify offsets into arrays */
int4 data = bvh_nodes[i + nsize_bbox];
int4 data1 = bvh_nodes[i + nsize_bbox - 1];
if (use_obvh) {
int4 data1 = bvh_nodes[i + nsize_bbox - 1];
data.z += (data.z < 0) ? -noffset_leaf : noffset;
data.w += (data.w < 0) ? -noffset_leaf : noffset;
data.x += (data.x < 0) ? -noffset_leaf : noffset;
@@ -545,6 +546,8 @@ void BVH::pack_instances(size_t nodes_size, size_t leaf_nodes_size)
data1.w += (data1.w < 0) ? -noffset_leaf : noffset;
data1.x += (data1.x < 0) ? -noffset_leaf : noffset;
data1.y += (data1.y < 0) ? -noffset_leaf : noffset;
pack_nodes[pack_nodes_offset + nsize_bbox] = data;
pack_nodes[pack_nodes_offset + nsize_bbox - 1] = data1;
}
else {
data.z += (data.z < 0) ? -noffset_leaf : noffset;
@@ -553,10 +556,7 @@ void BVH::pack_instances(size_t nodes_size, size_t leaf_nodes_size)
data.x += (data.x < 0) ? -noffset_leaf : noffset;
data.y += (data.y < 0) ? -noffset_leaf : noffset;
}
}
pack_nodes[pack_nodes_offset + nsize_bbox] = data;
if (use_obvh) {
pack_nodes[pack_nodes_offset + nsize_bbox - 1] = data1;
pack_nodes[pack_nodes_offset + nsize_bbox] = data;
}
/* Usually this copies nothing, but we better

View File

@@ -22,20 +22,20 @@
#include "bvh/bvh_params.h"
#include "bvh_split.h"
#include "render/curves.h"
#include "render/hair.h"
#include "render/mesh.h"
#include "render/object.h"
#include "render/scene.h"
#include "render/curves.h"
#include "util/util_algorithm.h"
#include "util/util_foreach.h"
#include "util/util_logging.h"
#include "util/util_progress.h"
#include "util/util_stack_allocator.h"
#include "util/util_simd.h"
#include "util/util_time.h"
#include "util/util_queue.h"
#include "util/util_simd.h"
#include "util/util_stack_allocator.h"
#include "util/util_time.h"
CCL_NAMESPACE_BEGIN

View File

@@ -35,9 +35,9 @@
#ifdef WITH_EMBREE
# include <embree3/rtcore_geometry.h>
# include <pmmintrin.h>
# include <xmmintrin.h>
# include <embree3/rtcore_geometry.h>
# include "bvh/bvh_embree.h"
@@ -45,9 +45,9 @@
*/
# include "kernel/bvh/bvh_embree.h"
# include "kernel/kernel_compat_cpu.h"
# include "kernel/split/kernel_split_data_types.h"
# include "kernel/kernel_globals.h"
# include "kernel/kernel_random.h"
# include "kernel/split/kernel_split_data_types.h"
# include "render/hair.h"
# include "render/mesh.h"

View File

@@ -18,10 +18,11 @@
#ifdef WITH_OPTIX
# include "bvh/bvh_optix.h"
# include "render/hair.h"
# include "render/geometry.h"
# include "render/hair.h"
# include "render/mesh.h"
# include "render/object.h"
# include "util/util_foreach.h"
# include "util/util_logging.h"
# include "util/util_progress.h"

View File

@@ -155,9 +155,13 @@ class CUDADevice : public Device {
virtual void const_copy_to(const char *name, void *host, size_t size);
void tex_alloc(device_memory &mem);
void global_alloc(device_memory &mem);
void tex_free(device_memory &mem);
void global_free(device_memory &mem);
void tex_alloc(device_texture &mem);
void tex_free(device_texture &mem);
bool denoising_non_local_means(device_ptr image_ptr,
device_ptr guide_ptr,

View File

@@ -39,8 +39,8 @@
# include "util/util_path.h"
# include "util/util_string.h"
# include "util/util_system.h"
# include "util/util_types.h"
# include "util/util_time.h"
# include "util/util_types.h"
# include "util/util_windows.h"
# include "kernel/split/kernel_split_data_types.h"
@@ -185,7 +185,7 @@ void CUDADevice::cuda_error_message(const string &message)
}
CUDADevice::CUDADevice(DeviceInfo &info, Stats &stats, Profiler &profiler, bool background_)
: Device(info, stats, profiler, background_), texture_info(this, "__texture_info", MEM_TEXTURE)
: Device(info, stats, profiler, background_), texture_info(this, "__texture_info", MEM_GLOBAL)
{
first_error = true;
background = background_;
@@ -684,7 +684,8 @@ void CUDADevice::move_textures_to_host(size_t size, bool for_texture)
device_memory &mem = *pair.first;
CUDAMem *cmem = &pair.second;
bool is_texture = (mem.type == MEM_TEXTURE) && (&mem != &texture_info);
bool is_texture = (mem.type == MEM_TEXTURE || mem.type == MEM_GLOBAL) &&
(&mem != &texture_info);
bool is_image = is_texture && (mem.data_height > 1);
/* Can't move this type of memory. */
@@ -724,8 +725,7 @@ void CUDADevice::move_textures_to_host(size_t size, bool for_texture)
device_ptr prev_pointer = max_mem->device_pointer;
size_t prev_size = max_mem->device_size;
tex_free(*max_mem);
tex_alloc(*max_mem);
mem_copy_to(*max_mem);
size = (max_size >= size) ? 0 : size - max_size;
max_mem->device_pointer = prev_pointer;
@@ -759,7 +759,7 @@ CUDADevice::CUDAMem *CUDADevice::generic_alloc(device_memory &mem, size_t pitch_
* If there is not enough room for working memory, we will try to move
* textures to host memory, assuming the performance impact would have
* been worse for working memory. */
bool is_texture = (mem.type == MEM_TEXTURE) && (&mem != &texture_info);
bool is_texture = (mem.type == MEM_TEXTURE || mem.type == MEM_GLOBAL) && (&mem != &texture_info);
bool is_image = is_texture && (mem.data_height > 1);
size_t headroom = (is_texture) ? device_texture_headroom : device_working_headroom;
@@ -922,6 +922,9 @@ void CUDADevice::mem_alloc(device_memory &mem)
else if (mem.type == MEM_TEXTURE) {
assert(!"mem_alloc not supported for textures.");
}
else if (mem.type == MEM_GLOBAL) {
assert(!"mem_alloc not supported for global memory.");
}
else {
generic_alloc(mem);
}
@@ -932,9 +935,13 @@ void CUDADevice::mem_copy_to(device_memory &mem)
if (mem.type == MEM_PIXELS) {
assert(!"mem_copy_to not supported for pixels.");
}
else if (mem.type == MEM_GLOBAL) {
global_free(mem);
global_alloc(mem);
}
else if (mem.type == MEM_TEXTURE) {
tex_free(mem);
tex_alloc(mem);
tex_free((device_texture &)mem);
tex_alloc((device_texture &)mem);
}
else {
if (!mem.device_pointer) {
@@ -950,7 +957,7 @@ void CUDADevice::mem_copy_from(device_memory &mem, int y, int w, int h, int elem
if (mem.type == MEM_PIXELS && !background) {
pixels_copy_from(mem, y, w, h);
}
else if (mem.type == MEM_TEXTURE) {
else if (mem.type == MEM_TEXTURE || mem.type == MEM_GLOBAL) {
assert(!"mem_copy_from not supported for textures.");
}
else if (mem.host_pointer) {
@@ -993,8 +1000,11 @@ void CUDADevice::mem_free(device_memory &mem)
if (mem.type == MEM_PIXELS && !background) {
pixels_free(mem);
}
else if (mem.type == MEM_GLOBAL) {
global_free(mem);
}
else if (mem.type == MEM_TEXTURE) {
tex_free(mem);
tex_free((device_texture &)mem);
}
else {
generic_free(mem);
@@ -1017,7 +1027,25 @@ void CUDADevice::const_copy_to(const char *name, void *host, size_t size)
cuda_assert(cuMemcpyHtoD(mem, host, size));
}
void CUDADevice::tex_alloc(device_memory &mem)
void CUDADevice::global_alloc(device_memory &mem)
{
CUDAContextScope scope(this);
generic_alloc(mem);
generic_copy_to(mem);
const_copy_to(mem.name, &mem.device_pointer, sizeof(mem.device_pointer));
}
void CUDADevice::global_free(device_memory &mem)
{
if (mem.device_pointer) {
CUDAContextScope scope(this);
generic_free(mem);
}
}
void CUDADevice::tex_alloc(device_texture &mem)
{
CUDAContextScope scope(this);
@@ -1027,7 +1055,7 @@ void CUDADevice::tex_alloc(device_memory &mem)
size_t size = mem.memory_size();
CUaddress_mode address_mode = CU_TR_ADDRESS_MODE_WRAP;
switch (mem.extension) {
switch (mem.info.extension) {
case EXTENSION_REPEAT:
address_mode = CU_TR_ADDRESS_MODE_WRAP;
break;
@@ -1043,22 +1071,13 @@ void CUDADevice::tex_alloc(device_memory &mem)
}
CUfilter_mode filter_mode;
if (mem.interpolation == INTERPOLATION_CLOSEST) {
if (mem.info.interpolation == INTERPOLATION_CLOSEST) {
filter_mode = CU_TR_FILTER_MODE_POINT;
}
else {
filter_mode = CU_TR_FILTER_MODE_LINEAR;
}
/* Data Storage */
if (mem.interpolation == INTERPOLATION_NONE) {
generic_alloc(mem);
generic_copy_to(mem);
const_copy_to(bind_name.c_str(), &mem.device_pointer, sizeof(mem.device_pointer));
return;
}
/* Image Texture Storage */
CUarray_format_enum format;
switch (mem.data_type) {
@@ -1169,15 +1188,6 @@ void CUDADevice::tex_alloc(device_memory &mem)
}
/* Kepler+, bindless textures. */
int flat_slot = 0;
if (string_startswith(mem.name, "__tex_image")) {
int pos = string(mem.name).rfind("_");
flat_slot = atoi(mem.name + pos + 1);
}
else {
assert(0);
}
CUDA_RESOURCE_DESC resDesc;
memset(&resDesc, 0, sizeof(resDesc));
@@ -1214,25 +1224,20 @@ void CUDADevice::tex_alloc(device_memory &mem)
cuda_assert(cuTexObjectCreate(&cmem->texobject, &resDesc, &texDesc, NULL));
/* Resize once */
if (flat_slot >= texture_info.size()) {
const uint slot = mem.slot;
if (slot >= texture_info.size()) {
/* Allocate some slots in advance, to reduce amount
* of re-allocations. */
texture_info.resize(flat_slot + 128);
texture_info.resize(slot + 128);
}
/* Set Mapping and tag that we need to (re-)upload to device */
TextureInfo &info = texture_info[flat_slot];
info.data = (uint64_t)cmem->texobject;
info.cl_buffer = 0;
info.interpolation = mem.interpolation;
info.extension = mem.extension;
info.width = mem.data_width;
info.height = mem.data_height;
info.depth = mem.data_depth;
texture_info[slot] = mem.info;
texture_info[slot].data = (uint64_t)cmem->texobject;
need_texture_info = true;
}
void CUDADevice::tex_free(device_memory &mem)
void CUDADevice::tex_free(device_texture &mem)
{
if (mem.device_pointer) {
CUDAContextScope scope(this);

View File

@@ -25,11 +25,11 @@
#include "util/util_logging.h"
#include "util/util_math.h"
#include "util/util_opengl.h"
#include "util/util_time.h"
#include "util/util_string.h"
#include "util/util_system.h"
#include "util/util_time.h"
#include "util/util_types.h"
#include "util/util_vector.h"
#include "util/util_string.h"
CCL_NAMESPACE_BEGIN

View File

@@ -27,8 +27,8 @@
#include "util/util_list.h"
#include "util/util_stats.h"
#include "util/util_string.h"
#include "util/util_thread.h"
#include "util/util_texture.h"
#include "util/util_thread.h"
#include "util/util_types.h"
#include "util/util_vector.h"

View File

@@ -264,7 +264,7 @@ class CPUDevice : public Device {
CPUDevice(DeviceInfo &info_, Stats &stats_, Profiler &profiler_, bool background_)
: Device(info_, stats_, profiler_, background_),
texture_info(this, "__texture_info", MEM_TEXTURE),
texture_info(this, "__texture_info", MEM_GLOBAL),
#define REGISTER_KERNEL(name) name##_kernel(KERNEL_FUNCTIONS(name))
REGISTER_KERNEL(path_trace),
REGISTER_KERNEL(convert_to_half_float),
@@ -372,6 +372,9 @@ class CPUDevice : public Device {
if (mem.type == MEM_TEXTURE) {
assert(!"mem_alloc not supported for textures.");
}
else if (mem.type == MEM_GLOBAL) {
assert(!"mem_alloc not supported for global memory.");
}
else {
if (mem.name) {
VLOG(1) << "Buffer allocate: " << mem.name << ", "
@@ -396,9 +399,13 @@ class CPUDevice : public Device {
void mem_copy_to(device_memory &mem)
{
if (mem.type == MEM_TEXTURE) {
tex_free(mem);
tex_alloc(mem);
if (mem.type == MEM_GLOBAL) {
global_free(mem);
global_alloc(mem);
}
else if (mem.type == MEM_TEXTURE) {
tex_free((device_texture &)mem);
tex_alloc((device_texture &)mem);
}
else if (mem.type == MEM_PIXELS) {
assert(!"mem_copy_to not supported for pixels.");
@@ -430,8 +437,11 @@ class CPUDevice : public Device {
void mem_free(device_memory &mem)
{
if (mem.type == MEM_TEXTURE) {
tex_free(mem);
if (mem.type == MEM_GLOBAL) {
global_free(mem);
}
else if (mem.type == MEM_TEXTURE) {
tex_free((device_texture &)mem);
}
else if (mem.device_pointer) {
if (mem.type == MEM_DEVICE_ONLY) {
@@ -453,51 +463,50 @@ class CPUDevice : public Device {
kernel_const_copy(&kernel_globals, name, host, size);
}
void tex_alloc(device_memory &mem)
void global_alloc(device_memory &mem)
{
VLOG(1) << "Texture allocate: " << mem.name << ", "
VLOG(1) << "Global memory allocate: " << mem.name << ", "
<< string_human_readable_number(mem.memory_size()) << " bytes. ("
<< string_human_readable_size(mem.memory_size()) << ")";
if (mem.interpolation == INTERPOLATION_NONE) {
/* Data texture. */
kernel_tex_copy(&kernel_globals, mem.name, mem.host_pointer, mem.data_size);
}
else {
/* Image Texture. */
int flat_slot = 0;
if (string_startswith(mem.name, "__tex_image")) {
int pos = string(mem.name).rfind("_");
flat_slot = atoi(mem.name + pos + 1);
}
else {
assert(0);
}
if (flat_slot >= texture_info.size()) {
/* Allocate some slots in advance, to reduce amount
* of re-allocations. */
texture_info.resize(flat_slot + 128);
}
TextureInfo &info = texture_info[flat_slot];
info.data = (uint64_t)mem.host_pointer;
info.cl_buffer = 0;
info.interpolation = mem.interpolation;
info.extension = mem.extension;
info.width = mem.data_width;
info.height = mem.data_height;
info.depth = mem.data_depth;
need_texture_info = true;
}
kernel_global_memory_copy(&kernel_globals, mem.name, mem.host_pointer, mem.data_size);
mem.device_pointer = (device_ptr)mem.host_pointer;
mem.device_size = mem.memory_size();
stats.mem_alloc(mem.device_size);
}
void tex_free(device_memory &mem)
void global_free(device_memory &mem)
{
if (mem.device_pointer) {
mem.device_pointer = 0;
stats.mem_free(mem.device_size);
mem.device_size = 0;
}
}
void tex_alloc(device_texture &mem)
{
VLOG(1) << "Texture allocate: " << mem.name << ", "
<< string_human_readable_number(mem.memory_size()) << " bytes. ("
<< string_human_readable_size(mem.memory_size()) << ")";
mem.device_pointer = (device_ptr)mem.host_pointer;
mem.device_size = mem.memory_size();
stats.mem_alloc(mem.device_size);
const uint slot = mem.slot;
if (slot >= texture_info.size()) {
/* Allocate some slots in advance, to reduce amount of re-allocations. */
texture_info.resize(slot + 128);
}
texture_info[slot] = mem.info;
texture_info[slot].data = (uint64_t)mem.host_pointer;
need_texture_info = true;
}
void tex_free(device_texture &mem)
{
if (mem.device_pointer) {
mem.device_pointer = 0;

View File

@@ -16,9 +16,9 @@
#ifdef WITH_CUDA
# include "device/cuda/device_cuda.h"
# include "device/device.h"
# include "device/device_intern.h"
# include "device/cuda/device_cuda.h"
# include "util/util_logging.h"
# include "util/util_string.h"

View File

@@ -14,8 +14,8 @@
* limitations under the License.
*/
#include "device/device.h"
#include "device/device_memory.h"
#include "device/device.h"
CCL_NAMESPACE_BEGIN
@@ -31,8 +31,6 @@ device_memory::device_memory(Device *device, const char *name, MemoryType type)
data_depth(0),
type(type),
name(name),
interpolation(INTERPOLATION_NONE),
extension(EXTENSION_REPEAT),
device(device),
device_pointer(0),
host_pointer(0),
@@ -76,7 +74,7 @@ void device_memory::host_free()
void device_memory::device_alloc()
{
assert(!device_pointer && type != MEM_TEXTURE);
assert(!device_pointer && type != MEM_TEXTURE && type != MEM_GLOBAL);
device->mem_alloc(*this);
}
@@ -96,7 +94,7 @@ void device_memory::device_copy_to()
void device_memory::device_copy_from(int y, int w, int h, int elem)
{
assert(type != MEM_TEXTURE && type != MEM_READ_ONLY);
assert(type != MEM_TEXTURE && type != MEM_READ_ONLY && type != MEM_GLOBAL);
device->mem_copy_from(*this, y, w, h, elem);
}
@@ -139,4 +137,93 @@ device_sub_ptr::~device_sub_ptr()
device->mem_free_sub_ptr(ptr);
}
/* Device Texture */
device_texture::device_texture(Device *device,
const char *name,
const uint slot,
ImageDataType image_data_type,
InterpolationType interpolation,
ExtensionType extension)
: device_memory(device, name, MEM_TEXTURE), slot(slot)
{
switch (image_data_type) {
case IMAGE_DATA_TYPE_FLOAT4:
data_type = TYPE_FLOAT;
data_elements = 4;
break;
case IMAGE_DATA_TYPE_FLOAT:
data_type = TYPE_FLOAT;
data_elements = 1;
break;
case IMAGE_DATA_TYPE_BYTE4:
data_type = TYPE_UCHAR;
data_elements = 4;
break;
case IMAGE_DATA_TYPE_BYTE:
data_type = TYPE_UCHAR;
data_elements = 1;
break;
case IMAGE_DATA_TYPE_HALF4:
data_type = TYPE_HALF;
data_elements = 4;
break;
case IMAGE_DATA_TYPE_HALF:
data_type = TYPE_HALF;
data_elements = 1;
break;
case IMAGE_DATA_TYPE_USHORT4:
data_type = TYPE_UINT16;
data_elements = 4;
break;
case IMAGE_DATA_TYPE_USHORT:
data_type = TYPE_UINT16;
data_elements = 1;
break;
case IMAGE_DATA_NUM_TYPES:
assert(0);
return;
}
memset(&info, 0, sizeof(info));
info.data_type = image_data_type;
info.interpolation = interpolation;
info.extension = extension;
}
device_texture::~device_texture()
{
device_free();
host_free();
}
/* Host memory allocation. */
void *device_texture::alloc(const size_t width, const size_t height, const size_t depth)
{
const size_t new_size = size(width, height, depth);
if (new_size != data_size) {
device_free();
host_free();
host_pointer = host_alloc(data_elements * datatype_size(data_type) * new_size);
assert(device_pointer == 0);
}
data_size = new_size;
data_width = width;
data_height = height;
data_depth = depth;
info.width = width;
info.height = height;
info.depth = depth;
return host_pointer;
}
void device_texture::copy_to_device()
{
device_copy_to();
}
CCL_NAMESPACE_END

View File

@@ -23,6 +23,7 @@
#include "util/util_array.h"
#include "util/util_half.h"
#include "util/util_string.h"
#include "util/util_texture.h"
#include "util/util_types.h"
#include "util/util_vector.h"
@@ -31,7 +32,14 @@ CCL_NAMESPACE_BEGIN
class Device;
enum MemoryType { MEM_READ_ONLY, MEM_READ_WRITE, MEM_DEVICE_ONLY, MEM_TEXTURE, MEM_PIXELS };
enum MemoryType {
MEM_READ_ONLY,
MEM_READ_WRITE,
MEM_DEVICE_ONLY,
MEM_GLOBAL,
MEM_TEXTURE,
MEM_PIXELS
};
/* Supported Data Types */
@@ -208,8 +216,6 @@ class device_memory {
size_t data_depth;
MemoryType type;
const char *name;
InterpolationType interpolation;
ExtensionType extension;
/* Pointers. */
Device *device;
@@ -310,7 +316,7 @@ template<typename T> class device_only_memory : public device_memory {
* in and copied to the device with copy_to_device(). Or alternatively
* allocated and set to zero on the device with zero_to_device().
*
* When using memory type MEM_TEXTURE, a pointer to this memory will be
* When using memory type MEM_GLOBAL, a pointer to this memory will be
* automatically attached to kernel globals, using the provided name
* matching an entry in kernel_textures.h. */
@@ -503,6 +509,33 @@ class device_sub_ptr {
device_ptr ptr;
};
/* Device Texture
*
* 2D or 3D image texture memory. */
class device_texture : public device_memory {
public:
device_texture(Device *device,
const char *name,
const uint slot,
ImageDataType image_data_type,
InterpolationType interpolation,
ExtensionType extension);
~device_texture();
void *alloc(const size_t width, const size_t height, const size_t depth = 0);
void copy_to_device();
uint slot;
TextureInfo info;
protected:
size_t size(const size_t width, const size_t height, const size_t depth)
{
return width * ((height == 0) ? 1 : height) * ((depth == 0) ? 1 : depth);
}
};
CCL_NAMESPACE_END
#endif /* __DEVICE_MEMORY_H__ */

View File

@@ -14,8 +14,8 @@
* limitations under the License.
*/
#include <stdlib.h>
#include <sstream>
#include <stdlib.h>
#include "device/device.h"
#include "device/device_intern.h"

View File

@@ -14,9 +14,9 @@
* limitations under the License.
*/
#include "device/device_network.h"
#include "device/device.h"
#include "device/device_intern.h"
#include "device/device_network.h"
#include "util/util_foreach.h"
#include "util/util_logging.h"

View File

@@ -19,19 +19,19 @@
#ifdef WITH_NETWORK
# include <boost/archive/text_iarchive.hpp>
# include <boost/archive/text_oarchive.hpp>
# include <boost/archive/binary_iarchive.hpp>
# include <boost/archive/binary_oarchive.hpp>
# include <boost/archive/text_iarchive.hpp>
# include <boost/archive/text_oarchive.hpp>
# include <boost/array.hpp>
# include <boost/asio.hpp>
# include <boost/bind.hpp>
# include <boost/serialization/vector.hpp>
# include <boost/thread.hpp>
# include <deque>
# include <iostream>
# include <sstream>
# include <deque>
# include "render/buffers.h"

View File

@@ -16,9 +16,9 @@
#ifdef WITH_OPENCL
# include "device/opencl/device_opencl.h"
# include "device/device.h"
# include "device/device_intern.h"
# include "device/opencl/device_opencl.h"
# include "util/util_foreach.h"
# include "util/util_logging.h"

View File

@@ -17,28 +17,28 @@
#ifdef WITH_OPTIX
# include "device/cuda/device_cuda.h"
# include "device/device_intern.h"
# include "device/device_denoising.h"
# include "bvh/bvh.h"
# include "render/scene.h"
# include "device/cuda/device_cuda.h"
# include "device/device_denoising.h"
# include "device/device_intern.h"
# include "render/buffers.h"
# include "render/hair.h"
# include "render/mesh.h"
# include "render/object.h"
# include "render/buffers.h"
# include "render/scene.h"
# include "util/util_debug.h"
# include "util/util_logging.h"
# include "util/util_md5.h"
# include "util/util_path.h"
# include "util/util_time.h"
# include "util/util_debug.h"
# include "util/util_logging.h"
# ifdef WITH_CUDA_DYNLOAD
# include <cuew.h>
// Do not use CUDA SDK headers when using CUEW
# define OPTIX_DONT_INCLUDE_CUDA
# endif
# include <optix_stubs.h>
# include <optix_function_table_definition.h>
# include <optix_stubs.h>
// TODO(pmours): Disable this once drivers have native support
# define OPTIX_DENOISER_NO_PIXEL_STRIDE 1
@@ -477,9 +477,9 @@ class OptiXDevice : public CUDADevice {
// Calculate maximum trace continuation stack size
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 = max(trace_css, stack_size[PG_HITD].cssIS + stack_size[PG_HITD].cssAH);
trace_css = max(trace_css, stack_size[PG_HITL].cssIS + stack_size[PG_HITL].cssAH);
trace_css = max(trace_css, stack_size[PG_HITS].cssIS + stack_size[PG_HITS].cssAH);
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);
OptixPipelineLinkOptions link_options;
link_options.maxTraceDepth = 1;
@@ -548,8 +548,9 @@ class OptiXDevice : public CUDADevice {
&pipelines[PIP_SHADER_EVAL]));
// Calculate continuation stack size based on the maximum of all ray generation stack sizes
const unsigned int css = max(stack_size[PG_BAKE].cssRG,
max(stack_size[PG_DISP].cssRG, stack_size[PG_BACK].cssRG)) +
const unsigned int css = std::max(stack_size[PG_BAKE].cssRG,
std::max(stack_size[PG_DISP].cssRG,
stack_size[PG_BACK].cssRG)) +
link_options.maxTraceDepth * trace_css;
check_result_optix_ret(optixPipelineSetStackSize(

View File

@@ -428,8 +428,10 @@ class OpenCLDevice : public Device {
int mem_sub_ptr_alignment();
void const_copy_to(const char *name, void *host, size_t size);
void tex_alloc(device_memory &mem);
void tex_free(device_memory &mem);
void global_alloc(device_memory &mem);
void global_free(device_memory &mem);
void tex_alloc(device_texture &mem);
void tex_free(device_texture &mem);
size_t global_size_round_up(int group_size, int global_size);
void enqueue_kernel(cl_kernel kernel,

View File

@@ -613,7 +613,7 @@ OpenCLDevice::OpenCLDevice(DeviceInfo &info, Stats &stats, Profiler &profiler, b
kernel_programs(this),
preview_programs(this),
memory_manager(this),
texture_info(this, "__texture_info", MEM_TEXTURE)
texture_info(this, "__texture_info", MEM_GLOBAL)
{
cpPlatform = NULL;
cdDevice = NULL;
@@ -945,7 +945,7 @@ void OpenCLDevice::mem_alloc(device_memory &mem)
cl_mem_flags mem_flag;
void *mem_ptr = NULL;
if (mem.type == MEM_READ_ONLY || mem.type == MEM_TEXTURE)
if (mem.type == MEM_READ_ONLY || mem.type == MEM_TEXTURE || mem.type == MEM_GLOBAL)
mem_flag = CL_MEM_READ_ONLY;
else
mem_flag = CL_MEM_READ_WRITE;
@@ -969,9 +969,13 @@ void OpenCLDevice::mem_alloc(device_memory &mem)
void OpenCLDevice::mem_copy_to(device_memory &mem)
{
if (mem.type == MEM_TEXTURE) {
tex_free(mem);
tex_alloc(mem);
if (mem.type == MEM_GLOBAL) {
global_free(mem);
global_alloc(mem);
}
else if (mem.type == MEM_TEXTURE) {
tex_free((device_texture &)mem);
tex_alloc((device_texture &)mem);
}
else {
if (!mem.device_pointer) {
@@ -1077,8 +1081,11 @@ void OpenCLDevice::mem_zero(device_memory &mem)
void OpenCLDevice::mem_free(device_memory &mem)
{
if (mem.type == MEM_TEXTURE) {
tex_free(mem);
if (mem.type == MEM_GLOBAL) {
global_free(mem);
}
else if (mem.type == MEM_TEXTURE) {
tex_free((device_texture &)mem);
}
else {
if (mem.device_pointer) {
@@ -1101,7 +1108,7 @@ int OpenCLDevice::mem_sub_ptr_alignment()
device_ptr OpenCLDevice::mem_alloc_sub_ptr(device_memory &mem, int offset, int size)
{
cl_mem_flags mem_flag;
if (mem.type == MEM_READ_ONLY || mem.type == MEM_TEXTURE)
if (mem.type == MEM_READ_ONLY || mem.type == MEM_TEXTURE || mem.type == MEM_GLOBAL)
mem_flag = CL_MEM_READ_ONLY;
else
mem_flag = CL_MEM_READ_WRITE;
@@ -1141,9 +1148,9 @@ void OpenCLDevice::const_copy_to(const char *name, void *host, size_t size)
data->copy_to_device();
}
void OpenCLDevice::tex_alloc(device_memory &mem)
void OpenCLDevice::global_alloc(device_memory &mem)
{
VLOG(1) << "Texture allocate: " << mem.name << ", "
VLOG(1) << "Global memory allocate: " << mem.name << ", "
<< string_human_readable_number(mem.memory_size()) << " bytes. ("
<< string_human_readable_size(mem.memory_size()) << ")";
@@ -1155,7 +1162,7 @@ void OpenCLDevice::tex_alloc(device_memory &mem)
textures_need_update = true;
}
void OpenCLDevice::tex_free(device_memory &mem)
void OpenCLDevice::global_free(device_memory &mem)
{
if (mem.device_pointer) {
mem.device_pointer = 0;
@@ -1173,6 +1180,25 @@ void OpenCLDevice::tex_free(device_memory &mem)
}
}
void OpenCLDevice::tex_alloc(device_texture &mem)
{
VLOG(1) << "Texture allocate: " << mem.name << ", "
<< string_human_readable_number(mem.memory_size()) << " bytes. ("
<< string_human_readable_size(mem.memory_size()) << ")";
memory_manager.alloc(mem.name, mem);
/* Set the pointer to non-null to keep code that inspects its value from thinking its
* unallocated. */
mem.device_pointer = 1;
textures[mem.name] = &mem;
textures_need_update = true;
}
void OpenCLDevice::tex_free(device_texture &mem)
{
global_free(mem);
}
size_t OpenCLDevice::global_size_round_up(int group_size, int global_size)
{
int r = global_size % group_size;
@@ -1273,10 +1299,10 @@ void OpenCLDevice::flush_texture_buffers()
foreach (TexturesMap::value_type &tex, textures) {
string name = tex.first;
device_memory *mem = tex.second;
if (string_startswith(name, "__tex_image")) {
int pos = name.rfind("_");
int id = atoi(name.data() + pos + 1);
if (mem->type == MEM_TEXTURE) {
const uint id = ((device_texture *)mem)->slot;
texture_slots.push_back(texture_slot_t(name, num_data_slots + id));
num_slots = max(num_slots, num_data_slots + id + 1);
}
@@ -1289,22 +1315,20 @@ void OpenCLDevice::flush_texture_buffers()
/* Fill in descriptors */
foreach (texture_slot_t &slot, texture_slots) {
device_memory *mem = textures[slot.name];
TextureInfo &info = texture_info[slot.slot];
MemoryManager::BufferDescriptor desc = memory_manager.get_descriptor(slot.name);
if (mem->type == MEM_TEXTURE) {
info = ((device_texture *)mem)->info;
}
else {
memset(&info, 0, sizeof(TextureInfo));
}
info.data = desc.offset;
info.cl_buffer = desc.device_buffer;
if (string_startswith(slot.name, "__tex_image")) {
device_memory *mem = textures[slot.name];
info.width = mem->data_width;
info.height = mem->data_height;
info.depth = mem->data_depth;
info.interpolation = mem->interpolation;
info.extension = mem->extension;
}
}
/* Force write of descriptors. */

View File

@@ -19,8 +19,8 @@
#include "device/device.h"
#include "util/util_map.h"
#include "util/util_vector.h"
#include "util/util_string.h"
#include "util/util_vector.h"
#include "clew.h"

View File

@@ -16,15 +16,15 @@
#ifdef WITH_OPENCL
# include "device/opencl/device_opencl.h"
# include "device/device_intern.h"
# include "device/opencl/device_opencl.h"
# include "util/util_debug.h"
# include "util/util_logging.h"
# include "util/util_md5.h"
# include "util/util_path.h"
# include "util/util_time.h"
# include "util/util_system.h"
# include "util/util_time.h"
using std::cerr;
using std::endl;

View File

@@ -320,6 +320,26 @@ ccl_device_inline uint object_patch_map_offset(KernelGlobals *kg, int object)
return kernel_tex_fetch(__objects, object).patch_map_offset;
}
/* Volume step size */
ccl_device_inline float object_volume_density(KernelGlobals *kg, int object)
{
if (object == OBJECT_NONE) {
return 1.0f;
}
return kernel_tex_fetch(__objects, object).surface_area;
}
ccl_device_inline float object_volume_step_size(KernelGlobals *kg, int object)
{
if (object == OBJECT_NONE) {
return kernel_data.background.volume_step_size;
}
return kernel_tex_fetch(__object_volume_step, object);
}
/* Pass ID for shader */
ccl_device int shader_pass_id(KernelGlobals *kg, const ShaderData *sd)

View File

@@ -51,10 +51,14 @@ ccl_device float volume_attribute_float(KernelGlobals *kg,
const ShaderData *sd,
const AttributeDescriptor desc)
{
float3 P = volume_normalized_position(kg, sd, sd->P);
/* todo: optimize this so we don't have to transform both here and in
* kernel_tex_image_interp_3d when possible. Also could optimize for the
* common case where transform is translation/scale only. */
float3 P = sd->P;
object_inverse_position_transform(kg, sd, &P);
InterpolationType interp = (sd->flag & SD_VOLUME_CUBIC) ? INTERPOLATION_CUBIC :
INTERPOLATION_NONE;
float4 r = kernel_tex_image_interp_3d(kg, desc.offset, P.x, P.y, P.z, interp);
float4 r = kernel_tex_image_interp_3d(kg, desc.offset, P, interp);
return average(float4_to_float3(r));
}
@@ -62,10 +66,11 @@ ccl_device float3 volume_attribute_float3(KernelGlobals *kg,
const ShaderData *sd,
const AttributeDescriptor desc)
{
float3 P = volume_normalized_position(kg, sd, sd->P);
float3 P = sd->P;
object_inverse_position_transform(kg, sd, &P);
InterpolationType interp = (sd->flag & SD_VOLUME_CUBIC) ? INTERPOLATION_CUBIC :
INTERPOLATION_NONE;
float4 r = kernel_tex_image_interp_3d(kg, desc.offset, P.x, P.y, P.z, interp);
float4 r = kernel_tex_image_interp_3d(kg, desc.offset, P, interp);
if (r.w > 1e-6f && r.w != 1.0f) {
/* For RGBA colors, unpremultiply after interpolation. */

View File

@@ -19,8 +19,8 @@
/* CPU Kernel Interface */
#include "util/util_types.h"
#include "kernel/kernel_types.h"
#include "util/util_types.h"
CCL_NAMESPACE_BEGIN
@@ -38,7 +38,7 @@ void *kernel_osl_memory(KernelGlobals *kg);
bool kernel_osl_use(KernelGlobals *kg);
void kernel_const_copy(KernelGlobals *kg, const char *name, void *host, size_t size);
void kernel_tex_copy(KernelGlobals *kg, const char *name, void *mem, size_t size);
void kernel_global_memory_copy(KernelGlobals *kg, const char *name, void *mem, size_t size);
#define KERNEL_ARCH cpu
#include "kernel/kernels/cpu/kernel_cpu.h"

View File

@@ -54,12 +54,6 @@ ccl_device void kernel_adaptive_post_adjust(KernelGlobals *kg,
#ifdef __PASSES__
int flag = kernel_data.film.pass_flag;
if (flag & PASSMASK(SHADOW))
*(ccl_global float3 *)(buffer + kernel_data.film.pass_shadow) *= sample_multiplier;
if (flag & PASSMASK(MIST))
*(ccl_global float *)(buffer + kernel_data.film.pass_mist) *= sample_multiplier;
if (flag & PASSMASK(NORMAL))
*(ccl_global float3 *)(buffer + kernel_data.film.pass_normal) *= sample_multiplier;
@@ -74,6 +68,11 @@ ccl_device void kernel_adaptive_post_adjust(KernelGlobals *kg,
if (kernel_data.film.use_light_pass) {
int light_flag = kernel_data.film.light_pass_flag;
if (light_flag & PASSMASK(MIST))
*(ccl_global float *)(buffer + kernel_data.film.pass_mist) *= sample_multiplier;
/* Shadow pass omitted on purpose. It has its own scale parameter. */
if (light_flag & PASSMASK(DIFFUSE_INDIRECT))
*(ccl_global float3 *)(buffer + kernel_data.film.pass_diffuse_indirect) *= sample_multiplier;
if (light_flag & PASSMASK(GLOSSY_INDIRECT))

View File

@@ -35,11 +35,11 @@
# define __NODES_FEATURES__ NODE_FEATURE_ALL
#endif
#include "util/util_half.h"
#include "util/util_math.h"
#include "util/util_simd.h"
#include "util/util_half.h"
#include "util/util_types.h"
#include "util/util_texture.h"
#include "util/util_types.h"
#define ccl_addr_space

View File

@@ -22,8 +22,8 @@
#include "kernel/kernel_profiling.h"
#ifdef __KERNEL_CPU__
# include "util/util_vector.h"
# include "util/util_map.h"
# include "util/util_vector.h"
#endif
#ifdef __KERNEL_OPENCL__

View File

@@ -198,7 +198,7 @@ ccl_device void cmj_sample_2D(int s, int N, int p, float *fx, float *fy)
ccl_device float pmj_sample_1D(KernelGlobals *kg, int sample, int rng_hash, int dimension)
{
/* Fallback to random */
if (sample > NUM_PMJ_SAMPLES) {
if (sample >= NUM_PMJ_SAMPLES) {
int p = rng_hash + dimension;
return cmj_randfloat(sample, p);
}
@@ -211,10 +211,11 @@ ccl_device float pmj_sample_1D(KernelGlobals *kg, int sample, int rng_hash, int
ccl_device void pmj_sample_2D(
KernelGlobals *kg, int sample, int rng_hash, int dimension, float *fx, float *fy)
{
if (sample > NUM_PMJ_SAMPLES) {
if (sample >= NUM_PMJ_SAMPLES) {
int p = rng_hash + dimension;
*fx = cmj_randfloat(sample, p);
*fy = cmj_randfloat(sample, p + 1);
return;
}
uint tmp_rng = cmj_hash_simple(dimension, rng_hash);
int index = ((dimension % NUM_PMJ_PATTERNS) * NUM_PMJ_SAMPLES + sample) * 2;

View File

@@ -171,19 +171,19 @@ ccl_device_forceinline VolumeIntegrateResult kernel_path_volume(KernelGlobals *k
Ray volume_ray = *ray;
volume_ray.t = (hit) ? isect->t : FLT_MAX;
bool heterogeneous = volume_stack_is_heterogeneous(kg, state->volume_stack);
float step_size = volume_stack_step_size(kg, state->volume_stack);
# ifdef __VOLUME_DECOUPLED__
int sampling_method = volume_stack_sampling_method(kg, state->volume_stack);
bool direct = (state->flag & PATH_RAY_CAMERA) != 0;
bool decoupled = kernel_volume_use_decoupled(kg, heterogeneous, direct, sampling_method);
bool decoupled = kernel_volume_use_decoupled(kg, step_size, direct, sampling_method);
if (decoupled) {
/* cache steps along volume for repeated sampling */
VolumeSegment volume_segment;
shader_setup_from_volume(kg, sd, &volume_ray);
kernel_volume_decoupled_record(kg, state, &volume_ray, sd, &volume_segment, heterogeneous);
kernel_volume_decoupled_record(kg, state, &volume_ray, sd, &volume_segment, step_size);
volume_segment.sampling_method = sampling_method;
@@ -229,7 +229,7 @@ ccl_device_forceinline VolumeIntegrateResult kernel_path_volume(KernelGlobals *k
{
/* integrate along volume segment with distance sampling */
VolumeIntegrateResult result = kernel_volume_integrate(
kg, state, sd, &volume_ray, L, throughput, heterogeneous);
kg, state, sd, &volume_ray, L, throughput, step_size);
# ifdef __VOLUME_SCATTER__
if (result == VOLUME_PATH_SCATTERED) {

View File

@@ -91,7 +91,7 @@ ccl_device_forceinline void kernel_branched_path_volume(KernelGlobals *kg,
Ray volume_ray = *ray;
volume_ray.t = (hit) ? isect->t : FLT_MAX;
bool heterogeneous = volume_stack_is_heterogeneous(kg, state->volume_stack);
float step_size = volume_stack_step_size(kg, state->volume_stack);
# ifdef __VOLUME_DECOUPLED__
/* decoupled ray marching only supported on CPU */
@@ -100,7 +100,7 @@ ccl_device_forceinline void kernel_branched_path_volume(KernelGlobals *kg,
VolumeSegment volume_segment;
shader_setup_from_volume(kg, sd, &volume_ray);
kernel_volume_decoupled_record(kg, state, &volume_ray, sd, &volume_segment, heterogeneous);
kernel_volume_decoupled_record(kg, state, &volume_ray, sd, &volume_segment, step_size);
/* direct light sampling */
if (volume_segment.closure_flag & SD_SCATTER) {
@@ -171,7 +171,7 @@ ccl_device_forceinline void kernel_branched_path_volume(KernelGlobals *kg,
path_state_branch(&ps, j, num_samples);
VolumeIntegrateResult result = kernel_volume_integrate(
kg, &ps, sd, &volume_ray, L, &tp, heterogeneous);
kg, &ps, sd, &volume_ray, L, &tp, step_size);
# ifdef __VOLUME_SCATTER__
if (result == VOLUME_PATH_SCATTERED) {

View File

@@ -294,12 +294,15 @@ ccl_device_inline bool sample_is_even(int pattern, int sample)
if (pattern == SAMPLING_PATTERN_PMJ) {
/* See Section 10.2.1, "Progressive Multi-Jittered Sample Sequences", Christensen et al.
* We can use this to get divide sample sequence into two classes for easier variance
* estimation. There must be a more elegant way of writing this? */
* estimation. */
#if defined(__GNUC__) && !defined(__KERNEL_GPU__)
return __builtin_popcount(sample & 0xaaaaaaaa) & 1;
#elif defined(__NVCC__)
return __popc(sample & 0xaaaaaaaa) & 1;
#elif defined(__KERNEL_OPENCL__)
return popcount(sample & 0xaaaaaaaa) & 1;
#else
/* TODO(Stefan): popcnt intrinsic for Windows with fallback for older CPUs. */
int i = sample & 0xaaaaaaaa;
i = i - ((i >> 1) & 0x55555555);
i = (i & 0x33333333) + ((i >> 2) & 0x33333333);

View File

@@ -35,6 +35,7 @@ KERNEL_TEX(KernelObject, __objects)
KERNEL_TEX(Transform, __object_motion_pass)
KERNEL_TEX(DecomposedTransform, __object_motion)
KERNEL_TEX(uint, __object_flag)
KERNEL_TEX(float, __object_volume_step)
/* cameras */
KERNEL_TEX(DecomposedTransform, __camera_motion)

View File

@@ -887,13 +887,13 @@ enum ShaderDataFlag {
SD_HAS_DISPLACEMENT = (1 << 26),
/* Has constant emission (value stored in __shaders) */
SD_HAS_CONSTANT_EMISSION = (1 << 27),
/* Needs to access attributes */
SD_NEED_ATTRIBUTES = (1 << 28),
/* Needs to access attributes for volume rendering */
SD_NEED_VOLUME_ATTRIBUTES = (1 << 28),
SD_SHADER_FLAGS = (SD_USE_MIS | SD_HAS_TRANSPARENT_SHADOW | SD_HAS_VOLUME | SD_HAS_ONLY_VOLUME |
SD_HETEROGENEOUS_VOLUME | SD_HAS_BSSRDF_BUMP | SD_VOLUME_EQUIANGULAR |
SD_VOLUME_MIS | SD_VOLUME_CUBIC | SD_HAS_BUMP | SD_HAS_DISPLACEMENT |
SD_HAS_CONSTANT_EMISSION | SD_NEED_ATTRIBUTES)
SD_HAS_CONSTANT_EMISSION | SD_NEED_VOLUME_ATTRIBUTES)
};
/* Object flags. */
@@ -1275,6 +1275,7 @@ typedef struct KernelBackground {
/* only shader index */
int surface_shader;
int volume_shader;
float volume_step_size;
int transparent;
float transparent_roughness_squared_threshold;
@@ -1282,7 +1283,6 @@ typedef struct KernelBackground {
float ao_factor;
float ao_distance;
float ao_bounces_factor;
float ao_pad;
} KernelBackground;
static_assert_align(KernelBackground, 16);
@@ -1355,7 +1355,7 @@ typedef struct KernelIntegrator {
/* volume render */
int use_volumes;
int volume_max_steps;
float volume_step_size;
float volume_step_rate;
int volume_samples;
int start_sample;

View File

@@ -48,7 +48,8 @@ ccl_device_inline bool volume_shader_extinction_sample(KernelGlobals *kg,
shader_eval_volume(kg, sd, state, state->volume_stack, PATH_RAY_SHADOW);
if (sd->flag & SD_EXTINCTION) {
*extinction = sd->closure_transparent_extinction;
const float density = object_volume_density(kg, sd->object);
*extinction = sd->closure_transparent_extinction * density;
return true;
}
else {
@@ -84,6 +85,11 @@ ccl_device_inline bool volume_shader_sample(KernelGlobals *kg,
}
}
const float density = object_volume_density(kg, sd->object);
coeff->sigma_s *= density;
coeff->sigma_t *= density;
coeff->emission *= density;
return true;
}
@@ -101,15 +107,19 @@ ccl_device float kernel_volume_channel_get(float3 value, int channel)
#ifdef __VOLUME__
ccl_device bool volume_stack_is_heterogeneous(KernelGlobals *kg, ccl_addr_space VolumeStack *stack)
ccl_device float volume_stack_step_size(KernelGlobals *kg, ccl_addr_space VolumeStack *stack)
{
float step_size = FLT_MAX;
for (int i = 0; stack[i].shader != SHADER_NONE; i++) {
int shader_flag = kernel_tex_fetch(__shaders, (stack[i].shader & SHADER_MASK)).flags;
bool heterogeneous = false;
if (shader_flag & SD_HETEROGENEOUS_VOLUME) {
return true;
heterogeneous = true;
}
else if (shader_flag & SD_NEED_ATTRIBUTES) {
else if (shader_flag & SD_NEED_VOLUME_ATTRIBUTES) {
/* We want to render world or objects without any volume grids
* as homogeneous, but can only verify this at run-time since other
* heterogeneous volume objects may be using the same shader. */
@@ -117,13 +127,19 @@ ccl_device bool volume_stack_is_heterogeneous(KernelGlobals *kg, ccl_addr_space
if (object != OBJECT_NONE) {
int object_flag = kernel_tex_fetch(__object_flag, object);
if (object_flag & SD_OBJECT_HAS_VOLUME_ATTRIBUTES) {
return true;
heterogeneous = true;
}
}
}
if (heterogeneous) {
float object_step_size = object_volume_step_size(kg, stack[i].object);
object_step_size *= kernel_data.integrator.volume_step_rate;
step_size = fminf(object_step_size, step_size);
}
}
return false;
return step_size;
}
ccl_device int volume_stack_sampling_method(KernelGlobals *kg, VolumeStack *stack)
@@ -158,12 +174,13 @@ ccl_device int volume_stack_sampling_method(KernelGlobals *kg, VolumeStack *stac
ccl_device_inline void kernel_volume_step_init(KernelGlobals *kg,
ccl_addr_space PathState *state,
const float object_step_size,
float t,
float *step_size,
float *step_offset)
{
const int max_steps = kernel_data.integrator.volume_max_steps;
float step = min(kernel_data.integrator.volume_step_size, t);
float step = min(object_step_size, t);
/* compute exact steps in advance for malloc */
if (t > max_steps * step) {
@@ -199,7 +216,8 @@ ccl_device void kernel_volume_shadow_heterogeneous(KernelGlobals *kg,
ccl_addr_space PathState *state,
Ray *ray,
ShaderData *sd,
float3 *throughput)
float3 *throughput,
const float object_step_size)
{
float3 tp = *throughput;
const float tp_eps = 1e-6f; /* todo: this is likely not the right value */
@@ -207,7 +225,7 @@ ccl_device void kernel_volume_shadow_heterogeneous(KernelGlobals *kg,
/* prepare for stepping */
int max_steps = kernel_data.integrator.volume_max_steps;
float step_offset, step_size;
kernel_volume_step_init(kg, state, ray->t, &step_size, &step_offset);
kernel_volume_step_init(kg, state, object_step_size, ray->t, &step_size, &step_offset);
/* compute extinction at the start */
float t = 0.0f;
@@ -264,8 +282,9 @@ ccl_device_noinline void kernel_volume_shadow(KernelGlobals *kg,
{
shader_setup_from_volume(kg, shadow_sd, ray);
if (volume_stack_is_heterogeneous(kg, state->volume_stack))
kernel_volume_shadow_heterogeneous(kg, state, ray, shadow_sd, throughput);
float step_size = volume_stack_step_size(kg, state->volume_stack);
if (step_size != FLT_MAX)
kernel_volume_shadow_heterogeneous(kg, state, ray, shadow_sd, throughput, step_size);
else
kernel_volume_shadow_homogeneous(kg, state, ray, shadow_sd, throughput);
}
@@ -533,7 +552,8 @@ kernel_volume_integrate_heterogeneous_distance(KernelGlobals *kg,
Ray *ray,
ShaderData *sd,
PathRadiance *L,
ccl_addr_space float3 *throughput)
ccl_addr_space float3 *throughput,
const float object_step_size)
{
float3 tp = *throughput;
const float tp_eps = 1e-6f; /* todo: this is likely not the right value */
@@ -541,7 +561,7 @@ kernel_volume_integrate_heterogeneous_distance(KernelGlobals *kg,
/* prepare for stepping */
int max_steps = kernel_data.integrator.volume_max_steps;
float step_offset, step_size;
kernel_volume_step_init(kg, state, ray->t, &step_size, &step_offset);
kernel_volume_step_init(kg, state, object_step_size, ray->t, &step_size, &step_offset);
/* compute coefficients at the start */
float t = 0.0f;
@@ -679,12 +699,13 @@ kernel_volume_integrate(KernelGlobals *kg,
Ray *ray,
PathRadiance *L,
ccl_addr_space float3 *throughput,
bool heterogeneous)
float step_size)
{
shader_setup_from_volume(kg, sd, ray);
if (heterogeneous)
return kernel_volume_integrate_heterogeneous_distance(kg, state, ray, sd, L, throughput);
if (step_size != FLT_MAX)
return kernel_volume_integrate_heterogeneous_distance(
kg, state, ray, sd, L, throughput, step_size);
else
return kernel_volume_integrate_homogeneous(kg, state, ray, sd, L, throughput, true);
}
@@ -735,7 +756,7 @@ ccl_device void kernel_volume_decoupled_record(KernelGlobals *kg,
Ray *ray,
ShaderData *sd,
VolumeSegment *segment,
bool heterogeneous)
const float object_step_size)
{
const float tp_eps = 1e-6f; /* todo: this is likely not the right value */
@@ -743,9 +764,9 @@ ccl_device void kernel_volume_decoupled_record(KernelGlobals *kg,
int max_steps;
float step_size, step_offset;
if (heterogeneous) {
if (object_step_size != FLT_MAX) {
max_steps = kernel_data.integrator.volume_max_steps;
kernel_volume_step_init(kg, state, ray->t, &step_size, &step_offset);
kernel_volume_step_init(kg, state, object_step_size, ray->t, &step_size, &step_offset);
# ifdef __KERNEL_CPU__
/* NOTE: For the branched path tracing it's possible to have direct

View File

@@ -72,7 +72,7 @@ void kernel_const_copy(KernelGlobals *kg, const char *name, void *host, size_t s
assert(0);
}
void kernel_tex_copy(KernelGlobals *kg, const char *name, void *mem, size_t size)
void kernel_global_memory_copy(KernelGlobals *kg, const char *name, void *mem, size_t size)
{
if (0) {
}

View File

@@ -474,7 +474,7 @@ ccl_device float4 kernel_tex_image_interp(KernelGlobals *kg, int id, float x, fl
{
const TextureInfo &info = kernel_tex_fetch(__texture_info, id);
switch (kernel_tex_type(id)) {
switch (info.data_type) {
case IMAGE_DATA_TYPE_HALF:
return TextureInterpolator<half>::interp(info, x, y);
case IMAGE_DATA_TYPE_BYTE:
@@ -498,28 +498,34 @@ ccl_device float4 kernel_tex_image_interp(KernelGlobals *kg, int id, float x, fl
}
}
ccl_device float4 kernel_tex_image_interp_3d(
KernelGlobals *kg, int id, float x, float y, float z, InterpolationType interp)
ccl_device float4 kernel_tex_image_interp_3d(KernelGlobals *kg,
int id,
float3 P,
InterpolationType interp)
{
const TextureInfo &info = kernel_tex_fetch(__texture_info, id);
switch (kernel_tex_type(id)) {
if (info.use_transform_3d) {
P = transform_point(&info.transform_3d, P);
}
switch (info.data_type) {
case IMAGE_DATA_TYPE_HALF:
return TextureInterpolator<half>::interp_3d(info, x, y, z, interp);
return TextureInterpolator<half>::interp_3d(info, P.x, P.y, P.z, interp);
case IMAGE_DATA_TYPE_BYTE:
return TextureInterpolator<uchar>::interp_3d(info, x, y, z, interp);
return TextureInterpolator<uchar>::interp_3d(info, P.x, P.y, P.z, interp);
case IMAGE_DATA_TYPE_USHORT:
return TextureInterpolator<uint16_t>::interp_3d(info, x, y, z, interp);
return TextureInterpolator<uint16_t>::interp_3d(info, P.x, P.y, P.z, interp);
case IMAGE_DATA_TYPE_FLOAT:
return TextureInterpolator<float>::interp_3d(info, x, y, z, interp);
return TextureInterpolator<float>::interp_3d(info, P.x, P.y, P.z, interp);
case IMAGE_DATA_TYPE_HALF4:
return TextureInterpolator<half4>::interp_3d(info, x, y, z, interp);
return TextureInterpolator<half4>::interp_3d(info, P.x, P.y, P.z, interp);
case IMAGE_DATA_TYPE_BYTE4:
return TextureInterpolator<uchar4>::interp_3d(info, x, y, z, interp);
return TextureInterpolator<uchar4>::interp_3d(info, P.x, P.y, P.z, interp);
case IMAGE_DATA_TYPE_USHORT4:
return TextureInterpolator<ushort4>::interp_3d(info, x, y, z, interp);
return TextureInterpolator<ushort4>::interp_3d(info, P.x, P.y, P.z, interp);
case IMAGE_DATA_TYPE_FLOAT4:
return TextureInterpolator<float4>::interp_3d(info, x, y, z, interp);
return TextureInterpolator<float4>::interp_3d(info, P.x, P.y, P.z, interp);
default:
assert(0);
return make_float4(

View File

@@ -124,7 +124,7 @@ ccl_device float4 kernel_tex_image_interp(KernelGlobals *kg, int id, float x, fl
CUtexObject tex = (CUtexObject)info.data;
/* float4, byte4, ushort4 and half4 */
const int texture_type = kernel_tex_type(id);
const int texture_type = info.data_type;
if (texture_type == IMAGE_DATA_TYPE_FLOAT4 || texture_type == IMAGE_DATA_TYPE_BYTE4 ||
texture_type == IMAGE_DATA_TYPE_HALF4 || texture_type == IMAGE_DATA_TYPE_USHORT4) {
if (info.interpolation == INTERPOLATION_CUBIC) {
@@ -149,14 +149,25 @@ ccl_device float4 kernel_tex_image_interp(KernelGlobals *kg, int id, float x, fl
}
}
ccl_device float4 kernel_tex_image_interp_3d(
KernelGlobals *kg, int id, float x, float y, float z, InterpolationType interp)
ccl_device float4 kernel_tex_image_interp_3d(KernelGlobals *kg,
int id,
float3 P,
InterpolationType interp)
{
const TextureInfo &info = kernel_tex_fetch(__texture_info, id);
if (info.use_transform_3d) {
P = transform_point(&info.transform_3d, P);
}
const float x = P.x;
const float y = P.y;
const float z = P.z;
CUtexObject tex = (CUtexObject)info.data;
uint interpolation = (interp == INTERPOLATION_NONE) ? info.interpolation : interp;
const int texture_type = kernel_tex_type(id);
const int texture_type = info.data_type;
if (texture_type == IMAGE_DATA_TYPE_FLOAT4 || texture_type == IMAGE_DATA_TYPE_BYTE4 ||
texture_type == IMAGE_DATA_TYPE_HALF4 || texture_type == IMAGE_DATA_TYPE_USHORT4) {
if (interpolation == INTERPOLATION_CUBIC) {

View File

@@ -47,7 +47,7 @@ ccl_device_inline float4 svm_image_texture_read(KernelGlobals *kg,
int id,
int offset)
{
const int texture_type = kernel_tex_type(id);
const int texture_type = info->data_type;
/* Float4 */
if (texture_type == IMAGE_DATA_TYPE_FLOAT4) {
@@ -202,11 +202,19 @@ ccl_device float4 kernel_tex_image_interp(KernelGlobals *kg, int id, float x, fl
}
}
ccl_device float4
kernel_tex_image_interp_3d(KernelGlobals *kg, int id, float x, float y, float z, int interp)
ccl_device float4 kernel_tex_image_interp_3d(KernelGlobals *kg, int id, float3 P, int interp)
{
const ccl_global TextureInfo *info = kernel_tex_info(kg, id);
if (info->use_transform_3d) {
Transform tfm = info->transform_3d;
P = transform_point(&tfm, P);
}
const float x = P.x;
const float y = P.y;
const float z = P.z;
if (info->extension == EXTENSION_CLIP) {
if (x < 0.0f || y < 0.0f || z < 0.0f || x > 1.0f || y > 1.0f || z > 1.0f) {
return make_float4(0.0f, 0.0f, 0.0f, 0.0f);

View File

@@ -33,6 +33,9 @@ set(LIB
${LLVM_LIBRARY}
)
# OSL and LLVM are built without RTTI
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${RTTI_DISABLE_FLAGS}")
include_directories(${INC})
include_directories(SYSTEM ${INC_SYS})

View File

@@ -33,12 +33,12 @@
#ifndef __OSL_CLOSURES_H__
#define __OSL_CLOSURES_H__
#include "util/util_types.h"
#include "kernel/kernel_types.h"
#include "util/util_types.h"
#include <OSL/genclosure.h>
#include <OSL/oslclosure.h>
#include <OSL/oslexec.h>
#include <OSL/genclosure.h>
CCL_NAMESPACE_BEGIN

View File

@@ -27,8 +27,8 @@
# include "util/util_map.h"
# include "util/util_param.h"
# include "util/util_thread.h"
# include "util/util_vector.h"
# include "util/util_unique_ptr.h"
# include "util/util_vector.h"
# ifndef WIN32
using std::isfinite;

View File

@@ -1222,8 +1222,8 @@ bool OSLRenderServices::texture3d(ustring filename,
ShaderData *sd = (ShaderData *)(sg->renderstate);
KernelGlobals *kernel_globals = sd->osl_globals;
int slot = handle->svm_slot;
float4 rgba = kernel_tex_image_interp_3d(
kernel_globals, slot, P.x, P.y, P.z, INTERPOLATION_NONE);
float3 P_float3 = make_float3(P.x, P.y, P.z);
float4 rgba = kernel_tex_image_interp_3d(kernel_globals, slot, P_float3, INTERPOLATION_NONE);
result[0] = rgba[0];
if (nchannels > 1)

View File

@@ -25,8 +25,8 @@
* attributes.
*/
#include <OSL/oslexec.h>
#include <OSL/oslclosure.h>
#include <OSL/oslexec.h>
#ifdef WITH_PTEX
class PtexCache;

View File

@@ -14,8 +14,8 @@
* limitations under the License.
*/
#include "stdcycles.h"
#include "node_color.h"
#include "stdcycles.h"
vector environment_texture_direction_to_equirectangular(vector dir)
{

View File

@@ -14,8 +14,8 @@
* limitations under the License.
*/
#include "stdcycles.h"
#include "node_fresnel.h"
#include "stdcycles.h"
shader node_fresnel(float IOR = 1.45, normal Normal = N, output float Fac = 0.0)
{

View File

@@ -14,8 +14,8 @@
* limitations under the License.
*/
#include "stdcycles.h"
#include "node_fresnel.h"
#include "stdcycles.h"
shader node_glass_bsdf(color Color = 0.8,
string distribution = "sharp",

View File

@@ -14,8 +14,8 @@
* limitations under the License.
*/
#include "stdcycles.h"
#include "node_fresnel.h"
#include "stdcycles.h"
shader node_glossy_bsdf(color Color = 0.8,
string distribution = "GGX",

View File

@@ -14,8 +14,8 @@
* limitations under the License.
*/
#include "stdcycles.h"
#include "node_color.h"
#include "stdcycles.h"
shader node_hsv(float Hue = 0.5,
float Saturation = 1.0,

View File

@@ -14,8 +14,8 @@
* limitations under the License.
*/
#include "stdcycles.h"
#include "node_color.h"
#include "stdcycles.h"
point texco_remap_square(point co)
{

View File

@@ -14,8 +14,8 @@
* limitations under the License.
*/
#include "stdcycles.h"
#include "node_fresnel.h"
#include "stdcycles.h"
shader node_layer_weight(float Blend = 0.5,
normal Normal = N,

View File

@@ -14,8 +14,8 @@
* limitations under the License.
*/
#include "stdcycles.h"
#include "node_math.h"
#include "stdcycles.h"
/* OSL asin, acos, and pow functions are safe by default. */
shader node_math(string type = "add",

View File

@@ -14,8 +14,8 @@
* limitations under the License.
*/
#include "stdcycles.h"
#include "node_color.h"
#include "stdcycles.h"
color node_mix_blend(float t, color col1, color col2)
{

View File

@@ -14,8 +14,8 @@
* limitations under the License.
*/
#include "stdcycles.h"
#include "node_noise.h"
#include "stdcycles.h"
#include "vector2.h"
#include "vector4.h"

View File

@@ -14,10 +14,10 @@
* limitations under the License.
*/
#include "node_noise.h"
#include "stdcycles.h"
#include "vector2.h"
#include "vector4.h"
#include "node_noise.h"
#define vector3 point

View File

@@ -14,8 +14,8 @@
* limitations under the License.
*/
#include "stdcycles.h"
#include "node_fresnel.h"
#include "stdcycles.h"
shader node_principled_bsdf(string distribution = "Multiscatter GGX",
string subsurface_method = "burley",

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