Archived

This topic is now archived and is closed to further replies.

Ivyn

Discussion: Realistic Grass (and fur)

Recommended Posts

One thing I really yearn to see in games is realistic grass. What I mean by ''realistic grass'' is grass that actually protrudes from the ground and sways softly in the wind even encumbering the character''s feet. Currently all 3D games have just flat polygon surfaces colored green. I''m wondering if it''s resonable to take on the challenge of representing realistic grass in my game and I want all your opinions on how this could be accomplished and still run at a resonable speed for a realtime game. I recall seeing in a behind the scenes look at the movie ''Shrek'' they said they used a fur system for their grass because it worked so fine. This got me to thinking. Has anyone ever tried to add realistic fur into a realtime game? And/or realistic grass? I''m open to all suggestions, post on!! -- Ivyn --

Share this post


Link to post
Share on other sites
the wolfman demo by nvidia that had good looking fur had layers of textures, all slightly bigger than the ones below. maybe that would work? or theres that codecreatures engine that is incredibly slow and high poly with real grass.

Share this post


Link to post
Share on other sites
I actually did a fair bit of testing with this. Probably the best method at the moment is some variation of the "Shell and Fin" approach. If you do a search for that you''ll most likely find some Siggraph papers on the evolution of this technique.

The short version of it is that you have a bunch of planes that are evenly spaced apart. The planes each have a texture applied to them such that if you look at it the collection of planes it looks like the blades/hairs/etc are continuous from one layer to the next. In other words, imagine actually having the geometry of all of the blades of grass and then imagin cutting that into a bunch of layers. That''s the shells part of it.

The fins are another set of planes that are perpendicular to the other set of planes and lie inside of them. These are used so that as you get down to the horizon you don''t notice that you have a bunch of layered planes. These "fins" help fill in the detail. Hmmm, that may be hard to picture. But, like I say, just do a search for it and you should be able to find papers on it with pictures of what I''m describing.

Further work on this approach has involved creating and applying other textures, such as normal maps, to allow additional effects, like using a pixel shader to actually shade the grass somewhat correctly. You can also use tightly tiled maps for the grass blades themselves and then modulate the color over larger distances with another map. This allows you to get variations in the overall grass color, for areas that have been trampled through, or have gotten less water, etc. Another thing you can do is to use a vertex shader to swim the uv''s around a bit. This will give you an approximation of the blowing in the wind effect that you were askin'' about.

BUT......one thing you should be aware of is that to get really good looking stuff, you''ll need to use a decent number of layers. This is NOT cheap....especially since you''ll want to use variable alpha for the planes, which will cause a lot of overdraw. But, OTOH, it does look a helluva lot better than that badly mapped ground plane we''ll all grown to know and hate All in all, I''d say it''s certainly do-able on a decently high-end system, but just so you know, it''ll probably take you awhile to get it working efficiently and work out all the quirks involved with the process.

Well, I hope that helps!

-John

Share this post


Link to post
Share on other sites
go to the ati developer page, they show you the currently most advanced way to draw fur, wich you can use for grass as well..

"take a look around" - limp bizkit
www.google.com

Share this post


Link to post
Share on other sites
quote:

Has anyone ever tried to add realistic fur into a realtime game? And/or realistic grass?


Yep. I implemented a modified version of this system for our game (I added bumpmapping and various perpixel lighting effects). It looks nice, but I wouldn't call it totally photorealistic yet. It is pretty efficient though.

Screenshot:

Runs at about 45fps on a GF4 Ti4600. But it isn't optimized yet.

/ Yann


[edited by - Yann L on August 18, 2002 4:14:22 PM]

Share this post


Link to post
Share on other sites
Yann L: Christ, that''s the most amazing thing I''ve ever seen! OMG! Are you sure that''s in game!! (Well of course since you made it ) But WOW!

Thanks for the link to the paper, I will download and read. Tho the screens on that page don''t look nearly as good as yours do.

Teknofreek thank you for your excellent post as well!

-- Ivyn --

Share this post


Link to post
Share on other sites
there is a way to apply an effect that makes it look like grass is swaying lightly in the wind that we are now using for our game. (actually 2, i''ll post the second one tommorow)

