Notifications
Clear all

[Closed] rendertime instancing

I examined a maxscript referance example with prerender callback and based on it wrote a simple script:


macroScript RenderSwapOn category:"kojak How To"
(
	callbacks.removescripts id:#koj_renderswap
	
	txt = "myT = selection[1] 
"
	txt += "myT.renderable = false
"
	txt += "myT.name = \"mySourceName\"
"
	--txt += "myT.ishidden = true
" 
	txt += "mySel = selection
"
	txt += "for i = 2 to mySel.count do (
"
		txt += "sourceTrans = mySel[i].transform
"
		txt += "sourceMat = mySel[i].material
"
		txt += "mySel[i].renderable = false
"
		txt += "newT = instance myT
"
		txt += "newT.name = \"myRenderTarget\"
"
		txt += "newT.ishidden = true
"
		txt += "newT.material = sourceMat
"
		txt += "newT.renderable = true
"
		txt += "newT.transform = sourceTrans
"
		txt += ")
"
		
		callbacks.addscript #prerender txt id:#koj_renderswap
		
		txt = "delete $myRenderTarget*"
		callbacks.addscript #postrender txt id:#koj_renderswap
)

which copies given object to proxies at rendertime and deletes them after rendering.
The problem is in it’s performance. When object count gets large the script becomes painfully slow what is normal because it does nothing extraordinary just ensures that the copies don’t clutter the viewport.
Can I do anything to make this faster?
Is it the case where SDK should be used? For thousands of objects?
Is it possible for MAX to read the geometry from disk and not load it into memory.
I know about vray proxies and true instances but it’s not the case.

2 Replies

If during the preRender or postRender stages you see viewport updates you could start with disabling the viewports, [b]disableSceneRedraw/b , do the swapping, render, swap back proxies, and finally enable the viewports enableSceneRedraw().

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.