for amber waves of grain

Started by
4 comments, last by Norman Barrows 8 years, 11 months ago

swaying vegetation - been there done that. sinusoidal based motion. function of wind speed and direction. phase offset based perhaps on a function of world x,z (for global wind sources) etc. etc.

now...

what about a field of vegetation waving in the breeze, like waves on the ocean?

what's a good algo for that?

and what about gusty winds? just toss in a little random gusty motion? it _should_ be an area of gusty wind that moves across the game world like in the real world.... coming and going, etc.

all this seems to point to modeling swaying vegetation at the individual level, driven by some higher level code that models swaying vegetation/wind effects over large areas.

in general, i'm talking about natural wind sources here , not a "wind emitter:" like a helicopter in a game engine.

cursory searches here and on google turn up the usual suspects with regard to swaying individual plants, but nothing on area effects of wind on swaying vegetation.

as i continue work on Caveman, which is quickly evolving from a RPG into a paleo-world simulation, i'm discovering that good animations are key to bringing the world to life. to that end, i'd like to try to take my vegetation animations to the next level in this new version of the game, by adding "waves of grain" to simple wind based animation of swaying vegetation. I suspect the effect would be most dramatic in the game, given the large view distances (i'm now testing at >300 meters at highest LOD), use of high lod at all ranges with no impostors, and the extremely dense vegetation (often > 10K instances visible onscreen at once).

how to do that, and how to animate a rigged model in truespace (yes, i'm going to try for skinned meshes!) are about the only two things on the project i haven't figured out yet.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

Advertisement

Could you extend the wind emitter into a wind generator system? I mean you have to model the wind external from the shader in order to keep the vegetation in sync, what if you did something as simple as generating a series of spheres that modeled where the wind is coming from and apply the wind force from the nearest sphere to the vegetation. You then could control the expansion rate/direction of the wind spheres to get that gusting behavior.

Just spit balling here, the problem interests me.

Perception is when one imagination clashes with another

i want to stay away from wind emitters. think directional light vs point lights, but for wind. with emitters you end up summing a bunch of stuff like doing lighting equations. and a lighting model is not really the type of model required. wind is more like modeling fluid dynamics. the actual output is just a rotation added to the world transform matrix for a mesh in a model when drawing. a mesh such as a tree trunk, branch, or clump of grass. sinusoidal displacement based on game clock or update_counter gives a nice sway to things. then you need to make them out of phase with each other so they don't all sway in unison. phase shift based on x,z world location works well. i suspect the solution will involve something similar to your "spheres that model where the wind is coming from", but it would be more like BBox (or Bcircle) area where a big blast of wind sways a field of vegetation in wavelike unison. these BBoxes would move across the game world, occasionally waving the vegetation inside them. The BBoxes themselves could be a particle system, extending out to perhaps 1Km around the camera.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

you would have one or more points on a "line" which is the direction of the wind. Move the points down the line in the direction of the wind. where the points are, the stronger the wind, would that work for you? that would give you a straight gust of wind. you could add in points along the other axis which says where the wind is coming from first to get round gusts of wind

I wrote that kind of fast. the points on the direction of the wind line would actually be a perpendicular line

EDIT:

alright, have a little more time now to explain what i mean in case the above didn't make much sense.

so for a straight gust of wind, you have your vector pointing in the direction of the wind, we'll just say its pointing down the x-axis (1,0,0). for each gust of wind, you have a point which moves through the world on this vector. one gust might start at (0,0,0). next frame the gust is at (1,0,0), then (2, 0, 0) until it reaches the end of the world and starts back at (0,0,0). anything affected by wind would have its distance from that point on the wind direction vector calculated, and the closer it is to the point on that vector, the stronger the gust of wind. So say you have a plant at (15, 0, 7) and the gust of wind is at (7, 0, 0). the distance would be 8, so compared to another plant at (8, 0, 14), where the distance from the gust is only 1, it would bend less. This would give you a straight gust throughout your world.

To make the gust more roundish, you could add in points along the perpendicular axis, in this case could be (0, 0, 1). say you have a point at (0, 0, 15). The closer a plant is to that position on the z-axis, the sooner it will be hit by a gust of wind when it comes than a plant that's further away from that point on the z-axis.

You actually don't need points, i just thought it would be easier to visualize, you really only need a scalar value for the gust and for where the gust hits first (to make it round)

If this still doesn't make much sense, i could just draw it out to show you


so for a straight gust of wind, you have your vector pointing in the direction of the wind, we'll just say its pointing down the x-axis (1,0,0). for each gust of wind, you have a point which moves through the world on this vector. one gust might start at (0,0,0). next frame the gust is at (1,0,0), then (2, 0, 0) until it reaches the end of the world and starts back at (0,0,0). anything affected by wind would have its distance from that point on the wind direction vector calculated, and the closer it is to the point on that vector, the stronger the gust of wind. So say you have a plant at (15, 0, 7) and the gust of wind is at (7, 0, 0). the distance would be 8, so compared to another plant at (8, 0, 14), where the distance from the gust is only 1, it would bend less. This would give you a straight gust throughout your world.

this still has you solving wind equations for multiple sources on a plant by plant basis.

i should probably mention that it will need to be performed on up to 20,000 meshes per render. so lighting type summations for each mesh might be too processor intensive.

i'm thinking a more simplistic approach: bend = function of (windspeed, wind direction) + gust_modifier() + waves_modifier() + phase_offset()

waves_modifier() would be an area effect, similar to your points. possibly a particle system of areas around the camera.

gust_modifier() would be some sort of random noise factor.

phase_offset() would simply keep them all from swaying in unison, perhaps by some mod based on world location.

it might even be used to get the wave effect. after all, a wave is particles in uniform motion but out of phase with each other. IE water in a wave moves mostly up and down, with a slight forward-back motion, so its roughly circular or elliptical. water at the crest of a wave is at its highest point in the motion, water in the trough of a wave is 180 degrees out of phase with respect to the motion of the water at the crest, and is at the bottom of its motion.

if you have a large area of grass, and sway it all uniformly based on windspeed, direction, and sin(time), and then introduce phase shift (based on world location) across the area, you get waves! but the area doesn't automatically propagate across the game world. you'd just get a field of wavy grass. with no gustiness or randomness, it would probably look too perfect, like synchronized swimming.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

for future reference...

related topic:

http://www.gamedev.net/topic/668085-performance-of-drawing-vegetation-overdraw-alpha-testing-alpha-cutout-model-generation/

third image in the OP shows the "wave of grain" effect.

how its done:

Infinisearch replied:

"This presentation might help you out: Rendering Technologies from Crysis 3... starts page 29. I think they had another one but I'm drawing a blank at the moment, if I remember I'll post it."

http://www.slideshare.net/TiagoAlexSousa/rendering-technologies-from-crysis-3-gdc-2013

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

This topic is closed to new replies.

Advertisement