You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After an initial SDF calculation for some pixel yielding distance "D", we know that the result for the neighboring pixel will be off by at most 1. So when iterating the mipmap, we can throw out any regions, whose farthest point is nearer than D-1 and regions whose nearest point is farer than D+1.
Unfortunately this makes parallelisation more complicated. Each Thread has to track this neighbor pixel info separately, because they all work on different parts of the image. We need to use a thread local variable for that; either using thread_local!(static LAST_PIXEL_INFO: RefCell<Option<LastPixelInfo>> = RefCell::new(None)); or manually using Thread::spawn to create an actually local variable in there. Also it makes long consequtive runs of pixels more effective, s.t. a manual allocation of work regions to threads may be beneficial, although I guess Rayon already tries to allocate consequtive regions as much as possible, so a comparison benchmark should be done first.
To avoid a reset at the end of each line of pixels, we can either also store the data for the first pixel of the last visited line and refer to that on line switch, or we can switch direction (right-to-left vs left-to-right) for each line.
The text was updated successfully, but these errors were encountered:
After an initial SDF calculation for some pixel yielding distance "D", we know that the result for the neighboring pixel will be off by at most 1. So when iterating the mipmap, we can throw out any regions, whose farthest point is nearer than D-1 and regions whose nearest point is farer than D+1.
Unfortunately this makes parallelisation more complicated. Each Thread has to track this neighbor pixel info separately, because they all work on different parts of the image. We need to use a thread local variable for that; either using
thread_local!(static LAST_PIXEL_INFO: RefCell<Option<LastPixelInfo>> = RefCell::new(None));
or manually usingThread::spawn
to create an actually local variable in there. Also it makes long consequtive runs of pixels more effective, s.t. a manual allocation of work regions to threads may be beneficial, although I guess Rayon already tries to allocate consequtive regions as much as possible, so a comparison benchmark should be done first.To avoid a reset at the end of each line of pixels, we can either also store the data for the first pixel of the last visited line and refer to that on line switch, or we can switch direction (right-to-left vs left-to-right) for each line.
The text was updated successfully, but these errors were encountered: