Jump to content

Recommended Posts

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.

 

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

12 hours ago, ThomasPara said:

Interesting, do you use intrinsic uvs or do you create your own uv for the carve position? (or is this a question i have to pay for). Is it 10x faster than the carve sop if you dont want per primitive controll?

No I don't use any uvs but rather create new points at the carve min max values based on the input point attribute values. So if you have 2 neighbor points with attribute values 0 and 1, a min or max value of 0.5 will create a new point in the center etc.

No I compared it with a carve sop in a loop, all compiled. The idea is this tool will carve each primitive differently even if the carve values are the same.

4 hours ago, anim said:

how does it compare to Clip SOP technique?

Performance wise? This is something I have been meaning to compare.

Functionality wise, this tool can carve each primitive with different carve min max values if there are primitive attributes present to override the node parameters.

Here is a carve result from a single curve. AFAIK the clip method can not perform multi clip per primitive. This is using node parameter values.

tKnTebh.png

 

Edited by pusat
  • Thanks 1
Link to comment
Share on other sites

Yes, performance wise, I've been using Clip as it's pretty versatile and you can perform as many cuts as you want with a single Clip SOP too, it's just the matter of transforming the curves in Y for example, using the attribute which can be offset or modified per curve) then Clip once and transform back, attribs are interpolated automatically so the main question is whether there is more speedup to be gained using pure VEX, which seems like a bit more work on the other hand

Link to comment
Share on other sites

3 minutes ago, anim said:

Yes, performance wise, I've been using Clip as it's pretty versatile and you can perform as many cuts as you want with a single Clip SOP too, it's just the matter of transforming the curves in Y for example, using the attribute which can be offset or modified per curve) then Clip once and transform back, attribs are interpolated automatically so the main question is whether there is more speedup to be gained using pure VEX, which seems like a bit more work on the other hand

Any chance you can make a simple scene clipping a circular polyline like above, so I can test the same thing but with dense geometry? I am not sure how to set Clip so that all of the right sections are left out like in the above pic, using a single Clip operation.

It would be interesting to compare but yes it's quite a bit of work to do it in VEX, and all of the attribute interpolation have to be done afterwards using Attrib Interpolate and Attrib Copy for prims, etc.

Link to comment
Share on other sites

Thanks for posting that. It's a neat method. I did some comparisons, for plain simple geometry with no extra attributes and groups, Clip SOP is very fast. But once you add those, Clip SOP's performance severely degrades, which I assume is due to their attribute interpolation code.

In the end, both methods yield 1:1 results with the same number of points and prims but with different point and prim numbers. I checked one of the interpolated vertex attributes, and it was perfectly matching.

So the speed varies based on the geo but here is an example with a lot of extra float attributes for all classes and groups where Poly Carve SOP was more than 6x faster than the Clip method. I also compiled the Clip subnet to make it as fast as possible.

 

Edited by pusat
Link to comment
Share on other sites

44 minutes ago, ThomasPara said:

Did an experiment with subsampling the curve instead of adding extreme amounts of points to get precision

the extreme amounts of points were actually just to get some complexity not a requirement as otherwise it's super fast, it'd cut at any interopolated value even on very sparse curves/meshes

Link to comment
Share on other sites

9 hours ago, anim said:

thanks for testing, maybe it's time for sidefx to optimize Clip SOP and Poly Cut SOP as both more or less can be used in this way, but it's not nice to be paying speed penalty over more custom VEX solutions

Agreed, that's why I always wish they propagate the new changes all across the app. I have a feeling the Attrib Interpolate has the fastest and most recent code for attribute interpolation.

 

Link to comment
Share on other sites

  • 2 years later...

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.

11.thumb.png.eff6007cdd5eef8daaa12730ce5103b8.png

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):

image.thumb.png.b8fa4221b6a867df18a1a45a7dca1846.png

Left shows original polygon, right shows the result of Poly Carve SOP that carves from 0.308 to 0.73849.

 

image.thumb.png.3e0d8e85d4d808be624bc6f40e17dfdd.png

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".

image.thumb.png.2e3c0db1674c6c43148b3d61f389f403.png

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.

11.thumb.png.d211617e1e1ed49fa7cc22bfc9de97ad.png

 

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

Thanks for the detailed comparison! It's good to know that one can make a tool using VEX that's faster than built-in nodes.

Can your tool be used to simply clip geometry?

Are you planning to release this tool or will you only ship it with your course?

Link to comment
Share on other sites

18 hours ago, ZeitG said:

Thanks for the detailed comparison! It's good to know that one can make a tool using VEX that's faster than built-in nodes.

Can your tool be used to simply clip geometry?

Are you planning to release this tool or will you only ship it with your course?

Normally carving operation is distinct from clipping a geometry, but due to how I designed and implemented it, it can actually clip a geometry as well. It's far easier to do this using Poly Carve.

Because of this, I added 3 operations to this node: Carve, Slice and Clip.

Carve is obvious.

Slice is the same as clip except it uses the second input's points with N to slice up a geometry, so you can either compute N yourself i.e. using tangents or let the tool compute them for you.

Clip is also the same as the Clip SOP except because Poly Carve supports multi clipping, I added this using a multi param.

All of this also support adaptive workflows so you can subdivide affected regions yourself (outside Poly Carve) and keep very high detail only in those areas.

The tool will be shipped with Pragmatic VEX: Volume 2. The main goal is to teach people how to create this using VEX among a ton of other topics like it was done in Pragmatic VEX: Volume 1. You can either use the provided tool or make your own version as you see fit.

  • 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...