In preparation for our discussion today, To be honest I suggest that you read June’s Draw textured spheres if you haven’t already done so.
In this article, we’ll be rendering scene elements directly onto todisplay.
Toarticle demonstrates a ray tracing approach to rendering images. As we add finer detail to togrid, we reduce toscale of changes that we make. By the way, an obvious question arises. How much do we perturb togrid? Answer is that we start out with a roughness coefficient 0 roughness At iteration n of our DiamondSquare algorithm we add a random perturbation to togrid. Of course, our constructor accepts two values that define tofrequency of our terrain. We use these to compute altitudes and colors using Math.sin and Math.cos. In toconstructor, we specify both toroughness coefficient roughness and toextent of detail lod. Our terrain going to be very smooth tochanges will very rapidly diminish to zero, I’d say if we choose a small value for roughness. With that said, this approach will, however, be extremely slow.
We could fire rays into toworld and try to determine which part of toterrain they strike, as we did in toprevious article.
We now have a terrain map defined over a square domain.
We need to decide how we are preparing to actually draw this onto toscreen. Also, in our final application this issue would not arise being that we will actually match tolocations where we sample toterrain to toamount of detail that we request. Therefore, this method is simpler, and good enough at the moment, we will actually interpolate between surrounding sample points.intention to compute toaltitude of a point.
You can be asking yourself.
Instead we decompose our terrain to triangles as we can guarantee that any three points in space could be coplanar.
Toproblem with using tosquares of togrid is that they’re not flat in 3D space. So to. Why triangles and not squares? Oftentimes it’s extremely unlikely that they’ll be coplanar, Therefore in case you consider four random points in space. Now regarding toaforementioned fact…
So it is called todiamond step as we are creating a diamond pattern on togrid.
We hereafter take so take any of todiamonds that we have produced, average tofour corners, add a random perturbation and assign this to todiamond midpoint. We will evenly sample our terrain into a regular grid and cover this grid with triangles two for every square of togrid, intention to form totriangle mesh. Actually, tocolor of our terrain is described simply as a RGB triplet. So RGB class defines pretty simple color container. Now pay attention please. What we seek for is something that looks at least passably real. We could use real topography files as our terrain map. It’s somewhat dull, while it’s easy and practical. Notice, simple mathematical terrains are no fun. Did you know that the Mandelbrot set is a fractal function. From close up, small features of an individual mountain resemble large features of tomountain range, even down to toroughness of individual boulders. Mandelbrot set greatly you will find tiny internal structures that resemble tomain Mandelbrot itself.