Before I begin describing this feature, I’d like to note that I caught a mistake involving my water. After hearing other people talk about it, I realized that the reflection on my water wasn’t changing as the camera moved. After a few attempts, I managed to fix it, and now my water reflects different skybox scenes as the camera moves around it. I don’t know how essential this was, because I hardly noticed it, but it makes me feel better now that it works properly.
As for texturing my terrain, it was fairly simple to apply a texture to my terrain but fairly difficult to get the texture to look good. Reading in my image was as easy as reading in a new image, and having done water and a skybox already I had no issues with this. The only part that hung me up was how to correctly interpolate the image’s size to the terrain. I finally found the correct method to be dividing my position.xz by 128 (the size of my terrain). Like with my water I considered passing the 128 as a uniform, but I would have had to hardcode it in somewhere anyway. I suppose I could have written a function to find the max height, but it would have involved a lot of file reading for one value, and I wouldnt’ have used the function elsewhere.
After this I went to work building a texture. I decided to make my own, although I cobbled it together out of images I found online. I wanted a snow covered mountain in the middle of my scene surrounding my grass and a dirt path, so I found the following images to use:
I then built my terrain by pasting the images over and over again. This didn’t take too long, because I left the images fairly large while I was pasting them. However, my terrain ended up fairly pixelated, as seen here:
These textures created a slight nostalgic feeling because it reminded me of the old Harry Potter PC game I played as a kid, but that was hardly the effect I was looking for, so I looked for a way to fix it. I first tried scaling the image to a larger size, but this didn’t help. Looking back, I realize this only would have made it more pixelated. I ended up creating a better terrain by scaling the original images of the grass, snow, etc. down. This meant I had to paste them next to each other more times, but it really didn’t take all that long of a time. After this I scaled the image down. I then had the following image (on the left), which was noticeably better than the old one (on the right).
The old one looks better at this size, but the grass looks better on the terrain when it is scaled down. The lines between the grass images also aren’t visible when it is scaled up.
And lastly, a short video: