iiceman Posted July 26, 2015 Share Posted July 26, 2015 Hey folks, I was playing around with a custom version of a mesh outline that (so I hoped) would work a bit better as the normal mesh.renderOutline. It all looked pretty good until I tried it with a cylinder: http://www.babylonjs-playground.com/#E51MJ#8 It seems that the sideOrientation is not applied correctly for the cylinder. Or am I doing something wrong here? Bonus question: could I somehow just clone the original mesh and set the sideOrientation for the cloned version or is it only possible to set that in the constructor? It didn't seem to work when I tired setting it after the mesh is created. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted July 26, 2015 Share Posted July 26, 2015 for bonus question: No so far the only way is throught the constructor Your technique is great but won't work for custom objects loaded from .babylon right? Quote Link to comment Share on other sites More sharing options...
iiceman Posted July 26, 2015 Author Share Posted July 26, 2015 Yeah, it probably won't if we can't set the side oriantation for a loaded mesh. But if we could do that, I don't see why it wouldn't work for loaded meshes as well. Is it technically possible to change the side orientation of a mesh afterwards and just not available yet? Or is there a problem doing it on the fly and that's why it's not possible at all? Quote Link to comment Share on other sites More sharing options...
iiceman Posted July 26, 2015 Author Share Posted July 26, 2015 Hmm.. I tried and failed horribly: http://www.babylonjs-playground.com/#E51MJ#9 Why doesn't it work? Am I doing something wrong when I try to invert the side orientation or is there another problem why this can't work and I just don't realize it? Quote Link to comment Share on other sites More sharing options...
jerome Posted July 27, 2015 Share Posted July 27, 2015 for cylinder backside orientation : As the cylinder implementation was changed just some days ago (ribbon based now) in order to fix the "seam" normal issue (light artifact), maybe something has been forgotten in the code or maybe the underlying ribbon is simply wrapped the opposite way on the cylinder shape. We need to check this. Quote Link to comment Share on other sites More sharing options...
ozRocker Posted July 27, 2015 Share Posted July 27, 2015 It would be neat if there was a fix for normal renderOutline when it comes to text. I get this kind of effect: The outline seems to be on a different Z plane than the plane the text is on Quote Link to comment Share on other sites More sharing options...
jahow Posted July 27, 2015 Share Posted July 27, 2015 Hey iiceman, There's a method for flipping faces now:mesh.flipFaces(flipNormals? : boolean)If that can make your life easier As for the cylinder implementation, if I'm not wrong the new one still haven't been implemented in the playground. Take a look at this: http://www.babylonjs-playground.com/#1S6POH#5Still the good ol' seam, right? And that is consistent with your observations, since the old implementation didn't handle side orientation. iiceman and jerome 2 Quote Link to comment Share on other sites More sharing options...
iiceman Posted July 27, 2015 Author Share Posted July 27, 2015 @jahow: sweet, works like a charm: http://www.babylonjs-playground.com/#E51MJ#10 but it's not really the perfect result for the outline... too bad, guess it's just not possible for complex imported meshes. About the cylinder: I'll check again somewhen. I'll let you know here if it finally works with the new cylinder version. Quote Link to comment Share on other sites More sharing options...
jahow Posted July 27, 2015 Share Posted July 27, 2015 Yeah, your idea is good, but I think it requires a convex mesh or something like that. Of course the best outlines are made using screen-space shaders, but this would probably be tricky to implement Quote Link to comment Share on other sites More sharing options...
iiceman Posted August 1, 2015 Author Share Posted August 1, 2015 Uhm.. the playgorund from the inital post now looks even more weird http://www.babylonjs-playground.com/#E51MJ#8 I assume thats not supposed to happen, right? Quote Link to comment Share on other sites More sharing options...
jahow Posted August 1, 2015 Share Posted August 1, 2015 Oops, that's definitely a bug in the new CreateCylinder code... Will fix this ASAP. Thanks iiceman!! iiceman 1 Quote Link to comment Share on other sites More sharing options...
iiceman Posted August 6, 2015 Author Share Posted August 6, 2015 Okay, the bug seems to be fixed but somehow the side orientation of the top and the bottom of the cylinder doesn't work quite yet. Is that... fixable? http://www.babylonjs-playground.com/#E51MJ#11 Quote Link to comment Share on other sites More sharing options...
jahow Posted August 6, 2015 Share Posted August 6, 2015 Oh god, I forgot about those... I swear, I'll never mess with the meshes again Will fix ASAP EDIT: also, since we're talking about cylinders, it's not visible in your PG but the normals on the side of the cylinders are tilted. Jerome, if you're around.... help!! Quote Link to comment Share on other sites More sharing options...
iiceman Posted November 28, 2015 Author Share Posted November 28, 2015 Did anything about the flipFaces function change? I am playing around with it again to create an outline. I clone a mesh and then flipFaces on the cloned mesh. But somehow it flips the faces of the original mesh, too. Is that intended behavior? I don't remember that it was like this before. You can see it here: http://www.babylonjs-playground.com/#E51MJ#16 Edit: or maybe it's not the flipFaces but the clone function that changed? I found this playground where I try to flip the faces manually on a cloned mesh and it seems to have the same result: http://www.babylonjs-playground.com/#E51MJ#9 Edit2: It seems that the geometry is shared between the original mesh and the cloned one... I think that is the whole sense of cloning. So I deduce that's how it's meant to be. But somehow I remember I made it work here: http://p215008.mittwaldserver.info/space/ - if you hover over an asteroid it gets the outline like that:asteroid.customOutline = asteroid.clone('customAsteroidOutline');asteroid.customOutline.isVisible = false;asteroid.customOutline.isOutline = true;asteroid.customOutline.scaling = new BABYLON.Vector3(1.1, 1.1, 1.1);asteroid.customOutline.material = new BABYLON.StandardMaterial('outlineMaterial', scene);asteroid.customOutline.material.diffuseColor = new BABYLON.Color3(1, 0, 0);asteroid.customOutline.material.emissiveColor = new BABYLON.Color3(1, 0, 0);asteroid.customOutline.material.specularColor = new BABYLON.Color3(0,0,0);asteroid.customOutline.material.alpha = 0.7;Any idea why that doesn't seem to work anymore? I jsut tried with the old version that I used back then, but somehow I still can't get it to work in my new project. Not sure what I am doing wrong. I am so confused Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 28, 2015 Share Posted November 28, 2015 Hello IIceman, the clone shares the same geometry as its source. So updating geometry on one will impact the other Quote Link to comment Share on other sites More sharing options...
iiceman Posted November 28, 2015 Author Share Posted November 28, 2015 Hi DK, I just edited my post after figuring that out so far. But I still don't understand how I made it work back then. Is there a way to really copy a mesh? Can I somehow avoid that they share the same geometry? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 28, 2015 Share Posted November 28, 2015 You can use something like mesh.getVerticesData and then create a new mesh using these vertexData Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 28, 2015 Share Posted November 28, 2015 Like: clone.geometry= source.geometry.copy() Quote Link to comment Share on other sites More sharing options...
iiceman Posted November 28, 2015 Author Share Posted November 28, 2015 I tried that and it almost worked but something didn't seem right.this.highlightedMesh = new BABYLON.Mesh('outline', scene);var vertexData = new BABYLON.VertexData();vertexData.positions = mesh.getVerticesData(BABYLON.VertexBuffer.PositionKind);vertexData.indices = mesh.getIndices();vertexData.normals = mesh.getVerticesData(BABYLON.VertexBuffer._NormalKind);var clonesGeometry = new BABYLON.Geometry(mesh._geometry.id + '_clone', this.scene, vertexData, false, this.highlightedMesh);vertexData.applyToMesh(this.highlightedMesh, false);I'll try that copy, that sounds promising, thanks. I'll try that tomorrow and let you know how it went Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 29, 2015 Share Posted November 29, 2015 ok, send a PG if you need help Quote Link to comment Share on other sites More sharing options...
iiceman Posted November 29, 2015 Author Share Posted November 29, 2015 I guess I do. I tried copying the geometry like you suggested: http://www.babylonjs-playground.com/#83MVD#0 But it looks like it still flips the original, too. What did I do wrong? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 30, 2015 Share Posted November 30, 2015 Tadammm http://www.babylonjs-playground.com/#83MVD#1 Quote Link to comment Share on other sites More sharing options...
iiceman Posted November 30, 2015 Author Share Posted November 30, 2015 ooohhwww... I see, thanks! Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted November 30, 2015 Share Posted November 30, 2015 why dont use frensel for that ? http://www.babylonjs.com/cyos/#2KUJ1T jerome 1 Quote Link to comment Share on other sites More sharing options...
iiceman Posted November 30, 2015 Author Share Posted November 30, 2015 Might be a cool alternative, thanks Nasimi! Maybe on of you shader pros can make a cool outline shader! Not sure how hard it is since I stoll don't know much about shaders 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.