Turn mesh into height field

   9755   3   0
User Avatar
Member
5 posts
Joined: Jan. 2017
Offline
Hi!

I just updated to 16 and now am experimenting around with the new Terrain tools. My problem is that I want to create a heightfield that is based on a nurbs shape and not square. However so far I have found no way to turn my triangulated nurbs into a terrain. Is there any way to solve my problem other than creating a normal heightfield and then cutting it to shape afterwards using booleans or something?

Something like an inverted Convert HeightField node would be ideal.
User Avatar
Member
147 posts
Joined: March 2014
Offline
afaik you cannot start with a piece of geo, but you can add geo to the heightfield with a heightfield_project node.

rob
Apprentice Attribute / Houdini 17.0.381 / GTX 970 - driver 411.63
User Avatar
Member
73 posts
Joined: Jan. 2009
Online
I am also interested in this has there been any new devlopments to be able to have a custom shape as a heightfield.
User Avatar
Member
436 posts
Joined: July 2005
Offline
Here you go. attributeVOP for displace along normals. hipnc ACSII attached.

VOP CVEX COde


//

#ifndef VOP_OP
#define VOP_OP
#endif
#ifndef VOP_CVEX
#define VOP_CVEX
#endif

#pragma opname dispAlongNormal_tX
#pragma oplabel “Local Vop Code”
#pragma opmininputs 1
#pragma opmaxinputs 1
#pragma label ptnum “Point Number”
#pragma hint ptnum invisible
#pragma range ptnum 0 10
#pragma label vtxnum “Vertex Number”
#pragma hint vtxnum invisible
#pragma range vtxnum 0 10
#pragma label primnum “Primitive Number”
#pragma hint primnum invisible
#pragma range primnum 0 10
#pragma label id Id
#pragma hint id invisible
#pragma range id 0 10
#pragma label numpt “Number of Points”
#pragma hint numpt invisible
#pragma range numpt 0 10
#pragma label numvtx “Number of Vertices”
#pragma hint numvtx invisible
#pragma range numvtx 0 10
#pragma label numprim “Number of Prims”
#pragma hint numprim invisible
#pragma range numprim 0 10
#pragma label Time Time
#pragma hint Time invisible
#pragma range Time 0 1
#pragma label TimeInc “Time Inc”
#pragma hint TimeInc invisible
#pragma range TimeInc 0 1
#pragma label Frame Frame
#pragma hint Frame invisible
#pragma range Frame 0 1
#pragma label life Life
#pragma hint life invisible
#pragma range life 0 1
#pragma label age Age
#pragma hint age invisible
#pragma range age 0 1
#pragma label OpInput2 “Second Input”
#pragma hint OpInput2 invisible
#pragma label OpInput3 “Third Input”
#pragma hint OpInput3 invisible
#pragma label OpInput4 “Fourth Input”
#pragma hint OpInput4 invisible
#pragma label OpInput1 “First Input”
#pragma hint OpInput1 invisible
#pragma label uv UV
#pragma hint uv invisible
#pragma label P P
#pragma hint P invisible
#pragma label v Velocity
#pragma hint v invisible
#pragma label force Force
#pragma hint force invisible
#pragma label Cd Cd
#pragma hint Cd invisible
#pragma label N N
#pragma hint N invisible
#pragma label map “map: Mandril.pic”
#pragma hint map image
#pragma label bias “Interpolation Bias”
#pragma range bias 0 1
#pragma label scale Scale
#pragma range scale -1 1
#pragma label basis “Noise Type”
#pragma choice basis “value_fast” “Value Noise | Fast”
#pragma choice basis “sparse” “Value Noise | Sparse Convolution”
#pragma choice basis “alligator” “Value Noise | Alligator”
#pragma choice basis “perlin” “Perlin”
#pragma choice basis “flow” “Perlin | Flow”
#pragma choice basis “simplex” “Simplex”
#pragma choice basis “worleyFA” “Worley/Cellular | F1”
#pragma choice basis “worleyFB” “Worley/Cellular | F2-F1”
#pragma choice basis “mworleyFA” “Worley/Cellular | Manhattan F1”
#pragma choice basis “mworleyFB” “Worley/Cellular | Manhattan F2-F1”
#pragma choice basis “cworleyFA” “Worley/Cellular | Chebyshev F1”
#pragma choice basis “cworleyFB” “Worley/Cellular | Chebyshev F2-F1”
#pragma label freq Frequency
#pragma label offset Offset


#include <pyro_utils.h>
#include <pyro_noise.h>


#include <voptype.h>
#include <voplib.h>

#include <voptype.h>
#include <voplib.h>

#include <shaderlayer.h>

#include <voptype.h>
#include <voplib.h>

