Jump to content

applyDisplacementMap on importedMesh?


MarianG
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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

 

 

Link to comment
Share on other sites

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, 
image.png.398cdd658cc2b01e8f20594129c9abbe.png
but on babylonjs when looking for uv they are not there. I have to do something more for this getting this uv?
Thank you 

Link to comment
Share on other sites

  • 1 month later...
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 by dogyear
accidentally hit enter XD
Link to comment
Share on other sites

@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)
});
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...