Sign in to follow this  
MarianG

applyDisplacementMap on importedMesh?

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
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

 

 

Share this post


Link to post
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 

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

@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.

Share this post


Link to post
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)
});

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.