Flomotion Posted July 8, 2016 Share Posted July 8, 2016 Hi, I've created a box that should have flat shading (see box-good). But it displays in babylon as a shaded box. The model is distorted by bones. I tried mesh.convertToFlatShadedMesh(); but there's no difference. Are there any other ways to get rid of the shaded polygons? Or is there a way to adjust the phong angle in babylonjs? I really really hope so.. because the model is useless now. Thanks! Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted July 8, 2016 Share Posted July 8, 2016 Hummm..mesh.convertToFlatShadedMesh() should work...Can you share your code on the playground? Quote Link to comment Share on other sites More sharing options...
Flomotion Posted July 11, 2016 Author Share Posted July 11, 2016 I don't know how to load an external file into the playground.. I use BABYLON.SceneLoader.ImportMesh("", "http://flomotion.nl/cloudlab/cup/assets/", "cup.babylon", scene, function (newMeshes) { // Set the target of the camera to the first imported mesh camera.target = newMeshes[0]; }); but nothing happens. It's stuck at 'loading assets.. Quote Link to comment Share on other sites More sharing options...
V!nc3r Posted July 11, 2016 Share Posted July 11, 2016 From which 3d software do you export ? Quote Link to comment Share on other sites More sharing options...
Nabroski Posted July 11, 2016 Share Posted July 11, 2016 Hello I have absolutely no idea whats the answer to your question is. First of all you have to allow Crossorgin at your server. I created a playground for you for experimenting just to get started. I use googledrive coz i get used to it, but you can use any sharing service.(whit crossorgin) You should also check from time to time if your browser gives you some error messages. Press F12 (red text - not good).http://www.babylonjs-playground.com/#1BCGCE#2 Have Fun P.S 3,86Mb for a single cup - is a full playable game level. Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted July 11, 2016 Share Posted July 11, 2016 test this source that use shaderbuilder : mesh.material = new BABYLONX.ShaderBuilder() .Light({phonge:1.5,direction:'vec3(100.)',normal:BABYLONX.Normals.Flat}) .InLine('float l1 = length(result.xyz);') .Map({ path:'/textures/ground.jpg' }) .InLine('result = vec4(result.xyz*max(.2,l1),1.);') .BuildMaterial(scene); http://www.babylonjs-playground.com/#4XFH7#0 with light : x:100,y:100,z:100 http://www.babylonjs-playground.com/#4XFH7#1 for light from camera position this should be work Quote Link to comment Share on other sites More sharing options...
adam Posted July 11, 2016 Share Posted July 11, 2016 1 hour ago, Nabroski said: First of all you have to allow Crossorgin at your server. I'm not sure what you mean by that. You just have to prepend the url with https://crossorigin.me/ http://www.babylonjs-playground.com/#21XUBV#11 Edit: my bad. I thought you said crossorigin.me. Quote Link to comment Share on other sites More sharing options...
Nabroski Posted July 11, 2016 Share Posted July 11, 2016 8 hours ago, Flomotion said: I don't know how to load an external file into the playground.. I use BABYLON.SceneLoader.ImportMesh("", "http://flomotion.nl/cloudlab/cup/assets/", "cup.babylon", scene, function (newMeshes) { // Set the target of the camera to the first imported mesh camera.target = newMeshes[0]; }); but nothing happens. It's stuck at 'loading assets.. didn't work for me. also i want not so spend too much of my time on this, reload the file to my website was, the fastest solution. Best@adam send me a link with a good tutorial how to share files on one drive so their are accessible to the playground. i have tried it, but it didn't work. i think i have 5gb left. Quote Link to comment Share on other sites More sharing options...
adam Posted July 11, 2016 Share Posted July 11, 2016 Get the embed URL for the file like this (right-click the file in one-drive and select embed): https://onedrive.live.com/embed?cid=5EC364B914099C70&resid=5EC364B914099C70%2147288&authkey=AB-s0PufO_Yi68I Change "embed" to "download": https://onedrive.live.com/download?cid=5EC364B914099C70&resid=5EC364B914099C70%2147288&authkey=AB-s0PufO_Yi68I Then prepend https://crossorigin.me/ to make it work in the PG: https://crossorigin.me/https://onedrive.live.com/download?cid=5EC364B914099C70&resid=5EC364B914099C70%2147288&authkey=AB-s0PufO_Yi68I Quote Link to comment Share on other sites More sharing options...
Nabroski Posted July 11, 2016 Share Posted July 11, 2016 @adam i was running in the same error, kind of funny Did it in 70(High poly)http://www.babylonjs-playground.com/#LA4VD#8 Best Quote Link to comment Share on other sites More sharing options...
Nabroski Posted July 13, 2016 Share Posted July 13, 2016 @Flomotion Hello You have to add (at least) one loop cut at your model. See my 100kB example, if you convert the mesh to flatshadet (see code: chage to "useFlatShading":true) you will notice their are 2lines, mostly not visible, but they are their. Press Debug Layer you see i have 900 vertices, if i want not get rid of the 2 lines, i have to add more loopcuts this will look much better, but i will run the same model (shape) at 10200 vertices (mean: much more computer power). As long this element is only a subelement, i can live with those two lines. also if i add color or textures, nobody will recognize those two lines. But still at some vertices count no graphic engine will ever gives you more then you put it. less in, less out. So i hope to share my experience, will help u. Best 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.