Day 111 - Horizontal Duplication ground textures

There's definitely something going on in the ground textures, here's what the guy in the Q&A end of the stream had noticed.

I'm going to say this is being caused by the perspective rendering, and will go away with orthographic rendering. I'll try to explain why the perspective rendering is causing this.

First, remember that the spats of each chunk actually spread out and overlap the adjacent chunks. To make sure the chunks join into a continuous texture, the splats of adjacent chunks are rendered as well. There are a total of 9 chunks worth of splats being splatted in each chunk, but only the splats that cross inside each chunks clipping region are rendered in. Again, each horizontally or vertically adjacent pair chunks shares 6 chunks worth of splats, but only those that overlap get rendered.

In comes perspective. If you skip back to where Casey first got the splats rendering again, you see that they were all clustered tightly into the middle of each chunk, with thick yellow borders between. Those tight clusters of splats are actually all of those 9 chunks perspective projected into a tight cluster, all inside the chunks clipping region. Rather than each chunks splats being rendered into their position relative to each chunks center, perspective foreshortening has crammed all 9 chunks together. The result is that those shared 6 chunks worth of spats are now fully visible. If you look closely at these tight clusters, a full 2/3 of each chuck is the same as it's neighbor.

Now when Casey added a scale factor to bring the size of the splats up to something reasonable, he got them to cover the chunk and then some, but perspective foreshortening is still causing splats from adjacent chunks to render relative to a different center point than the actual center point of the adjacent chunk. Because of this, we are still seeing too much of the adjacent chunks splats, and thus the repetition (which is actually present both horizontally and vertically).

Edited by Jerry Siebe on Reason: grammar/spelling
To illustrate what I tried (and probably failed) to describe above, I added a PushRectOutline to draw the chunk boundaries as rendered into the chunk.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
diff -Naur a/handmade.cpp b/handmade.cpp
--- a/handmade.cpp      2015-04-30 17:55:54.000000000 -0700
+++ b/handmade.cpp      2015-05-03 04:52:32.164578544 -0700
@@ -572,6 +572,7 @@
                 v2 P = Center + Hadamard(HalfDim, V2(RandomBilateral(&Series), RandomBilateral(&Series)));
                 PushBitmap(RenderGroup, Stamp, 0.4f, V3(P, 0.0f));
             }
+            PushRectOutline(RenderGroup, V3(Center,0.0f), HalfDim, V4(0.0f,0.0f,1.0f,1.0f));
         }
     }
     


The blue squares should exactly match the chunk size and positions (yellow squares). Notice that the duplication aligns with the blue squares.