Jump to content

Multi-part obj dynamic texturing best practices


iif
 Share

Recommended Posts

Hello everyone,

First of all, thanks for all the amazing contents I managed to find here. It really helped me to understand better how BJS works.

Background :

I am much more a back-end developer, so excuse me if I lack (too much) knowledge about front-end or 3D modeling.

Anyway, I learned some Unity and Unreal by myself and built several Unity applications (no games, regular mobile apps, Augmented Reality apps, ...) so I understand a bit how 3D modeling works (textures, UV maps, normal maps, materials, baking, ...).

I am thinking about using BJS, but can't set a tech stack until I am sure that it can answer all my needs. That's why I started building some POCs with BJS.

The need : 

To make it quick : I have an application where I want to integrate a frame with a single 3D object (with BJS). I want to interact with this object and change its look just by clicking on a button in the interface (in less than a second would be great).

The objects will be multiparts : for example, the obj of a table would include a feet part and a top part. I want to be able to change the top part and the feet part textures/mats separately.

I need the result to be in very high quality and to display fast enough (but since I don't want to build a full world, just a single object, I hope this will be OK).

What I understood / What I tried :

Thanks to some tutorials/samples, I loaded some models from .babylon or .obj files , in the Sandbox or in a local application. I managed to change mats for these meshes using some code of the "rabbit sample" (glass, metal, ... materials).

If I'm not wrong, I'll be able to change textures (with a .jpg or .tga file), the behaviour of light (to create metalic, glass, wood or plastic behaviour), the color, ... with something like :

mesh.material.diffuseTexture = new BABYLON.Texture(texture, scene);

or

var mat = new BABYLON.PBRMaterial("clay", scene);
mat.cameraExposure = exposure;
mat.cameraContrast = contrast;
mat.microSurface = 0.06;
mat.reflectivityColor = new BABYLON.Color3(0.5, 0.9, 0.9);
mat.albedoColor = new BABYLON.Color3(0.5, 0.5, 1);

Plus, if I understood well, I can "isolate" my mesh after it's instanciation with a "onSuccess" event, to be able to access it easily after loading the page (or loading a new item).

I am planning to create a scene from scratch and add just a simple background and lights to make the object looks great by itself :).

Here is what I didn't understood (or not sure about that) :

Q1 : what's the good way to load an object and to identify every sub-part of it ?

For example, if my (lovely and friendly) graphical artists build and export an .obj "object1" with 2 sub-parts called "obPart1" and "obPart2" with Maya or 3DSMax, what's the best way to interact with obPart1 and obPart2 after loading object1 in BJS ?

Q2: Am I forced to play with many maps for one object, or can I obtain sufficient result using multi-part object and a BABYLON.PBRMaterial for each sub-part ?

Q3 : What's the main difference between using a .obj or a .babylon ? I would clearly prefer to directly use .obj files (to stay closer to standards and avoid to use plugins) but would I miss something that I couldn't replace in my BJS scene (like a light...) ?

Q4 : If I am smart enough (crossing fingers), I should be able to display a glossy wood and a not glossy one with only one .jpg texture, just by having 2 different BABYLON.PBRMaterial, right ? Am I wrong if I am thinking about doing the same thing to have a blue wood and a pink one (erm ... why not ?) ?

Q5 : Last but not least : if I am smart enough (crossing fingers to death), I could build a back-office where I can upload .obj or .babylon, identify sub-parts of it, chose wich texture/mat can be applied on which sub-part, and use all of this in the "display" part of the application. I may be a dreamer (but i'm not the only one ...) but if I didn't miss some main specifications, I believe that this could be achieved with a clever architecture. Am I mad to think about that ?

 

I (really) searched in this forum (and some others) and in the documentation, sorry if I missed the answers (or didn't understood the words I read).

I am much more used to back-end technologies so I may have not been as efficient as I use to be, but I'll learn fast ;).

Feel free to tell me if I understood some parts wrong.

Thanks a lot for your experience and answers :).

Link to comment
Share on other sites

Hey!

q1: how these subparts are defined? two different objects? Then use names to find them. If using submeshes (one mesh and multiple material) then you can get sub part using mesh.submeshes[]

q2: I see no problem to use multi-part objects (assuming you are mentioning submeshes)

q3: .babylon file are far more rich. But if .obj are more convenient go ahead :) please note that .babylon file can be saved with multiple parts per mesh (submeshes) where .obj don't

q4: Correct

q5: I can't see why you cannot do that :)

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