I've implemented VRay render instancing in my plugin and it works fine to a degree, but it's slower than expected and uses more memory than expected, so I want to know if I'm doing things right.
I'm doing things the same way that they're done in the VrayInstancer sample project: at render time, new instances are created with calls to VRenderObject::newRenderInstance. Once those instances are created, they're passed to the renderer with calls to RenderBegin and FrameBegin, and when a render finishes, they're cleaned up with FrameEnd/RenderEnd.
However, when creating multiple millions of instances, these initialization/cleanup times can take extra-ordinarily long times. Several minutes. Testing other plugins (like Thinkbox's Frost) using their VRay Instance mode takes only a few seconds for the same number of instances. Also RAM seems to bloat in my implementation....10 million instances of some lowres geospheres can require 50+gigs of RAM in some cases. sizeof(VR::VRenderInstance) returns 1320 bytes, so at minimum 10m instances would require about 13 gigs of RAM excluding any extra allocations during initialization...but the amount of usage I'm seeing is still much higher than what's returned when using Frost for the same particle count, so I'm not sure what I'm doing wrong.
Since all of my instances use the same geometry, my thought is that maybe I'm doing things wrong. Do I need a new VRenderInstance for each actual instance? Or is there a way to pass VRay a single VRenderInstance object along with a list of transforms for it that represent the total number of desired instances or something? There's not much documentation on how these things work under the hood, so I'm hoping a developer can shed some light.
Thanks!
I'm doing things the same way that they're done in the VrayInstancer sample project: at render time, new instances are created with calls to VRenderObject::newRenderInstance. Once those instances are created, they're passed to the renderer with calls to RenderBegin and FrameBegin, and when a render finishes, they're cleaned up with FrameEnd/RenderEnd.
However, when creating multiple millions of instances, these initialization/cleanup times can take extra-ordinarily long times. Several minutes. Testing other plugins (like Thinkbox's Frost) using their VRay Instance mode takes only a few seconds for the same number of instances. Also RAM seems to bloat in my implementation....10 million instances of some lowres geospheres can require 50+gigs of RAM in some cases. sizeof(VR::VRenderInstance) returns 1320 bytes, so at minimum 10m instances would require about 13 gigs of RAM excluding any extra allocations during initialization...but the amount of usage I'm seeing is still much higher than what's returned when using Frost for the same particle count, so I'm not sure what I'm doing wrong.
Since all of my instances use the same geometry, my thought is that maybe I'm doing things wrong. Do I need a new VRenderInstance for each actual instance? Or is there a way to pass VRay a single VRenderInstance object along with a list of transforms for it that represent the total number of desired instances or something? There's not much documentation on how these things work under the hood, so I'm hoping a developer can shed some light.
Thanks!
Comment