windy grass. . .

Blitz3D Forums/Blitz3D Programming/windy grass. . .

Mr Snidesmin(Posted 2005) [#1]
I have some grass built with criss-cross type meshes that are spread across a terrain. see here

I could implement them in 3 ways:
1) 1 mesh, multiple entity copies
2) mulitiple mesh copies
3) 1 mesh all combined.

currently I'm using 1)

I'd like to create some kind of effect to make them turn slightly or shift the verts around to make it look like wind blowing through them. Is there any way to do this that isn't too processor heavy?

I'm open to all possibilties, including not trying this if it will be too hard :O)


KuRiX(Posted 2005) [#2]
The easiest way perhaps is to animate the model in your modeler software then export the animation. Anyway i don't know if this will be fast because you will need to animate lot of entities.

The most efficient way should be to have 1 mesh containing all the grass, then animating only the needed vertex or moving the textures...

The problem is that you should clusterize that mesh to render only the viewing zone...


Mr Snidesmin(Posted 2005) [#3]
Hmm. yep thats a nice easy way, but the problem is all of the copies will move in sync. It would be nice to get a kind of gust effect with some grass moving and not others...


KuRiX(Posted 2005) [#4]
then you can apply different animation speeds...


Mr Snidesmin(Posted 2005) [#5]
ooh didn't think of that. . . that might work :O)


Baystep Productions(Posted 2005) [#6]
Actualy a function in the Grass System code archive entry does that. And thats just plugging in sprites. Maybe you could use that.


Banshee(Posted 2005) [#7]
I'd like to create some kind of effect to make
them turn slightly or shift the verts around to make it look like wind blowing through them. Is there any way to do this that isn't too processor heavy?


My method works a bit like this.

Portalise your data in regions, so if your map is 512x512 make 8x8 block's filled with a number of grasses.

Calculate which block is nearest the camera every 100 milliseconds or so (or more usually just infront of camera). This becomes the waypoint block.

From your list of grass meshes place mesh entities at the waypoint block and other adjacent waypoints.

Now animate only those meshes tied to waypoints nearest the camera.

You can fill a massively large area with just a few hundred grass objects, of which even fewer need actually be animated in runtime.


Mr Snidesmin(Posted 2005) [#8]
Thanks Becky! this is just the sort of thing I'm looking to do I think. I will probably be associating each grass object with a triangle on the terrain. . .

Do you have any example code for this sort of thing?


Banshee(Posted 2005) [#9]
None that would be easy to extract from an engine and show you clearly what i've done and why at the moment Mr S - but I am thinking hard about doing some Grass/Tree related products soon, depending upon factors unrelated to this thread.


Mr Snidesmin(Posted 2005) [#10]
I've written quite alot of stuff for autogen trees already - I need to clean up a bit and make the algo more flexible but I think I might be producing something really cool on this front. . .


RifRaf(Posted 2005) [#11]
I would use meshes. Not really a single surface system, uness you want to get into that.
Get the brushhandle for your meshes, and the texturehandle.. then just rotate the texture back and forth on a cosine. all your grass will move , and if you have staggered the yaw (turnentity 0,whatever,0) then they will not all move exactly the same direction at the same time.

You can then make clusters of grass by using addmesh on X number of grass that are close to each other .. reducing the total entity count by a great deal, then use entityautofade on the clusters you have created.

The most processor effecient way to do it. IMO

Theres a function in the archives for rotating and scaling a texture while mainting its central origin. use that.


jfk EO-11110(Posted 2005) [#12]
Having lots of grass in a scene is always a tricky job because it may slow things down a lot. I have developed a method that is positioning grass quads around the camera automaticly, where their rotation etc. is reproducable (rnd uses world location as seed), together with EntityAutofade. This way you can have very dense grass on a very big terrain.

I would also reccomend to develop some kind of Grass LOD system.


Mr Snidesmin(Posted 2005) [#13]
Thanks for all the ideas. . . I will be using LOD and I like the idea of rotating the texture because it's way way simple.

Thanks!

-K