Grass

Started by
18 comments, last by soconne 19 years, 9 months ago
Hi,
what is a color keyed texture? Sorry I'm new to this whole OpenGL thingy. :)
Advertisement
Quote:Original post by DerAndiY
Hi,
what is a color keyed texture? Sorry I'm new to this whole OpenGL thingy. :)


a Texture with an alpha channel set to 1 everywere except where your KEYCOLOR is present, there it is 0. so that one color is transparent, while everything else is Fully opaque

(Bright Purple is a common used color for this, sence you hardly ever would see such a color in a texture)

AlphaTesting is commonly used with Color Keyed Textures, senced there is no need to have partially blended colors.
"I seek knowledge and to help those who also seek it"
A method that works very well when you're relatively above the grass looking down is simply to have a series of quads with a masked texture of dots layered on top of eachother to give the illusion that you have complete lines. It's also pretty easy to get some motion. The main problems are that it's impossible to move blades of grass individually (only in "chunks") and that it's hard to get curved blades, along with the fact that if your perspective gets too sharp, you'll end up seeing between the quads and your grass will look flickery or simply as separate floating dots ;).
-~-The Cow of Darkness-~-
Thanks for the explanation... I know what you mean. I'm just not familiar with the terminology.
Cheers
Andy
Quote:
...that if your perspective gets too sharp, you'll end up seeing between the quads and your grass will look flickery or simply as separate floating dots


true, you've described the 'shells' part of the 'fins and shells' algorithm, but the 'fins' part solves that problem you mentioned :)
do unto others... and then run like hell.
Quote:Original post by cowsarenotevil
A method that works very well when you're relatively above the grass looking down is simply to have a series of quads with a masked texture of dots layered on top of eachother to give the illusion that you have complete lines.

That's part of the shells ans fins algorithm, as FreY mentioned.
Note that this effect only (ie without fins) has been used in many games like Star Fox Adventures (GameCube) and look pretty good granted that the camera has limited view angles. The mistake made in Star Fox Adventures is that the effect was not only applied on grass : it was also applied on the hero (note: the hero is a fox, thus fur rendering) but the polygons of the hero can be parallelto the viewing direction, and in that case the shells look crap without the fins.

Quote:Original post by cowsarenotevil
It's also pretty easy to get some motion.

True.

Quote:Original post by cowsarenotevil
The main problems are that it's impossible to move blades of grass individually (only in "chunks") and that it's hard to get curved blades,

With vertex programs thing become a tad easier, but it's true that there's still no complete freedom for the grass physics.

Quote:Original post by cowsarenotevil
along with the fact that if your perspective gets too sharp, you'll end up seeing between the quads and your grass will look flickery or simply as separate floating dots ;).

A common way to avoid the minification (flicker) problem is to play with mipmaps, because in OpenGL you can define your own mipmap levels (and this is a perfect example on where it's useful NOT to use traditional mipmap computation).
As for magnification, there are other techniques, such as LOD bias which works more or less depending on your application.
A paper by a friend of mine:
Realtime Animated Grass


Basically the Shells, but with curved blades and wind.
Waramp.Before you insult a man, walk a mile in his shoes.That way, when you do insult him, you'll be a mile away, and you'll have his shoes.
Just forgot to mention, but shells and fins rendering can be enhanced by anisotropic lighting.
I'm not sure if this technique is performance-friendly enough, but it looks to give very good results.

http://w3imagis.imag.fr/Publications/2001/PC01/paper.pdf
You could just do it the way battlefield and many many other games do it, including FarCry.

Create a texture that represents where grass is on your terrain, if a pixel has a value of 0, no grass, > 0 there is grass. Then during rendering, figure out where the player is in relation to the texture, then scan all pixels in the texturemap within a specified radius on the texture, and for each pixel you encounter with a value > 0, render a set of grass quads, or even a single grass quad.

This is by far the easiest method and actually looks pretty good. With this method it is very easy to have grass fade in and out with distance.
Author Freeworld3Dhttp://www.freeworld3d.org

This topic is closed to new replies.

Advertisement