Jump to content

HUD-FUI-UI-DESIGN IN HOUDINI


Librarian

Recommended Posts

in this order
 

int dim = sqrt(@numelem);
vector pos = set(@elemnum%dim,@elemnum/dim)/(dim-1);

float point_spacing = 1.0/(dim-1) + 0.00001;
pos -= {0.5,0.5};
if (length(pos)*2<0.9*noise(pos*5.1)*@Time){
int pt = addpoint(0,pos);
setpointattrib(0,"pt_sp",pt,point_spacing);
}
int near_pts[] = pcfind(0,"P",@P,@pt_sp,999);

if (len(near_pts)<chi("fate"))
@Cd = hsvtorgb(dot(@P,{1,1,1}),1,1);
else @Cd = {0,0.1,0};
vector pos = @P;
i@class = pcfind (1,"P",pos,1000,2)[0];
@Cd = rand(@class);
int pts[] = pcfind(0,"P",@P,@pt_sp,999);
i[]@pt= pts;
int near_pts;
int class;

foreach(int pt; pts){
    int bool = @class == point(0,"class",pt);
    if(bool) near_pts++;
    }
    
    
    
if(near_pts<chi("fate")) 
@P.z += 0.001*@class+0.3;
else 
@Cd ={0,0.1,0};
int pts[] = pcfind(0,"P",@P,@pt_sp+ch("r"),999);
i[]@pt= pts;
int near_pts;
int class;

foreach(int pt; pts){
    int bool = @class == point(0,"class",pt);
    if(bool) near_pts++;
    }
    
    
    
if(near_pts<chi("fate")) 
@P.x -= 0.7;

//@P.z += 0.001*@class+0.1;
else {@P.x -=1.4;}
int pts[] = pcfind(0,"P",@P,@pt_sp,999);
i[]@pt= pts;
int near_pts;
int class;

foreach(int pt; pts){
    int bool = @class == point(0,"class",pt);
    if(bool) near_pts++;
    }
    
if(@P.z == 0 && near_pts<chi("fate")){
    @P.z += 0.1;
    @Cd = {1,0,0};
    }
    else if(@P.z == 0.1) @Cd = rand (@class);

foreach
 

int pts[] = pcfind(0,"P",@P,@pt_sp,999);
i[]@pt = pts;
int near_pts;
int class;
foreach(int pt; pts){
    int bool = @class == point(0,"class",pt);
    if(bool) near_pts++;
    }
    
float u =float(detail(1,"iteration"))/(detail(1,"numiterations")-1);
if(@P.z == 0 && near_pts<chi("fate")){
    @Cd = rand(@class);
    @P.z += 0.1*chramp("ramp",u);
    }

 

cfunsgsuuyyyssssff.gif

sgsgsgsgsg.jpg

Link to comment
Share on other sites

cut any dir
 

string in0 = @OpInput1;
int nprims = nprimitives(in0);

int op;
string operation = chs("keep");
if(operation == "above")op= 1;
if(operation == "below")op= 2;
else op= 0;

vector cutDir = normalize(chv("cutDir"));
vector cutOrigin = chv("cutOrigin");
float dist = ch("dist");

//////////////////////////////////////////////////////////////////

