Notifications
Clear all
[Closed] Viewport drawing optimizations?
Jun 17, 2021 11:20 am
Is there any good way with maxscript to draw simple lines or shapes to the viewport without absolutely destroying the framerate? Some way to batch process what needs to be drawn maybe?
For example, here’s a simple pixel grid being drawn in screen space, and even with nothing else being drawn the viewport becomes a stuttery mess:
(
global thePixGridFN = fn drawPixelGrid = (
if ::gbl_pixelGrid.count > 0 do (
gw.setTransform (matrix3 1)
gw.setRndLimits #(#colorVerts, #illum, #wireframe)
gwRect = gw.wRect
pSize = ::gbl_pixelSize
for pixRow in ::gbl_pixelGrid do (
for curPix in pixRow do (
pixPos = Box2 curPix[1] curPix[2] (pSize+1) pSize --x,y,width,height
gwRect pixPos curPix[3]
)
)
gw.enlargeUpdateRect #whole
gw.updateScreen()
)
)
--basic grid settings
gridSize = [10,10]
gridScale = 50
gridStart = [100,100]
--Get positions
::gbl_pixelGrid = #() --each sub-array is; #(x,y,color)
::gbl_pixelSize = gridScale
for h=1 to gridSize[2] do (
curRow = #()
y = (gridStart[2] + ((h-1) * gridScale)) as integer
for w=1 to gridSize[1] do (
x = (gridStart[1] + ((w-1) * gridScale)) as integer
theColor = random (color 0 0 0) (color 255 255 255)
append curRow #(x,y,theColor)
)
append ::gbl_pixelGrid curRow
)
--run
unregisterRedrawViewsCallback thePixGridFN
registerRedrawViewsCallback thePixGridFN
completeRedraw()
)
1 Reply
Jun 17, 2021 11:20 am
seems to be a nitrous thang (or what ever the latest max “de rigueur” driver of the day is)…
max 2010 500 fps
max 2020 6-128 fps
the fastest screen space drawing would be a post effect shader whether you can “easily” get the same kind of shapes and lines going on as I’ve not kept abreast of whats possible with the latest hardware and directxGazillion
“seems” to work without the lines
gw.enlargeUpdateRect #whole
gw.updateScreen()
with a marginal frame rate gain