Difference between revisions of "Houdini learning"
Jump to navigation
Jump to search
(→Misc Attr Wrangle expressions) |
|||
(11 intermediate revisions by the same user not shown) | |||
Line 58: | Line 58: | ||
</pre> | </pre> | ||
− | === | + | === Kill emission on a smoke source after frame 300 === |
<pre> | <pre> | ||
− | |||
if (@Frame>300) @density = 0; | if (@Frame>300) @density = 0; | ||
</pre> | </pre> | ||
Line 155: | Line 154: | ||
// Copy P from second input | // Copy P from second input | ||
@P = v@opinput1_P; | @P = v@opinput1_P; | ||
+ | </pre> | ||
+ | |||
+ | === Bounding-box - Position Reference color === | ||
+ | <pre> | ||
+ | // As seen on https://houdinihelp.ru/ref/expression_cookbook.html | ||
+ | |||
+ | // In an attribwrangle set on primitives | ||
+ | @Cd.r = relbbox(0,@P).x; | ||
+ | @Cd.g = relbbox(0,@P).y; | ||
+ | @Cd.b = relbbox(0,@P).z; | ||
+ | </pre> | ||
+ | |||
+ | === Group by uv.y === | ||
+ | <pre> | ||
+ | // Thanks to https://vfxbrain.wordpress.com/2019/06/14/vex-snippets-2/ | ||
+ | |||
+ | // In an attribwrangle set on points | ||
+ | if(@uv.y<chf("seuil")) @group_base = 1; | ||
+ | |||
+ | // ALTERNATIVE | ||
+ | @uv.x<0.2 | ||
+ | </pre> | ||
+ | |||
+ | === Specify attribute value for one point === | ||
+ | <pre> | ||
+ | if (@ptnum == 322) f@mask=1; | ||
+ | </pre> | ||
+ | |||
+ | === Pscale by Bbox Y === | ||
+ | <pre> | ||
+ | //set pscale first | ||
+ | |||
+ | f@bboxY = relbbox(0,@P).y; | ||
+ | @pscale *= chramp("rampBbox",@bboxY)*4 ; | ||
+ | </pre> | ||
+ | |||
+ | === Delete primitives by height === | ||
+ | <pre> | ||
+ | if ( @P.y<chf("seuil") ) removeprim(0,@primnum,1); | ||
+ | </pre> | ||
+ | |||
+ | === Falloff geometry === | ||
+ | <pre> | ||
+ | // Get camOrigin | ||
+ | |||
+ | vector pt0 = point(1,'P',0); | ||
+ | v@raydir = normalize( pt0 - @P )*-1; | ||
+ | |||
+ | @falloff = dot(v@raydir, @N); | ||
+ | |||
+ | // Promote raydir in Primitives | ||
+ | |||
+ | if ( f@falloff>chf("seuil") ) removeprim(0,@primnum,1); | ||
+ | </pre> | ||
+ | |||
+ | === Labs Maps Baker - Bake with UDIMs === | ||
+ | <pre> | ||
+ | // Add %(UDIM)d in the file path - don't need to check Output UDIMs | ||
+ | </pre> | ||
+ | |||
+ | === Gets the digits from node name=== | ||
+ | <pre> | ||
+ | // Add `padzero(3,opdigits("."))` | ||
+ | // Add `padzero(3,opdigits(".."))` for previous node padding | ||
+ | // padzero(3,opdigits(".")) without hscript | ||
+ | </pre> | ||
+ | |||
+ | === Self-shadows in Mantra=== | ||
+ | <pre> | ||
+ | // Add by example * ^RENDER_ground in Shadow Mask of every of your lights to exclude self-shadows | ||
+ | </pre> | ||
+ | |||
+ | === Search and replace in VEX === | ||
+ | <pre> | ||
+ | // To remove ShapeDeformed from Maya Alembics by example, in an Attribute Wrangle in Primitives | ||
+ | |||
+ | string path = @path; | ||
+ | s@path = re_replace(r"Deformed", "", path); | ||
+ | </pre> | ||
+ | |||
+ | === Get only shape name from Maya alembic path === | ||
+ | <pre> | ||
+ | // Attribwrangle on Primitives | ||
+ | |||
+ | s@last_split = split(s@path, "/")[-1]; | ||
+ | s@last_split = split(s@last_split, ":")[-1]; | ||
</pre> | </pre> |
Latest revision as of 10:57, 7 May 2024
Contents
- 1 Houdini learning
- 1.1 Center Pivot
- 1.2 Delete by Connectivity attribute
- 1.3 Increase Volume Density
- 1.4 Substract any VDB by another VDB
- 1.5 Get bound & centroid
- 1.6 UVs
- 1.7 Kill emission on a smoke source after frame 300
- 1.8 Attribfrommap - Use UDIMs images
- 1.9 Attribwrangle - Udim number on primitives attributes
- 1.10 Place at World center, scale et re-transform for export
- 1.11 Misc Attr Wrangle expressions
- 1.12 Delete small pieces
- 1.13 Attribute Wrangle - Copy attribute from second input
- 1.14 Bounding-box - Position Reference color
- 1.15 Group by uv.y
- 1.16 Specify attribute value for one point
- 1.17 Pscale by Bbox Y
- 1.18 Delete primitives by height
- 1.19 Falloff geometry
- 1.20 Labs Maps Baker - Bake with UDIMs
- 1.21 Gets the digits from node name
- 1.22 Self-shadows in Mantra
- 1.23 Search and replace in VEX
- 1.24 Get only shape name from Maya alembic path
Houdini learning
Center Pivot
// In Pivot Translate in a Transform node centroid(0,0) centroid(0,1) centroid(0,2)
Delete by Connectivity attribute
// In a Delete node, in Group (by example) @class=7777
Increase Volume Density
// In a volumewrangle @density *= 10;
Substract any VDB by another VDB
// In a volumewrangle if (volumesample(1,"surface",@P)<0)@density=0; //inverse: if (volumesample(1,"surface",@P)>0)@density=0;
Get bound & centroid
// In a null object bbox(opinputpath('.',0),D_XSIZE) bbox(opinputpath('.',0),D_YSIZE) bbox(opinputpath('.',0),D_ZSIZE) centroid(opinputpath('.',0),D_X) centroid(opinputpath('.',0),D_Y) centroid(opinputpath('.',0),D_Z)
UVs
// In this order : uvautoseam - uvflatten - uvlayout In uvflatten : Seams = seams
Kill emission on a smoke source after frame 300
if (@Frame>300) @density = 0;
Attribfrommap - Use UDIMs images
// Replace 1001 by <UDIM> and check UDIM Filename Expansion
Attribwrangle - Udim number on primitives attributes
// In a wrangle set on Primitives vector uv = primuv(0, "uv", @primnum, set(0.5, 0.5, 0)); i@udim = 1001 + int(uv.x) + int(uv.y)*10;
Place at World center, scale et re-transform for export
// In a transform translates -centroid(0,0) -centroid(0,1) -centroid(0,2) // In a transform Uniform scale (bbox("/obj/neigeSol/timeshift1/", D_ZSIZE))/(bbox("/obj/neigeSol/transform_centerWorld/", D_ZSIZE)) // At end, in a transform Uniform scale 1/((bbox("/obj/neigeSol/timeshift1/", D_ZSIZE))/(bbox("/obj/neigeSol/transform_centerWorld/", D_ZSIZE)))
Misc Attr Wrangle expressions
// Delete by color if (@Cd.x<chf("seuilColor"))removepoint(0,@ptnum); // Set random pscale @pscale = fit01(pow(rand(@ptnum), ch("power")), ch("pscale_min"), ch("pscale_max")); // Udim attr for each Udim vector uv = primuv(0, "uv", @primnum, set(0.5, 0.5, 0)); i@udim = 1001 + int(uv.x) + int(uv.y)*10; // Next, with a Delete SOP: Group: @udim=$F - Pattern mode !* // Set pscale Min/Max @pscale = fit01(pow(rand(@ptnum), ch("power")), ch("pscale_min"), ch("pscale_max")); // Remove small parts - In a Foreach connected piece loop @size = (getbbox_size(0).x+getbbox_size(0).y+getbbox_size(0).z); if(@size < chf("taille")) removepoint(geoself(), @ptnum); // Set @variant integer for Copytopoints (change objects number) i@variant =floor(rand(@id)*3); //// Get position difference between two objects, and match animation // On Rest pose object: v@fixe = 0; @fixe.x = getbbox_center(0).x; @fixe.y = getbbox_center(0).y; @fixe.z = getbbox_center(0).z; // On animated object: v@anim = 0; @anim.x = getbbox_center(0).x; @anim.y = getbbox_center(0).y; @anim.z = getbbox_center(0).z; // After two previous AttrWrangles: v@anim_offset = point(0, 'fixe', 1) - point(1, 'anim', 1); // To match animation: @P = point(0, "P", @ptnum) + point(1, 'anim_offset', 1); //// Blend shape through a mask attribute - Posted by Cudarsjanis on Odforce // Geo with mask attribute in first input, blend shape in second v@P=lerp(v@P, point(1,'P',@ptnum), f@mask*ch('blend')); //// Set a fixed normal attribute v@z = set(0,1,0); //// Place at world center v@P -= getbbox_center(0);
Delete small pieces
// As seen on Sidefx forum, posted by paulboiii // First create a measure SOP, set to per piece // Then, in an attribwrangle set on primitives float threshold = chf("Size_Threshold"); if ( f@area < threshold ) removeprim(0,@primnum,1);
Attribute Wrangle - Copy attribute from second input
// With same number of points on both inputs - From Bonsak on Sidefx.com // Copy P from second input @P = v@opinput1_P;
Bounding-box - Position Reference color
// As seen on https://houdinihelp.ru/ref/expression_cookbook.html // In an attribwrangle set on primitives @Cd.r = relbbox(0,@P).x; @Cd.g = relbbox(0,@P).y; @Cd.b = relbbox(0,@P).z;
Group by uv.y
// Thanks to https://vfxbrain.wordpress.com/2019/06/14/vex-snippets-2/ // In an attribwrangle set on points if(@uv.y<chf("seuil")) @group_base = 1; // ALTERNATIVE @uv.x<0.2
Specify attribute value for one point
if (@ptnum == 322) f@mask=1;
Pscale by Bbox Y
//set pscale first f@bboxY = relbbox(0,@P).y; @pscale *= chramp("rampBbox",@bboxY)*4 ;
Delete primitives by height
if ( @P.y<chf("seuil") ) removeprim(0,@primnum,1);
Falloff geometry
// Get camOrigin vector pt0 = point(1,'P',0); v@raydir = normalize( pt0 - @P )*-1; @falloff = dot(v@raydir, @N); // Promote raydir in Primitives if ( f@falloff>chf("seuil") ) removeprim(0,@primnum,1);
Labs Maps Baker - Bake with UDIMs
// Add %(UDIM)d in the file path - don't need to check Output UDIMs
Gets the digits from node name
// Add `padzero(3,opdigits("."))` // Add `padzero(3,opdigits(".."))` for previous node padding // padzero(3,opdigits(".")) without hscript
Self-shadows in Mantra
// Add by example * ^RENDER_ground in Shadow Mask of every of your lights to exclude self-shadows
Search and replace in VEX
// To remove ShapeDeformed from Maya Alembics by example, in an Attribute Wrangle in Primitives string path = @path; s@path = re_replace(r"Deformed", "", path);
Get only shape name from Maya alembic path
// Attribwrangle on Primitives s@last_split = split(s@path, "/")[-1]; s@last_split = split(s@last_split, ":")[-1];