Search the Community
Showing results for tags 'facet'.
-
Hi ladies and Gentlemen, Here comes a new feature in the FacetData pack. As you may know, for performance reasons, the facets of a given mesh are always drawn in the same order. This comes to visual issues when the mesh is transparent and is no longer oriented in the right place from the camera : http://playground.babylonjs.com/#FWKUY0 This new feature solves the self transparency issue by sorting the mesh facets from some location (the camera position by default) just before drawing them. The mesh is required to be updatable. The depth sort is done on each call to updateFacetData(). It can be disabled at any time to save CPU cycles if the mesh and the camera don't move any more. Usage : // the mesh must be updatable var mesh = BABYLON.MeshBuilder.CreateTorusKnot("mesh", {updatable: true}, scene); mesh.material = mat; // transparent material mesh.mustDepthSortFacets = true; // enable the depth sort, can be disabled at any time scene.registerBeforeRender(function() { mesh.updateFacetData(); // sort the facets each frame }); Note that this feature uses more memory and more CPU than an usual standard mesh. Please wait for the code review and the PR to be merged and to be pushed in the PG. Demo : http://jerome.bousquie.fr/BJS/test/facetDepthSort.html
- 8 replies
-
- facet
- depth sort
-
(and 1 more)
Tagged with:
-
Hello, Raycast TerrainMap and get MixMap %'s? CONTEXT: Raycast over a Terrain Map... and determine the type of terrain (floor, rock, grass, etc) where the Ray Intersects mesh. Looking at Mixed-Map-Materials and Facet-Data... QUESTION: is there a way, to get the MixMap through a Raycast Intersection? Or any suggestions on detecting floor, rock, grass... thx. Kind regards, UPDATE: using this playground, stepping into raycast... http://www.babylonjs-playground.com/#7CPS7 Found: results[0].pickedMesh, pickedPoint, collisionGroup, looking around... : ) .subMeshes.materialIndex?... DEMO-TEST: fork Multi-Map playground and add the touch raycast. : ) Worked perfectly - Clickable Multi Map playground (debugger on cast): https://www.babylonjs-playground.com/#E6OZX#7 looking around... AbstactMesh.collisionGroup? faceId? UPDATE: idea of how to do this, need to get the mixmap.png rgb at the location of the getTextureCoordinates()...greatest intensity wins. And... looks like Context2D can do that... (perhaps) https://www.babylonjs-playground.com/#1UCP5L#5
-
Hey guys, I'm thinking there's a really simple answer to this, but I'm currently blanking on it. Basically, I'm trying to position/rotate a cylinder such that it is perpendicular to a given facet. Here's the PG: https://www.babylonjs-playground.com/#U8ZVF8 It looks like it works for facets on part of the sphere (maybe?), but there's clearly something I'm missing. Thanks in advance!
-
Hi Folks, I'm proud to introduce a brand new feature already integrated in the BJS core : FacetData This feature provides some methods to access and to play with mesh facets. Facets are the elementary triangles drawn by WebGL. We call them "facets" here in order to be not confused with the term "faces" : a box has 6 squared planar faces but each face is drawn with 2 facets (triangles). In bulk, you've got : mesh.updateFacetData(); // enables the feature or recompute things mesh.disableFacetData(); // disables it mesh.isFacetDataEnabled; // boolean, as it says ... mesh.facetNb; // number of facets mesh.getFacetPosition(i); // gives the world position of the i-th facet mesh.getFacetNormal(i); // gives the world normal values of the i-th facet mesh.getClosestFacetAtCoordinates(x,y,z); // gives the index of the closest facet to (x,y,z) in the world // etc ... and plenty of other fun tools to play with ! Please have a read at the doc (it should be in the section "Advanced Tutorials" of the doc site as soon as Monday the 23rd of January... if @RaananW accepts my bribes) and at the provided PG examples. For those who cares, all the facet indexes here are the same than the ones used by the object PickingInfo or the pickable SPS, called there faceId. So you can easily mix all these different features. Example : to get the normal of the facet from a picked point on a mesh. Have fun