Jump to content

VEXpression Presets


Noobini

Recommended Posts

hey all,
I might start this thread and ppl can keep adding presets to it.

Requirements: H16

I've done Spherify and Morph using the new Point SOP as can be seen here:

and here:

Now next step was to create presets so I've done that to my file in:

C:\Program Files\Side Effects Software\Houdini 16.0.633\houdini\VEXpressions.txt

File is attached...but you don't have to use it...you can edit it manually if you prefer...so navigate to your file (do a backup first), and add near the bottom:


#
# Attribute Expression
#
attribexpression/snippet
    Pass Through
    self

attribexpression/snippet
    Constant Value
    value

attribexpression/snippet
    Multiply by Constant Value
    self * value

attribexpression/snippet
    Add Constant Value
    self + value

attribexpression/snippet
    Random
    rand(@elemnum)

attribexpression/snippet
    Random Scale of Value
    value * float(rand(@elemnum))

attribexpression/snippet
    Random Offset of Value
    value + rand(@elemnum)

attribexpression/snippet
    Second Input's Position
    @opinput1_P

attribexpression/snippet
    Flatten Vector
    set(self.x, 0, self.z)

attribexpression/snippet
    Uniform Parameter on Polyline
    vertexprimindex(0, @vtxnum) / (primvertexcount(0, @primnum) - 1.0)

attribexpression/snippet
    Subtract Center of First Input
    self - getbbox_center(0)

attribexpression/snippet
    Spherify P
    lerp(self,(normalize(self - getbbox_center(0)) * ch("radius")) + getbbox_center(0),ch("Amt"))

attribexpression/snippet
    Spherify N
    @P - getbbox_center(0)

attribexpression/snippet
    Morph to 2nd Input
    lerp(self, point(1,"P",@ptnum),ch("Amt"))

You can see the ones I added in bold called Spherify P, Spherify N and Morph to 2nd Input...so next time you use your Point SOP you'll have these presets.

(the Spherify P and N logically go together in one Point SOP)

 

VEXpressions.txt

  • Like 6
Link to comment
Share on other sites

where is this $HOME thing ?...still not very confident with these variables...so i read a post on SESI and some guy had so much troubles trying out this file in umpteenth locations...so i thought...screw it...i'll edit the file directly instead of 'appending'

https://www.sidefx.com/forum/topic/50259/

Edited by Noobini
Link to comment
Share on other sites

On Windows example locations are:

$HOME  C:\Users\username\Documents
$HFS   C:\Program Files\Side Effects Software\Houdini 16.0.633
$HH    C:\Program Files\Side Effects Software\Houdini 16.0.633\houdini

"$HOME/houdiniX.X/VEXpressions.txt" is a portable way to say something like "C:\Users\JohnDoe\Documents\houdini16.0\VEXpressions.txt". You can override stuff from $HH here.

  • Like 1
Link to comment
Share on other sites

ok, my C:\Users\xxx\Documents\houdini16.0\VEXpressions.txt works straightaway, so only include user/custom snippets in here otherwise, it will double up. (note: Documents is just an alias of My Documents)

# Lines starting with # are comments and ignored
#
# Each entry starts with no indentation and gives the key used
# by the menu callback.  By convention, this is nodename/parmname.
# Multiply keys can be given for the same entry.
#
# The next line gives the name of the expression.  Its indentation
# level is then used for the remainder of the text.  All the
# code until the next parameter are appended together to make
# the snippet.  All preceeding indentation is removed.
# Note that tabs == 8 is assumed.


#
# Attribute Expression
#

attribexpression/snippet
    Spherify P
    lerp(self,(normalize(self - getbbox_center(0)) * ch("radius")) + getbbox_center(0),ch("Amt"))

attribexpression/snippet
    Spherify N
    @P - getbbox_center(0)

attribexpression/snippet
    Morph to 2nd Input
    lerp(self, point(1,"P",@ptnum),ch("Amt"))

attribexpression/snippet
    Flat Bottom
    set(self.x, clamp(self.y, ch("Level") + getbbox_min(0).y, getbbox_max(0).y), self.z)

...and btw, your custom ones will appear BEFORE the default ones...

Link to comment
Share on other sites

a couple of common ones, Archimedean Spiral and Helix...no need for any 'plugins'.

