Viewport 2.0 draw multiple kLineStrip & update problems.

Viewport 2.0 draw multiple kLineStrip & update problems.

Anonymous
Not applicable
388 Views
1 Reply
Message 1 of 2

Viewport 2.0 draw multiple kLineStrip & update problems.

Anonymous
Not applicable

Hi guys,

 

I'm recently trying to port a node I wrote  a while ago to VP2.0, that renders curves (hairs/grass). It is not very different from an instancer, where I draw always the same geo multiple times in the same node.

I'm trying to wrap my head around this API, using as an example the foorNodeGeometryOverride and reading the documentation, but I encountered some problems (please note that, while I feel comfortable writing nodes and commands, I'm a rookie when it comes to draw stuff in viewport).

 

First of all, I am trying to understand the concept behind the renderItems: initially I thought I should have created a renderItem for every curve, and tag that very curve as "kLineStrip", but from what I see I should give a different name to every curve... is that correct? Considering that I want to draw ten of thousands curves, I wonder if that is an efficent way to do it.

 

In the meanwhile, I tried to use only one render item to draw all my curves, but I don't know how to specify multiple kLineStrip(s) in the same render item (or if that is even possible). Currently I'm using kLine, basically doubling the number of indices to correctly draw my curves, but it sounds like a big waste of resources to me.

 

Finally, I have a problem understanding how to update the index buffer:  I don't have any problems updating the vertexBuffer (maybe because is not dependant from the render items?), but the indices array seems to be unable to update its size: it always retains its original length.

In my case, the index array should be able to dinamically change its size, when the "numberOfHairs" attribute changes.

I've read that one way to notify the renderer of "topology changes" is to call MHWRender::MRenderer::setGeometryDrawDirty(), but this didn't work for me.

 

Thank you!

0 Likes
389 Views
1 Reply
Reply (1)
Message 2 of 2

cheng_xi_li
Autodesk Support
Autodesk Support

Hi ZioBlu,

 

It sounds like you want to create multiple instances with the same renderItems. Using MPxSubsceneOverride will be more efficient. There is a sample of using renderItems with MPxSubsceneOverride in our devkit(apiMeshShape). After that, you can use MPxSubsceneOverride::addInstanceTransform to draw multiple instances of the same renderItem.

 

I am not sure about how you manage to update the number of hairs. Are you updating them in the MPxNode::Compute? MHWRender::MRenderer::setGeometryDrawDirty() probably won't trigger a compute, so you have to manually trigger it. A trick here is to get a plug of your node, it will enforce a compute on your node.

 

Yours,

Li

 

0 Likes