Better perimeter with polygon 2d

Hey, I’m doing a little series of sketches with noise and contour.
My current patch has a noise texture going through some thresholds and blurs then in AsImage for the contour then everything is built into a 2D polygon.


My problem is with the accuracy of the contour when built as a polygon, the two images below are from the same frame of noise, one is rendered with Line one with Polygon with the same exact setup
You can see that the line is much more defined while polygon mesh is completely chaotic.

This becomes more evident with more complex forms like turbulence:

There are methods to improve the approximation of the polygon?

note with the Polygon (DX11.Geomertry 2d) node that it can only draw convex polygons correctly, but not concave ones! for an explanation of the difference see here. i’d be surprised if @microdee or @everyoneishappy wouldn’t have anything to offer here though…

if you can fall back to EX9, i can offer: Polygon (EX9.Geometry 2d Concave) which would be rather slow but should work as expected for those cases…

Uh, it makes sense, I’ll look through the mp packs
Thanks @joreg

actually DX11 polygon can draw concave shapes, problem here is just proper binsizing and the order of the vertices in the spread ;) BUT what the polygon node can’t do is drawing shapes with holes in them, for that you have 1.5 options:
1: this: , + the order of the vertices here is not important but it’s slower
1.5: this: , it’s only proof of concept and I haven’t touched it for a while, but it’s much faster than Triangle

@microdee apparently I’m working with too many vertices for either method, plus I’m trying to work with animation and this two nodes doesn’t seem particularly keen to be animated, in short the patch keep crashing.

I’ve tried to go from Polygon Concave ex9 (which is drawn fine) to Dx11 with FromEX9Mesh node but it’s not really working

Up left corner the shape in DX9, the big one is the mesh ported with the FromEX9 node

I’ve tried to change the topology inside the FromEX9Mesh but I still have some misplaced vertex

However this method seems pretty slow too so it’s not reliable

do you want to do anything with the triangles after or you just want to slice stuff? because if the latter it would be much more faster to use clip(alpha-test) in pixel shader of a plane, instead of tryring to triangulate. Even if you need to extrude it in 3D you can create a 2D Distance field out of them and raymarch them accordingly

@microdee at the moment I just want to slice stuff really!
I’m slow on shader stuff so I’ll leave it as last option.

My first go was with raymarching in FieldTrip but I had trouble with the “quality” of the shape, like borders not defined and this kind of things so I switched to the good old polygon method, but apparently I have to go back to the distance field and spend some more time on it if I want to animate this.
Thanks anyway

for your purpose those three lines of shader code that make the pixel shader discard would be realy the easiest…

float discard_mask = tex0.Sample(sampler0, uv).r;
if(discard_mask < 0.5){

Meaning, you are sampling a mask and if the red value of the mask is smaller then 0.5 it get rid of the entire pixel, leaving you with the perfect shape that you are looking for.
No geometry hassle…


Here’s a Filedtrip based way, in case you’re interested. Note for 2D distance fields there’s no need to raymarch.
NoiseSection.v4p (8.9 KB)

Thanks to all for the nice suggestions!
@tekcor thanks, if it’s that easy I’ll definitely try

@everyoneishappy Thanks! I did a test with sdf extrude to get from 2d to 3d and it’s working nicely, but I still have the “jagged” border problem, but I saw it’s a common thing among raymarching stuff, so I don’t know if there’s a solution

i recommend you render it in double or tripple resolution and apply fxaa :) also if you do it with discard

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.