Jump to content
konstantin magnus

Orient noise pattern along vectors

Recommended Posts

I have made some progress in making the wrinkles run towards the outer edges. Unfortunately i still get lots of warping issues that I can't quite explain.

box_wrinkles_curves.png.d03f628363f98989bb4b463b0609ef05.png

Ideally I want all folds to run in a parallel manner towards their nearest outer edge. This is the code I am currently using:

vector pos_b = minpos(1, v@P);

vector dir = normalize(pos_b - v@P);
vector rect = cross(v@N, dir);
vector nml = cross(dir, rect);
matrix3 rot = set(dir, nml, rect);

vector freq = {8, 1, 40};
vector pos = rot * v@P * freq;

float deform = noise(pos);
v@P += v@N * deform * 0.05;

folds_wrinkles_2.hiplc

Edited by konstantin magnus

Share this post


Link to post
Share on other sites

You should normalize your crossed vectors as they are not unit size.

Also, order of your operations matters. If you want to 'replicate' your tree on the left, then probably you would like to:

vector pos_b = minpos(1, v@P);

vector dir = rint(normalize(pos_b - v@P));
vector rect = normalize(cross(v@N, dir));
vector nml = normalize(cross(dir, rect));
matrix3 rot = set(dir, nml, rect);

vector freq = {8,1, 40};
vector pos = (rot * v@P) * freq;

float deform = noise(pos);
v@P += v@N * deform * 0.05;

 

Although that probably still would not solve your initial issue

Edited by tmdag

Share this post


Link to post
Share on other sites

Thanks for your help @tmdag. I had to invert the rotation matrix. So its:

vector freq  = chv('frequency');

vector dir   = normalize( minpos(1, v@P) - v@P );
vector rect  = normalize( cross(v@N, dir) );
vector nml   = normalize( cross(dir, rect) );
matrix3 rot  = set(dir, nml, rect);
float deform = noise(v@P * invert(rot) * freq);

v@P += v@N * deform * 0.05;

image.png.09c3b4a9cc71b054bb1fc775a2533c76.png

Edited by konstantin magnus
  • Like 1

Share this post


Link to post
Share on other sites

Hi. How about computing local space per primitive instead, and then get noise position from point position in the local space? Some sort of edge based UV unwrap.

// Primitive wrangle.

int pts[] = primpoints(0, @primnum);

// Compute averaged primitive normal from point normals computed from their neighbours.
vector normals[];
foreach (int pt; pts)
{
    vector normalized_edges[];
    vector pt_pos = point(0, "P", pt);
    foreach (int nb; neighbours(0, pt))
    {
        vector nb_pos = point(0, "P", nb);
        append(normalized_edges, normalize(pt_pos - nb_pos));
    }
    append(normals, normalize(avg(normalized_edges)));
}
vector normal = normalize(avg(normals));

// Compute edge tangent.
vector pt0 = point(0, "P", pts[0]);
vector pt1 = point(0, "P", pts[1]);
vector edge = normalize(pt0 - pt1);

// Compute bitangent and orthonormalize matrix.
vector perp = normalize(cross(normal, edge));
normal = normalize(cross(edge, perp));

3@tangent_space = set(perp, normal, edge);

Final deformation code:

// Point wrangle.

int prim;
xyzdist(1, @P, prim, set(0));
matrix3 tangent_space = prim(1, "tangent_space", prim);

vector pos = @P * invert(tangent_space);
float deform = noise(pos * {10,1,100}) * 0.05;
v@P += v@N * deform;

tangent_space_noise.thumb.png.f5e37e826559046ec17e33af19e3adbe.png

Some image sampling could work too:

tangent_space_mandril.thumb.png.567bcc043f4f1229c2f7e5d577c6921e.png

 

 

tangent_space_noise.hipnc

Edited by f1480187
  • Like 3
  • Thanks 1

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

×