The swamp is another biome that I had to implement. The difficulty here, as always, is to generate its procedurally using algorithms, rather than drawing by hand. There were no problems with generating the landscape and placing the vegetation - the algorithms that I used before to create other biomes worked fine here. But I couldn’t make the surface of the water look like a swamp.
Clearly something is missing. I know! Duckweed!
Yes, it’s better now, but I came across a new problem - the sharp edges of duckweed on the border between water and ground. I tried to mask this edge with the texture on the terrain, but that didn't help much. Then I decided to hide the border using swamp debris. For this, I prepared several models of individual strips.
I can find out the exact border between water and ground using the Marching Squares algorithm, knowing the height of the landscape at each point and the water level.
I went through all the borders, placed points with an equal interval, and paved the resulting segments with elements of swamp debris.
Seems fine, but sometimes sections of the border quite far get out beyond the boundaries of one debris element. Therefore, as a final refinement, I select all the points on the boundary for each element and define the line that best approximates these points. Then I move the selected item to this line.
Now the result is quite fine with me.