for(int primnum = 0; primnum < nprims; primnum++)
{
    int vers[] = primvertices(0, primnum);
    int length = len(vers);
    
    int border=0;
    int prim0pts[];
    int prim1pts[];
    int numNewPts = 0;
    
    // check if this mesh is split
    for(int i = 0; i< length; i++)
    {
        int srcPoint = vertexpoint(in0, vers[i]);
        vector srcP = point(in0, "P", srcPoint);
        vector srcPDir = normalize(srcP - cutOrigin);
        
        float dot = dot(cutDir, srcPDir);
        
        if(dot<=0)border += 1;
    }
    
    // if it is not cut, maybe remove and done.
    if(border == 0)
    {
        if(op == 2)removeprim(geoself(),primnum,1);
        //        continue;continue;
    }
    else if(border == length)
    {
        if(op == 1)removeprim(geoself(),primnum,1);
        //continue;
    }
    
    else
    {
        // cut mesh
        int srcPoint;
        float srcDot;
        
        for(int i = 0; i< length; i++)
        {
            int hedge = vertexhedge(in0, vers[i]);
            
            //int primary = hedge_isprimary(in0, hedge);
            //if(primary == 0)continue;
            
            int destVtx = hedge_dstvertex(in0, hedge);
                    
            srcPoint = vertexpoint(in0, vers[i]);
            int destPoint = vertexpoint(in0, destVtx);
            vector srcP = point(in0, "P", srcPoint);
            vector destP = point(in0, "P", destPoint);
            
            vector srcPDir = normalize(srcP - cutOrigin);
            vector destPDir = normalize(destP - cutOrigin);
            srcDot = dot(cutDir, srcPDir);
            float destDot = dot(cutDir, destPDir);
            
            if(srcDot > 0)
            {
                push(prim0pts, srcPoint);
            }
            else if(srcDot == 0)
            {
                push(prim0pts, srcPoint);
                push(prim1pts, srcPoint);
            }
            else if(srcDot < 0)
            {
                push(prim1pts, srcPoint);
            }
            
            
            if((sign(srcDot) != sign(destDot)) && srcDot != 0 && destDot != 0)
            {
                //@Cd=set(float(i)/length, float(border)/length, 0);
                float bias = -destDot/(srcDot - destDot);
                int newPt = addpoint(geoself(), lerp(destP, srcP, bias));
                push(prim0pts, newPt);
                push(prim1pts, newPt);
        
                numNewPts += 1;
            }
        }
        
        
        
        // remove original mesh, and add 2 meshes which cover original
        
        removeprim(geoself(),primnum,1);
        if(op != 2)
        {
            int newPrim = addprim(geoself(), "poly");
            foreach(int pt; prim0pts)
            {
                addvertex(geoself(), newPrim, pt);
            }
        }
        if(op != 1)
        {
            int newPrim = addprim(geoself(), "poly");
            foreach(int pt; prim1pts)
            {
                addvertex(geoself(), newPrim, pt);
            }
        }
    }
}

alpha+info

 

cut.jpg

e90.hiplc

info.jpg

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...
  • 2 weeks later...

thanx To Asia Forums

Hm How to make this In Vex????

 

from math import cos,sin
geo = hou.pwd().geometry()
poly = geo.createPolygon()
for i in range (36):
    t = -6.2*i/36.0
    p = cos(t),sin(t),0
    point = geo.createPoint()
    point.setPosition(p)
    poly.addVertex(point)
    
dim = 30
 
    
bbx= poly.boundingBox()
min= bbx.minvec()
max = bbx.maxvec()
    
for point in poly.points():
        p = point.position()
        p[0]=hou.hmath.fit(p[0],min[0],max[0],3,dim-3)
        p[1]=hou.hmath.fit(p[1],min[1],max[1],3,dim-3)
        p[2]-=0.1
        point.setPosition(p)
        
        
group_inside = geo.createPointGroup('inside')
group_outside=geo.createPointGroup('outside')
group_all = geo.createPointGroup('all',1)




for i in range(dim*dim):
    index = hou.Vector3(i%dim,i/dim,0)
    point = geo.createPoint()
    point.setPosition(index)
    group_all.add(point)
    dir = hou.Vector3(0,0,-1)
    pos_out = hou.Vector3()
    normal_out = hou.Vector3()    
    uvw_out = hou.Vector3()
    inside=geo.intersect(index,dir,pos_out,normal_out,uvw_out)
    if(inside+1):
        group_inside.add(point)
    else:
        group_outside.add(point)
        
    
