Wednesday, March 05, 2008

Reeds

With the new terrain foliage system it's now very easy to add new layers of foliate by just altering the .terrain xml file. Yesterday I set out to try this by adding some reeds to the world. We've had textures for reeds for a while, done by zzorn, but since there hasn't been a good system for adding them to the world they've been unused so far. Adding them now was however trivial. We want the reeds to grow by the water, and only there. They are also very much like grass, so they should use the same rendering technique as the normal grass. Adding them to the world was thus as simple as editing the moraf.terrain file so that the sand layer definitions looks like this:

<layer shadername="sand" diffusetexture="3d_objects/environment/ground/textures/sand/sand_AD.png" normalmaptexture="3d_objects/environment/ground/textures/sand/sand_AN.png" tilesize="8">
<foliage planttype="grass" populationtechnique="cluster" rendertechnique="grass">
<param key="minClusterRadius">2</param>
<param key="maxClusterRadius">10</param>
<param key="clusterDistance">25</param>
<param key="density">2</param>
<param key="falloff">0.6</param>
<param key="material">/global/plants/grass/ducktail/single</param>
<param key="minHeight">2.0</param>
<param key="maxHeight">2.5</param>
<param key="minWidth">1.0</param>
<param key="maxWidth">1.5</param>
<param key="swayLength">0.25</param>
<param key="renderTech">quad</param>
</foliage>
</layer>
This tells the terrain system to add foliage to the sand layer, and the sand layer only. It also tells it to use the "cluster" population technique for placement, and the "grass" technique for rendering, using the "ducktail" material. The other parameters should be pretty self-explanatory. The end result can be seen here:


Not too bad. The main point here though is how easy it is to alter and add new foliage layers. Worth noting also is that we used the built in cluster populating technique, but this would be a prime candidate for using Mercator Areas. By using areas, the world designers would have much greater control of where to put the reeds, and it could also be possible for players to affect them in the world, for example by using a scythe to cut them down.

Yesterday I also committed some performance improvements to the foliage engine, mainly by using batch stores for the sub areas, thus avoiding having to iterate through all plants for each geometry page.
I stumbled upon a bug in the entity editor which caused a crash when deleting entities in the world. It was however an easy fix (don't hold on to deleted entities...) which I will commit later today.

No comments: