Pryme8 Posted February 16, 2018 Share Posted February 16, 2018 Does the Obj importer support alpha on the diffuseTexture with the mtl file and if so how do I use it? Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted February 16, 2018 Author Share Posted February 16, 2018 So basically I know this has been asked before... but Im not sure how he got to his solution after reading through this: Is what I am getting right now and this is my mtl file: # WaveFront *.mtl file (generated by CINEMA 4D) newmtl Trunk_oak Kd 0.80000001192093 0.80000001192093 0.80000001192093 map_Kd bark1_color.jpg illum 7 newmtl Leafs_Oak Kd 0.80000001192093 0.80000001192093 0.80000001192093 map_Kd branch1_color.png Ks 1 1 1 Ns 43.219 illum 7 Ive done this in the past by stripping out the mtl file and just assigning the materials manually, but I am trying to avoid that. Quote Link to comment Share on other sites More sharing options...
Guest Posted February 16, 2018 Share Posted February 16, 2018 I don't think it is supported Do you know how we can detect if the diffuse has alpha? Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted February 18, 2018 Author Share Posted February 18, 2018 I would assume if its a extension that supports alpha we could assume it has it? so like png's automatically get that added? Quote Link to comment Share on other sites More sharing options...
Guest Posted February 20, 2018 Share Posted February 20, 2018 Yes and no Yes because it will work but no because it will turn alpha blending on on all meshes using this texture which will drastically slow down the rendering (not mentioning the depth sorting issues) Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted February 21, 2018 Author Share Posted February 21, 2018 hmmm so, maybe once the texture is loaded from the mtl file test a few pixels for alpha or not. So like every corner the middle and like every 1/6th width/height point so like 36 points which would be minimal load but if any of the points tick off as having an alpha other then 1 then you know there is an alpha pass? Maybe I am just over complicating this. Quote Link to comment Share on other sites More sharing options...
Guest Posted February 21, 2018 Share Posted February 21, 2018 Not necessarily Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted February 21, 2018 Author Share Posted February 21, 2018 We could also script in like BJS specific strings in the mtl files that our parser could handle. https://github.com/BabylonJS/Babylon.js/blob/master/loaders/src/OBJ/babylon.objFileLoader.ts#L152 So like add else if(key=='bjs_alpha' && material){ if(value==1){...}else{} }else if(key=='bjs_alpha_pass' && material){ ... } Quote Link to comment Share on other sites More sharing options...
Guest Posted February 21, 2018 Share Posted February 21, 2018 I'm not opposed to this idea. Fancy trying to update the mtl loader? Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted February 21, 2018 Author Share Posted February 21, 2018 I'm in it to win it yes sir! If I can find some time today I will do a PR. Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted February 21, 2018 Author Share Posted February 21, 2018 @Deltakosh What is some good info I can look up on the alpha depth sorting and all other things alpha pass, so this PR is a success. Quote Link to comment Share on other sites More sharing options...
Guest Posted February 21, 2018 Share Posted February 21, 2018 Ha! here is the reference: http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered I try to keep it as complete as possible Pryme8 1 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted February 21, 2018 Author Share Posted February 21, 2018 https://github.com/BabylonJS/Babylon.js/pull/3801 One of these days I need to figure out how to build my custom branch, so I can test changes before I submit a pull. Quote Link to comment Share on other sites More sharing options...
brianzinn Posted February 21, 2018 Share Posted February 21, 2018 If you run "gulp typescript-compile" you could then copy the files in /dist/preview release/ to a project to test out, but you can also run a local playground server. Maybe I didn't understand your question, though. Pryme8 1 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted February 21, 2018 Author Share Posted February 21, 2018 I might have to harass you about this at some point. If I get some time Ill see about setting this up and if I have any problems ill pm you. Its tough to submit PR's without even getting to test it. Cause otherwise its like hmmm cross your fingers and hope you know what you are doing. 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.