Jump to content

Cylinder sub meshes


royibernthal
 Share

Recommended Posts

I'd like to have different textures on different sides of a cylinder, as depicted in this image:

cylinder.png.ce7e0ff6ce8b5be5e7f7ab0584fe999b.thumb.png.f52b275b25a0b629af59477c0c865771.png

A cylinder has 3 faces to the best of my understanding, so with faceUV, I'm only able to divide it into top, middle and bottom. Even if it was possible for me to have "4" faces, I'd need at least the middle to divide into 2 textures from different sources that are not part of a texture atlas, which means faceUV would most likely not be a good solution for this anyway.

https://www.babylonjs-playground.com/#CWPN2T#6

When trying to apply a multimaterial to submeshes, it seems I'm unable to capture the required indices in order to assign each different submaterial to each different face, not to mention dividing the middle face into 2 as well.

 

Any ideas?

Link to comment
Share on other sites

Oh, this is really worse than just that.  This is not possible outside of some-kind of texture atlas implemented in the fragment shader.  Reason is at the borders, you need one duplicate vertices, one for each textures / materials meeting.

When an exporter (Blender / 3DSMax) make multi-materials, not only do they sort vertices to be continuous, but write duplicates.  The real answer is to use an exporter.  Blender can easily make cylinders, & mult-imaterials.  I am not going to teach people how to use it.  Any dev should have a basic understand of at least one exporting app, for just this reason.  It is child's play for them.

Link to comment
Share on other sites

48 minutes ago, JCPalmer said:

Reason is at the borders, you need one duplicate vertices, one for each textures / materials meeting.

Does that part refer to the issue of dividing the middle part into 2?

 

What if we merge 3 and 4 and have only top, middle (undivided) and bottom, would I still need an exporter?

Link to comment
Share on other sites

You would have to look at how the top and bottom are made.  Are they re-using vertices from the side.  If so then no.  You would also need to check that top, bottom, and center are contiguous.  You could still not need to use an exporter, if you copied / edited the CreateCylinder code to get valid results. 

If the middle is contiguous, you might also just make 3 meshes.  It is the same number of draw calls.

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