Letting textures flow seamlessly across UV islands by pre-storing UV sampling positions on a separate map. An invoke block inside COPs picks up the offsets to sample from the input texture to create a streaking effect.
An unwrapped polygon mesh with several UV islands indicated by green boundary edges. The gradient vectors pointing along the surface towards the top will define the streaking directions.
1. Input texture: A grayscale texture contains a few drops from noise created in world space.
2. UV Offsets: A vector map stores the UV sampling positions of the surface positions slightly shifted by the surface gradients.
3. Streaking texture: The input texture is sampled iteratively on the location defined by the offset map.
4. Recolouring: The grayscale streaking texture gets its final color from a custom color ramp.
This VEX code calculates the position offset on the mesh surface based on a radius
parameter and the gradient
vector and maps the resulting position to UV coordinates. It uses the relative bounding box position of the 2D image volume, finds the closest position on the mesh surface via UV distance, offsets the position along the gradient, and outputs the final UV coordinates to the uvw attribute.
float radius = chf('radius');
vector bb = relbbox(0, v@P);
vector uv = set(bb.x, bb.y, 0.0);
int pr;
vector st;
uvdist(1, 'uv', uv, pr, st);
vector pos = primuv(1, 'P', pr, st);
vector grad = primuv(1, 'gradient', pr, st);
pos += normalize(grad) * radius;
pos = xyzdist(1, pos, pr, st);
vector uvw = primuv(1, 'uv', pr, st);
v@uvw = uvw;
Added a COP only version.