Normal Mapping Grass

Member
Posts: 509
Joined: 2002.05
Post: #1
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?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
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.
Quote this message in a reply
Member
Posts: 184
Joined: 2004.07
Post: #3
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.
Quote this message in a reply
Member
Posts: 509
Joined: 2002.05
Post: #4
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!
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #5
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.
Quote this message in a reply
Member
Posts: 509
Joined: 2002.05
Post: #6
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.
Quote this message in a reply
Puzzler183
Unregistered
 
Post: #7
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.
Quote this message in a reply
Oldtimer
Posts: 834
Joined: 2002.09
Post: #8
Excuse a question, but: normal mapping grass? How would you do that? It sounds interesting. Smile
Quote this message in a reply
Member
Posts: 509
Joined: 2002.05
Post: #9
Fenris Wrote:Excuse a question, but: normal mapping grass? How would you do that? It sounds interesting. Smile

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!
Quote this message in a reply
Moderator
Posts: 529
Joined: 2003.03
Post: #10
Couldn't you do this just with GL_LINES ?

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."
Quote this message in a reply
Member
Posts: 509
Joined: 2002.05
Post: #11
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.
Quote this message in a reply
Member
Posts: 509
Joined: 2002.05
Post: #12
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?

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);
Quote this message in a reply
Oldtimer
Posts: 834
Joined: 2002.09
Post: #13
Ah, we're talking flat-on-the-ground grass? I eee.
Quote this message in a reply
Member
Posts: 509
Joined: 2002.05
Post: #14
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.
Quote this message in a reply
Puzzler183
Unregistered
 
Post: #15
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.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Normal Mapping Precision on iOS OptimisticMonkey 6 20,428 Apr 13, 2011 11:35 PM
Last Post: OptimisticMonkey
  Getting the Normal for a polygon. Jaden 3 5,814 May 1, 2009 01:47 PM
Last Post: Nosredna
  Vector (Normal) Map blending operations? kelvin 10 6,742 Mar 16, 2007 04:31 PM
Last Post: OneSadCookie
  drawing or displaying vertex normal shru_ani 3 3,588 Oct 29, 2006 06:04 AM
Last Post: shru_ani
  Gouraud vs Normal maps for dinamic terrains sohta 6 4,084 Oct 11, 2006 12:55 AM
Last Post: sohta