Scaling Dynamic texture images to dynamic models?

Is there way to consistently map a texture image to a model such that I could dynamically generate a material to fit and not have it be tiled?

For example, here’s a playground where i generate a model of any size and can happily generate a custom texture image to fit, but I don’t want the texture to get tiled. I would like it wrapped from the center point of one side of the model and wrapped around the to the other side. I’m generating these models entirely from babylon based on the making a frame example. I’m having a hard time figuring out from the docs how to make this work. This example is using a packed texture from a different approach, but the idea is the similar. Any advice would be appreciated.

(Making A Frame | Babylon.js Documentation)

Hello and welcome to the Babylon community! You’ll need to generate custom UVs for your mesh: UV mapping - Wikipedia :smiley:

1 Like

Thanks for the hint, Carol. I thought I might have to go down the UV mapping route, but was hoping it might be avoidable.

I took a look at the UV maps in place on the generated model and they seem to be triangles and not square UVs like i’d usually expect to see? Do you think this might be a side effect of the way the frame builder example builds the meshes? or how the meshes get merged?

Update: those triangles inside the frame aren’t edges like I thought they were – they’re un-selectable within Blender. If I select each corner point of a given side, I can do a “New Edge/Face from Vertices” which does at least give me a consistent selectable face there.

I exported the glb and imported it into blender to get a better look.

I took a look at the GLB too now, the triangles are actually part of the plane that’s made and merged to the frame between lines 105 and 109 :smiley:

and yeah, the way the UVs are generated is a result of the frame construction, since it’s done automatically, it won’t be very optimized in every circumstance.

Thanks! Really just trying to put a face on the front portion with that plane. Not sure if there’s a better approach that wouldn’t result in the UVs being wacky

Oh yeah that’s perfectly fine :slight_smile: I did a bunch of checks and the UVs depend more on the shape of the ribbon (which is the primitive used to build the frames):

The frames without the extra face still look the same:

But this other ribbon example looks pretty ok:

Hello @unclek just checking in on things, would you like any more help on this?

Thanks for following up! I went down a bit of a rabbit hole and landed over UVs for ExtrudedPolygons? - #10 by JohnK using an ExtrudedPolygon approach.