Migration to the new help center
We are currently migrating to a new help center. Old documentation articles will remain here until they are updated in the new version. However, keep in mind that this migration goes along a completely new ShapeDiver platform, a new version of the viewer and an updated Grasshopper plugin. Therefore, the information contained in the present article might contain outdated information. If you have questions about the topic addressed in the present article but cannot find a version of it in the new help center, don't hesitate to let us know on the forum so we can work on an update shortly.
Grasshopper represents geometry in two ways: using b-reps or using meshes. Mishandling them can affect the performance of Grasshopper definitions when they run on ShapeDiver. This performance is especially crucial for any ShapeDiver model that will be accessed or interacted with via a web browser, where the available internet connection or even the device's own hardware can play a significant role on the UX. We recommend to create definitions that typically load in under 5 seconds.
What Is A Mesh?
A mesh is the native geometry representation your graphics card (GPU) needs in order to display objects and it consists of a collection of vertices (points) and faces (typically triangles and rectangles). The more vertices and faces a mesh has, the more time will be required to transfer the mesh to the end device and the more GPU resources will be used. This amount of vertices and faces is what we need to keep the lowest possible in order to have a definition with a great performance.
What Is A B-Rep?
On the other hand, a b-rep is the short name given to "Boundary Representation". It consists of representing surfaces through mathematical equations and a set of limits in the 3D space. B-Reps are both more compact in their definition while retaining more structural information about the shape. Therefore, one can define complex operations on them easily (such as boolean differences or piping) which is challenging to do with meshes.
However, b-reps need to be converted to meshes in order to be rendered by a GPU. During this operation, any performance benefit from using b-rep can be cancelled by the meshing algorithm, if it isn't done right. To get precise information on any given b-rep, type "what" in the Rhino command line. This will open a window describing the object you have selected. At the bottom of this window you'll be able to see the size of the mesh that is being rendered to display this object.
What Happens When Displaying B-Reps In ShapeDiver's Viewer?
All b-reps output to ShapeDiver's viewer are eventually converted to meshes. We try to make this conversion as efficient as possible. However, the automatic conversion potentially comes with two issues: it will increase the online loading times of the models in a non predictable way, and it can produce visual artefacts since the amount of vertices and faces of the meshes can't be controlled. For example, whenever a b-rep contains several faces grouped with hard edges, those faces might be meshed independently and might not appear watertight in the online viewer.
Optimal performance on ShapeDiver can be achieved by balancing b-rep and mesh operations, keeping the b-rep representation as long as necessary to perform complex operations in the most efficient way but switching to meshes whenever it makes sense, and definitely before outputting geometry to the viewer using one of the ShapeDiver display components.
Keep in mind that the meshing steps of a definition increase the computation time, but at least it is a time that one can predictably control, as opposed to letting servers do the meshing themselves and possibly output heavy meshes to the viewer. One should always think of how relevant and how big each piece of geometry is in the definition, and optimize their mesh size as much as possible according to it.
How Does One Convert B-Reps Into Meshes?
The most efficient way is to use primitive shapes since Grasshopper already offers direct solutions to create meshes in which you can clearly and exactly define the amount of polygons that you wish to use.
However, in most cases, the geometry will be more complex than a primitive shape, which means one needs to use the component "MeshBrep" that offers different settings solutions to play with the amount of faces and vertices your mesh has.
The simplest setting component is called "Settings(Speed)" and will try to make a mesh as efficient as possible. However, sometimes it is better to use the "Settings(Custom)" as this one has a variety of options to optimize a mesh even more.
Other components which need meshes as inputs will also convert your b-reps directly into meshes, such as the Texture Mapping components in the Human plugin or our own component "ShapeDiverTextureTransform", but it is not recommended to convert a b-rep in this way as it doesn't allow any control over the conversion.
Tip
If you want to visually check how the wireframe (faces and vertices) of your mesh is, type ctrl+m in Grasshopper, as usually Grasshopper hides the wireframe by default.
Vertices and faces count difference when converting to mesh directly vs using mesh settings with the "MeshBrep" component.
How Can One Be Even More Efficient?
Using C# Scripting or other programming languages available in Grasshopper, one can create very efficient definitions by coding exactly the way a mesh will be constructed from scratch. You can also use different components inside the mesh tab in Grasshopper.
Comments
0 comments
Article is closed for comments.