Hahaha! I bring you wind!:evilgrin: Pictures don’t fully do it justice, but take a look(it looks different because I made the grass smaller and added more of it- changes which aren’t included in the shader I’m going to share):
I added configurable dynamic wind, and tweaked the shading a bit. Here’s the download link:
http://www.mediafire.com/view/?mbpb16f9ppuxw09
Setup instructions:
1.Replace the grass shader with the one in the link above.
2.Add a float property called “windTime” to the grass object, and leave its value at zero.
3.Add a float property called “windSpeed” to the grass object. This value controls how fast the grass waves in the wind. A value of 0.01 works good for me.
EDIT: I forgot to add something important. I changed the calculation for uvX and uvY on lines 144 and 145 to be this:
uvX=(int(round(player.localPosition[0]/cell)))
uvY=(int(round(player.localPosition[1]/cell)))
This rounds off the player’s cell position to the nearest integer, whereas the old method of simply converting it to an int always rounded down(not ideal). I recommend you make the same changes to the terrain shader, because it looks better(but if you’re just trying out my grass shader, you don’t have to do this).
There are some wind setting variables to tweak (XY direction vector, strength, and wavelength in Blender units) at the top of the vertex shader. There are additional variables to tweak in the fragment shader that are related to lighting.
The changes I made to the shading include an approximate AO factor, and a rim light factor (which probably doesn’t work how you’d expect; it brightens the grass slightly when the light source is nearly perpendicular to it (grass and fur tend to have this property in real life)).
benj, you can incorporate this new addition into your download file whenever you feel like it (it’s quite easy to set up).
Also, does the terrain height seem to have some banding issues for anyone else? It looks more in line with the 256 levels you’d get from an 8-bit heightmap than the 65536 levels you should get from a 16-bit heightmap. Look at this picture. It looks like there are terraces on the side of the hill. Hmmm.