When trying to light some procedurally-generated terrain, I see these alarmingly bright lines:
These lines run along polygon edges, so I thought maybe doing lighting in the fragment shader would help. In that case, the vertex normals were still subject to linear interpolation, and even after re-normalizing, produces almost the exact same sort of lines.
I tried vertex smoothing. It helped a little, mainly by removing the areas of highest contrast. I tried tesselating quads into 4 triangles instead of two (with a new generated midpoint), but that didn't help at all.
Finally, I decided that the problem must be that I want to filter linearly over a quad and I can only do that when sampling a texture, so I tried packing my lighting data into a texture. This texture has one pixel per vertex.
On the left, you see the terrain rendered with the terrain texture using nearest filtering. You can see there is one pixel per vertex and it is centered neatly on it. On the right, you see what it looks like with linear interpolation. I really really really did not expect to see those sharp lines. I expected to see nice blurry shapes.
I tried resizing the image in paint.net and was surprised that bilinear interpolation in a image editing tool displays the same lines:
The third image is bicubic filtering. That is more like the result I was hoping for.
I feel like I'm doing this all wrong. I don't think I want to generate a higher-res texture just to do some fancy spline interpolation on it. I think I just have to hide the artifacts using some noise from the ground texture, normal smoothing, less contrast, more ambient light, and maybe some noise in the lighting calculation.
Any thoughts are appreciated.
One more thing: In the side-by side, you can see on the left side, even though all coloring is coming from the fragment shader
Dumb, dumb, dumb. I accidentally left some lighting in the shader, it wasn't just a texture lookup. When removed, the lines along polygon edges on the left disappears as expected, but the lines remain in the bilinear filter:
It just doesn't look "linear" to me.