Everything posted by animatrix

I recreated this tool from scratch for Pragmatic VEX: Volume 2, and did some comparisons with the Clip SOP method. While the Clip SOP method is super easy to use, it has some major flaws: 1. Clip SOP doesn't always clip out the geometry accurately at a specific position. As you can see in the screenshot, those highlighted points have values outside the range that should be clipped. (bug pending) Not sure how else to clip out these since we can't just delete the points. So this would be a deal breaker if you need to accurately carve out a geometry using an arbitrary scalar attribute. I reckon for polylines, this is not an issue, which was what was tested in this thread. But for complex geometry, it's a lot harder to just clip out sections appropriately. Poly Carve SOP had 0 points that are outside the range. 2. Clip SOP also clips away geometry within the range rather than carving out sections of it properly, meaning the entire polygon is deleted. Here is an example polygon that shows the issue (bug pending): Left shows original polygon, right shows the result of Poly Carve SOP that carves from 0.308 to 0.73849. Here you can see the Clip SOP's clipping plane that completely removes the polygon. 3. Clip SOP doesn't have a way to invert the carving operation. Imagine a poly line where you are keeping the middle part. If you invert the operation, you need to have the 2 ends that were carved out before. But it's not possible to do this using Clip SOP, unless you keep all parts and then delete the middle part, which may or may not work. I don't know it you can use it to consistently keep out the "middle section". Right shows Poly Carve SOP operation inverted. Combining both modes will get the whole geometry for all polygons, whether they are polylines or closed polygons. They are handled differently. 4. When you use a primitive group for the Clip SOP, it won't properly stitch the adjacent primitives, therefore introduce new holes to the geometry. Even if not the default, there should be an option for this. Poly Carve SOP handles adjacent primitives correctly. Of course this takes some of the cooking time, so the comparison is not completely 1 to 1. I used 2 Clip SOPs since Poly Carve SOP does Min/Max Clipping by default, so some of this cost is amortized throughout the entire operation. Clip method also includes the swapping of P back and forth. Both methods use compiled networks. So in the end for ~5.8M polygons geometry with a single attribute to be used for carving, Poly Carve SOP is about 3x faster.

http://www.patreon.com/posts/31506335 Carves out polygons using a point attribute with the ability to define the carve values per primitive using primitive attributes. Pure VEX implementation, 10x faster than the default Carve SOP (compiled). It preserves all available attributes. It supports both open and closed polygons.

Get the corner position of a diagonal line
animatrix replied to shadowst17's topic in General Houdini Questions
Yes in that case it's possible. Have to implement a line line intersection such as this one: paulbourke.net/geometry/pointlineplane/lineline.c Point, Line, Plane (paulbourke.net) 
Get the corner position of a diagonal line
animatrix replied to shadowst17's topic in General Houdini Questions
Hi, There are more than 1 intersection in this case. Do you require the intersected lines form 90 degrees? But even then, there are infinite number of intersections that would revolve around the vector defined by your 2 points. 
can't select @P.y with point function
animatrix replied to GergelyP's topic in General Houdini Questions
Yes, you can't use subscript as attribute name, you have to do it after you read the proper attribute type. In this case vector, and then access the Y component. 
Hi, Clip SOP is a compiled SOP so you can't dive inside. For your use case I would actually store P as rest, apply the mountain to the input geometry before clipping and then reset P back to rest.