def extend(point,dist):
    points = []
    dist = int(dist)   
    p = point.position()
    
    
    ori = p-hou.Vector3(dist,dist,0)
    dim0 =1+2*dist
    n = int(dim0*dim0)
    for i in range(n):
        p= ori+hou.Vector3(i%dim0,i/dim0,0)
        num= int(p[1]*dim+p[0])
        points.append(group_all.iterPoints()[num])
    return points
    
geo.addAttrib(hou.attribType.Point,'Cd',(1.0,1.0,1.0))
point= geo.point(500)
dist= hou.frame()
points=extend(point,dist)

for point in points:
    point.setAttribValue('Cd',(1.0,0,0))
    
    
#groups

group = geo.createPrimGroup('group')
lim_n0 = 100

for i in range(lim_n0):
    outside_points = set(group_outside.points())
    max_dist = 0
    point0 = group_inside.iterPoints()[0]
    
    for point in group_inside.points():
        lim_n=20
        for i in range(lim_n):
            points = set(extend(point,i))
            if(len(points & outside_points)):
                dist=i-1
                break
        if max_dist<dist:
            max_dist = dist
            point0 = point
            
            
    pos = point0.position()
    val = hou.Vector3(0.5,0.5,0)
    max_dist += 0.5

    p0 = pos+hou.Vector3(-max_dist,-max_dist,1)
    p1 = pos+hou.Vector3(-max_dist,+max_dist,1)
    p2 = pos+hou.Vector3(max_dist,max_dist,1)
    p3 = pos+hou.Vector3(max_dist,-max_dist,1)

    points=geo.createPoints([p0,p1,p2,p3])
    polys=geo.createPolygons([points,])

    group.add(polys)

    points=extend(point0,max_dist)
    group_outside.add(points)
    group_inside.remove(points)
    if len(group_inside.points())==0:break
    

 

vex444.jpg

Link to comment
Share on other sites

  • 3 weeks later...
  • 3 weeks later...

Some Vex
before block

setdetailattrib(0,"center",@P/@numpt,"add");

prim

float area = primintrinsic(0,"measuredarea",@primnum);
if(area>ch("min_area")){
    vector center =detail(0,"center");
    float k = relbbox(@P).x;
    
    float bias = 0.5*smooth(0,0.5,k-1+@Time*ch("speed"),ch("rolloff"));
    
    vector ps[];
    vector new_ps[];
    
    for (int vtx=0;vtx<@numvtx;vtx++){
        int pt0= primpoint(0,@primnum,vtx);
        vector pos0= point(0,"P",pt0);
        append(ps,pos0);
        
        int pt1 = primpoint(0,@primnum,(vtx+1)%@numvtx);
        
        vector pos1 = point(0,"P",pt1)-center;
        removepoint(0,pt0);
        
        pos0 -=center;
        matrix3 rot = slerp(dihedral(pos0,pos0),dihedral(pos0,pos1),bias);
        pos0 = pos0*rot;
        vector primcenter = normalize(@P-center)*length(pos0-center);
        
        rot = slerp(dihedral(pos0,pos0),dihedral(pos0,primcenter),ch("s")*sin(PI*2*bias));
        pos0= pos0*rot+center;
        
        int pt3 = addpoint(0,pos0);
        setvertexpoint(0,@primnnum,vtx,pt3);
        append(new_ps,pos0);
        }
 
        
 foreach(int vtx;vector p;new_ps){
    int pt0= addpoint(0,ps[vtx]);
    int pt1= addpoint(0,new_ps[vtx]);
    
    int pt2 =addpoint(0,new_ps[(vtx-1)%@numvtx]);
    int prim0 = addprim(0,"poly",pt0,pt1,pt2);
    setprimattrib(0,"Cd",prim0,{1,0,0});
    if(1){
        pt0 = addpoint(0,ps[vtx]);
        pt1 = addpoint(0,new_ps[vtx]);
        int pt3 = addpoint(0,ps[(vtx+1)%@numvtx]);
        prim0 = addprim(0,"poly",pt3,pt1,pt0);
        setprimattrib(0,"Cd",prim0,{0,1,0});
        
        }
        }
        
        @Cd = { 0,0,1};
        }




 

bhgns.gif

Link to comment
Share on other sites

  • 3 weeks later...

combining with fuicolors file chops <----> Cops and Mantra.



'Cop Snippet'

float roughness = rough;    

float VanDerCorpus(int n; int base)
{
    float invBase = 1.0f / float(base);
    float denom   = 1.0f;
    float result  = 0.0f;

    for(int i = 0; i < 32; ++i)
    {
        if(n > 0)
        {
            denom   = float(n) % 2.0f;
            result += denom * invBase;
            invBase = invBase / 2.0f;
            n       = int(float(n) / 2.0f);
        }
    }

    return result;
}
// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------
vector2 HammersleyNoBitOps(int i; int N)
{
    return set(float(i)/float(N), VanDerCorpus(i, 2));
}


vector ImportanceSampleGGX(vector2 Xi;vector N;float roughness)
{
    float a = roughness*roughness;

    float phi = 2.0 * PI * Xi.x;
    float cosTheta = sqrt((1.0 - Xi.y) / (1.0 + (a*a - 1.0) * Xi.y));
    float sinTheta = sqrt(1.0 - cosTheta*cosTheta);

    // from spherical coordinates to cartesian coordinates
    vector H;
    H.x = cos(phi) * sinTheta;
    H.y = sin(phi) * sinTheta;
    H.z = cosTheta;

    // from tangent-space vector to world-space sample vector
    vector up        = abs(N.z) < 0.999 ? set(0.0, 0.0, 1.0) : set(1.0, 0.0, 0.0);
    vector tangent   = normalize(cross(up, N));
    vector bitangent = cross(N, tangent);

    vector sampleVec = tangent * H.x + bitangent * H.y + N * H.z;
    return normalize(sampleVec);
}



vector sampleSphere(vector dir; string img){
    float phi = atan2(dir.x, dir.z);
    float theta = acos(dir.y);
    float u = phi / (2.000 *PI );
    float v = 1 - theta / PI;
    //u = clamp(u,0,1);
    //v = clamp(v,0,1);
    vector imgL = texture(img,u,v);
    return imgL;
}


int SAMPLE_COUNT = count;
vector N = normalize(localPos);    
vector R = N;

vector V = R;
float totalWeight = 0.0;   
vector prefilteredColor = 0.0;  

for(int i = 0; i < SAMPLE_COUNT; ++i)
{
    int testi = i;
    vector2 xy = HammersleyNoBitOps(testi,SAMPLE_COUNT);
    
    vector H  =  ImportanceSampleGGX(xy, N, roughness*roughness);
    vector L  = normalize(2.0 * dot(V, H) * H - V);

    float NdotL = max(dot(N, L), 0.0);
    if(NdotL > 0.0)
    {
        prefilteredColor += sampleSphere(L,map) * NdotL;
        totalWeight      += NdotL;
    }
    
}


prefilteredColor = prefilteredColor / totalWeight;

color = prefilteredColor;


 

bys.jpg

bydds.jpg

byde65.jpg

Edited by Librarian
  • Like 2
Link to comment
Share on other sites

  • 2 weeks later...
  • 2 months later...

from beauty Of Asia  @thu Thanx ..Volume Domain Wrapping.
 

function vector gumbelDistribution(vector v) {
    return -log(-log(v));
}

// return 0 ~ 1
function vector selectedNoise(int noiseId; vector pos; float time; float flow) {
    int Random = 0,                 // random
        PerlinNoise =  1,           // noise
        OriginalPerlinNoise = 2,    // onoise
        SimplexNoise = 3,           // xnoise
        SparseConvolutionNoise = 4, // snoise
        FlowNoise = 5,              // flownoise
        CurlNoise = 6,              // curlnoise
        ArigatorNoise = 7,          // anoise
        WorleyNoise = 8,
        ManhattanDistWorleyNoise = 9,
        ChebyshevDistWorleyNoise = 10;

    if(Random == noiseId) {// 0 ~ 1
        return random(set(pos.x, pos.y, pos.z, time));
    }

    if(PerlinNoise == noiseId) { // 0 ~ 1
        return noise(set(pos.x, pos.y, pos.z, time));
    }

    if(OriginalPerlinNoise == noiseId) { // 0 ~ 1
        error("Error: OriginalPerlinNoise");
    }

    if(SimplexNoise == noiseId) { // 0 ~ 1
        return xnoise(set(pos.x, pos.y, pos.z, time));
    }

    if(SparseConvolutionNoise == noiseId) { // -1.7 ~ 1.7
        return snoise(pos);
    }

    if(FlowNoise == noiseId) { // 0 ~ 1 (0.2 ~ 0.8), args(p, flow(0 ~ 1))
        return flownoise(set(pos.x, pos.y, pos.z, time), flow);
    }

    if(CurlNoise == noiseId) { // -1 ~ 1.02
        return curlxnoise(set(pos.x, pos.y, pos.z, time));
    }

    if(ArigatorNoise == noiseId) { // anoise 0 ~ 1
        // return anoise(pos);
        vector4 p = set(pos.x, pos.y, pos.z, time);
        return anoise(pos,
            0,
            noise(p),
            noise(p)
        );
    }

    if(WorleyNoise == noiseId) {
        vector4 p = set(pos.x, pos.y, pos.z, time);
        int seed;
        float dist1, dist2, dist3, dist4;
        wnoise(p, seed, dist1, dist2, dist3, dist4);

        return set(dist1, dist2, dist3);
    }

    if(ManhattanDistWorleyNoise == noiseId) {
        vector4 p = set(pos.x, pos.y, pos.z, time);
        int seed;
        float dist1, dist2, dist3, dist4;
        mwnoise(p, seed, dist1, dist2, dist3, dist4);

        return set(dist1, dist2, dist3);
    }

    if(ChebyshevDistWorleyNoise == noiseId) {
        vector4 p = set(pos.x, pos.y, pos.z, time);
        int seed;
        float dist1, dist2, dist3, dist4;
        cwnoise(p, seed, dist1, dist2, dist3, dist4);

        return set(dist1, dist2, dist3);
    }

    error("Error: selected");
}

function vector fitTo01(int noiseId; vector vec) {
    int OriginalPerlinNoise = 2,    // onoise
        SparseConvolutionNoise = 4, // snoise
        CurlNoise = 6;              // curlnoise

    // -1 ~ 1
    if(OriginalPerlinNoise == noiseId) 
        return fit11(vec, {0,0,0}, {1,1,1});
    
    // -1.7 ~ 1.7
    if(SparseConvolutionNoise == noiseId) 
        return fit(vec, {-1.7, -1.7, -1.7}, {1.7, 1.7, 1.7}, {0,0,0}, {1,1,1});

    // -1 ~ 1.02
    if(CurlNoise == noiseId)
        return fit(vec, {-1, -1, -1}, {1.02, 1.02, 1.02}, {0,0,0}, {1,1,1});

    return vec; // 0 ~ 1
}

function vector sampling(int fbmId; vector v) {
    int Normal = 1,
        Cauchy = 2,
        Sphere_Uniform = 3,
        Orientation_Uniform = 4,
        GumbelDistribution = 5;

    int samplingId = chi("fbm" + itoa(fbmId) + "_SamplingID");

    if (samplingId == Normal) {
        vector vec = fitTo01(chi("fbm" + itoa(fbmId) + "_NoiseID"), v);
        return sample_normal(vec);
    }
    
    if (samplingId == Cauchy) {
        vector vec = fitTo01(chi("fbm" + itoa(fbmId) + "_NoiseID"), v);
        return sample_cauchy(vec);// -1 ~ 0 ~ 1
    }
    
    if (samplingId == Sphere_Uniform) {
        vector vec = fitTo01(chi("fbm" + itoa(fbmId) + "_NoiseID"), v);
        return sample_sphere_uniform(vec);
    }
    
    if (samplingId == Orientation_Uniform) {
        vector vec = fitTo01(chi("fbm" + itoa(fbmId) + "_NoiseID"), v);
        return sample_orientation_uniform(vec);
    }

    if (samplingId == GumbelDistribution) {
        vector vec = fitTo01(chi("fbm" + itoa(fbmId) + "_NoiseID"), v);
        return gumbelDistribution(vec);
    }

    error("ERROR: Sampling");
}

