Here’s the note that i would like to share with you to make spherical waves by Houdini using vex to create a sphere from a grid and project wavy lines on to the surface.
Concept:
Make some wavy lines on a 2D Plane 🠒 Project them onto a Sphere (which is made from the 2D Plance) 🠒 Create Stripes based on the generated waves.
Make waves
- To generate some 2d waves, we start by create a grid (in this example, i set up the grid orientation as ZX plane and connectivity as Columns).
- Next, we keep just the first Column by Delete SOP.
- Apply Resample Node with Maximum Segments of 13 (so we have 14 points on the line).
- Wrangle 01 – create waves by transform the position of P.x
float overall_speed = ch("overall_speed");
float leading_wave_speed = ch("leading_wave_speed");
@P.x += @Time * overall_speed;
if (@ptnum % 3 == 2)
{
@P.x += @Time * leading_wave_speed;
}
@P.x = clamp(@P.x,-5.0,5.0);
- The wave is now formed but it’s sharp. Therefore, we smooth it by convert the line to Nurb.
- Use Trail SOP to offset-clone the waves we’ve just made.
- We project the waves on to 2D grid by using vex function intersect
vector project_dir = chv("project_dir");
vector project_points;
vector uvw;
int primid = intersect(1, @P, project_dir, project_points, uvw);
if (primid >= 0)
{
@P = project_points;
@N = prim(1, "N", primid);
}
v@project_prim = primid;
v@project_uv = uvw;
- Now we convert the flat 2D Grid to sphere by writing vex code as follow:
vector relbox = relbbox(0,v@P);
float u = relbox.z;
float v = relbox.x;
float rad = ch("radius");
u *= (2*$PI);
v *= $PI;
float x = rad * sin(v) * cos(u);
float y = rad * sin(v) * sin(u);
float z = rad * cos(v);
v@P = set(x,y,z);
- Let’s put the 2D waves into first input of the Wrangle and the Sphere into the second and project the waves into the spherical geometry:
v@P = primuv(1, "P", i@project_prim, v@project_uv);