Sign in to follow this  
yLacaute

Set texture per face of loaded mesh

Recommended Posts

I am stuck. And mad.

  • I don't mange to apply textures on loaded mesh (@Pryme8 I understand nothing to your PG which is too complicated for me to just set a f*#!#g texture, please note I am beginner)
  • I tried to apply 2 repeated textures on Blender : it works "inside blender" but when I export : i lose the repeat option

The video shared above show "a way of doing" by adapting textures to a shape : you build one image with all inside. I understand this can be useful for a complete object (a character for example) but I would like the opposite : I have a plane (with 2 faces) and each face should be attached to a texture (with offset and repeat option). As I already have a lot of textures, I want to exploit them and NOT create a new image containing existing texture. If many objects share the same texture, I load it many times, that has no sense for me. A solution could be to put ALL textures in a single image, but same, that is a crazy solution, the single image will become unusable (the hell to edit it).

Currently, I fail on the simplest possible export :

  • Blender > new plane
  • Blender > add material > add texture from image > repeat x = 2
  • Blender rendering : it works
  • Export
  • Babylon > load > I see my texture, but without repeat option

I can't find any good tutorial for basic things... please help :blink:

My objectif is still the same as the first comment here : get a plane with 2 faces with 2 different textures applied (but now textures are directly applied in Blender instead of in babylonjs)

Share this post


Link to post
Share on other sites

So perhaps let's try to go back to the initial goal.

You want to edit a mesh to apply two textures. based on faces right?

So you need to first build a multimaterial made of 2 materials (one per face)

and then create subMeshes (like in the doc I sent you) to split your mesh per face:

https://www.babylonjs-playground.com/#4ZTUVS

 

Share this post


Link to post
Share on other sites

@Pryme8 I am using physicImpostors so I try to limit the number of mesh for performance, that's why I did not 2 planes :)

I just succeed to import a plane from Blender, with 2 textures on it with repeat option. But there is something strange :  the rendering in Blender is not the same than in BabylonJS. I played with the size property to repeat the textures (as explained here http://doc.babylonjs.com/resources/blender#textures) but the result is that the exported file is not exactly the same as the rendered view in Blender. See attached images.

@Deltakosh You applied materials on a mesh created with Babylon, and all problems are coming when you applied materials from an imported mesh : you can't do the same as in your PG from what I have understood.

 

babylon_render.jpg

blender_render.jpg

Share this post


Link to post
Share on other sites
12 minutes ago, yLacaute said:

@Pryme8 I am using physicImpostors so I try to limit the number of mesh for performance, that's why I did not 2 planes :)

I just succeed to import a plane from Blender, with 2 textures on it with repeat option. But there is something strange :  the rendering in Blender is not the same than in BabylonJS. I played with the size property to repeat the textures (as explained here http://doc.babylonjs.com/resources/blender#textures) but the result is that the exported file is not exactly the same as the rendered view in Blender. See attached images.

@Deltakosh You applied materials on a mesh created with Babylon, and all problems are coming when you applied materials from an imported mesh : you can't do the same as in your PG from what I have understood.

 

babylon_render.jpg

blender_render.jpg

try
mesh.material.diffuseTexture.uOffset = 0.5;

Looks like the offsets are different for some reason.

Share this post


Link to post
Share on other sites
18 minutes ago, Deltakosh said:

This is the point here: why is it not working on a mesh imported from blender? does it have more faces?

That is exactly why I opened this topic : why ? :D
Here is the PG : https://www.babylonjs-playground.com/#JQDPT6#6
You can see it is easy to put a texture on a Babylon box, not in an imported plane from Blender.

Keep in mind I am still speaking with a newbie langage, when i speak about "face" I speak about "face I I can select in blender" not "triangle" (So in the PG above, the plane is composed with 2 rectangular faces, but more triangles)

Share this post


Link to post
Share on other sites

What the... Great !!
I must admit I used random 0 or 1 just to try with a length of 36... 

Have to undertand now and find the good values, I will update the PG with the final result, with exactly what I wanted :)

Thank you !!
 

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.