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
2022-07-18Subdiv: remove unused GPU device choice, fix crash with libepoxy on initBrecht Van Lommel
openSubdiv_init() would detect available evaluators before any OpenGL context exists, causing a crash with libepoxy. This test however is redundant as we already check the requirements on the Blender side through the GPU API. To simplify things, completely remove the device detection in the opensubdiv module and reduce the evaluators to just CPU and GPU. The plan here is to move to the GPU module abstraction over OpenGL/Metal/Vulkan and so all these different backends no longer make sense. This also removes the user preference for OpenSubdiv compute device, which was not used for the new GPU subdivision implementation. Ref D15291 Differential Revision: https://developer.blender.org/D15470
2022-06-07Cleanup: spelling in comments, additional white spaceCampbell Barton
2022-05-30Merge branch 'blender-v3.2-release'Brecht Van Lommel
2022-05-30Fix T98449: Cycles crash changing frame after recent changesBrecht Van Lommel
Subdivision did not properly update when evaluating first without and then with orco coordinates. Now update the subdivision evaluator settings every time, and reallocate the vertex data buffer when needed. there is an additional issue in this file where orco coordinates are not available immediately on the first frame when they should be, and only appear on the second frame. However that is an old limitation related to the depsgraph not getting re-evaluated on viewport display mode changes, here we just fix the crash.
2022-05-18Merge branch 'blender-v3.2-release'Sergey Sharybin
2022-05-18Subdiv: support interpolating orco coordinates in subdivision surfacesBrecht Van Lommel
This makes changes to the opensubdiv module to support additional vertex data besides the vertex position, that is smootly interpolated the same way. This is different than varying data which is interpolated linearly. Fixes T96596: wrong generated texture coordinates with GPU subdivision. In that bug lazy subdivision would not interpolate orcos. Later on, this implementation can also be used to remove the modifier stack mechanism where modifiers are evaluated a second time for orcos, which is messy and inefficient. But that's a more risky change, this is just the part to fix the bug in 3.2. Differential Revision: https://developer.blender.org/D14973
2022-05-12Cleanup: More proper sections in subdiv codeSergey Sharybin
Follows the code style.
2022-02-11File headers: SPDX License migrationCampbell Barton
Use a shorter/simpler license convention, stops the header taking so much space. Follow the SPDX license specification: https://spdx.org/licenses - C/C++/objc/objc++ - Python - Shell Scripts - CMake, GNUmakefile While most of the source tree has been included - `./extern/` was left out. - `./intern/cycles` & `./intern/atomic` are also excluded because they use different header conventions. doc/license/SPDX-license-identifiers.txt has been added to list SPDX all used identifiers. See P2788 for the script that automated these edits. Reviewed By: brecht, mont29, sergey Ref D14069
2022-01-14Cleanup: Remove unused subdiv functionsHans Goudey
I noticed these when doing final cleanup on rBcfa53e0fbeed. One use was removed in that commit, the others were unused going further back a few years. Differential Revision: https://developer.blender.org/D13834
2022-01-13Refactor: Move normals out of MVert, lazy calculationHans Goudey
As described in T91186, this commit moves mesh vertex normals into a contiguous array of float vectors in a custom data layer, how face normals are currently stored. The main interface is documented in `BKE_mesh.h`. Vertex and face normals are now calculated on-demand and cached, retrieved with an "ensure" function. Since the logical state of a mesh is now "has normals when necessary", they can be retrieved from a `const` mesh. The goal is to use on-demand calculation for all derived data, but leave room for eager calculation for performance purposes (modifier evaluation is threaded, but viewport data generation is not). **Benefits** This moves us closer to a SoA approach rather than the current AoS paradigm. Accessing a contiguous `float3` is much more efficient than retrieving data from a larger struct. The memory requirements for accessing only normals or vertex locations are smaller, and at the cost of more memory usage for just normals, they now don't have to be converted between float and short, which also simplifies code In the future, the remaining items can be removed from `MVert`, leaving only `float3`, which has similar benefits (see T93602). Removing the combination of derived and original data makes it conceptually simpler to only calculate normals when necessary. This is especially important now that we have more opportunities for temporary meshes in geometry nodes. **Performance** In addition to the theoretical future performance improvements by making `MVert == float3`, I've done some basic performance testing on this patch directly. The data is fairly rough, but it gives an idea about where things stand generally. - Mesh line primitive 4m Verts: 1.16x faster (36 -> 31 ms), showing that accessing just `MVert` is now more efficient. - Spring Splash Screen: 1.03-1.06 -> 1.06-1.11 FPS, a very slight change that at least shows there is no regression. - Sprite Fright Snail Smoosh: 3.30-3.40 -> 3.42-3.50 FPS, a small but observable speedup. - Set Position Node with Scaled Normal: 1.36x faster (53 -> 39 ms), shows that using normals in geometry nodes is faster. - Normal Calculation 1.6m Vert Cube: 1.19x faster (25 -> 21 ms), shows that calculating normals is slightly faster now. - File Size of 1.6m Vert Cube: 1.03x smaller (214.7 -> 208.4 MB), Normals are not saved in files, which can help with large meshes. As for memory usage, it may be slightly more in some cases, but I didn't observe any difference in the production files I tested. **Tests** Some modifiers and cycles test results need to be updated with this commit, for two reasons: - The subdivision surface modifier is not responsible for calculating normals anymore. In master, the modifier creates different normals than the result of the `Mesh` normal calculation, so this is a bug fix. - There are small differences in the results of some modifiers that use normals because they are not converted to and from `short` anymore. **Future improvements** - Remove `ModifierTypeInfo::dependsOnNormals`. Code in each modifier already retrieves normals if they are needed anyway. - Copy normals as part of a better CoW system for attributes. - Make more areas use lazy instead of eager normal calculation. - Remove `BKE_mesh_normals_tag_dirty` in more places since that is now the default state of a new mesh. - Possibly apply a similar change to derived face corner normals. Differential Revision: https://developer.blender.org/D12770
2022-01-06Cleanup: spelling in commentsCampbell Barton
2021-12-27OpenSubDiv: add support for an OpenGL evaluatorKévin Dietrich
This evaluator is used in order to evaluate subdivision at render time, allowing for faster renders of meshes with a subdivision surface modifier placed at the last position in the modifier list. When evaluating the subsurf modifier, we detect whether we can delegate evaluation to the draw code. If so, the subdivision is first evaluated on the GPU using our own custom evaluator (only the coarse data needs to be initially sent to the GPU), then, buffers for the final `MeshBufferCache` are filled on the GPU using a set of compute shaders. However, some buffers are still filled on the CPU side, if doing so on the GPU is impractical (e.g. the line adjacency buffer used for x-ray, whose logic is hardly GPU compatible). This is done at the mesh buffer extraction level so that the result can be readily used in the various OpenGL engines, without having to write custom geometry or tesselation shaders. We use our own subdivision evaluation shaders, instead of OpenSubDiv's vanilla one, in order to control the data layout, and interpolation. For example, we store vertex colors as compressed 16-bit integers, while OpenSubDiv's default evaluator only work for float types. In order to still access the modified geometry on the CPU side, for use in modifiers or transform operators, a dedicated wrapper type is added `MESH_WRAPPER_TYPE_SUBD`. Subdivision will be lazily evaluated via `BKE_object_get_evaluated_mesh` which will create such a wrapper if possible. If the final subdivision surface is not needed on the CPU side, `BKE_object_get_evaluated_mesh_no_subsurf` should be used. Enabling or disabling GPU subdivision can be done through the user preferences (under Viewport -> Subdivision). See patch description for benchmarks. Reviewed By: campbellbarton, jbakker, fclem, brecht, #eevee_viewport Differential Revision: https://developer.blender.org/D12406
2021-07-15Cleanup: replace BLI_assert(!"text") with BLI_assert_msg(0, "text")Campbell Barton
This shows the text as part of the assertion message.
2021-06-24Cleanup: comment blocks, trailing space in commentsCampbell Barton
2020-09-24Fix normal computation in opensubdiv when surface derivates are the sameSebastian Parborg
In very rare occations, the returned derivates would be the same. This would lead to the normal calculation breaking (zero normals). Solution: Add this edge case to the other corner case checks. Reviewed By: Sergey
2020-08-07Cleanup: Blenkernel, Clang-Tidy else-after-return fixesSybren A. Stüvel
This addresses warnings from Clang-Tidy's `readability-else-after-return` rule in the `source/blender/blenkernel` module. No functional changes.
2020-04-01Subdiv: Split evaluation begin+refine into separate stepsSergey Sharybin
Actually, begin will do the entire initialization. Refine will only refine if there is a topology refiner associated with the Subdiv descriptor. Allows to refine Subdiv to new coarse positions without touching displacement evaluation. Will be needed to update SubdivCCG during sculpt undo.
2020-03-19Cleanup: `make format` after SortedIncludes changeDalai Felinto
2020-03-03Subdiv: Fix/Workaround for surface partial derivativesSergey Sharybin
Both partial derivatives were evaluated to 0 for a special vertex on Suzanne model: this is happening on a vertex where two adjacent faces with 2 common edges are connected (in the nose of Suzanne). This was breaking multires in this point since tangent matrix is all zeroes, and hence no displacement can be applied in that vertex.
2020-02-28Cleanup: SpellingSergey Sharybin
2019-09-26Fix T70163: Error painting with Subdivision at end of stackSergey Sharybin
Deformation of subdivision surface modifier was using wrong coordinates for the coarse mesh: as the modifier flow goes the coordinates are to be taken from the input array of coordinates.
2019-09-07Cleanup: use post increment/decrementCampbell Barton
When the result isn't used, prefer post increment/decrement (already used nearly everywhere in Blender).
2019-06-15Cleanup: spellingCampbell Barton
2019-04-17ClangFormat: apply to source, most of internCampbell Barton
Apply clang format as proposed in T53211. For details on usage and instructions for migrating branches without conflicts, see: https://wiki.blender.org/wiki/Tools/ClangFormat
2019-02-18doxygen: add newline after \fileCampbell Barton
While \file doesn't need an argument, it can't have another doxy command after it.
2019-02-06Cleanup: remove redundant doxygen \file argumentCampbell Barton
Move \ingroup onto same line to be more compact and make it clear the file is in the group.
2019-02-01Cleanup: remove redundant, invalid info from headersCampbell Barton
BF-admins agree to remove header information that isn't useful, to reduce noise. - BEGIN/END license blocks Developers should add non license comments as separate comment blocks. No need for separator text. - Contributors This is often invalid, outdated or misleading especially when splitting files. It's more useful to git-blame to find out who has developed the code. See P901 for script to perform these edits.
2019-01-16Subdiv: Reset evaluator creation statisticsSergey Sharybin
Makes it more clear to see what was exactly happening at the last invocation of subsurf modifier.
2019-01-04Fix T60124: Multires modifier not reading data from external filesSergey Sharybin
2018-09-04Subdiv: Move evaluation functionality to own headerSergey Sharybin
2018-08-15Multires: Initial groundwork to hook up displacement to new Subdiv objectSergey Sharybin
Adds a displacement support for OpenSubdiov based subsurf object implemented as a callback which gives vector displacement in object space. Currently is implemented to calculate displacement based on myltires displacement grids, but we can support things in the future if needed. Submitting to review to see if there is something obviously wrong in the direction (old multires code was sharing same displacement code to both calculate final displaced mesh and reshape an existing one, which is rather confusing and probably can be done more cleanly?). Reviewers: brecht Reviewed By: brecht Differential Revision: https://developer.blender.org/D3604
2018-08-13OpenSubdiv: Add stub implementation of C-APISergey Sharybin
C-API is way smaller than the rest of the code which uses it. So better to conditionally compile stub implementation than to keep adding ifdef everywhere.
2018-08-08Cleanup: styleCampbell Barton
2018-08-02Cleanup: warnings, trailing spaceCampbell Barton
2018-08-01Subsurf: Evaluate all UV layersSergey Sharybin
Before that it was only first UV layer which was properly evaluated, the rest were ignored. Now all layers are being properly handled.
2018-08-01Subsurf: Support subdivision of mesh with just loose elementsSergey Sharybin
2018-08-01Subsurf: Support subdivision of loose elementsSergey Sharybin
Applies to vertices and edges. Biggest annoyance here is that OpenSubdiv's topology converter expects that there is no loose geometry, otherwise it is getting confused. For now solution is to create some sort of mapping from real Mesh vertex and edge index to a non-loose-index. Now the annoying part is that this is an extra step to calculate before we can compare topology, meaning FPS will not be as great as if we knew for sure that topology didn't change. Loose edges subdivision is different from what it used to be with old subdivision code, but probably nice feature now is that endpoints of loose edges are stay at the coarse vertex locations. This allows to have things like plane with hair strands, without need to duplicate edge vertices at endpoints. All this required some re-work of topology refiner creation, which is now only passing edges and vertices which are adjacent to face. This is how topology refiner is supposed to be used, and this is how its validator also works. Vertices which are adjacent to loose edges are marked as infinite sharp. This seems to be good-enough approximation for now. In the future we might tweaks things a bit and push such vertices in average direction of loose edges, to match old subdivision code closer.
2018-07-20Subsurf: Add basic statistics to help benchmarkingSergey Sharybin
2018-07-18Subsurf: Begin new subdivision surface moduleSergey Sharybin
The idea is to use this as a replacement of old CCG, now it is based on OpenSubdiv. The goal is to reduce any possible overhead which was happening with OpenSubdiv used by CCG. Currently implemented/supported: - Creation from mesh, including topology on OpenSubdiv side, its refinement. - Evaluation of limit point, first order derivatives, normal, and face-varying data for individual coarse position. - Evaluation of whole patches. Currently not optimized, uses evaluation of individual coarse positions. - Creation of Mesh from subdiv, with all geometry being real: all mvert, medge, mloop, and mpoly. This includes custom data interpolation, but all faces currently are getting separated (they are converted to ptex patches, which we need to weld back together). Still need to support lighter weights grids and such, but this is already a required part to have subsurf working in the middle of modifier stack. Annoying part is ifdef all over the place, to keep it compilable when OpenSubdiv is disabled. More cleaner approach would be to have stub API for OpenSubdiv, so everything gets ifdef-ed in a much fewer places.