Triangle gradient smoothing

Started by
2 comments, last by Ryan_001 8 years, 11 months ago

Below is a section of a hex grid where each tile corner is assigned a slope value, expressed as a shade of grey*. The per-vertex value is interpolated from the three tile slopes that intersect at the vertex. The tile slopes are calculated directly from the height map using bidirectional interpolation.

However, I'm having trouble identifying why the output is so uneven (see the dark column or the ridge snaking from top to bottom on the right side) and why the tiles seem to have an internal structure/brighter edges whereas all vertex values are uniform.

[attachment=27131:hexagons.jpg]

The hexagons are generated in a geometry shader from a single point and are emitted as a triangle strip.

I realize part of the problem is perception. However, this doesn't quite account for the noticeably harsh edges - both within the strips themselves and in between hexagons.

PS - I'm packing the slope values, but the loss of precision is uniform (as evidenced by the lack of discontinuities) and does not account for the harsh edges. As far as I can tell the output should be smooth.

* apparently there's more than 50

Advertisement

What does the triangulation look like for your hexagons? I don't see anything that looks like it is not interpolated properly. Can you point out a specific hex that you think is wrong?

What does the triangulation look like for your hexagons? I don't see anything that looks like it is not interpolated properly. Can you point out a specific hex that you think is wrong?

Indeed - it appears I'd made a mistake in my vertex ordering and while the diffuse output looked okay, the strip was being drawn incorrectly.

While this gets rid of much of the edge roughness inside the hexagons themselves, there are several ways to handle interpolation on hex corners. Notably, using a minimal length strip gives very different results from a fan-style solution, which also factors in the value at the center of the hex. Ultimately the problem lies with how the slope values are interpolated - as best I can tell there is no single good way to calculate them so the slope values wouldn't be subject to distortion when dealing with a hexagonal grid. Which sucks, because unless I blur the slope map, it will start inhibiting artificial patterns.

What does the triangulation look like for your hexagons? I don't see anything that looks like it is not interpolated properly. Can you point out a specific hex that you think is wrong?


Indeed - it appears I'd made a mistake in my vertex ordering and while the diffuse output looked okay, the strip was being drawn incorrectly.

While this gets rid of much of the edge roughness inside the hexagons themselves, there are several ways to handle interpolation on hex corners. Notably, using a minimal length strip gives very different results from a fan-style solution, which also factors in the value at the center of the hex. Ultimately the problem lies with how the slope values are interpolated - as best I can tell there is no single good way to calculate them so the slope values wouldn't be subject to distortion when dealing with a hexagonal grid. Which sucks, because unless I blur the slope map, it will start inhibiting artificial patterns.


From your description, my guess would be that this is just an artifact of using a linear approximation of a non-linear function (ie. your slope map). My suggestions would be to subdivide the hexagons and see how it looks.

This topic is closed to new replies.

Advertisement