Skip to main content
GameDev.net gamedev.net
🔒 Locked

Real-time grass

Started by Sages Aug 13, 2003 at 9:34 PM 29 replies 10.3k views
Original Post
Sages
Sages
I just finished my terrain renderer, well I finished the original project, but now I want to add more. Specifically, I want to make the scenes more complex by rendering grass and shrubs near the player (ala PlanetSide, and Star Wars Galaxies). However, I really don''t know where to begin. I think I''m mostly having trouble understanding how to store that data. If anyone has any insight into how the pros are doing this, or if you have any related thoughts at all, I''d appreciate the replies.
Mirgatroid
Mirgatroid
look at ATI''s site (or nvidia) on real-time fur

fur can be grasslike i''d imagine
End Of Discussion.
_DarkWIng_
_DarkWIng_
Look at the FAQ of this forum. There is a link to paper caled "Animating Prairies in Real-Time". ( http://w3imagis.imag.fr/Publications/2001/PC01/ )

You should never let your fears become the boundaries of your dreams.
You should never let your fears become the boundaries of your dreams.
WarAmp
WarAmp
The way NeverWinter Nights and Star Wars: Knights of the Old Republic do it is to simply have a bunch of vertical, but randomly facing quads with a pretty texture that sort of matches the ground texture. Create a grid of these quads and tile that grid over the grassy areas, fading the quads in/out as they get far enough away from you. Looks pretty nice imo, and you can animate the top 2 vertices of the quads in a VP to get wind effects, and such.


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."
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.
WarAmp
WarAmp
Also, check this out:
http://www.cs.ubc.ca/~bbakay/grass/grass.html



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."
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.
toucel
toucel
Wow WarAmp, thanks for that link!

It shows a method that I was already playing around with, but has inspired me with its ideas behind the animation.

Sweet
RajanSky
RajanSky
Personally I think using quads with pretty textures is currently the best way to do it in real-time... Most of the grass I''ve seen which uses a polygon for each blade looks pretty horrid.

It''s not that it can''t be done. I mean, in the movie, Shrek, they modeled each individual grass blade and it looked great. But to do that in *real-time* and have it look really nice probably won''t be feasible for another 4-5 years, imo
BeanDog
BeanDog
I once implemented something like this. It works best with short grass (ankle-high, not knee-high). I used MAX to pre-render a ton of grass from several camera angles. Then I used one big quad... I measured the camera angle relative to the quad, found the closest match in my pre-renders, and made that one the current texture for the quad. It worked pretty durn well. It looks really 3d, since the texture changes as the angle changes, but it''s just a single quad.



~BenDilts( void );
WarAmp
WarAmp
hmm, thats a really great idea actually, BeanDog. I was thinking of doing something similar with my grass, but I was hoping I could somehow trick a projective texture of the grass into doing that for me. It''s still very much a meta-idea tho.





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."
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.
VanKurt
VanKurt
Yeah, kewl idea. Can you post a screenshot of that?
Sander
Sander
Dwonload the RoboBlast demo from my signature. Two of the levels use a grass technique similar to this. Here's a screenshot:

EDIT: Dang.... linked the wrong pic...


Sander Maréchal
[Lone Wolves Game Development][RoboBlast][Articles][GD Emporium][Webdesign][E-mail]


GSACP: GameDev Society Against Crap Posting
To join: Put these lines in your signature and don't post crap!

[edited by - sander on August 16, 2003 11:50:52 AM]
Mirgatroid
Mirgatroid
BeadDog,

your idea is similar to mine, which is more of a hybrid. I have the fur rendered up front as grass, then i have the grass texture in the background


renders real perty like
End Of Discussion.
VanKurt
VanKurt
What is that "fur" stuff you''re talking about? Is "fur" a new geometric object? ;-)

No, seriously, whats the idea behind that? 3D Blades? Sprites? Impostors? Or.. i dunno....?
VanKurt
VanKurt
Oh, and could you guys tell me more about that pre-rendered-quad approach?
I love grass!!!

PS: That screenshot looks GOOD!

[edited by - VanKurt on August 16, 2003 12:26:04 PM]
Sander
Sander
Thanks, but trust me, it looks even better when you can see the level scrolls. Then you really see the 3D effect. You can see the idea behind it in the following screenshot.



The grass is made up of several layers packed very close together (There''s more space in the above pic to make the layers show). It''s made of one texture. The RGB image contains your regular grass texture (this one was ripped from Unreal). The Alpha channel contains a 0/1 noise pattern. The lowest layer is rendered normally. The layers above that are rendered with alpha testing and hence, will only show a dot on a 1 in the alpha channel. I also made the higher layers a bit stretched in the x and z direction to enhance the 3D effect. You can animate it real easy by shifting around the texture coords. To improve the rendering speed I draw top-bottom (reduce overdraw).



Sander Maréchal
[Lone Wolves Game Development][RoboBlast][Articles][GD Emporium][Webdesign][E-mail]


GSACP: GameDev Society Against Crap Posting
To join: Put these lines in your signature and don''t post crap!
WarAmp
WarAmp
I tried that method on my terrain engine, but it just murdered my framerate. Too much fillrate I think. The Random quad method seems to be much better for me for some reason, even tho it is more poly''s. The main bottleneck in that method seems to be finidng the height of the terrain beneath each quad. Anyone have a bit of webspace I could use to toss up a screenshot?



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."
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.
PmanC
PmanC
i've never tried that method so i don't know for sure but if you had a terrain engine you re going to be walking on the terrain most likely(sp?). this means you view is going to be close to parallel to the ground. wouldn't ruin the look of the grass? i guess it all depends on how tall the grass is and how packed the shells are. -PmanC

[edited by - PmanC on August 16, 2003 9:26:04 PM]
WarAmp
WarAmp
Yes, it does harm the look of the grass as you can see between slices on hills and in the distance. one thing I played with to compensate for that is to ''squish'' the upper layers inward, so that the slices all sort of line up with your line of sight. However, that has the side effect of making it seem that all the grass points towards you at all times...



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."
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.
blueknight
blueknight
I''ve done the layered grass before too on PC and GameCube. Anyway, there are a few improvements that can be made to make it look better and be more viable.

1) Store a heightmap in your alpha channel and give your grass some shape (imagine an elongated bullet). You can also have blades of varying height.
2) Generate a bumpmap from that heightmap and then use that for lighting. This does wonders.
3) Alpha blend (and alpha test) so that the grass is opaque at the bottom but upper layers will become more translucent. This will help anti-alias your grass and done right it can look alot nicer.
4) Apply offsets to each layer and make the grass move. Or even better, displace each layer along your vertices normals then apply an animation to those normals. This way grass can move in different directions on different parts of you mesh.
5) Change the number of layers based on where the camera is when compared to the grass. You can smoothly decrease the detail (number of layers) until you just have your base (ground) layer.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.