bilgorajskim Posted October 30, 2018 Share Posted October 30, 2018 Hello everyone! Currently when I'm adding vertex attributes other than those specified in VertexBuffer (PositionKind etc.) via Mesh.setVerticesData(), it throws an error: Uncaught (in promise) Error: Invalid kind 'test' I think it would be useful to be able to add attributes of any kind. For example: I have a terrain mesh with a custom shader that takes "color" (vec3) and "moisture, temperature" (vec2) vertex attributes. It uses moisture and temperature to mix between 4 greyscale ground textures (wet and hot; dry and hot; wet and cold; dry and cold) and colorizes it. Now I have two options: - use UV2Kind, UV3Kind.. - it will work in this use case, but they are all vec2 and I may need a couple of vec3 in the future - manually create a Buffer and attach it to the mesh via mesh.setVerticesBuffer() - I'm trying to figure out how to do it. InstancedMesh is using setVerticesBuffer(): https://github.com/BabylonJS/Babylon.js/blob/c5e53c8f89b115a4c151d8dfce2e9eba12bd08b6/src/Mesh/babylon.mesh.ts#L1387 I'm unsure how to use it with a typical, non-instanced mesh. I would be very thankful for an example. I wasn't sure whether to post in Bugs or Questions, please move the thread if you consider it more a question than a bug. EDIT: I figured out a way: var vertexBuffer = new VertexBuffer( this.engine, builtMesh.groundData, "test", false, false, 2); mesh.geometry!.setVerticesBuffer(vertexBuffer); But still, wouldn't it be more convenient with setVerticesData? Quote Link to comment Share on other sites More sharing options...
Guest Posted October 31, 2018 Share Posted October 31, 2018 Well I think that mesh.setVerticesData("test", data) should work. Do you have a repro of your issue in the PG? Quote Link to comment Share on other sites More sharing options...
bilgorajskim Posted October 31, 2018 Author Share Posted October 31, 2018 I know why it didn't work.. I was calling it like this: mesh.setVerticesData("test", builtMesh.groundData); When it should be this: mesh.setVerticesData("test", builtMesh.groundData, false, 2); The stride must be specified, otherwise Babylon will try to deduce it and fail. Logical. My bad. Problem solved Quote Link to comment Share on other sites More sharing options...
Guest Posted October 31, 2018 Share Posted October 31, 2018 Wonderful 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.