Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2021-09-09Geometry Nodes: fields and anonymous attributesJacques Lucke
This implements the initial core framework for fields and anonymous attributes (also see T91274). The new functionality is hidden behind the "Geometry Nodes Fields" feature flag. When enabled in the user preferences, the following new nodes become available: `Position`, `Index`, `Normal`, `Set Position` and `Attribute Capture`. Socket inspection has not been updated to work with fields yet. Besides these changes at the user level, this patch contains the ground work for: * building and evaluating fields at run-time (`FN_fields.hh`) and * creating and accessing anonymous attributes on geometry (`BKE_anonymous_attribute.h`). For evaluating fields we use a new so called multi-function procedure (`FN_multi_function_procedure.hh`). It allows composing multi-functions in arbitrary ways and supports efficient evaluation as is required by fields. See `FN_multi_function_procedure.hh` for more details on how this evaluation mechanism can be used. A new `AttributeIDRef` has been added which allows handling named and anonymous attributes in the same way in many places. Hans and I worked on this patch together. Differential Revision: https://developer.blender.org/D12414
2021-07-15Fix: missing null checkJacques Lucke
This was a regression in rB3b6ee8cee7080af200e25e944fe30d310240e138.
2021-07-13Refactor: Move vertex group names to object dataHans Goudey
This commit moves the storage of `bDeformGroup` and the active index to `Mesh`, `Lattice`, and `bGPdata` instead of `Object`. Utility functions are added to allow easy access to the vertex groups given an object or an ID. As explained in T88951, the list of vertex group names is currently stored separately per object, even though vertex group data is stored on the geometry. This tends to complicate code and cause bugs, especially as geometry is created procedurally and tied less closely to an object. The "Copy Vertex Groups to Linked" operator is removed, since they are stored on the geometry anyway. This patch leaves the object-level python API for vertex groups in place. Creating a geometry-level RNA API can be a separate step; the changes in this commit are invasive enough as it is. Note that opening a file saved in 3.0 in an earlier version means the vertex groups will not be available. Differential Revision: https://developer.blender.org/D11689
2021-06-24Cleanup: comment blocks, trailing space in commentsCampbell Barton
2021-05-25Blenlib: Explicit Colors.Jeroen Bakker
Colors are often thought of as being 4 values that make up that can make any color. But that is of course too limited. In C we didn’t spend time to annotate what we meant when using colors. Recently `BLI_color.hh` was made to facilitate color structures in CPP. CPP has possibilities to enforce annotating structures during compilation and can adds conversions between them using function overloading and explicit constructors. The storage structs can hold 4 channels (r, g, b and a). Usage: Convert a theme byte color to a linearrgb premultiplied. ``` ColorTheme4b theme_color; ColorSceneLinear4f<eAlpha::Premultiplied> linearrgb_color = BLI_color_convert_to_scene_linear(theme_color).premultiply_alpha(); ``` The API is structured to make most use of inlining. Most notable are space conversions done via `BLI_color_convert_to*` functions. - Conversions between spaces (theme <=> scene linear) should always be done by invoking the `BLI_color_convert_to*` methods. - Encoding colors (compressing to store colors inside a less precision storage) should be done by invoking the `encode` and `decode` methods. - Changing alpha association should be done by invoking `premultiply_alpha` or `unpremultiply_alpha` methods. # Encoding. Color encoding is used to store colors with less precision as in using `uint8_t` in stead of `float`. This encoding is supported for `eSpace::SceneLinear`. To make this clear to the developer the `eSpace::SceneLinearByteEncoded` space is added. # Precision Colors can be stored using `uint8_t` or `float` colors. The conversion between the two precisions are available as methods. (`to_4b` and `to_4f`). # Alpha conversion Alpha conversion is only supported in SceneLinear space. Extending: - This file can be extended with `ColorHex/Hsl/Hsv` for different representations of rgb based colors. `ColorHsl4f<eSpace::SceneLinear, eAlpha::Premultiplied>` - Add non RGB spaces/storages ColorXyz. Reviewed By: JacquesLucke, brecht Differential Revision: https://developer.blender.org/D10978
2021-05-25Revert "Blenlib: Explicit Colors."Jeroen Bakker
This reverts commit fd94e033446c72fb92048a9864c1d539fccde59a. does not compile against latest master.
2021-05-25Blenlib: Explicit Colors.Jeroen Bakker
Colors are often thought of as being 4 values that make up that can make any color. But that is of course too limited. In C we didn’t spend time to annotate what we meant when using colors. Recently `BLI_color.hh` was made to facilitate color structures in CPP. CPP has possibilities to enforce annotating structures during compilation and can adds conversions between them using function overloading and explicit constructors. The storage structs can hold 4 channels (r, g, b and a). Usage: Convert a theme byte color to a linearrgb premultiplied. ``` ColorTheme4b theme_color; ColorSceneLinear4f<eAlpha::Premultiplied> linearrgb_color = BLI_color_convert_to_scene_linear(theme_color).premultiply_alpha(); ``` The API is structured to make most use of inlining. Most notable are space conversions done via `BLI_color_convert_to*` functions. - Conversions between spaces (theme <=> scene linear) should always be done by invoking the `BLI_color_convert_to*` methods. - Encoding colors (compressing to store colors inside a less precision storage) should be done by invoking the `encode` and `decode` methods. - Changing alpha association should be done by invoking `premultiply_alpha` or `unpremultiply_alpha` methods. # Encoding. Color encoding is used to store colors with less precision as in using `uint8_t` in stead of `float`. This encoding is supported for `eSpace::SceneLinear`. To make this clear to the developer the `eSpace::SceneLinearByteEncoded` space is added. # Precision Colors can be stored using `uint8_t` or `float` colors. The conversion between the two precisions are available as methods. (`to_4b` and `to_4f`). # Alpha conversion Alpha conversion is only supported in SceneLinear space. Extending: - This file can be extended with `ColorHex/Hsl/Hsv` for different representations of rgb based colors. `ColorHsl4f<eSpace::SceneLinear, eAlpha::Premultiplied>` - Add non RGB spaces/storages ColorXyz. Reviewed By: JacquesLucke, brecht Differential Revision: https://developer.blender.org/D10978
2021-05-25Cleanup: Convert to static type directly from CPPTypeHans Goudey
2021-04-23Merge branch 'blender-v2.93-release'Jacques Lucke
2021-04-23Fix T87582: incorrect interpolation from edge to corner domainJacques Lucke
2021-04-22Geometry Nodes: Add initializer for attribute creationHans Goudey
Previously we always had to set attribute values after creating the attribute. This patch adds an initializer argument to `attribute_try_create` which can fill it in a few ways, which are explained in code comments. This fixes T87597. Differential Revision: https://developer.blender.org/D11045
2021-04-17Geometry Nodes: use virtual arrays in internal attribute apiJacques Lucke
A virtual array is a data structure that is similar to a normal array in that its elements can be accessed by an index. However, a virtual array does not have to be a contiguous array internally. Instead, its elements can be layed out arbitrarily while element access happens through a virtual function call. However, the virtual array data structures are designed so that the virtual function call can be avoided in cases where it could become a bottleneck. Most commonly, a virtual array is backed by an actual array/span or is a single value internally, that is the same for every index. Besides those, there are many more specialized virtual arrays like the ones that provides vertex positions based on the `MVert` struct or vertex group weights. Not all attributes used by geometry nodes are stored in simple contiguous arrays. To provide uniform access to all kinds of attributes, the attribute API has to provide virtual array functionality that hides the implementation details of attributes. Before this refactor, the attribute API provided its own virtual array implementation as part of the `ReadAttribute` and `WriteAttribute` types. That resulted in unnecessary code duplication with the virtual array system. Even worse, it bound many algorithms used by geometry nodes to the specifics of the attribute API, even though they could also use different data sources (such as data from sockets, default values, later results of expressions, ...). This refactor removes the `ReadAttribute` and `WriteAttribute` types and replaces them with `GVArray` and `GVMutableArray` respectively. The `GV` stands for "generic virtual". The "generic" means that the data type contained in those virtual arrays is only known at run-time. There are the corresponding statically typed types `VArray<T>` and `VMutableArray<T>` as well. No regressions are expected from this refactor. It does come with one improvement for users. The attribute API can convert the data type on write now. This is especially useful when writing to builtin attributes like `material_index` with e.g. the Attribute Math node (which usually just writes to float attributes, while `material_index` is an integer attribute). Differential Revision: https://developer.blender.org/D10994
2021-04-12Fix T87348: convert vertex colors to linear color spaceJacques Lucke
Differential Revision: https://developer.blender.org/D10956
2021-04-08Spreadsheet: support showing data of specific nodeJacques Lucke
Previously, the spreadsheet editor could only show data of the original and of the final evaluated object. Now it is possible to show the data at some intermediate stages too. For that the mode has to be set to "Node" in the spreadsheet editor. Furthermore, the preview of a specific node has to be activated by clicking the new icon in the header of geometry nodes. The exact ui of this feature might be refined in upcoming commits. It is already very useful for debugging node groups in it's current state though. Differential Revision: https://developer.blender.org/D10875
2021-03-28Cleanup: deduplicate attribute creating codeJacques Lucke
2021-03-25Geometry Nodes: rename attribute domainsJacques Lucke
This patch renames two domains: * `Polygon` -> `Face` * `Corner` -> `Face Corner` For the change from `polygon` to `face` I did a "deep rename" where I updated all (most?) cases where we refere to the attribute domain in code as well. The change from `corner` to `face corner` is only a ui change. I did not see a real need to update all code the code for that. It does not seem to improve the code, more on the contrary. Ref T86818. Differential Revision: https://developer.blender.org/D10803
2021-03-23Cleanup: allow looking up size of unsupported domainsJacques Lucke
There isn't really a reason for not supporting it.
2021-03-23Cleanup: use BLI_assert_unreachable in some placesJacques Lucke
2021-03-19Geometry Nodes: Implicit interpolations to and from the edge domainHans Goudey
This patch adds the remaining 6 interpolations for mesh domains. The new interpolations are: - Corner / point / polygon to edge - Edge to corner / point / polygon After this it is possible to adapt an attribute to and from every mesh domain. This is simple to test with the "Attribute Convert" node. Though, as a note for the future, there are still some improvements possible to the interpolations, like lazily calculating values for the interpolations where it's possible, and slightly improving the algorithms used for some interpolations, like using corner angles for polygon to point. Differential Revision: https://developer.blender.org/D10765
2021-03-17Cleanup: improve gathering supported domains by geometry typeJacques Lucke
2021-03-15Geometry Nodes: expose builtin crease attributeJacques Lucke
This exposes the `crease` attribute, that is used by the Subdivide Smooth node. It is also the first attribute on the edge domain. Domain interpolations for the edge domain have not been implemented yet. Ref T86397. Differential Revision: https://developer.blender.org/D10660
2021-03-15Cleanup: clang modernize-use-override errors.Jeroen Bakker
2021-03-13Geometry Nodes: Add "normal" attribute for face normalsHans Goudey
This commit adds a `normal` attribute on the polygon domain. Since normal data is derived data purely based off of the location of each face's vertices, it is exposed as a read-only attribute. After rB80f7f1070f17, this attribute can be interpolated to the other domains. Since this attribute is a special case compared to the others, the implementation subclasses `BuiltinAttributeProvider`. It's possible there is a better way to abstract this. Something else might also become apparent if we add similar read-only attributes. See rB2966871a7a891bf36 for why this is preferred over the previous implementation. Differential Revision: https://developer.blender.org/D10677
2021-03-13Geometry Nodes: Revert current normal attribute implementationHans Goudey
After further thought, the implementation of the "normal" attribute from D10541 is not the best approach to expose this data, mainly because it blindly copied existing design rather than using the best method in the context of the generalized attribute system. In Blender, vertex normals are simply a cache of the average normals from the surrounding / connected faces. Because we have automatic interpolation between domains already, we don't need a special `vertex_normal` attribute for this case, we can just let the generalized interpolation do the hard work where necessary, simplifying the set of built-in attributes to only include the `normal` attribute from faces. The fact that vertex normals are just a cache also raised another issue, because the cache could be dirty, so mutex locks were necessary to calculate normals. That isn't necessarily a problem, but it's nice to avoid where possible. Another downside of the current attribute naming is that after the point distribute node there would be two normal attributes. This commit reverts the `vertex_normal` attribute so that it can be replaced by the implementation in D10677. Differential Revision: https://developer.blender.org/D10676
2021-03-10Geometry Nodes: move geometry component type enum to CJacques Lucke
This allows us to use it in rna for the spreadsheet editor.
2021-03-09Geometry Nodes: Add Attribute interpolation for polygon domainsHans Goudey
This commit adds interpolation to and from attribute on the polygon domain. Interpolation is done automatically when a node uses attributes on two different domains. The following are the new interpolations and corresponding simple test cases: - **Point to Polygon**: Painting the shade smooth attribute in weight paint mode - **Polygon to Point**: Moving points along a normal based on the material index - **Polygon to Corner**: Scaling a UV map with the material index before sampling a texture {F9881516} This is also necessary for an improved implementation of the `normal` attribute. Differential Revision: https://developer.blender.org/D10393
2021-03-09Geometry Nodes: Expose "shade smooth" as an attributeHans Goudey
This patch exposes the "Shade Smooth" value as a boolean attribute. This setting is exposed as a check-box in the mesh data properties, but the value is actually stored for every face, allowing some faces to be shaded smooth with a simple per-face control. One bonus, this allows at least a workaround to the lack of control of whether meshes created by nodes are shaded smooth or not: just use an attribute fill node. Differential Revision: https://developer.blender.org/D10538
2021-03-08Cleanup: Move geometry component implementations to separate filesHans Goudey
Currently the implementations specific to each geometry type are in the same file. This makes it difficult to tell which code is generic for all component types and which is specific to a certain type. The two files, `attribute_access.cc`, and `geometry_set.cc` are also getting quite long. This commit splits up the implementation for every geometry component, and adds an internal header file for the common parts of the attribute access code. This was discussed with Jacques Lucke.