(note the names suggest usage on lines...by default a line is created straight up in the Y axis...so if you want to apply to a grid...then simply align your grid to the Y axis)
 

attribexpression/snippet
    Line - Archimedean Spiral
    set(ch("radius")*relbbox(@P).y*cos(relbbox(@P).y*ch("turns")*2*$PI),ch("radius")*relbbox(@P).y*sin(relbbox(@P).y*ch("turns")*2*$PI),self.z)

attribexpression/snippet
    Line - Helix
    set(chramp("width",relbbox(@P).y)*ch("radius")*sin(relbbox(@P).y*2*$PI*ch("turns")),ch("height")*relbbox(@P).y,chramp("width",relbbox(@P).y)*ch("radius")*cos(relbbox(@P).y*2*$PI*ch("turns")))

Does anyone know how to 'arrange' so that the custom ones appear AFTER the default ones...cuz I actually prefer to see the defaults on top...?

Edited by Noobini
  • Like 1
Link to comment
Share on other sites

I must be so dumb that I can't properly use the default Taper...

So I wrote my own VEXpressions:
 

attribexpression/snippet
    Taper X
    set(self.x,self.y*chramp("profile",relbbox(@P).x)*ch("mult"),self.z*chramp("profile",relbbox(@P).x)*ch("mult"))

attribexpression/snippet
    Taper Y
    set(self.x*chramp("profile",relbbox(@P).y)*ch("mult"),self.y,self.z*chramp("profile",relbbox(@P).y)*ch("mult"))

attribexpression/snippet
    Taper Z
    set(self.x*chramp("profile",relbbox(@P).z)*ch("mult"),self.y*chramp("profile",relbbox(@P).z)*ch("mult"),self.z)

Why can't it be this simple to use ?

 

Edited by Noobini
EDIT: added 'mult' channel as a Multiplier, after you created the Parameters, set the 'mult' to 1 (as default)
  • Like 1
Link to comment
Share on other sites

Droop: (move over squab...here comes Piggyphant)

attribexpression/snippet
    Droop
    set(@P.x,@P.y - ch("droop")*chramp("effect",fit(length(set(@P.x,0,@P.z)),0,getbbox_size(0),0,1)),@P.z)

 

Edited by Noobini
Link to comment
Share on other sites

Melt:

attribexpression/snippet
    Melt
    set(@P.x*ch("melt")*chramp("effect",relbbox(@P).y)+@P.x,clamp(@P.y - ch("melt"),getbbox_min(0).y,getbbox_max(0).y),@P.z*ch("melt")*chramp("effect",relbbox(@P).y)+@P.z)

 

  • Like 2
Link to comment
Share on other sites

Collision Deform:
- 1st input - Geo to deform
- 2nd input - Collider

attribexpression/snippet
    Collision Deform
    length(@P-point(1,"P",nearpoint(1, @P)))<ch("dist")?lerp(@P,@P+@N,ch("deform")*chramp("lip",fit(length(@P-point(1,"P",nearpoint(1,@P))),0,1,0,1))*(1-length(@P-point(1,"P",nearpoint(1,@P))))):@P

 

 

CheapAssCollisionDeform.hipnc

Edited by Noobini
added sample scene
  • Like 3
Link to comment
Share on other sites

so this is how I would do the Collision Deform with wrangle...yes, much more legible and don't have to repeatedly get the distance/nearest pt...question is: is it possible at all to declare/use 'variables' (like dist) in VEXpressions ? (are VEXpressions/snippets strictly one line jobs ?)
 

int nearestptnum = nearpoint(1, @P);            // get nearest pt number
vector nearestpt = point(1, "P", nearestptnum); // get nearest pt
float dist = length(@P - nearestpt);            // distance to nearest pt of collider

@P = dist < ch("range") ? lerp(@P,@P+@N, ch("deform")*chramp("lip",fit(dist,0,1,0,1))*(1-dist)) : @P;

 

Link to comment
Share on other sites

I guess, Attribute Expressions assumed to be simple and artist-friendly. You can use just a Wrangle for complex code, obviously. It's the most straightforward way. It also supports VEXpressions.txt file.

Since it is VEX, you can use semicolon to split instructions. It is possible to place almost everything in a single line. You can't hack everything with it: for example, modifying other attributes will output an error due to Python scripted restriction on exported bindings list (which attributes can be modified). Why this is forced to be selected attribute and not left to the default asterisk? Strange.

