Jump to content

ShaderMaterial


monkeyface
 Share

Recommended Posts

I'm trying to construct a custom mesh using ShaderMaterial porting some code from three.js.

In the example I'm copying though, since the shape is only 2d, they save performance by making the vertex positions in a vec2 buffer instead of vec3 and they don't use any indices at all (it just uses gl.TRIANGLE calls to make each set of 3 verts into a triangle.

The problem I am having is that if I don't do setVerticesData with the full vec3 vertices and then setIndices with a list of indices, Babylon doesn't seem to draw anything.

 

Is there some way to do these kind of tricks without having to fill in all the vertices and generate the indices manually?

 

Thanks!

Link to comment
Share on other sites

Unfortunately, we do not have "direct" support for unindexed vertices.

But you can inherit from AbstractMesh like the LineMesh for instance: https://github.com/BabylonJS/Babylon.js/blob/master/src/Mesh/babylon.linesMesh.ts

 

But are you sure there is no vertex redundancy with your model? I'm surprised that, even to draw a 2d mesh, you do not have reusable vertices.

Link to comment
Share on other sites

But you can inherit from AbstractMesh like the LineMesh for instance: https://github.com/BabylonJS/Babylon.js/blob/master/src/Mesh/babylon.linesMesh.ts

 

 

HI DK, 

 

I've got my class inheriting in this way, but I'm still not sure how it helps...

With  engine.bindBuffers I still need to pass in an index buffer as parameter and it doesn't work if I don't set the indices...

 

Also, with the vertexDeclaration = [3] and vertexStrideSize = 3 * 4, I understand we're telling it each vertex is made of 3 values, each of size 4 bytes (3*4), but what is the [3] part for?

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...