What we did was have some wind directions that didnt really affect gameplay that much so dont go on about that. Now, we had our 3d guy (who we sealed in carbonite to keep safe) to do a little trick with shadows and blur effects. First, we had a shadow cast on the ground with grass on it. Simple enough, we just made certain areas of the map have a "grass" tag put onto them.

Next we added in the math which calculated the angle of the wind, wind intensity, and grass variations, which was done by our math chick (if you are offended by the word chick, thats a name she came up with, so deal with it.) The angle of wind and wind intesity are pretty self explanatory, however, i should get into grass variations. Basically what this does is determine the shadow intesity based on the grass length (another simple thing based on the grasses length in inches) So the taller the grass is, and the higher variance amount (ya know, 3 inches give or take about half an inch).

Then, after all of this is put in next comes the shadow movement and blur effect. Wel, we just take the wind intensity and angle to determine the speed and direction the shadow on the grass is headed. That was simple. Then we apply a blur effect that has an intensity that changes depending on the length of the grass. Since we limit the amount of shadows, we get a nice and fast grass shadow system. I''ll post how we did large amounts of high grass tommorrow.

Share this post


Link to post
Share on other sites
Damn Yann! You sure that''s a real-time render there? The blades look really high-quality. I don''t suppose you can post a little viewer app of that scene, could you? I''d LOVE to look see how it holds up when looking/moving around in it

-John

Share this post


Link to post
Share on other sites
Ivyn: thanks, glad you liked it. And this is a realtime in-game shot of a small test level (a testbed for all kind of natural effects).

quote:

Thanks for the link to the paper, I will download and read. Tho the screens on that page don't look nearly as good as yours do.


Well, the paper doesn't really address the issue of rendering. They focus more on the animation of the individual grass blades and on the LOD system.

The parts I took from the paper is their LOD idea (slightly adapted): 3D blades in the near field, 2.5D further away and 2D far away from the camera. The LOD scheme is an important part, esp. on huge grass fields. Since the whole grass field is procedurally defined, you can easily get several hundred billions of blades. No 3D card can handle that

I also used parts of their animation idea. I liked their way to represent 'wind primitves'. That way, you can easily have a procedural weather system, that creates different controlled wind effects (from simple direction wind blows, to vortex/tornado like movement). However, I replaced the wind evaluation equations with a 2D fluid dynamic system (a 2D Navier Stokes solver). That way, the movement of the grass is physically more or less accurate.

About the rendering itself, it's actually not very complicated. Basically pixelshader magic Good colours and alpha antialising to render the individual blades. Shadows onto the grass are done via projective shadowmapping. The 2.5D and 2D representations are bumpmapped using an animated normalmap. From a distance it looks like 3D blades, at only a fraction of the cost of a real 3D blade.

The only real performance bottleneck are the true 3D blades near the camera. But the geometry is fully in VRAM, and all deformation is done on the GPU using vertex shaders. That way, you can render quite a bunch of blades on a GF4. It also automatically adapts to framerate: if the fps drops below a certain limit, it will reduce the number of 3D blades and replace them with faked bumpmapped 2.5D representations.

Teknofreek: yep, that's realtime (45fps on a GF4-Ti4600, Athlon XP 2100. It could faster, if I wasn't so lazy to optimize it a bit more ) About the viewer: hmm, game company, hmm, NDA, hmm, lawyers, hmm, nope, sorry. But we will have a public playable demo of our game for around november, it will have the grass and a lot more nice stuff (note the shameless plug )

/ Yann

[edited by - Yann L on August 18, 2002 10:33:29 PM]

Share this post


Link to post
Share on other sites
>>Teknofreek: yep, that''s realtime (45fps on a GF4-Ti4600, Athlon XP 2100. It could faster, if I wasn''t so lazy to optimize it a bit more )<<

Heh, sounds good enough to me Real nice work man!

>>About the viewer: hmm, game company, hmm, NDA, hmm, lawyers, hmm, nope, sorry.<<

Totally understood...I know how that stuff goes. I was just hopin'' you might be able to since you were able to post a screen shot

>>But we will have a public playable demo of our game for around november, it will have the grass and a lot more nice stuff (note the shameless plug )<<

Sweet! What type of game is it? Anyway, be sure to post another shameless plug up here when the demo is out so I''ll know to go check it out

-John

Share this post


Link to post
Share on other sites
Crap on a crutch YannL!

You''ve got that running at 54fps, and it ISNT optimized yet? You''ve got some crazy ass coding going on there. I cant even fake a grass effet that good.

Share this post


Link to post
Share on other sites
realistic grass would be a really cool thing to add to my 2d game later on. i'm certainly going to look into that. and YannL, that screenshot is truly breath-taking!

edit: YannL, you really should move this to the Graphics Programming and Theory forum.

---
shurcool
wwdev


[edited by - shurcool on August 19, 2002 2:26:41 PM]

Share this post


Link to post
Share on other sites
Yann: please don't post here ever again. You make me feel worthless

Seriously man, your work is amazing. Could you post a little about yourself? What kind of education you have, how long you've been working with graphics, how long you've been programming, stuff like that. I'm just interested because I've been heavily working with graphics for about 4 years (although I started out with 2d, that took a bit of time) and I'm not nearly close to being as good as you are. I'm just interested what it took for you to get that good.

I can't wait for the public demo of your game. I don't generally buy a lot of games, but you can be sure I'll buy yours when it's published.

EDIT: Yann, how do you deal with z-buffer precision? You have such little details as grass blades and apples on the grass that you can get very close to, how do you manage to keep your z-buffer usable over large areas?

[edited by - kill on August 19, 2002 5:06:04 PM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Yann, Are all the shots under http://membres.lycos.fr/ylmb/images/ from something running in real time?

Share this post


Link to post
Share on other sites
quote:

Yann: please don''t post here ever again. You make me feel worthless


Please don''t, it''s really not my intention to make people feel like that I''m just posting this stuff to show people what can be done on todays hardware, and give them ideas for their own projects. There are so many theoretical papers about advanced graphics out there, but finding pratical information about actually implementing them is incredibly hard. I think that information about those advanced effects needs to be shared. And if people see a cool screenshot and think "Oh man, that looks cool, I also want to code that !", and they actually try it (and learn a lot by doing so), then that goal is reached.

quote:

Seriously man, your work is amazing. Could you post a little about yourself? What kind of education you have, how long you''ve been working with graphics, how long you''ve been programming, stuff like that. I''m just interested because I''ve been heavily working with graphics for about 4 years (although I started out with 2d, that took a bit of time) and I''m not nearly close to being as good as you are. I''m just interested what it took for you to get that good.


Oh well, I don''t know if I''m really that good. You never stop learning, that''s part of the experience. I''m just incredibly passionate (read: addicted ) about computer graphics (esp. realtime). OK, if you insist, ''Yann in a nutshell'': I''m 25, I''m programming since the age of 12 or so (starting on a C-64). I really started with graphics in the early 90''s, I''ve been quite active in the demoscene at that time. And I knew I wanted to do 3D when I first saw Wolfenstein-3D About the education: I''ve done totally non-computer related studies (quantum physics). But I had to drop it, because I wasn''t able to finance it anymore. So I started to work in the computer graphics domain, which turned out to be quite a cool thing

quote:

EDIT: Yann, how do you deal with z-buffer precision? You have such little details as grass blades and apples on the grass that you can get very close to, how do you manage to keep your z-buffer usable over large areas?


It''s just a standard 24bit zbuffer. However, the near clipping plane is pretty far away (approx. 8 units), which gives me a lot of dynamic precision near the camera. When you go further away, then the grass blades will z-fight. But that''s no problem, since they get replaced by 2.5D patches long before that happens.

quote:

Sweet! What type of game is it?


Singleplayer medieval fantasy RPG with very strong adventure elements.

quote:

Yann, Are all the shots under http://membres.lycos.fr/ylmb/images/ from something running in real time?


Yep. They are mostly linked by that sky rendering thread some time ago. Except that poor looking photograph of a solar eclipse. I posted it on an eclipse thread in the lounge, in an attempt to show off my incredible photographic talents (*cough*)... Which failed miserably, because bishop_pass posted a link to his professional photo-gallery just a little later...

/ Yann

Share this post


Link to post
Share on other sites
quote:

Please don''t, it''s really not my intention to make people feel like that.


I know, I meant it as a joke. Your work definetly inspires me to do something new and to learn new things in order to do it.

Keep up the good work so we can all enjoy beautiful screenshots

Share this post


Link to post
Share on other sites