Trees and how to make custom ones

From The DarkMod Wiki
Revision as of 10:16, 3 June 2007 by Dram (talk | contribs)
Jump to navigationJump to search

Using, and creating TDM trees with particle leaves

There are currently two types of trees in TDM: model trees which use a model for the leaves, and model trees that use particles (like sprites) as the leaves.

Main differences between them:

1.Model trees which use a model for the leaves:

This is the standard way of making trees in games and is what everyone is probably used to. The problems are obvious, in that they tend to not look "bushy" and of course looking at the tree from different angles can look pretty bad, mainly due to each leaf face being lit differently.

2.Model trees which use particles for the leaves:

This method gives the tree a more "bushy" look because the particles are oriented to the player's view. This means that from whichever angle you look the leaves always look good. Of course, there is a problem with the particles being oriented to the player's view, and that is that they rotate to math the angles of the player's view, resulting in a "kaleidoscope" effect when viewed from the bottom or top and rotating the view.


This article covers how to use the TDM trees with the particle leaves and how to make custom leaves. Since this involves editing them through the particle editor, this doubles up as a tutorial on using the particle editor, but only covers the parts of it that are relevant to editing the leaves.


Adding a tree with particle leaves to your map

For this we need 2 things - a tree "skeleton" model, and the particle leaves.


1.For the tree "skeleton", make a func_static in the editor and select the model (choose a tree skeleton without leaves in it).

2.That makes our base, now make a func_emitter and select the particle (for example tdm_leaves_01).

3.Now select the particle emitter and set a key/val pair "shaderParm7" in the key and a value in the val. This controls how fast the movement of the texture is. When this is on 0 (which is default), there is no movement (which looks like there's no wind at all and the leaves stand still like in a screenshot). 1 would be some quite slow ambient movement while 2 would be a light breeze. 4 would be a windy place and about 8 would be a very windy place. Adjust the number to your liking. Note that this is only for the currently selected emitters, which means you can have no leaf movement for leaves in one part of the map, while in another part you may want them to be swaying like mad, for example.

To quote the material file:

//Note: parm7 controls how fast the leaves sway and by default it is 0, so for each leaf emitter, a key/val pair must be set.
//	Example: for ambient movement put key: shaderParm7   Val: 1  but for windy weather put the val to about 8 or so.

4.Now align the particle emitter to the middle of the branches, as the particles form a rough sphere around the emitter.

Done.


Note: The particles do not cast shadows (and cannot, even if you remove the noshadows line in the material file) but accept shadows being cast on them (even if you remove the noselfshadow line in the material file), which means that branches from the tree do cast shadows onto the leaves, which is nice, but means that the leaves do not cast a shadow onto the floor beneath them.


Making custom leaves

Making a custom leaf material:

To simplify the process, open tdm_leaves_materials.mtr and look at one of the leaf types. For this tutorial we will look at textures/particles/tdm_leaves_01.

textures/particles/tdm_leaves_01
{
	qer_editorimage models/darkmod/nature/leaves_d
	noshadows
	noselfshadow
	nonsolid
	
	{
		blend diffusemap	
		map models/darkmod/nature/leaves_d
		rgb 0.5
		alphatest 0.5
		scale 2,2
		translate 	0.022 * sintable [ time * (0.06 * parm7)], 0.022 * sintable [ time * (0.03 * parm7)]
	}

	{
		blend specularmap	
		map models/darkmod/nature/leaves_s
		scale 2,2
		translate 	0.022 * sintable [ time * (0.06 * parm7)], 0.022 * sintable [ time * (0.03 * parm7)]
	}

	{
		blend bumpmap	
		map models/darkmod/nature/leaves_l
		scale 2,2
		translate 	0.022 * sintable [ time * (0.06 * parm7)], 0.022 * sintable [ time * (0.03 * parm7)]
	}
	
	{
		blend add
		rgb 	0.075
		map 	models/darkmod/nature/leaves_d
		scale 2,2
		translate 	0.022 * sintable [ time * (0.06 * parm7)], 0.022 * sintable [ time * (0.03 * parm7)]
	}
}

Editing the particles themselves (size etc):

So, firstly make a tree as above and use one of the default leaf particles (this is the simplest way). Now open your test map in Doom3Ed and press F2 (this brings up the game in windowed) and in the console type EditParticles. This will bring up the particle editor in Doom3Ed and allows you to make changes, as well as see the result of them in the renderview.