View Full Version : Normal Mapping Grass
Has anyone had experience normal mapping grass? It seams like an easy way to add eye candy to GL Golf but I don't know how it will turn out on a grass surface. Also, if a card has enough texture units will it slowdown performance at all?
OneSadCookie
2005.04.23, 07:54 PM
I'm pretty sure that's one of the things that's standardly done with grass. You can probably find an article online, or nip down to your local bookshop and skim through the GPU Gems books.
It'll always be a performance hit, but whether it's an acceptable performance hit or not will depend on what hardware you're running on and what else you're drawing.
phydeaux
2005.04.23, 07:59 PM
Do you have grass tuft billboards in the game? You can add a lot of depth to the look just with that simple trick (I think most modern games still use this simple trick.) You'd only draw tufts relatively close to the camera so as not to add too many additional polygons.
I'm pretty sure that's one of the things that's standardly done with grass. You can probably find an article online, or nip down to your local bookshop and skim through the GPU Gems books.
It'll always be a performance hit, but whether it's an acceptable performance hit or not will depend on what hardware you're running on and what else you're drawing.
Cool, I am going to try it. I think i'm going to look at arekkusu's chart and only let good enough video cards take advantage of it.
Do you have grass tuft billboards in the game? You can add a lot of depth to the look just with that simple trick (I think most modern games still use this simple trick.) You'd only draw tufts relatively close to the camera so as not to add too many additional polygons.
Good idea, I will look into that too!
arekkusu
2005.04.24, 12:41 PM
I think i'm going to look at arekkusu's chart and only let good enough video cards take advantage of it.
That chart only deals with features. It doesn't say anything about performance. You have to figure performance out by trial and error, testing on all the hardware.
That chart only deals with features. It doesn't say anything about performance. You have to figure performance out by trial and error, testing on all the hardware.
I know, but I am one of those people that know how fast every CPU or video card is. From your chart I am just going to use cards with 4 or more units.
Puzzler183
2005.04.24, 01:50 PM
Btw, GPU Gems 2 has an excellent article on instancing grass billboards and other plants along with ways to make each instance unique via vertex shaders. Definitely worth a read if you are looking to make cool grass.
And don't worry, dot3 bumpmapping is very cheap now.
Fenris
2005.04.24, 02:56 PM
Excuse a question, but: normal mapping grass? How would you do that? It sounds interesting. :)
Excuse a question, but: normal mapping grass? How would you do that? It sounds interesting. :)
The same was as any other bump/normal mapping. I haven't actually done it yet but I have used the DOT3 function in openGL before and I know its not that hard to set up.
Now getting normal maps for my grass textures might be tricky!
Leisure Suit Lurie
2005.04.24, 04:13 PM
Couldn't you do this just with GL_LINES ?
Seems it would be simpler.
Couldn't you do this just with GL_LINES ?
Seems it would be simpler.
I could, but I bet a billboarded texture would look better and speed isn't an issue because I won't be making that many of them.
I have no clue how to modify this to work with a normal map, I am assuming I enable unit 2 and then i do something like this?
(unit1 mixes with unit 2 in the code posted below) modulated by (normal map dot3 light source vector)
Is that correct?
// set up the first texture unit to interpolate between grass and water using crossbar extension
glActiveTextureARB(GL_TEXTURE0);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, gv->texture[m]);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_INTERPOLATE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE1_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_TEXTURE0_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB, GL_PRIMARY_COLOR);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB, GL_SRC_ALPHA);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_INTERPOLATE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_TEXTURE1_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_TEXTURE0_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_ALPHA, GL_PRIMARY_COLOR);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_ALPHA, GL_SRC_ALPHA);
// set up the second texture unit for primary color tinting
glActiveTextureARB(GL_TEXTURE1);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, gv->texture[k]); // sampled only by first unit
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PRIMARY_COLOR);
GLfloat constant[4] = {1, 1, 1, 1}; // force final output alpha to 1, doesn't matter if not blending
glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, constant);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_CONSTANT);
Fenris
2005.04.25, 02:05 AM
Ah, we're talking flat-on-the-ground grass? I eee.
Well the normal map would be applied to the flat ground texture, who knows about the fake grass that grows vertical, I will either billboard some X's of grass or use GL_LINEs.
Puzzler183
2005.04.25, 04:47 PM
Use billboards........ GL_LINES is the truly naive solution: it would mean you would have many times as many vertices, and it probably wouldn't look as convincing. And you completely miss out on texture effects if you use lines.
aarku
2005.04.25, 05:38 PM
Although not specifically about OpenGL, I think this shows some really good results of normal mapping billboards. Check out the movies.
http://www.drone.org/tutorials/lighting_flat_objects.html
-Jon
Fenris
2005.04.25, 05:43 PM
Jesus H. Christ that's a nice quad.
aarku
2005.04.25, 05:44 PM
This is an interesting paper on real time grass:
http://w3imagis.imag.fr/Publications/2001/PC01/
Some ideas in there :)
-Jon
Cool, thanks for the links!
Right now (Before I read the post) I made a class that generates X amount of random points and then assigns variables depending on what surface they lay on (no grass growing in the water). I quickly then rendered them with GL_Lines and it looked bad because they were all the same width regardless of distance. I can still use the same code for billboards. I will post a screenshot when I get it finished.
vBulletin® v3.6.8, Copyright ©2000-2008, Jelsoft Enterprises Ltd.