Wrapping seamless generative texture to a 3D object

Hi all,

I have a generative texture made in GLSL which I would like to seamlessly wrap around a 3D model. The 3D model in question is just a free model of a human head I grabbed from somewhere.

I think I’ll first have open the model in Blender and unwrap the UV map so that I’ll have the correct shape for the texture. Then I’ll use the unwrapped shape as a canvas for the GLSL and set the GLSL output as the texture of the 3D model.

I just can’t figure out the best way to handle the seams of the texture. With a cylinder shape it is trivial as an unwrapped cylinder is just a rectangle and I can easily loop the UV values around on all the sides of the texture.

But what should I do if the unwrapped texture is something like this:
uv_unwrapsample

It has several seams and I need a way to connect the correct seam pairs together somehow in the GLSL code.

Any tips?

Well unfortunately there is no perfect solution if your glsl texture is 2d in nature, you have two paths:

A) you pull the left and right edges of the face to the sides of the uv space like a “pelt map” as it’s called sometimes in 3d/uv world. This can make your texture tile, but will introduce warping/distortion. some uv tools have the options to pin certain uv’s, and relax the rest, so maybe look into doing that in blender or elsewhere if you are ok with overall distortion.
image

B) you have minimal distortion, but seams, as you showed in your image.

A third option, but one that may not be applicable is to convert your glsl texture into a 3d texture, and feed it the world space position of the mesh as it’s uvw coords. at that point the glsl texture would not need to loop, as it would be using the inherent coordinates of 3d space. not all generative textures can be translated into 3d though, but something to consider!

1 Like

here’s an example of doing 3d noise using xyz coordinates
3dNoise.1.toe (1.1 MB)

1 Like

Thanks Lucas!

That 3d texture solution sounds perfect. I’ll have to investigate if that could be applied to my texture.

If that doesn’t work, maybe I can manage with the method A. But how should I handle the rest of the seams (green)?
Untitled

No problem!

There’s not a clean solution to the green areas. Invariably when flattening a 3d model into 2d space you have to make some trade offs.

You could sew some of those seams up so that you at least have just the vertical split down the back of the head instead of the split + those 2 T splits above the forehead and below the chin.

You could try to make the seams less distracting by making a mask in pshop or elsewhere that darkens the generative texture as it approaches those seams, or you could use that mask to fade into a similar looking 3d textured effect as it approaches the seams.

If you’re making use of lit surfaces, you could try and hide those areas by lighting them less, or placing geometry around / over them. Angling the camera so that they are less visible.

If you’re only viewing the face from the front, I think most of those seams will be hidden anyways

If you want ‘apparently seamless’ you could borrow the cross fade technique from making seamless video loops.

Essentially that would involve giving the points near seams an extra set of UVs and feathering the edges You can make a custom shader and a feathering attribute to blend them, or create an extra texture image with alpha and comp it over the texture in 2d.

Hiding the seams is not enough for this application because the texture I want to wrap around the object is made with a reaction diffusion algorithm. It uses a 3x3 kernel to determine the value of the current pixel so I would need a way for it to continue that kernel over the seams.

I haven’t had time to test the 3d texture method yet, but I think it would solve this problem if I can find out a way to implement that 3x3 kernel in UVW-space.