function vector fitTo11(int noiseId, samplingId; vector v) {
    int notSelectedSamplingId = 0;
    if(samplingId == notSelectedSamplingId) {
        int OriginalPerlinNoise = 2,    // onoise
            SparseConvolutionNoise = 4, // snoise
            CurlNoise = 6;              // curlnoise

        if(
            (OriginalPerlinNoise != noiseId) 
            && (SparseConvolutionNoise != noiseId)
            && (CurlNoise != noiseId)
        ) {
            return fit01(v, {-1,-1,-1}, {1,1,1});
        }
    }
}

function vector fbm(int octave;
                    int noiseId;
                    vector p;
                    vector sft;
                    float t;
                    float angle;
                    float flow) {
    vector pos = p;
    vector v = {0};
    vector a = {0.5, 0.5, 0.5};
    matrix mat = ident();
    // float radius = 3.1415;
    float time = t;
    // float scale = 2;
    vector shift = sft;

    for (int i = 0; i < octave; ++i) {
        v += a * selectedNoise(noiseId, pos, time, flow);

        //TODO: rotate parameter
        rotate(mat, radians(angle), {0,1,0});

        pos = mat * pos * {2,2,2} + shift;
        a *= 0.5;
        
    }

    return v / (1 - a);
}

function vector domainWarping(vector p; float time) {
    vector pos = p * chf("Scale");

    // FBM 1 ------------------------------------------
    vector fbm1 = fbm(
            chi("fbm1_Octave"),
            chi("fbm1_NoiseID"),
            pos,
            chv("fbm1_Shift"),
            time,
            chf("fbm1_Angle"),
            chf("fbm1_FlowNoise_Flow")
        );

    if (chi("fbm1_SamplingID") != 0) {
        fbm1 = sampling(1, fbm1);
    }
    
    fbm1 *= chv("fbm1_Scale") * chf("fbm1_Uniform_Scale");

    // return fbm1; //debug;

    // FBM 2 ------------------------------------------
    vector fbm2 = fbm(
            chi("fbm2_Octave"),
            chi("fbm2_NoiseID"),
            pos + fbm1,
            chv("fbm2_Shift"),
            time,
            chf("fbm2_Angle"),
            chf("fbm2_FlowNoise_Flow")
        );

    if (chi("fbm2_SamplingID") != 0) {
        fbm2 = sampling(2, fbm2);
    }

    fbm2 *= chv("fbm2_Scale") * chf("fbm2_Uniform_Scale");

    // FBM 3 ------------------------------------------
    vector fbm3 = fbm(
            chi("fbm3_Octave"),
            chi("fbm3_NoiseID"),
            pos * (chv("fbm3_Scale") * chf("fbm3_Uniform_Scale")) + fbm2,
            chv("fbm3_Shift"),
            time,
            chf("fbm3_Angle"),
            chf("fbm3_FlowNoise_Flow")
        );

    if (chi("fbm3_SamplingID") != 0) {
        fbm3 = sampling(3, fbm3);
    }

    if(chi("is_Fit_11")) {
       fbm3 = fitTo11(chi("fbm3_NoiseID"), chi("fbm3_SamplingID"), fbm3);
    }

    return fbm3;
}

if(chi("is_Density_Attribute"))
    f@density = domainWarping(v@P, chf("Time"));

if(chi("is_Velocity_Attribute"))
    v@velocity = domainWarping(v@P, chf("Time"));

Have fun.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...