To render distant forests, it is common to have some kind of bump map to simulate a forest- Though of course this approach would actually render a flat forest, where edges such as mountain ridges or tree lines would be simply cut off.
A simple image of a cut block shows the problem quite nicely:
|Cut Block near Hazelton B.C.|
Notice the edges around the cut block. You can see pointed tree tops along the bottom edge and trunks along the top edge. This image is about the distance that this approach would likely be appropriate for.
Per-Pixel Displacement Volume Rendering
A solution to this problem is to render a forest height map texture to the terrain contours to a separate render target, and then use that image as a key for a 2d displacement filter on the scene image.
|Forest Map Layer - Tree Height, dot(ViewVector, UpVector), and Depth rendered to terrain|
The Forest Map contains the necessary data from a 3D vertex shader to "smear" a 2D image
- red channel - tree height (also defines shape of tree)
- green channel - dot product of view vector and up. (Pixels to be dilated range between full displacement when viewing from the side and to no displacement when looking down)
- blue channel - distance from camera. Pixels to be displaced is dependent on distance.
|Basic displacement filter - using terrain color|
This displacement filter is a for loop that checks a small number of pixels bellow to determine if the current pixel should be recolored. The loop starts with the bottom sample first, as it would be closer to the camera, and calculates the approximate height of the sample from the Forest Map:
pixelHeight = depth * height * viewUpDot * maxPixelHeight;
If this value is greater than the current for loop counter, the pixel is recolored with the color of the base image. Effectively displacing the base color up according to the height in the Forest Map.
|Repeated displacement Filter|
Running this filter more than once by offsetting by the maximum shader amount produces some ugly artifacts, but already begins to represent a forest.
Though there are a few fundamental problems with this approach:
-For efficiency only a singular direction displacement filter is used, restricting the camera to no roll, and no upside down views
-Any forest bearing ground not seen by the camera (occluded by other terrain etc.. ) will not be rendered.
Though as a start, this process produces some interesting results. Here is a video showing a bit of the basic process: