Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose level of detail (LOD) settings for OpenShell and ODA #632

Closed
1 task
sebjf opened this issue Jul 18, 2023 · 2 comments
Closed
1 task

Expose level of detail (LOD) settings for OpenShell and ODA #632

sebjf opened this issue Jul 18, 2023 · 2 comments

Comments

@sebjf
Copy link
Contributor

sebjf commented Jul 18, 2023

Description

Mesh optimisation at the triangle level (#599) is more intractable than expected. For now, we should investigate whether immediate results can be achieved through the level of detail settings available in the importers, since the plugins, and therefore the tools, can support lod settings themselves.

Goals

  • A level of detail option on import that matches the plugins

Tasks

To be completed after the sprint...

Related Resources

MockUp : link to mockup
Coda doc: link to coda

@sebjf sebjf self-assigned this Jul 18, 2023
@sebjf
Copy link
Contributor Author

sebjf commented Jul 18, 2023

BimRv

https://forum.opendesign.com/showthread.php?22649-Tesselation-of-pipe-elbows-create-wrong-ouput&highlight=TESSELLATION
https://www.opendesign.com/blog/2019/may/tessellation-and-surface-tolerance

For BimRv (at least, this might apply to BimNv too, and it certainly applies to STL etc), tessellation is controlled by two things:

  1. The wrTriangulationParams structure
  2. The OdGiCommonDraw virtual method deviation()

When ODA draws, it uses a library to tessellate from the BRep primitives that make up the model. The level of detail is determined by the amount of error (deviation of the approximate triangular surface from the true curves) tolerated (set by the user).

The wrTriangulationParams Use New Tessellation flag instructs the draw class to re-tessellate, and sets a number of global parameters such as minimum facets per angle.

These are documented in its header wrTriangulationParams.h; this structure is one of the first things configured by FileProcessorRvt::readFile().

Additionally, the default implementation of OdGsView calculates the error per element based on the camera position.

This can be seen in the behaviour of the OdaBimRv sample:

image

The scene is rendered from far back (A) then zoomed in without regenerating, revealing a low poly representation of the chair (B), regenerating the scene at this time, rebuilds the chair with more triangles (C). Using the Triangulation Parameters dialog to deactivate the Auto Surface Tolerance, and setting a relatively high value, means the chair renders with low LOD no matter where the camera is between regens (D).

From looking at OdaTrianParamsDlg.cpp, it appears that we don't need to override deviation() in bouncer, but simply to turn off bRecalculateSurfaceTolerance and set a value for surfaceTolerance (and normalTolerance).

Updating bouncer to set these appears to have the desired effect:

image

@sebjf
Copy link
Contributor Author

sebjf commented Sep 14, 2023

As the tessellation works on basic geometric parameters comparing the discrete representation with the true curve, it is straightforward to compare the settings with the LOD levels in Revit, since we only need one suitably sensitive curved surface.

We can see immediately the BRep triangulators are not identical between ODA and Revit:

image

In the Very Low setting (or, the most tolerant parameters allowed by the ODA app), the ODA version has a higher minimum side count for cylinders, as can be seen on the chairs and column. The Revit version also tessellates the outside edges of the plates to a high degree. It is not obvious which parameter accounts for this, because setting both normal error to be lower, or max facet edge length to be lower, would affect other parts of the scene. The same effect can be achieved in ODA by adjusting the max facet edge length, but for Very Low we should not do this because as the lowest LOD, it should enable the maximum permissible errors.

Triangulation Params: 360, 100000, 10000 (all maximum).

image

For Low we can see the number of sides for the cylinders has increased for the larger ones, but not the smaller ones. This suggests that its not normal error, but the absolute error that has been adjusted. At this LOD there is no difference in the chairs and plates either, for example. However, reducing the surface tolerance without adjusting the normal error in ODA results in cylinder artefacts rather than just an increase in sides. We also don't see the fireplace artefacts removed as they are in Revit. The closest approximation to Revit in this view is achieved by increasing the normal tolerance alone.

Triangulation Params: 40, 100000, 10000.

image

Medium is where we begin to see the effect of the Surface Tolerance. The curve quality increases notably in Medium, but it is not due to the normal error. This is seen most clearly for the bath tub. Reducing the surface tolerance to 0.1 roughly matches the number of facets on both the tub and column. The normal tolerance is put back to 360 now, as the surface error is now low enough that cylinders are tessellated without artefacts.

Triangulation Params: 360, 100000, 0.1.

image

High is when the discretisation of curves becomes invisible to the eye, at least in our viewer with the normals smoothing the surfaces. Facets can still be counted, just, but it is difficult by eye. For this, the surface tolerance is decreased by 10.

Triangulation Params: 360, 100000, 0.01.

image

For Very High we need to use the wireframe view in Unity to see any difference. Above the bathtub can just be made out in front. A surface tolerance half of High gives a similar triangle density. We can also see how the algorithm differs based on the triangulation of the cylinder.

Triangulation Params: 360, 100000, 0.005.

image

For Maximum the appearance is effectively identical, but the triangle density is increased. This can be seen most clearly on the heat exchangers and fireplace.

Triangulation Params: 360, 100000, 0.0005.

Summary

The algorithms between ODA and Revit are different, still, they are likely parameterised by very similar physically based controls. With high surface tolerances, ODAs algorithm tends to introduce artefacts on cylinders, so the normal tolerance should be used at low LODs. As surface tolerance decreases, the normal error effect is reduced, and so it can be put back to maximum (leaving it at a low value wastes computation time).

Starting at Medium, Revit seems to increase the quality in steps of around 10.

The parameters above have been eyeballed to match the triangle density, though it should be considered that since the algorithms are different they will never match perfectly (see for example the different tessellation of the columns).

Anything lower than 0.0005 (half a mm) introduces an outsized computation time even for the Sample House model, so would probably be prohibitive on larger models.

Quality settings

Level Normal Tolerance Surface Tolerance
Very Low 360 10000
Low 40 10000
Medium 360 0.1
High 360 0.01
Very High 360 0.005
Maximum 360 0.0005

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants