0
\$\begingroup\$

I have a very large texture which I want to fill with values representing "distance in units from a river tile". The texture is already seeded with these origin river points (meaning distance/value = 0 in them).

From these points I want to floodfill outwards, incrementing the value with each step from these origin points.

Doing this on the CPU is no problem using a stack or similiar structure but ideally I want to do this in the middle of a Compute shader execution which runs over the entire texture.

I have read this which sound similiar to what I want to do but it mentions there might be a smarter way to do this with Compute shaders - which is what I am using.

Any ideas on how to solve this on compute shaders?

\$\endgroup\$
3
  • \$\begingroup\$ You may be interested in the Jump Flooding algorithm, which is specifically designed to speed up distance field computation on GPUs. it's an approximation, but in practice the errors are usually negligible, and it's fast compared to exact algorithms. Here's the paper that kicked off its use in this way \$\endgroup\$
    – DMGregory
    Dec 25, 2020 at 23:30
  • \$\begingroup\$ Yepp - I implemented it and it works. Thanks! \$\endgroup\$ Jan 2, 2021 at 10:52
  • \$\begingroup\$ Excellent! Want to document your solution in an Answer below to help other devs in the future? \$\endgroup\$
    – DMGregory
    Jan 2, 2021 at 12:23

0

You must log in to answer this question.

Browse other questions tagged .