-
Notifications
You must be signed in to change notification settings - Fork 634
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
DYN-3896 Add support for geometry instancing in render pipeline #11914
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will need to continue reviewing this and the LibG changes - at the moment I don't yet understand the changes in the HelixWatch3dViewModel
@saintentropy discussed with @saintentropy - I will work to add some tests for this repo for this functionality. |
add viewmodel test that renders instances add test classes add test file
/// <summary> | ||
/// A flag used to indicate if the current geometrical configuration of an item has instance information. | ||
/// </summary> | ||
bool InstanceInfoAvailable { get; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If something does not have instance information, it won't be an IInstanceableItem
, right?
/// <param name="package">The render package, where graphics data to be | ||
/// pushed.</param> | ||
/// <param name="parameters"></param> | ||
void AddBaseTessellation(IRenderPackage package, TessellationParameters parameters); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same q here.
try making interfaces internal
small fixes internals visible for test update tests
/// <returns></returns> | ||
public bool ContainsTessellationId(Guid id) | ||
{ | ||
return MeshVertexRangesAssociatedWithInstancing.ContainsKey(id) || LineVertexRangesAssociatedWithInstancing.ContainsKey(id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mjkkirschner Hmmmmm.... Not sure but we may need to handle a transform that has both mesh and line type tessellation data. Maybe when edges are on. I can't remember how that case was supported.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be a bit of a hack but the LIbG portion could actually handle this ^^^ I think. I always wondered why we didn't handle the ShowEdges
in the base tessellation call. Maybe puts too much ownership on those implementing IGraphicItem. In this case we are still internal so it may work to let the instanceableItem handle the data. In the case of a cube, AddBaseTessellation(instancingPackage, factory.TessellationParameters)
could inspect the TessellationParameters
and add only a mesh or a mesh and line data if edges are needed. They would have to have separate GUIDs. The subsequent call to AddInstance(instancingPackage, factory.TessellationParameters, labelKey)
could also add the correct instance references fo either mesh only or mesh and line data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may also be follow up task?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we can just push the line data to the baseTessellation from this method:
if (factory.TessellationParameters.ShowEdges) |
or always generate the edge data in baseTessellation but only using it (extracting it from the render package) if show edges is on.
For the current state of the PR, I think we need to decide the following:
- When show_edges is on, we don't use instancing OR -
- When show_edges is on, we use instancing but don't draw edges... OR
- When show_edges is on, we use instancing for the meshes, but push a bunch of non instanced edge data?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be also...
4. Edges added within instancing implementation.
} | ||
|
||
/// <summary> | ||
/// A test class that creates a pyramid using instancing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool :-)
add test that will fail until libG changes are merged
@@ -1276,6 +1276,28 @@ public void InstancedLinesAreAddedToBackGroundPreviewForEachMatrix() | |||
Assert.AreEqual(6 * 6 * 6, BackgroundPreviewGeometry.TotalLineInstancesToRender()); | |||
|
|||
} | |||
[Test] | |||
[Category("Failure")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can enable this after the LibG changes are merged, it will fail until then because the number of instances will be incorrect.
Hey @mjkkirschner, the show edges implementation looks good. This PR LGTM |
Purpose
https://jira.autodesk.com/browse/DYN-3896
The purpose of this PR is to add geometry instancing support in the render pipeline for the 3D background preview. This work build on the PR where we modified the render pipeline to gather one
RenderPackage
per node. Instancing can be utilized to reduce tessellation overhead for symmetrical geometry types (cube, rectangle, sphere, circle, ellipse, cylinders, coordinate systems, and planes) as well as dramatically improve render time and memory usage required for the 3D Preview. Perf and memory testing will depend on the object type and size of tessellation data but an example of 30,000 spheres reduces the tessellation and render time from 23 to 2 sec and memory size of Dynamo from 5gig to 500 mb.(500,000 Spheres)
Specifically this PR adds to Dynamo:
IInstanceableItem
interface that follows the pattern ofIGraphicItem
where the interface is applied to object who can be rendered via instancing. The interface add a method to the object to define a base set of tessellation data and methods to set transformation matrices for any instance geometry. The transforms handle the transition, rotation, and scaling of the base tessellation data to the objects placement in 3D spaceIRenderInstances
interface for extending RenderPackges to support storing base tessellation data and instance mtaricesHelixWatch3DViewModel
to utilize the Helix instancing APIs to render geometry with associated instance matrices.There will be an associated PR for LibG to utilize these new interfaces and new API's
Todo
Declarations
Check these if you believe they are true
*.resx
filesReviewers
@aparajit-pratap @mjkkirschner
FYIs
@QilongTang @jasonstratton