vex insert point along vector of two points in world units
animatrix replied to Trilec's topic in Scripting
Hi, There is no specialized function to do this but you can run this in a Detail Wrangle: vector p0 = point ( 0, "P", 0 ); vector p1 = point ( 0, "P", 1 ); vector dir = p1  p0; if ( length ( dir ) > 0.5 ) { vector n = normalize ( dir ); addpoint ( 0, p0 + n * 0.25 ); } 
How would one get xyzdist of surface based on range of vector directions
animatrix replied to Human_vX's topic in General Houdini Questions
Hi, You can fire rays for each given point within a cone in the opposite direction of the point normal: Here is the VEX code: int numrays = chi("numrays"); float maxangle = radians ( ch("maxangle") ); float maxdist = ch("maxdist"); int visualize = chi("visualize"); vector phit = 0; vector uvhit = 0; float nearestdist = 1e32; vector nearestp = @P; for ( int i = 0; i < numrays; ++i ) { vector2 u = rand ( i + 4523.4376 + @ptnum + ( @ptnum + 1 ) * 54.21 ); vector dir = sample_direction_cone ( @N, maxangle, u ); if ( visualize ) { int pt = addpoint ( 0, @P ); setpointattrib ( 0, "N", pt, dir ); } int pr = intersect ( 1, @P, dir * maxdist, phit, uvhit ); if ( pr != 1 ) { float dsq = distance2 ( phit, @P ); if ( dsq < nearestdist ) { nearestdist = dsq; nearestp = phit; } } if ( visualize ) { int pt = addpoint ( 0, phit ); setpointattrib ( 0, "P", pt, phit ); } } @P = nearestp; 
Hi, You can update your edge groups automatically using VEX (Detail Wrangle), but you will pay performance penalty for very high res geometry that has very large edge groups: string edgegroups [ ] = split ( chs("edgegroups"), " " ); foreach ( string edgegroup; edgegroups ) { int pts [ ] = expandedgegroup ( 1, edgegroup ); int count = len ( pts ); for ( int i = 0; i < count; i += 2 ) { int pt0 = pts [ i ]; int pt1 = pts [ i + 1 ]; int pts0 [ ] = neighbours ( 0, pt0 ); int pts1 [ ] = neighbours ( 0, pt1 ); int sharedpt = 1; foreach ( int pt; pts0 ) { if ( find ( pts1, pt ) >= 0 ) { sharedpt = pt; break; } } if ( sharedpt != 1 ) { setedgegroup ( 0, edgegroup, pt0, sharedpt, 1 ); setedgegroup ( 0, edgegroup, pt1, sharedpt, 1 ); } } } Edge group expression: `edgegrouplist(1)` If you need multiple levels of subdivision, you need to encapsulate the Subdivide and Attribute Wrangle inside a For Each Loop network, as the edges have to be updated at each subdivision. Alternatively you can change the VEX code to walk the edges instead, then it would handle any edge group regardless of the subdivision levels difference between 2 geometries.


There is also a new open source one called stable diffusion, so it will be great to use this. I heard it's not censoring stuff also. So the price of running on cloud and locally could actually be much cheaper than MJ.

FREE Patreon giveaway! To celebrate the 2 year anniversary of Pragmatic VEX: Volume 1, I am giving away 1 month of FREE patreon subscription for the new purchases of the course in this month. https://www.patreon.com/animatrix Started in 2017, I posted over 120 advanced production tools, tips, tricks and techniques with a lot more to come at 3 posts per month! Simply contact me after and I will arrange the patreon subscription!

