Skip to main content
gamedev.net
🔒 Locked

Grass Rendering

Started by Hiyar 6 replies 2.6k views
Original Post
Hiyar
Hiyar
Hi, How is dynamic painting and rendering of grass performed. Is it just the same as texture splatting? So that mask values control the visiblity and density of the grass meshes. I'm using vertex texture for terrain, that can be used to determine where to place the grass meshes I think that can be done in the GPU. I need more details how to do "Grass Rendering". (and instancing)
Hiyar
Hiyar
Thanks,
GPU Gems article is about animating grass meshes. I wanted to know how the visiblity of the grass is controlled. And how dynamic painting in the editor is performed. I want the grass only appear where grass texture is applied and also want to control the density and maybe random scale of the grass. It should look naturally. I don't know how to do this by using textures or maybe render targets?
dave j
dave j
Look at the VTP plants page I linked to. That has lots of papers discussing various approaches to both rendering and distributing plants - including grasses.
Matt Aufderheide
Matt Aufderheide
What i've done is to use a grass "mask"; if you are doing texture splatting on your terrain, you should have some kind of greyscale mask texture.

Then when i want to render grass, i have a finite number of grass positions calculated every so often depending on camera position. Then when I want to move the grass, i check the positions against the grass mask; if the mask is black, that particular position is disabled. You could expand this to use the greys in the mask to lower the number of meshes rendered for sparser grass areas.

As far as vertex textures go, i use these for terrain too, and for grass its ideal to get the right height so all you need to set is the x and z positions.

For actually rendering of the grass, there a number of methods. One can use meshes, sprites, or both. Either way you should use some kind of instancing or batching. There is a description of instancing on the directX document page if you are using D3D.

Either way, other than drawn call batching, the main problem with rendering lots of grass is overdrawing alpha-tested pixels; you should sort from front-to-back to eliminate this problem.



Hiyar
Hiyar
Yes, then I need to create render target textures, because some mask values are computed in the GPU (not stored as textures).

How are you calculating grass positions? I don't understand the part 'depending on camera position'.

[Edited by - Hiyar on March 30, 2009 10:21:13 AM]
Matt Aufderheide
Matt Aufderheide
Quote:
Original post by Hiyar
Yes, then I need to create render target textures, because some mask values are computed in the GPU (not stored as textures).

How are you calculating grass positions? I don't understand the part 'depending on camera position'.


Yes I do the same thing with masks becasue I use noise.

For the grass positions, I do somehting like this:

create a number of pseudo-random points around the the camera position. Every so often as the camera moves, I wrap around the grass positons to be in the same relative spot...because i fade the grass in and out using alpha noise, this movement is not noticeable. I dont use fixed points because of the massive size of my world; its much easier to work wiht a small number of moving positions calculated every so often..it also means I only render a certain maximum number of grass models per frame.

Vilem Otte
Vilem Otte
You may try even mine solution:

Cast some rays around Y axis around the camera (in random points, or grid ... it's up to you) and check (based on some map for terrain) if you're not on road, or if you did not hit some object (house, stone), then you can place grass on the collision point between ray and terrain.

If you use some optimisation (scene hierarchy - precomputed KD-trees should be okay for this), then you can do this in real time.

Topic Locked

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

Sign in to reply to this topic.