- Home /
Fur, Hair, and Alternative Grass
Hey there,
I've spent hours trying to find a way of creating a sphere planet object with terrain on it, such as grass thats effected but local wind, I found thats it not really possible to use unity's terrain tools on anything other than a plane.
What I'm trying to do Is find some sort of Fur shader, like Cinema4Ds shader, and use it to create grass on a sphere, What would be the best way to go around doing this??
thanks
Answer by Peter Bruun-Rasmussen · Jan 06, 2010 at 06:47 PM
We used the techniques found in GPU Gems Chapter 7 for rendering and animating grass in The SOL Game.
The basic idea is to do the actual grass animation on the GPU. In SOL the grass is distributed into clusters consisting of five transparent planes each. These clusters was manually positioned by the level designer. The planes was rendered using a custom shader that translates top vertices according to two sinusoids. The Cg code below shows how we did the animation in the vertex program.
v2f vert (appbase v) { float wind = _WaveAmplitude1 * sin(_WaveFrequency1 * 2 * 3.14 * _Time.y + v.vertex.x) + _WaveAmplitude2 * cos(_WaveFrequency2 * 2 * 3.14 * _Time.y + v.vertex.y);
float split_v = 0.9;
v.vertex = v.vertex + wind * v.texcoord.y * _WaveDirection * (v.texcoord.y > split_v);
v2f o;
PositionFog( v.vertex, o.pos, o.fog );
o.uv = v.texcoord;
o.lightDir = ObjSpaceLightDir( v.vertex );
o.normal = v.normal;
return o;
}
Notice that we use texture v-coordinates to tell top vertices from bottom vertices.
Unrelated to the question, I know, but... damn, that looked good. I hadn't seen SOL before, and I'm glad I found it through this question. I keep seeing interesting small games co$$anonymous$$g out of DADIU.