As shown in the figure below, a basic line drawing function is realized through the renderFeature of URP.
And when there is an enclosed area, turn it white.
Currently I am getting data through tex.ReadPixels and tex.GetPixels. Use the CPU to traverse each pixel through BFS to determine whether the closed area exists and use tex.SetPixel to cover the pixel.
This is too slow. Since I have almost no experience with compute shaders, I was wondering if it is possible to achieve the same functionality with compute shaders? If possible, can someone give me some keywords for me to search?
It works! And much faster than the CPU! But I still want to ask greedily, assuming that the texture has a resolution of 1024*1024, it is necessary to dispatch 1024 times to calculate the shader. Is there any way to optimize it?
for (int i = 0; i < splatmapWidth; i++)
{
shader.Dispatch(kernel, splatmapWidth / 8, splatmapWidth / 8, 1);
}