Pryme8 Posted August 2, 2016 Share Posted August 2, 2016 So what would cause every object that I import from c4d always has a flat grey shading to it with no lights casting on them? Is it a normal issue or a light rendering issue? Quote Link to comment Share on other sites More sharing options...
chicagobob123 Posted August 2, 2016 Share Posted August 2, 2016 Reaching from the memory isnt there Specular color that controls what it looks like when light its it? Nabroski 1 Quote Link to comment Share on other sites More sharing options...
RaananW Posted August 2, 2016 Share Posted August 2, 2016 Hi @Pryme8, could you show an example? I can only assume that it is your export process (as babylon has no "flat shader". it simply recalculates the normals in a different way). You could try recalculating the normalsafter loading the object, see if it helps. Pryme8 1 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted August 3, 2016 Author Share Posted August 3, 2016 I will try the normal recalculate. EDIT** Ive tried several ways to do this none with any effect, can you give me and example of what you mean maybe Im going about it differently. Does anyone have a good reference for the structure of an fbx file? I want to add fbx and c4d support to the object importer. Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted August 3, 2016 Author Share Posted August 3, 2016 wk.tools.modelPrep.loadModel = function(target, cse){ if(!target || !cse ){return false;} this._target = target; this._cse = cse; var loader = this._cse._scene.loader; var file = this._target.files[0]; console.log(file); var newload = loader.addMeshTask("newModel", "", "./files/test_model/", file.name); var parent = this; newload.onSuccess = function (task) { $.each(task.loadedMeshes, function(i,e){ e.renderingGroupId = 2; }); buildObjectList(task.loadedMeshes, parent._cse); }; loader.load(); it also seems once I apply a new material to the object and change its diffuse color nothing seems to be happening? even though if I look at my scene object and mesh object everything is right. ***EDIT correction the colors do work, I was just making one too close to the default Textures seem to work though, weird... anyways once I can fully figure out why they look like that I can wrap up this tool, but till then im finishing up the features like physics rigging, and animations then and object sterilizer that gets ran through my proprietary compression algorithm, and saved as a .kong file which has a loader that will put what ever you built into your scene with one string call, textures, riggins, animations, controls ect... with a built in CORS loader tailored for github, so you can host your kong files there... Quote Link to comment Share on other sites More sharing options...
RaananW Posted August 3, 2016 Share Posted August 3, 2016 So, recalculating normals: var positions = mesh.getVerticesData(BABYLON.VertexBuffer.PositionKind); var normals = mesh.getVerticesData(BABYLON.VertexBuffer.NormalKind); BABYLON.VertexData.ComputeNormals(positions, mesh.getIndices(), normals); Dunno if it will work, have no idea how the mesh is constructed. Which can also be the problem. About the material not being applied, it would be great to see a live example to understand what's going on there. Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted August 3, 2016 Author Share Posted August 3, 2016 $.each(task.loadedMeshes, function(i,e){ e.renderingGroupId = 2; var positions = e.getVerticesData(BABYLON.VertexBuffer.PositionKind); var normals = e.getVerticesData(BABYLON.VertexBuffer.NormalKind); BABYLON.VertexData.ComputeNormals(positions, e.getIndices(), normals); }); did not do anything :-(... well I would like to show you a live demo but unfortunately I am not trying to put these scripts online yet for licensing reasons. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted August 4, 2016 Share Posted August 4, 2016 If there is no light in your scene your objects must be black UNLESS you define material.emissive OR scene.ambientColor Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted August 9, 2016 Author Share Posted August 9, 2016 nope there is a light in my scene, it just seems like the normal are not being calculated correctly or something... maybe I need to have a normal tag on my obj in c4d for when I export it? **Edit, ok I have done everything I can think of... Ive recalculated the normal's, Ive reversed them (in bjs and in c4d), Ive added lights tried different methods... Im now coming to the conclusion that there is something happening in the obj import process..https://doc.babylonjs.com/tutorials/Lights but it still looks like they calculate like back faces no matter what i do. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted August 9, 2016 Share Posted August 9, 2016 Do you have a way to share it on the playground? Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted August 10, 2016 Author Share Posted August 10, 2016 possibly a similar method, let me see what I can whip up. What is the url for an obj embedded on the playground? Preferably one with no mtl file. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted August 11, 2016 Share Posted August 11, 2016 There is a bunny.obj: http://www.babylonjs-playground.com/#1P98HI#86 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted August 11, 2016 Author Share Posted August 11, 2016 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 it thank you. 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.