pencil_love Posted October 19, 2020 Share Posted October 19, 2020 I learned to use PIXI.Mesh( ) and PIXI.Geometry().addAttribute (instance:true) to render instanceMesh I want to render many similar graphics, And I want to improve informace by use instanceBuffer(to keep the Drawcall 1). Can I addAttribute on graphics.geometry(graphicsGeometry),and pass it to Mesh or Graphics?When I pass graphicsGeometry to Mesh's first argument.the VSCode tell me geometry is not == GraphicsGeometry. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted October 19, 2020 Share Posted October 19, 2020 GraphicsGeometry adds its attributes in constructor. Later, you can set "instanced" of those attributes. That leaves only one problem: which algorithm will fill extra attribute with translationMatrix, and other stuff that is usually an uniform. You have to make your own shader and batcher for graphics in that case. I can help you next weekend if you start this thing. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted October 19, 2020 Share Posted October 19, 2020 As a reference, here is what i do when i need to draw many bars: https://github.com/gameofbombs/pixi-candles/blob/master/src/Bars.ts . Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted October 19, 2020 Share Posted October 19, 2020 @ShukantPal explain what we have for instanced batchers please? Quote Link to comment Share on other sites More sharing options...
pencil_love Posted October 19, 2020 Author Share Posted October 19, 2020 9 minutes ago, ivan.popelyshev said: GraphicsGeometry adds its attributes in constructor. Later, you can set "instanced" of those attributes. That leaves only one problem: which algorithm will fill extra attribute with translationMatrix, and other stuff that is usually an uniform. You have to make your own shader and batcher for graphics in that case. I can help you next weekend if you start this thing. I remember that threejs use four vector4 attributes and compose them in vertex shader. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted October 19, 2020 Share Posted October 19, 2020 If you draw only rects, then you can try to use pixi-candles thingy. If you make extra step, you can modify its buffer to hold different rects. Are your rects rotated relatively to each other? Quote Link to comment Share on other sites More sharing options...
pencil_love Posted October 19, 2020 Author Share Posted October 19, 2020 Just now, ivan.popelyshev said: If you draw only rects, then you can try to use pixi-candles thingy. If you make extra step, you can modify its buffer to hold different rects. Are your rects rotated relatively to each other? THANKS for Reply. I just want different position; Quote Link to comment Share on other sites More sharing options...
Shukant Pal Posted October 19, 2020 Share Posted October 19, 2020 We don't have instancing in the core batch renderer right now. I never completed @pixi-essentials/instanced-renderer either. For instancing GraphicsGeometry, you would probably add a translationMatrix attribute that is equal to the world transform of each Graphics instance being drawn. You would essentially buffer the translationMatrix using Matrix.toArray into a Float32Array instanced attribute. Your vertex shader then would multiply this translationMatrix to the incoming points before the projectionMatrix. The rest of the shader would be the same as the default. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.