MarianG Posted August 11, 2018 Share Posted August 11, 2018 Hi.Short question Can we apply displacementMap to an importedMesh? I'm already haveing bump map on material I tried something, without succes. http://playground.babylonjs.com/#K2ES59 ps: I would like to have this feature. Thanks Quote Link to comment Share on other sites More sharing options...
Sebavan Posted August 12, 2018 Share Posted August 12, 2018 To apply displacement map on a mesh the current code requires to have positions, normals and UVs. Or the skull is not having any UVs defined. As a workaround, you can add uvs manually, or take a mesh with uvs for your tests. I ll see if I can easily remove the UV restriction from the code. Quote Link to comment Share on other sites More sharing options...
Sebavan Posted August 12, 2018 Share Posted August 12, 2018 Silliy me !!! This can not work without UVs as we require uv to know where to fetch in the displacement map ? Please, use a mesh which contains UVs to ensure it is working correctly. Quote Link to comment Share on other sites More sharing options...
MarianG Posted August 12, 2018 Author Share Posted August 12, 2018 Hi @Sebavan. Thanks for info. I tried, but it seems that all my meshes doesn't have set uvs, even if all of them have textures. So in this case maybe I can set uv manually? But how? Quote Link to comment Share on other sites More sharing options...
Sebavan Posted August 13, 2018 Share Posted August 13, 2018 You can use the function setVerticesData of the mesh to set any type of vertex data: https://www.babylonjs-playground.com/#15O3MB#5 Quote Link to comment Share on other sites More sharing options...
MarianG Posted August 13, 2018 Author Share Posted August 13, 2018 Ok, got it, http://playground.babylonjs.com/#K2ES59#1, no errors, but without effect too? Maybe wrong uv values? Quote Link to comment Share on other sites More sharing options...
Sebavan Posted August 13, 2018 Share Posted August 13, 2018 Yes, your uvs are wrong and not the good length as you can see here: http://playground.babylonjs.com/#K2ES59#2 (looking at the dev tools) So creating uvs by code for random shapes is almost sorcellery and I would advise you to use a 3d modeler for this task or only use models with uvs. I added some here just as an example: http://playground.babylonjs.com/#K2ES59#3 You can after easily use your displacement map: https://www.babylonjs-playground.com/#LYXHTH#11 Once you have all the required channels, you should be able to add your displacement map but you have to force update as loaded mesh are usually none updatable: http://playground.babylonjs.com/#K2ES59#6 MarianG 1 Quote Link to comment Share on other sites More sharing options...
MarianG Posted August 13, 2018 Author Share Posted August 13, 2018 Huge!!! Thanks @Sebavan It works exactly as expected. Quote Link to comment Share on other sites More sharing options...
MarianG Posted August 15, 2018 Author Share Posted August 15, 2018 Hi. I know I marked this as solved but I'm still missing something. I checked an object with 3ds max and it has uvs, but on babylonjs when looking for uv they are not there. I have to do something more for this getting this uv? Thank you Quote Link to comment Share on other sites More sharing options...
Sebavan Posted August 15, 2018 Share Posted August 15, 2018 Could you share one of your .babylon file with me ? Quote Link to comment Share on other sites More sharing options...
dogyear Posted October 6, 2018 Share Posted October 6, 2018 (edited) On 8/12/2018 at 1:55 AM, Sebavan said: To apply displacement map on a mesh the current code requires to have positions, normals and UVs. Or the skull is not having any UVs defined. As a workaround, you can add uvs manually, or take a mesh with uvs for your tests. I ll see if I can easily remove the UV restriction from the code. @Sebava sorry for the weird message. I messed up and accidentally hit enter Edited October 6, 2018 by dogyear accidentally hit enter XD Quote Link to comment Share on other sites More sharing options...
dogyear Posted October 6, 2018 Share Posted October 6, 2018 @Sebavan I am having the same issue with my imported mesh. My mesh definitely has normals and UVs, but I don't understand what you mean by, "...the code requires to have, position..." This may be what I am missing. Quote Link to comment Share on other sites More sharing options...
Sebavan Posted October 6, 2018 Share Posted October 6, 2018 @dogyear, are you sure it is related to this thread ? If yes, could you remind me the context of the question ? Quote Link to comment Share on other sites More sharing options...
dogyear Posted October 6, 2018 Share Posted October 6, 2018 @Sebavan I was actually alerted to this thread by another user, because I was having the same issue. I am trying to apply a displacement map on an imported mesh, but have had no success. I don't understand what I am doing wrong with regards to the applyDisplacementMap function. I have tried the code snippet below. I have also tried the same snippet and replacing the undefined with null, and I have omitted the last 4 paramters all together. None of those solutions worked. As another user wanted to make sure of on another thread, I confirmed that the mesh I am working with is indeed the correct mesh I am trying to apply the displacement map. I have also checked the network tab and the correct displacement map image is being loaded. It's just not reflected on the display. I have also confirmed that my mesh has position, UVs, and normals, but I only know how to confirm them in blender. In the console I can see my mesh has position, but I am unsure about UVs or normals. BABYLON.SceneLoader.ImportMesh('', 'assets/models/island/', 'island.babylon', scene, function (newMeshes) { var mesh = scene.getMeshByName('Island'); setTimeout(function(){ mesh.applyDisplacementMap('/assets/models/island/Sand_003_DISP.png', 0, 5, undefined, undefined, undefined, true); }, 2000) }); Quote Link to comment Share on other sites More sharing options...
Sebavan Posted October 6, 2018 Share Posted October 6, 2018 Oh I see, could you create a repro in the playground with your model I would would be way easier to troubleshoot ? Quote Link to comment Share on other sites More sharing options...
Sebavan Posted October 6, 2018 Share Posted October 6, 2018 I just checked and it seems all should work so having your playground will definitely help, (my test was http://playground.babylonjs.com/#K2ES59#7) Quote Link to comment Share on other sites More sharing options...
dogyear Posted October 6, 2018 Share Posted October 6, 2018 yea, sorry i'm taking so long. I'm trying to figure out how to work the playground. I don't see where to upload my babylon file Quote Link to comment Share on other sites More sharing options...
dogyear Posted October 6, 2018 Share Posted October 6, 2018 maybe you can take a look at the files generated by blender? island.zip 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.