Sunday, May 26, 2019

Variation in grass height, width and inclination

Although the grass field does look great with merely variation in rotation, position and color, it is meaningful to add the possibility to vary in the height, width and inclination of the grass blades. Using normal distributions for all of these attributes (just like it has been done with the rotation), values giving good looking grass variations have been chosen. The grass field now resembles a much wilder field when looking closer.

Grass field with variations
Pictures of the variation in height. Difference in inclination can also be seen.

However, a problem was also discovered during this iterative cycle. Although it's very, very difficult to notice, some grass blades are sometimes levitating in the air because of their random positioning.

A couple of levitating grass blades
This problem is again barely noticeable when not hugging the ground, but it would be good to remedy it. The way the algorithm works at the moment is that it assigns the y-coordinate depending on which vertex of the field mesh it is currently at. The problem with this, naturally, is that when randomizing the position, you also need to have a corresponding change in the y-coordinate, since the field changes elevation depending on its x and z coordinates. The current implementation does not tackle this.

An approximative solution is to at least try to reduce the distance the grass blade has from the closest point on the field. An easy implementation is to look at how far away the randomization brought the grass blade, and then either let the grass blade's y-coordinate remain the same as its home vertex or let it become the average of two vertices. Long story short, in some cases the y-position will now be the average of two vertex positions, rather than always the y-coordinate of the vertex that is currently being iterated on.

Less drastic levitations

That's the final procedural parameter implemented.

No comments:

Post a Comment