monkeyface Posted November 6, 2015 Share Posted November 6, 2015 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! Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 6, 2015 Share Posted November 6, 2015 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. Quote Link to comment Share on other sites More sharing options...
monkeyface Posted November 6, 2015 Author Share Posted November 6, 2015 Thanks! I will take a look at that.I think its a tradeoff... you do get some redundancy on the gpu side, but you save javascript cpu time constructing the indices and less I/O by using vec2 positions with no indices... Quote Link to comment Share on other sites More sharing options...
monkeyface Posted November 6, 2015 Author Share Posted November 6, 2015 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? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 6, 2015 Share Posted November 6, 2015 About performance: I think this is unwise to save some CPU cycles just at the beginning against saving GPU cycles on EVERY frame for my suggestion, you are completey right and I'm just stupid . I thought I added an API for VB only but I removed it sometimes ago (To favor indexed content) 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.