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?
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.
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.
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.
OneSadCookie Wrote: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.
Quote: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!
Jake Wrote: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.
arekkusu Wrote: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.
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.
And don't worry, dot3 bumpmapping is very cheap now.
Excuse a question, but: normal mapping grass? How would you do that? It sounds interesting.
Fenris Wrote: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!
Couldn't you do this just with GL_LINES ?
Seems it would be simpler.
Seems it would be simpler.
"Yes, well, that's the sort of blinkered, Philistine pig-ignorance I've come to expect from you non-creative garbage."
Daniel_Lurie Wrote: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?
(unit1 mixes with unit 2 in the code posted below) modulated by (normal map dot3 light source vector)
Is that correct?
Code:
// 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);
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.
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Normal Mapping Precision on iOS | OptimisticMonkey | 6 | 7,401 |
Apr 13, 2011 11:35 PM Last Post: OptimisticMonkey |
|
| Getting the Normal for a polygon. | Jaden | 3 | 4,677 |
May 1, 2009 01:47 PM Last Post: Nosredna |
|
| Vector (Normal) Map blending operations? | kelvin | 10 | 5,908 |
Mar 16, 2007 04:31 PM Last Post: OneSadCookie |
|
| drawing or displaying vertex normal | shru_ani | 3 | 3,006 |
Oct 29, 2006 06:04 AM Last Post: shru_ani |
|
| Gouraud vs Normal maps for dinamic terrains | sohta | 6 | 3,410 |
Oct 11, 2006 12:55 AM Last Post: sohta |
|