#include <voptype.h>
#include <voplib.h>
cvex
obj_geo1_dispAlongNormal_tX(int ptnum = 0;
int vtxnum = 0;
int primnum = 0;
int id = -1;
int numpt = 0;
int numvtx = 0;
int numprim = 0;
float Time = 0;
float TimeInc = 0;
float Frame = 0;
float life = 0;
float age = 0;
string OpInput2 = “”;
string OpInput3 = “”;
string OpInput4 = “”;
string OpInput1 = “”;
vector uv = { 0, 0, 0 };
export vector P = { 0, 0, 0 };
vector v = { 0, 0, 0 };
vector force = { 0, 0, 0 };
vector Cd = { 1, 1, 1 };
export vector N = { 0, 0, 0 };
string map = “GProjectsLocal/MayaGP/sourceimages/cobblestone_disp.rat”;
float bias = 0.28299999999999997;
float scale = 1;
string basis = “value_fast”;
vector4 freq = { 4, 4, 4, 4 };
vector4 offset = { 0, 0, 0, 0 })
{
vector P_tmp;
vector v_tmp;
vector force_tmp;
vector Cd_tmp;
vector uv_tmp;
vector N_tmp;
vector uv_tmp1;
int bound_uv;
vector uv_tmp2;
int bound_uv1;
vector noise;
float x_avg;
float x_oct;
vector x_off;
float output1;
float output2;
float output3;
int bool1;
vector uv3;
vector result;
vector result1;
float fval1;
float fval2;
float fval3;
int bool2;
vector uv5;
vector result2;
vector result3;
float fval11;
float fval21;
float fval31;
vector result4;
vector _uv1;
vector4 clr1;
vector output11;
float fval12;
float fval22;
float fval32;
float scaled;
float blend;
vector dispP;
vector dispN;

// Code produced by: geometryvopglobal1
vector P1 = vector();
vector v1 = vector();
vector force1 = vector();
float age1 = 0.0;
float life1 = 0.0;
int id1 = 0;
vector Cd1 = vector();
vector uv1 = vector();
vector N1 = vector();
float Time1 = 0.0;
float TimeInc1 = 0.0;
float Frame1 = 0.0;
int ptnum1 = 0;
int primnum1 = 0;
int vtxnum1 = 0;
int numpt1 = 0;
int numprim1 = 0;
int numvtx1 = 0;
string OpInput11 = “”;
string OpInput21 = “”;
string OpInput31 = “”;
string OpInput41 = “”;
{

// Code produced by: geometryvopglobal1/P
P_tmp = P;

// Code produced by: geometryvopglobal1/v
v_tmp = v;

// Code produced by: geometryvopglobal1/force
force_tmp = force;

// Code produced by: geometryvopglobal1/Cd
Cd_tmp = Cd;

// Code produced by: geometryvopglobal1/uv
uv_tmp = uv;

// Code produced by: geometryvopglobal1/N
N_tmp = N;

// Code produced by: geometryvopglobal1/suboutput1
P1 = P_tmp;
v1 = v_tmp;
force1 = force_tmp;
age1 = age;
life1 = life;
id1 = id;
Cd1 = Cd_tmp;
uv1 = uv_tmp;
N1 = N_tmp;
Time1 = Time;
TimeInc1 = TimeInc;
Frame1 = Frame;
ptnum1 = ptnum;
primnum1 = primnum;
vtxnum1 = vtxnum;
numpt1 = numpt;
numprim1 = numprim;
numvtx1 = numvtx;
OpInput11 = OpInput1;
OpInput21 = OpInput2;
OpInput31 = OpInput3;
OpInput41 = OpInput4;
}

// Code produced by: unifiednoise1
noise = 0;
x_avg = 0;
x_oct = 0;
x_off = 0;

#if !strcmp(“v3”, f1)
#define rtype float
#define ptype float
#elif !strcmp(“v3”, f2)
#define rtype float
#define ptype vector2
#elif !strcmp(“v3”, default)
#define rtype float
#define ptype vector
#elif !strcmp(“v3”, f4)
#define rtype float
#define ptype vector4
#elif !strcmp(“v3”, fd)
#define rtype float
#define ptype vector
#elif !strcmp(“v3”, fd4)
#define rtype float
#define ptype vector4
#elif !strcmp(“v3”, v1)
#define rtype vector
#define ptype float
#elif !strcmp(“v3”, v2)
#define rtype vector
#define ptype vector2
#elif !strcmp(“v3”, v3)
#define rtype vector
#define ptype vector
#elif !strcmp(“v3”, v4)
#define rtype vector
#define ptype vector4
#elif !strcmp(“v3”, vd)
#define rtype vector
#define ptype vector
#elif !strcmp(“v3”, vd4)
#define rtype vector
#define ptype vector4
#endif

if(1)
{
float dfreq = 1;
if(1)
dfreq = (int)1;

#if !strcmp(“v3”, “fd”) || !strcmp(“v3”, “vd”)
int dual = 1;
ptype p1 = (ptype)(P1.rest * freq - offset);
ptype p2 = (ptype)(P1.rest2 * freq - offset);
float kp1 = P1.rest_ratio;
float kp2 = P1.rest2_ratio;
#elif !strcmp(“v3”, “fd4”) || !strcmp(“v3”, “vd4”)
int dual = 1;
ptype p1 = (ptype)P1.rest;
ptype p2 = (ptype)P1.rest2;
p1.w = P1.time;
p2.w = P1.time;
p1 = p1 * freq - offset;
p2 = p2 * freq - offset;
float kp1 = P1.rest_ratio;
float kp2 = P1.rest2_ratio;
#else
int dual = 0;
ptype p1 = (ptype)(P1 * freq - offset);
ptype p2 = (ptype)p1;
float kp1 = 1;
float kp2 = 0;
#endif

ptype tperiod = (ptype) { 10, 10, 10, 10 };

if(dual) {
}

#if 0
float fwidth1 = 0.0;
float fwidth2 = 0.0;
#else
float fwidth1 = VOPFW(p1);
float fwidth2 = dual ? VOPFW(p2) : fwidth1;
#endif

// unified_noise parms which we don't expose, since they're sort
// of covered by the output correction
int inv = 0;
float expon = 1.0;

float fmax = max(freq);
float lw = 0*fmax;
float fs1 = fwidth1 * 1;
float fs2 = fwidth2 * 1;
float e = max(0,expon);

rtype n1=0, n2=0;

string callname = basis;
if (1)
callname = “p” + callname;

if(“hmfT” == “none”)
{
if(kp1>0) n1 = unified_noise(callname, p1,inv,0,0,0, fs1,e,tperiod,
0,0, lw,dfreq,0,0,
x_avg,x_off);
if(kp2!=0) n2 = unified_noise(callname, p2,inv,0,0,0, fs2,e,tperiod,
0,0, lw,dfreq,0,0,
x_avg,x_off);
}
else
{
//printf(“%s\n”, basis);
if(kp1>0) n1 = unified_fractal_noise(“hmfT”, callname, p1,inv,0,0,0, fs1,e,tperiod,
0,0, lw,dfreq,0,0,
x_avg,x_off, //export args
3.1000000000000001,2.01234,0.24399999999999999, // fractal args
x_oct); // fractal export args
if(kp2!=0) n2 = unified_fractal_noise(“hmfT”, callname, p2,inv,0,0,0, fs2,e,tperiod,
0,0, lw,dfreq,0,0,
x_avg,x_off, // export args
3.1000000000000001,2.01234,0.24399999999999999, // fractal args
x_oct); // fractal export args
}

noise = n1*kp1 + n2*kp2;

noise = noise_cc(noise, 0,
0,{ 0.5, 0.5, 0.5 },
0,{ 0.5, 0.5, 0.5 },
0,{ 0, 0, 0 },{ 1, 1, 1 }, { 0.23000000000000001, 0.23000000000000001, 0.23000000000000001 });
}

#undef rtype
#undef ptype

// Code produced by: autoconvert
vop_vectofloat(noise, output1, output2, output3);

// Code produced by: uvcoords1
string _mode = “uv”;
vector uv2 = vector();
float u = 0.0;
float v2 = 0.0;
float w = 0.0;
{

// Code produced by: uvcoords1/compare1
bool1 = (_mode == “st”);

// Code produced by: uvcoords1/parm1
bound_uv = isbound(“uv”);
uv_tmp1 = uv;

// Code produced by: uvcoords1/s_t
#ifdef VOP_SHADING
uv3 = set(s, t, 0);
#else
uv3 = {0,0,0};
#endif

// Code produced by: uvcoords1/switch1
if( bound_uv == 0 )
result = uv3;
else
result = uv_tmp1;

// Code produced by: uvcoords1/st_mode
if( bool1 == 0 )
result1 = result;
else
result1 = uv3;

// Code produced by: uvcoords1/vectofloat1
vop_vectofloat(result1, fval1, fval2, fval3);

// Code produced by: uvcoords1/suboutput1
uv2 = result1;
u = fval1;
v2 = fval2;
w = fval3;
}

// Code produced by: texture1
vector _uv = uv2;
vector _duv = vector();
string _map = map;
int _udim = 1;
string _srccolorspace = “auto”;
string _wrap = “decal”;
string _filter = “gauss”;
float _width = 1;
float _blur = 0;
float _pixelblur = 0;
vector4 _border = { 0, 0, 0, 1 };
int _extrapol = 0;
int _interp = 0;
vector4 _defclr = { 0, 0, 0, 0 };
string _channel = “”;
int _ptexface = 0;
int _orient = 0;
vector4 clr = vector4();
{

// Code produced by: texture1/uvcoords1
string _mode1 = “uv”;
vector uv4 = vector();
float u1 = 0.0;
float v3 = 0.0;
float w1 = 0.0;
{

// Code produced by: texture1/uvcoords1/compare1
bool2 = (_mode1 == “st”);

// Code produced by: texture1/uvcoords1/parm1
bound_uv1 = isbound(“uv”);
uv_tmp2 = uv;

// Code produced by: texture1/uvcoords1/s_t
#ifdef VOP_SHADING
uv5 = set(s, t, 0);
#else
uv5 = {0,0,0};
#endif

// Code produced by: texture1/uvcoords1/switch1
if( bound_uv1 == 0 )
result2 = uv5;
else
result2 = uv_tmp2;

// Code produced by: texture1/uvcoords1/st_mode
if( bool2 == 0 )
result3 = result2;
else
result3 = uv5;

// Code produced by: texture1/uvcoords1/vectofloat1
vop_vectofloat(result3, fval11, fval21, fval31);

// Code produced by: texture1/uvcoords1/suboutput1
uv4 = result3;
u1 = fval11;
v3 = fval21;
w1 = fval31;
}

// Code produced by: texture1/ifconnected1
result4 = 1 != 0 ? _uv : uv4;

// Code produced by: texture1/null1
_uv1 = result4;

// Code produced by: texture1/inline1
if (_map != “”) {


#if defined(VOP_SHADING)
int fptex = 0 ? _ptexface : getptextureid();
#else
int fptex = _ptexface;
#endif
string wrapmode = _wrap;
if (_orient & 0x02) { _uv1.y = 1 - _uv1.y; }
if (_orient & 0x04) { float x = _uv1.x; _uv1.x = _uv1.y; _uv1.y = x; }
string _map_udim = _map;
if (_udim) { _map_udim = expand_udim(_uv1.x, _uv1.y, _map); }
if (_map_udim == ‘') { clr1 = set(_defclr); }
else {
if (_map_udim != _map) {
_uv1.x %= 1.0; _uv1.y %= 1.0;
wrapmode = ’streak';
}
if (_orient & 0x01) { _uv1.x = 1 - _uv1.x; }
if (0 != 0) {
vector tduv = 0.5 * _duv;
if (_orient & 0x04) { float x = tduv.x; tduv.x = tduv.y; tduv.y = x; }
clr1 = texture(_map_udim,
_uv1.x - tduv.x, _uv1.y - tduv.y,
_uv1.x + tduv.x, _uv1.y - tduv.y,
_uv1.x + tduv.x, _uv1.y + tduv.y,
_uv1.x - tduv.x, _uv1.y + tduv.y,
“wrap”, wrapmode, “filter”, _filter,
“width”, _width, “border”, _border,
“extrapolate”, _extrapol, “lerp”, _interp,
“channel”, _channel, “face”, fptex,
“blur”, _blur, “pixelblur”, _pixelblur,
“srccolorspace”, _srccolorspace);
} else {
clr1 = texture(_map_udim, _uv1.x, _uv1.y, “wrap”, wrapmode,
“filter”, _filter, “width”, _width,
“border”, _border, “extrapolate”, _extrapol,
“channel”, _channel, “face”, fptex,
“lerp”, _interp,
“blur”, _blur, “pixelblur”, _pixelblur,
“srccolorspace”, _srccolorspace);
}
}
} else {
clr1 = set(_defclr);
}

// Code produced by: texture1/suboutput1
clr = clr1;
}

// Code produced by: autoconvert
output11 = (vector)clr;

// Code produced by: vectofloat1
vop_vectofloat(output11, fval12, fval22, fval32);

// Code produced by: mulconst1
scaled = fval12 * 5;

// Code produced by: mix1
#ifdef __vex
blend = lerp(output1, scaled, bias);
#else
blend = mix(output1, scaled, bias);
#endif

// Code produced by: displacenml1
vop_displaceAlongNormal((1 != 0) ? P1 : P,
(0 != 0) ? vector() : normalize(N),
blend, scale, 0, 0,
1, 1, 0, dispP, dispN);

// Code produced by: geometryvopoutput1
vector _P = dispP;
vector _v = vector();
vector _force = vector();
vector _Cd = vector();
vector _N = dispN;
{

// Code produced by: geometryvopoutput1/P
P = _P;

// Code produced by: geometryvopoutput1/N
N = _N;
}
}

Attachments:
dispAlongNormal_tX_NC2.hipnc (3.9 MB)

  • Quick Links