(Weak) Grass Simulation:

           

            Project Description:

                        This project (like most) set out to do something ambitious, I hade hoped to do a full featured, uber robust simulation of grass with wind, where the ‘wind’ was featured as a whole set of possibilities (voxel cubes,  particles, …). I was hoping to come up with a generic form for this ‘wind’, so that a creator could simply place a new item within the ‘wind’ field and the process for determining windswept behavior  would be automated.

                        This was not meant to be, not this quarter. In the end I settled on implementing an I-Wave hack (I-Wave –> Interactive Wave). I-Wave was one of the (if not the) original attempts to break away from using FFT’s to compute wave animations. What I-Wave was originally designed to be was a method for calculating waves (at real time speeds) which could interact with their surroundings. This was an improvement on FFT based waves because waves generated using FFT’s had to either ignore objects which intersect them, or they had to come up with a possibly infinite number of sub-wave additions/subtractions in order to describe the collision.

                        The description of the I-Wave algorithm supplied in Game Programming Gems 4 is nice and elegant. In fact I must have spent a full day trying to beat my brain around it completely before I determined that had I got it working it still would have been mostly unusable for my grass simulation. Therefore I decided to go with the hack described in Game Programming Gems  5 (section 4.2). The hack simply describes this as an algorithm:

 

            res_h[i,j] = (src_h[i-1,j] + src_h[i+1,j] + src_h[i,j-1] + src_h[i,j+1]) / 2 – src_h[i,j];

 

where damping can be calculated as follows:

 

            res_h[i,j] -= res_h[i,j] * dampingFactor

 

                        This still breaks my heart to look at. Basically there is nothing there but a mega-oversimplified description of a self propagating wave with damping.

 

                        I-Wave was originally designed to model waves (e.g ocean waves, water waves). The article previously referenced from Game Programming Gems 5 described a method for hacking the I-Wave algorithm even further so that it describes the effects of wind on a field of grass. The assumption being followed is that a field of grass is acted on initially by an gust of wind. Energy from that gust of wind is propagated through the field by interactions between neighboring blades of grass. In the end you have a 2D grid which behaves like the jell-o assignment laid on end. The only notable difference being that each blade of grass rotates to a new position instead of expanding/contracting).

 

                        The algorithm I used to determine the amount of rotation across both axis was simply to find the difference at each grid point between the ‘force exerted this time step’ from each end. Once this force had been calculated it was applied proportionally to the opposite axis of rotation (an x axis forces is given a y rotation and vise versa). Then these rotation angles were applied to the blade of grass additively.

 

Users Guide:

            Camera view rotations and zooming are accomplished through combinations of mouse buttons and dragging.

 

            To create a new ‘gust’ of wind  (1/4 the way down the y axis) press space bar

 

            To go to full screen  press ‘f’.

 

            To quite press ‘esc’

 

 

Short Comings:

 

            I have almost no user interaction going on, and for the most part when I look at my own simulation I feel like I’m driving through Oroville (the orchards). All I can typically see is row upon rows which end up looking like they are bending in the background because of how straight the rows are. Some randomness and maybe grass stalks that aren’t lines would help. (maybe a different color?)

            Some more interaction with the user would help.

            I am also getting strange boundary condition artifacts which I don’t like and would like to stop. (second screenshot)

            It would be nice to maybe have the ability to do something like hair also, or a leaf, or maybe even a tree, I really just did not have time.

            Enabling lighting would make these simulations much more realistic in my opinion.

 

Screen Shots: