FreeFrags Posted October 24, 2014 Share Posted October 24, 2014 Is it possible to only render the points in a mesh? I might be mistaken but looking at the code its only possible to render as a triangle mesh. Quote Link to comment Share on other sites More sharing options...
FreeFrags Posted October 24, 2014 Author Share Posted October 24, 2014 I thought i would try rendering spheres using instancing, but the page becomes unusably slow after like 60.000 meshes. Since i want to be able to show a "point cloud" which is larger im still looking for better options. var spheres = [];//i put this somewhere in my initspheres.push(BABYLON.Mesh.CreateSphere("sphere", 2.0, 0.05, scene));var indexY = 0;function OnTestInstancing() { var index = 0; for (var indexX = 0; indexX < 100; indexX++) { for (var indexZ = 0; indexZ < 100; indexZ++) { var newInstance = spheres[0].createInstance("i" + index); newInstance.position = new BABYLON.Vector3(indexX * 0.2, indexY, indexZ * 0.2); index++; } } indexY += 0.5;} Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 24, 2014 Share Posted October 24, 2014 You can ask for wireframe rendering like this: http://playground.babylonjs.com/#1KVF8R Quote Link to comment Share on other sites More sharing options...
FreeFrags Posted October 27, 2014 Author Share Posted October 27, 2014 Im having trouble viewing examples in the playground sent a PM to ask what this could be. If the example shows how to render the actual triangle mesh then its not what i was looking for. i would like to render only the vertices and be able to change the size of the "points". I looked in the code but judging from this line (287 in babylon.mesh.ts): engine.draw(useTriangles, useTriangles ? subMesh.indexStart : 0, useTriangles ? subMesh.indexCount : subMesh.linesIndexCount, instancesCount); it looks like this isnt possible only a choice between "solid" and "wireframe". But if im wrong please could you point me in the right direction. Quote Link to comment Share on other sites More sharing options...
FreeFrags Posted October 28, 2014 Author Share Posted October 28, 2014 Im still figuring out how to compile babylon but i believe we would need something like the following added to the engine in order to get this working. public drawNew(drawAs: number, start: number, count: number, instancesCount?: number): void { // Apply states this.applyStates(); // Render switch (drawAs) { case this._gl.LINES: case this._gl.TRIANGLES: { if (instancesCount) { this._caps.instancedArrays.drawElementsInstancedANGLE(drawAs, count, this._gl.UNSIGNED_SHORT, start * 2, instancesCount); } else { this._gl.drawElements(drawAs, count, this._gl.UNSIGNED_SHORT, start * 2); } } break; case this._gl.POINTS: { this._gl.drawArrays(drawAs, start, count); } break; } }This code isnt tested at all yet, and it doesnt use the instances for the points ... but if i manage to learn how to compile the TS to JS so i can test it before one of our pros comments ill post my updated code. im using Visual studio here Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 28, 2014 Share Posted October 28, 2014 great thanks!!! Quote Link to comment Share on other sites More sharing options...
FreeFrags Posted October 29, 2014 Author Share Posted October 29, 2014 I havent had time to figure out and read about how to compile babylon and how to submit a patch. So if anyone would like to use this code/idea to create a patch please do i hope i will have some time soon Quote Link to comment Share on other sites More sharing options...
FreeFrags Posted November 5, 2014 Author Share Posted November 5, 2014 Hi All I managed to add the ability to render a mesh as points to the engine. I forked the repo, i would appriciate it if this would be added to the official repo after a review https://github.com/FreeFrags/Babylon.js it is very easy to use i hope this is enough info for you to test it out if not please tell me and ill create a test page. Usage:Add this to your pixelshader:gl_PointSize = pointSize;On your material set:shadedMaterial.drawAs = WebGLRenderingContext.POINTS; //TRIANGLES draws a solid mesh Lines Draws the triangle mesh Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 5, 2014 Share Posted November 5, 2014 Hey that's great! Can you submit a PR so that I will be able to easily review it. Did you test on all modern browsers? Quote Link to comment Share on other sites More sharing options...
FreeFrags Posted November 7, 2014 Author Share Posted November 7, 2014 Well I tested with IE and Chrome, if it needs to be tested with any others pls tell me and i will. Quote Link to comment Share on other sites More sharing options...
FreeFrags Posted November 7, 2014 Author Share Posted November 7, 2014 Created a small test video: When i have something more interesting to show ill upload a new video Quote Link to comment Share on other sites More sharing options...
joshcamas Posted November 8, 2014 Share Posted November 8, 2014 Cool! This will be perfect for a vertex editor in my samacEditor! I tried making something like this and failed terribly. Amazing work! Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 11, 2014 Share Posted November 11, 2014 I've just pushed the release.Now you can enable point rendering with:sphere.material.pointsCloud = true;sphere.material.pointSize = 5; Carlos R 1 Quote Link to comment Share on other sites More sharing options...
joshcamas Posted November 11, 2014 Share Posted November 11, 2014 Awesome!!!!! Quote Link to comment Share on other sites More sharing options...
FreeFrags Posted November 14, 2014 Author Share Posted November 14, 2014 Cool thank you hope you guys enjoy using it. Quote Link to comment Share on other sites More sharing options...
joshcamas Posted November 14, 2014 Share Posted November 14, 2014 Would it be possible to have both wireframe and dots enabled? Quote Link to comment Share on other sites More sharing options...
FreeFrags Posted November 17, 2014 Author Share Posted November 17, 2014 @joshcamas Ill look in the modified code which got merged into babylon for you. But i can tell you in the changes i sent this would not be possible. I believe that when you set the mesh to be rendered as points, you should not have to set the indices (you could but it should ignore them). Why would you ask well, if i only want to render points the indices are irrelevant (And a waste of memory). That being said i cant see why it shouldnt be technically possible to render both the points and triangles. But it will require some more modifications. If its not too much work ill see if i can modify it and make a new pull request, but to be honest my interest is currently focused on something else (http://www.html5gamedevs.com/topic/10449-updateverticesdatadirectly/). So please feel free to look at it yourself and give it a try, i know many users will be great full if you add new functionality like that. Quote Link to comment Share on other sites More sharing options...
FreeFrags Posted November 17, 2014 Author Share Posted November 17, 2014 @Deltakosh hi i believe there might be a small bug, or im not using it in the correct way. the following code results in a solid mesh.sphere.material.pointsCloud = true;sphere.material.pointSize = 5;the following code does result in the point cloud.sphere.material.fillMode = BABYLON.Material.PointFillMode;thanks again Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 20, 2014 Share Posted November 20, 2014 This works well for me:http://www.babylonjs-playground.com/#OCR2S Quote Link to comment Share on other sites More sharing options...
nittrus Posted October 15, 2016 Share Posted October 15, 2016 On 11/20/2014 at 4:24 PM, Deltakosh said: This works well for me: http://www.babylonjs-playground.com/#OCR2S This is now broken in 2.5-beta Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 17, 2016 Share Posted October 17, 2016 And fixed..Thank you for having catch it! 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.