Trees and how to make custom ones: Difference between revisions
Springheel (talk | contribs) |
|||
Line 18: | Line 18: | ||
# For the tree "skeleton", make a func_static in the editor and select the model (choose a tree skeleton without leaves in it). | # For the tree "skeleton", make a func_static in the editor and select the model (choose a tree skeleton without leaves in it). | ||
# That makes our base, now make a func_emitter | # That makes our base, now make a func_emitter. | ||
# Now you need to select which particle to use (for example tdm_leaves_01). Select the emitter entity, and open the entity inspector. Right click anywhere in the Property list, and select "Add property...". Select the model folder, and in there select the model property and click Okay. This will bring you back to the entity inspector, now click on the newly created model property. Now two buttons will show up, click on the "Choose Particle" button. Browse through the list to find the particle you want. | |||
# 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. | # 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. | ||
Revision as of 03:36, 5 October 2008
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:
- 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.
- 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 match the angles of the player's view, resulting in a "kaleidoscope" effect when viewed from the bottom or top and rotating the view. Also, this method puts more strain on performance and can cause framerate drops.
Screenshot of the two types of tree:
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.
- For the tree "skeleton", make a func_static in the editor and select the model (choose a tree skeleton without leaves in it).
- That makes our base, now make a func_emitter.
- Now you need to select which particle to use (for example tdm_leaves_01). Select the emitter entity, and open the entity inspector. Right click anywhere in the Property list, and select "Add property...". Select the model folder, and in there select the model property and click Okay. This will bring you back to the entity inspector, now click on the newly created model property. Now two buttons will show up, click on the "Choose Particle" button. Browse through the list to find the particle you want.
- 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.
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 particle 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 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)] } }
Now let's go through what each part of that material does.
qer_editorimage models/darkmod/nature/leaves_d noshadows nonsolid
The first line is the image that is displayed in the editor, the other 2 lines disable shadow-casting for the material and collision with the material. Note that these are actually not needed as you cannot collide with particles anyway, and particles cannot cast shadows either. The lines are there mainly for if the texture is used on a brush, patch or model.
{ 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)] }
This is the diffusemap, basically the actual texture that gets shown in the game.
The first line defines that this is a diffusemap.
The second line is the path to the texture itself (note that it does not use an extension, such as JPG or TGA. This is so it can use DDS versions of the textures also).
The third line is how much it should be affected by lighting (rgb stands for Red Green Blue, and 0.5 is normal diffusion of light. rgb 1 would be overbright). Note that rgb affects all 3 colour channels, but you can specifically change each channel (by using "red <value>" [without quotes] in one line and then green in the next etc), for example making it more red or more blue etc. This can be useful if you have a leaf texture and want to make 2 materials, one with the leaf green and another with the leaf yellow, without making a new texture.
The fourth line is the amount by which to make the alpha channel within the image file transparent by (0.5 is a good value). Alpha channel settings for the image itself will be covered further down.
The fifth line scales the image by 2 in both the x and y directions. this means that each particle-face will have 2 by 2 of this image (so 4 in all) and is mainly so that less particles are needed to achieve the same effect. In other words, normally to achieve the same amount of bushiness you'd need 4 times the amount of particles (which are also half the size), which is visibly better, but more taxing on the renderer, thus lowering performance.
The sixth line is the movement of the material, or in other words, the "windiness". Basically it is a sinusoidal movement which is scaled by parm7, which is shaderParm7 in the editor (which, as I mentioned earlier, changes how much the leaves move by).
The specularmap and bumpmap are the same thing except that the paths define a specularmap texture and a bumpmap texture respectively. Also, in the above example they don't have rgb set, but this can be used to do a material-level change on their colour/brightness).
Also note that specular and bump maps cannot use alpha channels as they have a neutral colour in their texture for "no specular" (black in the specular map) and "flat" (for the bumpmap).
{ 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)] }
This adds an ambient brightness to the leaves, which means that in a pitch-black map these will be slightly glowing, but in a map with a mild ambient light this will make it slightly brighter in shadows or when facing away from the light. Adjust this to your liking, 0.075 is generally good for TDM maps.
Now back to the alpha channel. The alpha channel should be part of the diffuse texture and should look something like this:
To make your own custom material, make a .txt file and rename it to .mtr and open it with notepad. Then copy the above material and modify the parts you want and save it. It should then appear in DarkRadiant under the path specified in the name; so for this material it would be under textures/particles/ and would be tdm_leaves_01.
Editing the particles themselves (size etc):
See also: Particle Editor
So, firstly make a tree as above and use one of the default leaf particles (this is the simplest way). Make sure the map has a light lighting up the tree, so you can see it. 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.
Once the particle editor loads, you should see something like this:
Now to explain a few things. At the top you have the particle name next to "particle", next to it you have new, save, and save as. Now, for easiest editing of particles, load up an existing particle, such as the leaf one in the example, modify it and then use "save as". I will explain a bit more further down.
Now, for the leaves you can ignore all the color, fade color etc, we want to only look at count, time, distribution, speed, size, etc.
Firstly, and most importantly, we have material. This is the path to your material; not the image file but the material for your custom leaf. So for example you can see the example above has textures/particles/tdm_leaves_01. If you know the name of your material (for example textures/particles/green_leaves) then you can type that in there and press enter and it will find it by itself showing the changes in the render view.
Now that you can see your custom material we can continue on to the size of the leaves etc.
Bunching; this determines how much the particles tend to bunch together, 0 meaning they want to spread out as evenly as possible, while 1 means that they bunch together a bit. The effect is not actually that noticeable mind.
Count controls how many particles there are, so basically the example shown has 32 particles in total. Obviously the more you have, the more dense the tree. This is a slider so slide it around as necessary. Alternatively you can input a value into the box and then press apply down the bottom right.
To see the changes you are making, center your camera in the render view on the tree and press f7 and f6. F7 rebuilds everything and f6 enables animations. Leave it in render view and move the particle editor to the side so you can see the render view (to watch the changes you are making as you make them).
You will also notice the "time" input beneath it. This is the lifespan of a particle in seconds. If I may suggest, don't mess with this, as putting it too low will make the particle lifespan visible, as in you'll notice them appearing/disappearing etc. If you put it to something ridiculous, like 99999, then it will load for extremely long, and sometimes not at all. It's best to leave it at 300 (5 minute), as you won't notice the tree leaves changing around every 5 minutes.
Now, distribution. This is where things get a little more annoying. You'll notice 3 check dots - rect, cylinder, and sphere. Realistically you'd want to use sphere, but for some reason the algorithm for distribution in the sphere (at least for the leaves) does not work correctly and you get several particles occupying the same spot, which results in z-fighting and generally looks really bad. Now, the rectangle distribution works perfect; particles are properly distributed and there is no z-fighting, but it's a rectangular shape, but can look ok if not too many particles are used. Another alternative is the cylinder distribution. Cylinder distribution works well but annoyingly enough the particles get distributed only on the walls of the cylinder, which means a hole in the middle, so you need to adjust the particle size and cylinder size so that there is no hole in the middle.
The values to the right are the size values in doom units, so change that to roughly be the size you want the leaves to cover. If you selected cylindrical distribution, don't bother adding a ring value as it just makes it larger in diameter, so leave it at 0.
The offset is the offset from the center of the particle entity. Try keeping the leaves centered on the particle emitter, as Doom 3's light rendering system calculates whether or not to light the particles by checking whether the particle emitter is inside the boundary of the light; if yes then applies the lighting to it, but if not then it leaves the particle unaffected, ID did this for performance reasons.
Random Distribution is just what it says, so you may want to leave that ticked.
Speed; leave that at 0 for the leaves as that is the speed at which the particles move away from the center of the emitter.
Size is self-explanatory; it's the size of each particle.
Rotation is rotation speed of the particle and aspect stretches the particle from the center of the emitter. So leave these 2 alone for leaves.
Notice that each of these has 2 sliders. This is for time based particles, so one slider is "from" and the second is "to". This is governed over the lifespan, so for example a particle that has sizes 0 to 50 and a lifespan of 10 would mean that it would gradually increase it's size to 50 from 0 over a span of 10 seconds. So for leaves this means that you leave both sliders at the same value. The other values below the speed, size, rotation, and aspect sliders do various things and you can mess around with them if you wish but they are not useful for leaves.
Now that you know what each value does, just mess around with them until you reach something that looks good.
Once you have something that you wish to keep, it is time to save it. Now, press save as (presuming you modified one of the existing leaf particles) and it will come up with a dialog asking for the particle name. Enter the name you wish (for example green_leaves_01) and press ok. Now it comes up with a path dialog. Browse to the Doom3/base/particles folder (if there is no particles folder create one) and name it as what you want (this is the file name, not the particle name), for example something like "mymap_particles" and then press ok. Make sure you save it into doom3/base/particles as saving it into doom3/darkmod/particles WILL NOT WORK. Once you save it there you will find the particle file (in this case "mymap_particles.prt") in the doom3/darkmod/particles folder; strange, yes, but it saves it there due to the way Doom 3 mod-loading works.
Now in DarkRadiant you should be able to find your new leaf particle when browsing through the particle list.
Tutorial by Dram