After more than 5 months of unimaginable amount of work, I am proud to release my first indepth Houdini course on VEX More details in the video description and the website. Active Patreon members will receive additional discounts proportional to their lifetime support (25% of their lifetime support). Message me on Patreon for your discount coupon. Enjoy! Table of Contents 01  Introduction [Point Clouds] 02  Introduction [pcopen() vs pcfind() vs nearpoints()] 03  Introduction 04  Implementation 05  pcfilter() Implementation for pcfind() 06  pgfind() 07  pcfind_radius() 08  Excluding the Current Point & AdHoc Groups 09  Finding Min & Max Neighbour Points [Unique Pair Matching] 10  Concept 11  Implementation [Camera Based Occlusion with Variable Pscale] 12  Concept 13  Implementation [Uniform Point Distribution Over Polygonal Surfaces [Point Relaxation]] 14  Concept 15  Implementation 16  Decoupling Operators [Convolution Kernels] 17  Introduction 18  Border Handling [Connectivity & kDepth Point Neighbours Using Edges] 19  Introduction 20  Concept 21  Implementation [Connectivity & kDepth Point Neighbours Using Primitives] 22  Concept 23  Implementation [Extending kDepth Point Neighbours Using Edges] 24  Introduction 25  Concept 26  Implementation [Extending kDepth Point Neighbours Using Primitives] 27  Concept 28  Implementation [smoothstep() [Cubic Hermite Interpolation]] 29  Concept 30  Implementation [Shaping Functions] 31  Introduction 32  Implementation 33  Blurring Attributes [Sharpening Attributes Using Unsharp Mask] 34  Concept 35  Implementation [Generalizing the Kernel Code to Handle All Attribute Types] 36  Concept 37  Implementation [Attribute Gradient] 38  Introduction 39  Concept 40  Implementation [Gradient Ascent & Descent] 41  Planar Geometry  Introduction 42  Planar Geometry  Concept 43  Planar Geometry  Implementation 44  3D Geometry [Contour Lines] 45  Introduction 46  Concept 47  Implementation 48  Heightfields [Geometric Advection  Orthogonalization & Flowlines] 49  Introduction 50  Concept 51  Implementation [Clustering & Quadtrees] 52  Concept 53  Implementation [Adaptive Subdivision] 54  Introduction 55  Implementation 56  Hashing [Adaptive Subdivision] 57  Improving OpenSubdiv CatmullClark Subdivision Surfaces Algorithm 58  HalfEdges [Adaptive Subdivision] [Aggressive Performance Optimizations] 59  Eliminating Groups 60  Custom Fusing In VEX 61  Recreating Proximity Structures In VEX 62  Get Unshared Edges In VEX 63  Final Optimizations [Limit Surface Sampling] 64  Introduction 65  OpenSubdiv Patches 66  Moving Points to the Subdivision Limit Surface 67  Scattering Points on the Subdivision Limit Surface 68  Generating a Point Cloud on the Subdivision Limit Surface 69  PreGenerating a Point Cloud on the Subdivision Limit Surface 70  Creating Isolines on the Subdivision Limit Surface [Adaptive Subdivision] 71  Computing Surface Normals from the Subdivision Limit Surface [Custom Subdivision Surfaces] [Splitting Edges [Edge Divide]] 72  Concept 73  Converting Edges to Primitives 74  Creating New Edge Points [Rebuilding Polygons] 75  Concept 76  Implementation 77  Preserving & Interpolating Attributes 78  Multithreading by Connectivity 79  C++ vs VEX 80  Preserving Groups 81  Final Optimizations [Implementing Bilinear Subdivision] 82  Introduction 83  Concept 84  Modeling Test Geometry 85  Starting from Edge Divide 86  Creating New Face Points 87  Creating New Edge Points [Creating New Closed Polygons] 88  Concept 89  Implementation [Creating New Open Polygons] 90  Concept 91  Implementation 92  Preserving Primitive Groups & Interpolating Primitive Attributes [Preserving Vertex Groups & Interpolating Vertex Attributes for Closed Polygons] 93  Concept 94  Implementation 95  Preserving Vertex Groups & Interpolating Vertex Attributes for Open Polygons 96  Implementing Iterations 97  Preserving Literal Groups 98  Creating Neighbour Primitives 99  Final Changes 100  Testing On Complex Geometry [Implementing CatmullClark Subdivision] 101  Introduction [Closed Surfaces] 102  Rules [Gathering Edge & Face Points] 103  Concept 104  Implementation [Computing Weights for New Edge Points] 105  Concept 106  Implementation [Computing Weights for Original Points] 107  Concept 108  Implementation [Attribute Interpolation] 109  Concept 110  Implementation [Boundary Interpolation Rules for New Edge Points] 111  Concept 112  Implementation [Boundary Interpolation Rules for Original Points] 113  Concept 114  Implementation 115  Open Surfaces  Handling Corner Points 116  Handling NonManifold Topology [Open Polygons] [Computing Weights for Original Points] 117  Reverse Engineering OpenSubdiv 118  Implementation [Computing Weights for New Edge Points] 119  Reverse Engineering OpenSubdiv 120  Implementation 121  Handling Open Polygonal Curves [Handling Mixed Topology] 122  Full Geometry 123  SubGeometry 124  Testing On Complex Geometry [Performance] 125  Profiling [Grouping Boundary Edges from Primitive Group] 126  Concept 127  Implementation 128  VEX vs C++ [Caustics] 129  Introduction 130  Sea Caustics 131  Pool Caustics [Enhancing Gradient Ascent, Descent & Contour Lines] 132  Intro 133  Implementation 134  Tracing Both Directions [Updating Distances Properly] 135  Concept 136  Implementation 137  Looping Streamlines Problem 138  Adding Trace Parameter [Evenly Spaced Gradient Ascent, Descent & Contour Lines] 139  Intro 140  White Paper 141  Concept 142  Constructing the For Loop Network 143  Improving Seed Points Selection for Tighter Packing 144  Implementing Separation [Enforcing Separation Using Self Proximity] 145  Concept 146  Implementation 147  Optimization 148  Final Tweak 149  Applying to 3D Geometry 150  Conclusion
 40 replies

 14