Here is the hack. Start with "bypass" statement. It will allow for @P to stay unmodified and terminate initial assignment. Then add any statements you want. Check Generated Code tab to see the final snippet. It's all just a dirty hack, but it will work. So you don't need to call same expensive geometry traverse function again and again.

// Attribute expression.
@P; float x = @P.x + 1; @P = set(x, @P.y, @P.z)

// Generated Code.
v@P = @P; float x = @P.x + 1; @P = set(x, @P.y, @P.z);

// Same, but split statements by newlines.
v@P = @P;
float x = @P.x + 1;
@P = set(x, @P.y, @P.z);

 

Edited by f1480187
  • Like 1
Link to comment
Share on other sites

wow wee...I thought I'd keep it simple...yesterday I tested by prefixing a working one liner with int i=1;...surely that would work....but nooooooo it has to be @P first......thanks f1480187 !!! ok, let's hope I can do some cleanups and make these less cryptic...

Link to comment
Share on other sites

ok here's the Collision Deform in a more legible format if you you go ALT+E to go into Expression Editor mode:

attribexpression/snippet
    Collision Deform
    @P;
    int nearestptid = nearpoint(1,@P);
    vector nearestpt = point(1,"P",nearestptid);
    float dist=length(@P-nearestpt);
    @P = dist<ch("range")?lerp(@P,@P+@N,ch("deform")*chramp("lip",fit(dist,0,2*ch("range"),0,1))*(1-dist)) : @P

 

  • Like 2
Link to comment
Share on other sites

Taper: (3 axes in 1) you can delete the orig 3 separate Taper X/Y/Z

attribexpression/snippet
    Taper
    @P;
    if(chi("axis")==0)
    {
        @P=set(self.x,self.y*chramp("profile",relbbox(@P).x)*ch("mult"),self.z*chramp("profile",relbbox(@P).x)*ch("mult"));
    }
    else
    {
        if(chi("axis")==1)
        {
            @P=set(self.x*chramp("profile",relbbox(@P).y)*ch("mult"),self.y,self.z*chramp("profile",relbbox(@P).y)*ch("mult"));    
        }
        else
        {
            @P=set(self.x*chramp("profile",relbbox(@P).z)*ch("mult"),self.y*chramp("profile",relbbox(@P).z)*ch("mult"),self.z);
        }
    }

 

Edited by Noobini
  • Like 1
Link to comment
Share on other sites

Collision Deform: improved with N Bias

attribexpression/snippet
    Collision Deform
    @P;
    int nearestptid = nearpoint(1,@P);
    vector nearestpt = point(1,"P",nearestptid);
    vector nearestptn = normalize(point(1,"N",nearestptid));
    float dist=length(@P-nearestpt);
    @P = dist<ch("range")?lerp(@P,@P+(@N*ch("n_bias"))+(nearestptn*(1-ch("n_bias"))),ch("deform")*chramp("lip",fit(dist,0,2*ch("range"),0,1))*(1-dist)) : @P

 

N_bias.jpg

LippySpheres.hipnc

Edited by Noobini
  • Like 1
Link to comment
Share on other sites

I'm not yet capable of doing FLIP sims but just thinking ahead if it's possible to advect/art direct a crown splash with geo like this...(or use in pyro...)

 

Edited by Noobini
  • Like 3
Link to comment
Share on other sites

Melt: (less Z fighting)

attribexpression/snippet
    Melt
    set(@P.x*ch("melt")*chramp("effect",relbbox(@P).y)+@P.x,clamp(@P.y + ch("thickness")*@N.y - ch("melt"),getbbox_min(0).y+ch("thickness")*@N.y,getbbox_max(0).y),@P.z*ch("melt")*chramp("effect",relbbox(@P).y)+@P.z)

 

Melt1.jpg

Edited by Noobini
  • Like 1
Link to comment
Share on other sites

Neighbourhood Watch: (NB: to be found in Group Expression)...for quickly identifying 'polar' verts.

#
# Group Expression
#
groupexpression/snippet
    Neighbourhood Watch
    neighbourcount(0,@ptnum)==chi("count")

 

Edited by Noobini
  • Like 1
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...