Skip to main content
gamedev.net
🔒 Locked

Grass coverage map help

Started by Etus Jan 5, 2009 at 5:12 AM 0 replies 1.2k views
Original Post
Etus
Etus
Hi, I'm currently trying to impelemnt a grass system in my engine on the terrain, and right now I'm struggling with finding a good way to place grass in the right places. I've read a lot of papers and looked in the forums, and the best thing I came up with is to use a coverage map to decide where the grass will appear. What I don't understand is how I can place the grass billboards based on the coverage map? I know I can read the file into an array and find out the positions I need, but I want to do it on the GPU using shaders. The only idea I thought about was to read the value from the coverage map in the pixel shader and use that to determine whether or not the currently rendered billboard is visible. But it seems a waste since I'm sending a lot of grass billboards in advanced that might not be rendered anyway. I looked at NVIDIA's Nature Scene demo and Anti-Aliasing with Transparency(which renders grass too) and I didn't understand how they used the coverage map to decide where the grass is rendered (I think they used the stencil buffer, though I'm not sure). Any ideas? Thanks!
mrbastard
mrbastard
Quote:
Original post by Etus
I know I can read the file into an array and find out the positions I need, but I want to do it on the GPU using shaders.


Any particular reason you want to do it in the shaders? If the coverage map doesn't change between frames I'd suggest just reading the relevant positions into a vert buffer. In fact assuming your grass will follow the terrain, you could just create an extra index buffer and use the existing terrain vertices (with offsets applied in the vert shader).
[size="1"]

Topic Locked

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

Sign in to reply to this topic.