VEX query  unable to get a bounce effect
animatrix replied to archz2's topic in General Houdini Questions
It seems like SESI changed the behaviour of ramps so now no more implicit cycling behaviour. The author needs to update his tuto. 
You have to specify the type for the arguments: function float[] common_tangent_line(float x1, y1, r1, x2, y2, r2) { }

Hi, You also have to change the function calls like: Math.sqrt(delta1) results.push(l21) to: sqrt(delta1) push(results, l21)

VEX query  unable to get a bounce effect
animatrix replied to archz2's topic in General Houdini Questions
Hi, I haven't seen this tuto, but you can explicitly keep the fraction part of the time like this: float blend = @Time % 1.0; Otherwise the values get larger than 1, and so the ramp caps them at 1, hence why the "bounce" stops. 
After careful analysis and deliberation of the new features in Houdini 19.5, Pragmatic VEX: Volume 1 has been updated to the latest version so you can be confident you are still using the latest techniques and methods available. A number of videos have received updated content as well as the corresponding scene files. All existing users immediately received the latest content as soon as it went live. Enjoy!

Rodeo Visual Effects is the latest studio to join the impressive list of studios that use Pragmatic VEX: Volume 1 as part of their training. More studios to follow!

Cannot access attribute of point inside the wrangle in which it is created
animatrix replied to JH12's topic in General Houdini Questions
Because the geometry creation happens after the entire VEX code is executed and the result is finalized as the output of that particular wrangle. So you don't have those geometry actually created while you are still in the same VEX kernel, but after. That's why you can't use them in the same code that used to create them. 
Cannot access attribute of point inside the wrangle in which it is created
animatrix replied to JH12's topic in General Houdini Questions
Hi, You can't access attributes of a point you just created inside the same wrangle node. 
Scatter points uniformly by density
animatrix replied to nomojosh's topic in General Houdini Questions
What you are looking for is the straight skeleton / medial axis. It's hard to do it on arbitrary geometry but if your geometry has consistent topology, you can use some of these ideas: 
Create Point That Lasts Only One Frame, At Random Time Intervals [SOLVED]
animatrix replied to GlennimusPrime's topic in General Houdini Questions
A similar method if you want to add a chance parameter: if ( @Frame >= chi("start") && @Frame <= chi("end") ) { if ( rand ( @Frame + ( ch("seed") + 3145.5672 ) * 5463.4573 ) < ch("chance") ) addpoint ( 0, 0 ); } 
I think it's called "Save Asset".

Grouping clusters and Isolation to create more detail
animatrix replied to aliaq95's topic in Modeling
You can use Point Split SOP to split using the cluster attribute. 5 replies

 1

 aircraft
 hardsurface

(and 1 more)
Tagged with: