Archived

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

Sages

Real-time grass

Recommended Posts

Sages    630
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.

Share this post


Link to post
Share on other sites
_DarkWIng_    602
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.

Share this post


Link to post
Share on other sites
WarAmp    750
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."

Share this post


Link to post
Share on other sites
WarAmp    750
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."

Share this post


Link to post
Share on other sites
toucel    188
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

Share this post


Link to post
Share on other sites
RajanSky    100
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

Share this post


Link to post
Share on other sites
Sages    630
Thanks Waramp I think I''ll play with that randomly facing quad idea and see if I can get something up and running. If anyone else has any insight, ideas or comments, please post.

Share this post


Link to post
Share on other sites
BeanDog    1065
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 );

Share this post


Link to post
Share on other sites
WarAmp    750
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."

Share this post


Link to post
Share on other sites
Sander    1332
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]

Share this post


Link to post
Share on other sites
Mirgatroid    100
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

Share this post


Link to post
Share on other sites
VanKurt    133
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....?

Share this post


Link to post
Share on other sites
VanKurt    133
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]

Share this post


Link to post
Share on other sites
Sander    1332
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!

Share this post


Link to post
Share on other sites
WarAmp    750
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."

Share this post


Link to post
Share on other sites
PmanC    134
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]

Share this post


Link to post
Share on other sites
WarAmp    750
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."

Share this post


Link to post
Share on other sites
blueknight    122
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.

Share this post


Link to post
Share on other sites
Matt Halpin    139
I''ve used the billboarded quad technique before. Look at the bottom section of screenshots on my page:

http://www.mhalpin.34sp.com/images.html

The Old* images even use 15 tri models for each grass blade, rather than billboards.

If you''re using a heightfield, then you can map the geometry over the terrain using the vertex shader, so all your grass geometry is static:

Create a grass model with a number of blades covering an 8x8 tile section of terrain. For each blade, work out which triangle it sits on, and the barycentric weights of the triangle vertices. Now store this info in the mesh data using a similar scheme to skinning (indices + weights). Now, when rendering an 8x8 block of grass, pass the heights of each vertex in the shader constants, and have your shader do the ''skinning'' to get the final height of the blade. It''s not skinning as in using matrices, but just blending 3 height values based on the weights.

NB, this can be combined with billboarding - standard v.shader billboarding.

Also, you only need to store vertex heights in the shader constants, so you can pack in a shadow term and a 2D wind vector that can be used to perturb the grass as well.

HTH,

Matt Halpin

PS. I used the barycentric skinning stuff to map the rocks/flowers over the terrain as well.

Share this post


Link to post
Share on other sites
UltimaX    468
quote:
Original post by Matt Halpin
http://www.mhalpin.34sp.com/images.html

The Old* images even use 15 tri models for each grass blade, rather than billboards.



OldLandscape2 takes the win over them all. That looks sweet. Good job.



-UltimaX-

"You wished for a white christmas... Now go shovel your wishes!"

Share this post


Link to post
Share on other sites
Bruno    155
Hey,


"The Old* images even use 15 tri models for each grass blade, rather than billboards. "


You "Old" engine looks very sweet
What''s the frame rate with those grass meshes ?
And those rocks , can you have them all over the landscape or you have them only in small portions of the map ?

thanks,
Bruno

Share this post


Link to post
Share on other sites
Matt Halpin    139
quote:
Original post by Bruno
Hey,


"The Old* images even use 15 tri models for each grass blade, rather than billboards. "


You "Old" engine looks very sweet



Yeah. The new stuff looks slightly nicer in motion I think, though it''s a close call. I think I screwed up the water though, so the old ones have nicer looking water

quote:
Original post by Bruno
What''s the frame rate with those grass meshes ?
And those rocks , can you have them all over the landscape or you have them only in small portions of the map ?



Well, on a very early GF3 (the card I developed the Old* stuff on) it was between 20 and 30fps with everything on: all the detail meshes (grass + rocks), water reflections etc.

On my Radeon 9700 it zips along much faster than that

wrt Rocks: They''re actually all over the landscape, but fade out at a certain distance. That''s tweakable per mesh, so bigger rocks fade out much further than the grass, or small pebbles. I was planning on fading out the meshes, and fading in a bumpmap pass that has the rocks rendered into it, so that you don''t get them disappearing alltogether, but I never got around to it.

HTH,

Matt Halpin

Share this post


Link to post
Share on other sites
cowsarenotevil    3005
quote:
Original post by Sander
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).



Gah, why can none of my ideas be original?

Share this post


Link to post
Share on other sites