Jump to content

How to render Graphic rect by instanceGeometry


pencil_love
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...