dogyear Posted October 4, 2018 Share Posted October 4, 2018 Hi Everyone! I am new to babylonJs and for the life of me can't figure out how to export a mesh that contains a displacement map. Does the blender exporter support displacement maps? If no then how can I apply a displacement map after the mesh has been exported to babylonJs? I have tried the following code after importing the mesh. Again I would prefer it if I can just export the mesh with the displacement mapping, but if that's not possible then I would like to apply it after it has been imported to babylonJs. BABYLON.SceneLoader.ImportMesh('', 'assets/models/island/', 'island.babylon', scene, function (newMeshes) { newMeshes[0].applyDisplacementMap('/assets/models/island/Sand_003_DISP.png', 0, 5); }); Quote Link to comment Share on other sites More sharing options...
MarianG Posted October 4, 2018 Share Posted October 4, 2018 Hi @dogyear. Welcome I don't know if you can directly export your mesh with displacement map . Hope somebody with more experience with this can help. But I think I know why it doesn't work to add displacement after import, few months ago I had same problem. Please take a look at this topic To apply displacement map on a mesh, this should have positions, normals and UVs. dogyear 1 Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted October 4, 2018 Share Posted October 4, 2018 Blender exporter does export displacement maps at this time. You need to specify true for the forceUpdate parameter. An exported JSON (.babylon) is essentially a serialized mesh dogyear 1 Quote Link to comment Share on other sites More sharing options...
dogyear Posted October 4, 2018 Author Share Posted October 4, 2018 @MarianG Thanks. I do have UVs and normals set on my meshes. I'm not sure what I am doing wrong because I'm most likely doing something wrong. @JCPalmer Cool! Do you know how can I export the displacement maps? I have set the displacements on my blender texture, but they don't export with the babylon file. Here's what my blender looks like Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted October 4, 2018 Share Posted October 4, 2018 Since the exporter does not support it, you would have to add it. Kind of a waste of my time outlining any changes, since there does not seem like it can be serialized. Parse() is what is called to deserialize an exported mesh. See not place where a url can be taken from the data & call applyDisplacementMap() for you. Quote Link to comment Share on other sites More sharing options...
dogyear Posted October 4, 2018 Author Share Posted October 4, 2018 @JCPalmer ah... You must've miss typed because your original reply said the exporter does support exporting displacement maps. I got really excited lol! It would've made things so much easier as I know much more about Blender than BabylonJs. Oh well. Your tip seems simple enough. I'll do the force update when get home tonight. Thank you for the pointer! ? Quote Link to comment Share on other sites More sharing options...
dogyear Posted October 5, 2018 Author Share Posted October 5, 2018 @JCPalmer It tried adding true at the end, but nothing seems to happen. Going through the playground reveals a lot of examples with imported meshes that just doesn't work. I've also tried replacing the nulls with undefined without success. Are there other boilerplate code that must be present? BABYLON.SceneLoader.ImportMesh('', 'assets/models/island/', 'island.babylon', scene, function (newMeshes) { newMeshes[0].applyDisplacementMap('/assets/models/island/displace.png', 0, 5, null, null, null, true); }); Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted October 5, 2018 Share Posted October 5, 2018 Be absolutely sure that is the mesh you think it is. The number of times someone got this wrong is huge. Either console.log the mesh name, or better scene.getMeshByName('victim').applyDisplacementMap(...) Next check console that your file is actually being found. If this does not work, then a topic in the Q & A, might be better, since this is not really a blender issue. Quote Link to comment Share on other sites More sharing options...
dogyear Posted October 6, 2018 Author Share Posted October 6, 2018 @JCPalmer Thanks for all your help so far. I have tried what you suggested and it seems I was targeting the correct mesh. When I check my console tab, the applyDisplacementMap function was loading my displacement map image, but the displacement is still not being applied. I will move this question to Q&A after scouring that section for more info. ^__^ 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.