height based wind shaders

Started by
1 comment, last by Norman Barrows 7 years, 1 month ago

in a youtube video about making grass, i saw that cryengine2 had a "grass shader" option that animated plants with the wind. the interesting thing was that the mesh in question was 2 quads wide by 4 quads tall, and all the vertices seemed to move back and forth horizontally in proportion to their height from the base of the mesh. i figure either they do it proportional to the V texture coordinate or to some plant base y value vs the vertex's y value. has anybody heard of this type of thing? I have all the different types of plants and grasses in caveman swaying in the wind. So now its time to make trees sway too. and this effect would probably look better, given that tree trunks have multiple (3 or 4?) edge loops between the top and bottom loops on the mesh.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

Advertisement

For more complex shapes, like trees, you often use vertex colours to paint in some kind of location data (like using 'V' for "height from ground"). IIRC, Cry used one channel to store distance from the trunk, and another channel to store stiffness (so that thick branches wobble less than thin branches). If you make some assumptions about where the model's local origin is, you can also use the model-space vertex position to determine some useful information -- e.g. if the model's origin is at the base of it's trunk, then the input position.y is height above ground.

For more complex shapes, like trees, you often use vertex colours to paint in some kind of location data (like using 'V' for "height from ground").

yes, i saw that in one of the videos, might have been that one - but it think it was on a more complex mesh. i definitely remember them painting the reds and blues, just like weighting a skin to the bones of a skeleton.

Cry used one channel to store distance from the trunk, and another channel to store stiffness

i was thinking that y pos of plant base could be a global shader param for non-instanced drawing and you calc distance from ground in the shader, instead of sending distance from ground in each vertex. i use a random per instance plant stiffness variable in my grass w/ wind shader, but it really should be based on plant scale, so smaller plants sway less. i'm thinking that sway proportional to altitude should obtain results similar to weight painting. after all, you would paint pretty much the same influence as could be obtained with code. and then you don't have to weight paint all your meshes! <g>. just call your altitude based wind shader.

If you make some assumptions about where the model's local origin is, you can also use the model-space vertex position to determine some useful information -- e.g. if the model's origin is at the base of it's trunk, then the input position.y is height above ground.

Good point! all these trunk meshes have a base at about y=0 in object space! so pos.y=altitude! sweet! don't have to pass any extra per mesh info to the shader!

but branches are another story.... trees are of two basic types: multi mesh, and rigid body model. multi-mesh trees consist of a trunk mesh, and a branches mesh, which is a bunch of quads, similar to a plant mesh. but the base of the branches mesh may not be at y=0 in object space. it may be up where the branches start - i'd have to check the code. in that case i'd have to pass ground.y to the shader. rigid body is similar, but with multiple branch meshes per tree (acacia trees).

guess i'll give it a go and see what happens. i'd like to avoid weight painting. i plan on upgrading from rigid bodies to skinned meshes for all 50 or so animal types, so that's already plenty of rigging work i'm looking at ! <g>.

assuming it works, it could also be used for small plants. it would probably give better overall motion.

and now i'm off to implement two sided lighting for plants. time to take a look at phil's online sample code - i think it was an article here.

as always thanks for the help! you have no idea how helpful it its to have someone around who's been there and done that. reminds me of someone called biohazard on compuserv gamedev forum back in the day. they knew the answer to just about everything in the way of 3D graphics (for the times, that is).

BTW, you're located in Australia, right? what color are the lizards there? right now i'm using black with a purplish sheen for Megalania. Caveman actully has quite a number of Australian megafauna: Megalania, Giant Roo, Gt wombat, thylaco leo (marsupial lion), thylacene (tiger wolf), etc. still have to implement the gt constrictor snake. its the only snake so far, so it will require unique new animations.

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