Grass instancing using imposter sprites

Here’s a thing I’ve been wanting to try for a while. It’s a test that uses a quad with the imposteruv material function to get multi angle grass and fake a higher detailed look. There’s still lots of room for improvement (i’m not using a lot of the sprite so I’m wasting some performance on overdraw). Also want to get pixel depth offset and normals in there for better lighting. But as a proof of concept, i’m pretty happy with it so far.

Update:
20be6613fe057d953faf4623f7ec1c316f5c0c95.jpeg

old:

https://www.youtube.com/watch?v=F4zHneOQ9ds

It looks good.
Will you consider decreasing grass intensity with distance to keep some grass in the long distances instead of having grass only around the player ?

That is really nifty!

I’d be interested to see this being used as a way of faking furr. I think if you add Subsurface shading with the FuzzyShadingGrass it would add to the effect!

I’mnot sure what you mean by intensity but I’d love to be able for the instancing to vary the density with distance. Actually my main wish would be for the grass output to have a ‘starting distance’ as well so that we could control LODs by having a larger mesh but less of them at further distances.

Thats it , having less grass as distance increases, this would make smooth transition from full grass area around the player to no grass on long distance.

Unfortunately thats not something I can do on my side, its a limitation of the landscape grass system. I’ve been in the feedback forums and made a feedback request thread but no word yet. there are lots of people wanting improvements to the instancing system so hopefully epic will listen.

@dokipen - can you go over how you set these up? Is it just a matter of generating the imposters for the grass mesh, or…?

Eventually I get round to a tutorial but here’s the main bits…

  • In maya make a simple paintfx stroke using one of the preset grass brushes. Or you model you own grass patch which I might do.
  • set up a camera so that it is 45 degrees looking down on the grass.
  • put the camera in a group so that you can rotate it around the 0,0,0 point
  • set up the amount of frame you want to render to match with the number of angles in the sprite sheet
  • keyframe the camera group to rotate on Y (maya Y which would be Z in unreal) so that it does a 360 over the frame range.
  • render at 256x256 for 256 frames
  • use texture packer to arrange the rendered frames into a 4k sprite sheet (this would make 16 rows and columns of 256x256 sprites
  • in unreal I am using the imposterUV material function. I tried the quad from the engine content (in art tools) but I ended up making my own lower poly quad. its just a unit quad with verts at (-0.5, -0.5) to (0.5, 0.5).
  • use landscape grass instancing (see below)

One thing worth mentioning is that I had to do some hacking in the imposterUV material function to get the world position offset camera facing math to work out with the instancing. Had to hack it all into the vertex shader using customized uvs.

Thanks for the breakdown!

Isn’t there also some imposter rendering functionality in the engine itself? I swear I remember seeing something about it.

Here’s a quick update. I’m happy with the way its going. I’ve managed to get…

  • 8k maps
  • normals
  • depth for pixel depth offset to have the grass blades actually intersect to counteract the z fighting between the quads when they go trough each other
  • hacked the quad facing math so that I can blend between facing the camera position and facing the camera plane. this helps reduce the circular facing effect of them all facing perfectly at you. now they face a bit towards the camera plane to fake a bit of perspective.
  • random orientation and size.

3dfd6b6aae483b00b4af6db41f4a875731e24c3c.jpeg
20be6613fe057d953faf4623f7ec1c316f5c0c95.jpeg

The only outstanding thing is that they are still rendered from a fixed angle and I’m not sure how I’ll get vertical rotation going without sacrificing performance and texture memory.

I welcome everyone’s thoughts and ideas!

This looks really nice! Keep it up.

A quick update

spend some time on making the source texture a bit nicer as the alpha was causing some flickering.

5cdfd43fc35b69242d0c2b343f756e31157b78f8.jpeg

one thing that is wierd is that the grass density varies a lot with each landscape component…

is it a bug?

10be5d41824160611514d76e64382e711c83b731.jpeg

Excellent work! How is the performance on this?

The performance is pretty good actually. I’m on a beefy computer (6core i7, 64gb ram, geforce 770) but as long as I dont go crazy with the count then it stays above 60. Dynamic lightin g makes it sometimes dip into the 40-50 fps range if there are a lot on screen.

Small update.

Things I want to work on are the normals as I think they are being transformed incorrectly. Also I want to get shadowing working as they go away if I face the quads towards the camera but appear when facing towards the camera plane. The colour could do with a bit of work too.

How does this technique hold up with tall grass?

Well as long as they are sufficiently far away that you wouldn’t see any ‘lack of perspective’ then it should be okay. Other billboarding systems like the speedtree lods use billboards but they are pretty far away and dont use that many angles. I plan to get back to this soon and refine it a bit. Also one of my buddies has been working on an imposter from houdini setup which looks cool.

I was talking more like standing waist deep in grass. I imagine it isn’t as suited for that.