al404 Posted August 12, 2016 Share Posted August 12, 2016 I'm correctly loading a spaceship mesh with his material, but the ship looks dark even if other object are bright I guess it could be emissiveColor or diffuseColor so i try to edit that property spaceship = spaceshipMeshes[0]; spaceship.material.diffuseColor = new BABYLON.Color3(1.0, 0.2, 0.7); spaceship.material.emissiveColor = new BABYLON.Color3(1, .2, .7); i set 2 value from material example if i use this code my script stops without errors and display the ship but doesn't continue is not possible to edit material properties? i'm doing it the wrong way? material is loaded with .obj i attach my spaceship screenshot ( texture is almost white where it looks grey ) and console log of spaceship Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted August 12, 2016 Share Posted August 12, 2016 newload.onSuccess = function (task) { $.each(task.loadedMeshes, function(i,e){ var positions = e.getVerticesData(BABYLON.VertexBuffer.PositionKind); var indices = e.getIndices(); var normals = e.getVerticesData(BABYLON.VertexBuffer.NormalKind); BABYLON.VertexData.ComputeNormals(positions, indices, normals); e.updateVerticesData(BABYLON.VertexBuffer.NormalKind, normals, true, true); BABYLON.VertexData.ComputeNormals(positions, e.getIndices(), normals); ... fixed a similar problem I was having gryff 1 Quote Link to comment Share on other sites More sharing options...
gryff Posted August 12, 2016 Share Posted August 12, 2016 @al404 If you have "grey areas" on your mesh then it can be solved by importing your spaceship into Blender and "recalculating normals outside" . Then export as a .babylon file. Or you can use the code @Pryme8 is suggesting which seems to be recalculating normals. The.obj file format has been around a long time but you will find often find issues with normals -particularly older models. cheers, gryff Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted August 12, 2016 Share Posted August 12, 2016 The models will load more efficiently when from a system that exports an mtl with it. Quote Link to comment Share on other sites More sharing options...
al404 Posted August 12, 2016 Author Share Posted August 12, 2016 i did not specify but it has a .mtl with it the problem is that i don't know how to use blender even for basic tasks i bought the model and it comes with blender source too but when i open it i doesn't load the texture, i guess is only a path issue, i can try to look in it i guess it , because in .mtl file the texture path was referred to windows hard disk since was something like with D:\path\texture.png i can also remove the texture link in the .mtl file and manually apply the texture in babylon if this can help Pryme8 1 Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted August 12, 2016 Share Posted August 12, 2016 @gryff, do you think a exporter option 'Ignore Normals' for .BABYLON exporter, or 'Normals Post Load' for .JS exporter is a good idea to reduce media size? Would have to be coordinated with 'Flat shading' though. FYI, shape keys require flat shading be done on export. Quote Link to comment Share on other sites More sharing options...
Nabroski Posted August 12, 2016 Share Posted August 12, 2016 Not supported currently Smoothing groups (s parameter in OBJ file) Illumination (illum parameter in MTL file) The differents options for loading textures in MTL file. A good description about MTL file and his options could be found here: http://paulbourke.net/dataformats/mtl/ Possible Solution Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted August 12, 2016 Share Posted August 12, 2016 18 minutes ago, JCPalmer said: @gryff, do you think a exporter option 'Ignore Normals' for .BABYLON exporter, or 'Normals Post Load' for .JS exporter is a good idea to reduce media size? Would have to be coordinated with 'Flat shading' though. FYI, shape keys require flat shading be done on export. yes I think that would save on media size, and if we are recalculating natively why hold that data in the first place? it would be cool to have the object importer handle the normal recalculation as well instead of having to do it on the asset load. Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted August 12, 2016 Share Posted August 12, 2016 Sorry, hate to admit, but I do not even know what .obj or object importer are. Probably should not have changed the subject. Do not what 4 minutes ago, Pryme8 said: why hold that data in the first place? means. This really does need to be optional though. Flipping normals need to be honored, when say you wish the inside of a box be the 'outside'. Would upgrade .babylon exporter to 'Normals Post Load' as well, if someone handles the BJS side. With computer built in-line code, I can do anything I want, no .babylon file rules to deal with. Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted August 12, 2016 Share Posted August 12, 2016 eh, im starting to realize with BJS having your normal's on the model on export are really moot. You can recalc them in a fraction of a second and tell babylon how to handle them by the face rendering properties. Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted August 12, 2016 Share Posted August 12, 2016 4 hours ago, Pryme8 said: newload.onSuccess = function (task) { $.each(task.loadedMeshes, function(i,e){ var positions = e.getVerticesData(BABYLON.VertexBuffer.PositionKind); var indices = e.getIndices(); var normals = e.getVerticesData(BABYLON.VertexBuffer.NormalKind); BABYLON.VertexData.ComputeNormals(positions, indices, normals); e.updateVerticesData(BABYLON.VertexBuffer.NormalKind, normals, true, true); BABYLON.VertexData.ComputeNormals(positions, e.getIndices(), normals); FYI, the 2nd ComputeNormals should be pulled out. Does nothing but waste time. Implemented. I found that a Mesh with: num positions : 11322 num normals : 0 num uvs : 22644 num uvs2 : 0 num colors : 0 num indices : 51432 this reduced the media file by 225 kb. It increased the instancing time by 0.8 seconds. Pryme8 1 Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted August 12, 2016 Share Posted August 12, 2016 need to revise. 0.8 seconds is way wrong. It is just 0.01 seconds. Pryme8 1 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted August 12, 2016 Share Posted August 12, 2016 So its defiantly effective. GameMonetize 1 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.