animatrix Posted November 12, 2019 Share Posted November 12, 2019 (edited) 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 November 13, 2019 by pusat 3 Quote Link to comment Share on other sites More sharing options...
ThomasPara Posted November 12, 2019 Share Posted November 12, 2019 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? 1 Quote Link to comment Share on other sites More sharing options...
anim Posted November 12, 2019 Share Posted November 12, 2019 how does it compare to Clip SOP technique? Quote Link to comment Share on other sites More sharing options...
animatrix Posted November 13, 2019 Author Share Posted November 13, 2019 (edited) 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. Edited November 13, 2019 by pusat 1 Quote Link to comment Share on other sites More sharing options...
anim Posted November 13, 2019 Share Posted November 13, 2019 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 Quote Link to comment Share on other sites More sharing options...
animatrix Posted November 13, 2019 Author Share Posted November 13, 2019 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. Quote Link to comment Share on other sites More sharing options...
anim Posted November 13, 2019 Share Posted November 13, 2019 (edited) here is a simple example ts_carve_by_clip.hip Edited November 13, 2019 by anim 2 1 Quote Link to comment Share on other sites More sharing options...
animatrix Posted November 13, 2019 Author Share Posted November 13, 2019 (edited) 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 November 13, 2019 by pusat Quote Link to comment Share on other sites More sharing options...
anim Posted November 13, 2019 Share Posted November 13, 2019 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 2 Quote Link to comment Share on other sites More sharing options...
ThomasPara Posted November 13, 2019 Share Posted November 13, 2019 Did an experiment with subsampling the curve instead of adding extreme amounts of points to get precision. The downside is that you cant predefine the cuts with your own attribute. clip_by_noise.hiplc 5 Quote Link to comment Share on other sites More sharing options...
Librarian Posted November 13, 2019 Share Posted November 13, 2019 OJ OJ <3 Quote Link to comment Share on other sites More sharing options...
anim Posted November 13, 2019 Share Posted November 13, 2019 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 Quote Link to comment Share on other sites More sharing options...
ThomasPara Posted November 13, 2019 Share Posted November 13, 2019 Yes i understand, its not an attack on the solution(s). Its more the idea of cutting a segment several times without adding points. Since both metodes shown here (from my understanding) only can cut once between two points. Quote Link to comment Share on other sites More sharing options...
animatrix Posted November 14, 2019 Author Share Posted November 14, 2019 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. Quote Link to comment Share on other sites More sharing options...
animatrix Posted September 29, 2022 Author Share Posted September 29, 2022 (edited) 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. Edited September 30, 2022 by animatrix 1 1 Quote Link to comment Share on other sites More sharing options...
ZeitG Posted October 5, 2022 Share Posted October 5, 2022 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? Quote Link to comment Share on other sites More sharing options...
animatrix Posted October 6, 2022 Author Share Posted October 6, 2022 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. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.