Particle System Tutorial

Discussion in 'Models, Animations, and Particle Effects' started by vampiricpuppy, Jun 15, 2009.

Remove all ads!
  1. vampiricpuppy

    vampiricpuppy cuddly nosferatu

    Joined:
    Dec 4, 2006
    Messages:
    565
    Likes Received:
    0
    I have decided to write a tutorial for the use of the in-game particle system. This tutorial is based upon my researching other people's findings, as well as a couple of my own, but for the most part, i take very little credit for the information contained herein :). Much of the groundwork was done by other people, i am simply trying to create a primer tutorial for getting started with particle effects.

    So, big thankyou to all the people who have worked on spell effects and spells in the past (Id try to list them all, but id inevitably leave someone out, so i'll just say thanks, you know who you are ;))

    Particle effects in ToEE are governed by the parsys.tab files, which can be extracted from dat3 (there may be others floating around). The main spell effect file is partsys1.tab, and this is provided in the co8 stuff under the toee\data\rules\ folder. Having said that, not only spells use particle effects, blood spatters when you get hit use them, as do monsters such as fire elementals and so on. For the purposes of this guide, I'll be focusing on spell effects, but the principles can be applied to anything you require a particle effect for.

    Note: I'm going to assume a complete lack of knowledge for this tutorial, so i'll be taking everything step by step to ensure that nothing is left out.

    GETTING STARTED

    The main programs you will want are as follows:

    V2Brute:
    http://files.co8.org/others/V2Brute.exe

    This is Steve Moret's particle viewer, and will automatically update with the partsys files that are located in your toee\data\rules folder. Most people apparently have this already when the game is installed, however if, like me, you do not have the program, download it from the above link. Extract the file v2brute.exe and place it in your toee root folder.

    Phalzyr's Proto Editor:
    http://files.co8.org/tools/ProtoEd2-4-3.zip

    This program will allow you to edit many of the tab-delimited files that store information relevant to the game like protos.tab, spell.mes, or more relevantly to this tutorial, partsys1.tab.

    (optional) Zane's ToEE Dat Extractor tool:
    http://files.co8.org/tools/toeeextract.rar

    Use this if you want to extract the other partsys files from the dats.

    Note to vista users:

    I have to run all my toee based programs, those listed above, as well as toeefe-x and toee all in administrator mode. If you dont, you will probably encounter problems.



    FIRST THINGS FIRST

    Load up v2brute.exe from your toee root folder. select a spell effect from the top left list, and press the 'Play' button. It will play the effect that you have chosen, centred upon the little man on screen.


    [​IMG]

    This is how you will view effects as you make and modify them.

    To change the colour of the background upon which the effects play, use the following menu option:

    [​IMG]
     
    Last edited by a moderator: Oct 29, 2011
  2. vampiricpuppy

    vampiricpuppy cuddly nosferatu

    Joined:
    Dec 4, 2006
    Messages:
    565
    Likes Received:
    0
    Note that every time you change the effect file, partsys1.tab, you will need to close and re-open v2brute.

    So close it now, we dont need it just yet.

    Next, you will probably want to copy the partsys1.tab file to another location as a backup, in case you manage to totally mangle the file :)

    After that's done, load up Protoed, under the options menu, make sure that the Allow Add/Delete Rows option is checked

    [​IMG]

    and then load the partsys.tab file from toee\data\rules

    [​IMG]

    Once you've loaded the file, expand the first two columns on the screen so that you can read their contents clearly. Do this by selecting the line between columns on the top row, and dragging it to the right.

    [​IMG]

    Once you've done that for the first two columns, you should be able to read them in full. You can do this for any column you come across, that has more information than is shown in a small space.

    [​IMG]

    (in the options menu, there is an option to 'Auto Size on load' which can be helpful, but can also cause problems in some files that have extremely long entries)

    Now, the file is quite an extensive spreadsheet, and it has a lot of numbers and fields all over the place, so it can be quite daunting at first. To make reading and keeping track of lines easier, you can highlight columns and rows by clicking their header at the top, or left side of the screen, respectively.

    [​IMG]
     
    Last edited: Jun 15, 2009
  3. vampiricpuppy

    vampiricpuppy cuddly nosferatu

    Joined:
    Dec 4, 2006
    Messages:
    565
    Likes Received:
    0
    UNDERSTANDING THE PARTSYS.TAB FIELDS

    Agetian has a rather neatly compiled list of partsys.tab fields located here:
    http://www.co8.org/forum/showthread.php?t=5717

    A huge amount of credit for this guide goes to that thread alone :). However, the numbering compared to protoed is slightly off (due to people liking to number things different ways), so i have prepared a pdf version that lists them at the same numbers as you will see in protoed.

    Ag's guide also has a number of handy notations, which can help to use it as a quick reference - my pdf (and this tutorial) will only cover the bare basics, so take note of both :)

    PDF of basic particle parameters:
    http://rapidshare.com/files/244364031/particle_parameters.pdf.html

    I have listed all fields, and highlighted those that are most relevant to this tutorial
     
    Last edited: Jun 15, 2009
  4. vampiricpuppy

    vampiricpuppy cuddly nosferatu

    Joined:
    Dec 4, 2006
    Messages:
    565
    Likes Received:
    0
    CREATING A NEW PARTICLE SYSTEM

    Each line in partsys consists of an emitter, and its particles.

    The emitter is basically an invisible hose nozzle that sprays particles out, and the particles are either 2d flat images, or 3d models.

    This guide is only going to cover the 2d side of things, but once thats done, the principles can be extended to 3d stuff pretty readily :)

    This is a diagram of what a basic toee particle system (1 line) consists of.

    [​IMG]

    Particles can be made to spray out from the emitter at different angles and speeds, depending upon the coordinate system.

    Each line uses either Cartesian coordinates, or Polar coordinates.

    Explanation of Cartesian coordinates for the mathematically inclined
    http://en.wikipedia.org/wiki/Cartesian_coordinate_system

    Explanation of Polar coordinates for the mathematically inclined
    http://en.wikipedia.org/wiki/Polar_coordinate_system

    Diagrams for people who dont like maths very much :D

    Cartesian:
    [​IMG]

    Polar:
    [​IMG]

    Cartesian coordinates, x, y and z all represent measurements of distance. Polar coordinates, x and y are angles, and only z is a measurement of distance.

    Now, Both of these coordinate systems can do things that the others cannot. In the case of a verticle column of smoke, once you start to widen the area of the effect, you run into quirks- a polar-coordinate vertical column of smoke, starts to look a bit dome-ish once it is widened to a certain point, whereas a cartesian one will be blockish :D In reality, you can probably use either to create the effect you want. The particle system, being on a set angle, and often randomised, can look pretty convincing even if in reality you've created something with an odd shape.

    As a general rule of thumb, use Cartesian for linear effects, and polar for spherical effects.

    Now to play around with the position fields, protoed columns 53, 54, and 55, you need to understand a few basics.

    a particle with static coordinates will have a static position, so you must either keyframe that position so that it changes, or randomise that position to start with.

    Some particle systems, like rays, have the EMITTER move, instead of the particle, so once the particle is spawned, it stays in one spot and fades in that same spot.

    Other systems, the emitter is static, and the particle moves. For now we'll be looking at these. (if you want to move the emitter later, use fields 28, 29 and 30)

    To keyframe a position you do the following,

    in the relevant field, type: starting position,end position.

    for example in a cartesian system, set the x field: 0,500.

    In this case, the particle would move from the emitter, out to a position of x=500

    This can also be extended for more control, you could have a field that looks like 0,25,50,75,100,200,300,400,500.

    This particle would move at a slower rate for the first half of its lifetime (25 per keyframe) then pick up speed for the second half (100 per keyframe) before finally ending at position 500 again.

    These timed keyframes are ENTIRELY dependant on the lifespan of the particle, which is set in field 16 - if the particle has a short lifespan, it will move faster along those keyframes.

    Now, to RANDOMISE a particle's position, you would do the following:

    lowest position?highest position.

    for example, in a polar coordinate system, if we wanted to make a 20ft wide circular cloud of particles,

    we would set the z field: 0?300 (there is no direct correlation between 20ft and 300, but its in the rough ballpark)

    and the x field: 0?360 (creating a field of particles 360 degrees around the emitter)

    this would scatter particles in the circular area.

    Anyways, enough about positions for now. Lets get to work on playing with an actual particle system.
     
    Last edited: Jun 15, 2009
  5. vampiricpuppy

    vampiricpuppy cuddly nosferatu

    Joined:
    Dec 4, 2006
    Messages:
    565
    Likes Received:
    0
    WORKING WITH AN EXISTING PARTICLE SYSTEM

    Until you understand a lot more about particles, stick to copying existing systems, and making modifications.

    Generally, use a similar type of spell to the type of effect you want to emulate - for an explosion, use fireball, for something sparkly, maybe try glitterdust, etc.

    For now we'll begin with a very simple, single system particle effect.

    Load up partsys1.tab in protoed, then find the line sp-fog cloud.

    [​IMG]

    select the line by clicking the sp-fog cloud entry in the very left column, then right click one of the fields in the line, and select 'Copy this Row'

    [​IMG]

    you will now have two sp-fog cloud lines. Double click the bottom of the two entries name, and rename it sp-test cloud, then, in column 1, name it 'Main Cloud'. As you can tell, this step is not 100% necessary, but its a good habit to name your systems something vaguely descriptive, so that if you want to come back later and edit/copy them, you can find the one you want quickly.

    [​IMG]

    Save the file, then open v2brute, and find your new spell system.

    [​IMG]

    As you can see, if you press play, the new system is a clone of the main cloud effect for the fog cloud spell.

    Go back to protoed, and find column 15.

    [​IMG]

    As you can see, the current entry is fire-sprite. This refers to a MDF and TGA file that looks like this:

    [​IMG]

    This particle texture is used for a lot of fire and smoke effects. However, because we're trying to modify what this effect looks like, we're going to change it :).

    Go to column 15, and change the entry there from fire-sprite to flare-1. Save the file, and re-open v2brute (remember to close it and re open every time you make a change).

    [​IMG]

    Damn. We made a cloud of ugly weird square things :). This happens because there are certain Particle Sprites that dont mix well with certain particle blending modes.
     
    Last edited: Jun 15, 2009
  6. vampiricpuppy

    vampiricpuppy cuddly nosferatu

    Joined:
    Dec 4, 2006
    Messages:
    565
    Likes Received:
    0
    PARTICLE BLENDING MODES

    Go back into protoed, and find column 17. You'll see that the effect listed for sp-Test Cloud is Blend.

    This column can have one of four entries: Add, Subtract, Multiply and Blend.

    Add is used for bright shiny effects.

    Subtract is used for dark effects.

    Multiply is like a subtle version of subtract that only uses the darker areas of the particle sprite.

    Blend is like a subtle version of add that only uses the lighter areas of the particle sprite.

    So, for now, we're going to replace the Blend entry with Add.

    [​IMG]

    Save the file, and reload v2brute.

    [​IMG]

    Yay! no more weird square outlines.

    ok, so we have a cloud of faint sparkles that are all the same colour and size. They all have a random rotation, but they do not rotate as the cloud expands.

    Lets change all that :D

    find columns 62, 63, 64 and 65.

    these columns represent Alpha, Red, Green, Blue, respectively. Alpha is basically transparency. a Red 255, Green 255, Blue 255 particle is pure white, 0,0,0 is black (Which actually translates as INVISIBLE within this context - if you want dark colours you use Subtract, 255 255 255 on subtract is pure black). These particles are grey because they have an alpha entry of 0, 40, 0. This means they start their lifespan invisible, gradually grow to about 20% transparency, and then fade back again. Alpha also accepts values 0-255.

    As mentioned earlier, values seperated by commas are keyframed values that are evenly spaced along the lifespan of a particle.
     
    Last edited: Jun 15, 2009
  7. vampiricpuppy

    vampiricpuppy cuddly nosferatu

    Joined:
    Dec 4, 2006
    Messages:
    565
    Likes Received:
    0
    PARTICLE TRANSPARENCY

    Lets change the alpha value, column 62 to 0?255

    This will set the alpha value of each particle to one value for the whole lifespan, but 0?255 means a random number between 0 and 255.

    Change the value, save, and reload v2brute.

    [​IMG]

    Notice how now the particles run a range from very bright to very faint.

    Now, lets change the colour!
     
  8. vampiricpuppy

    vampiricpuppy cuddly nosferatu

    Joined:
    Dec 4, 2006
    Messages:
    565
    Likes Received:
    0
    PARTICLE COLOUR

    change the values of columns 64 (Green) and 65 (Blue) both to 0

    Save, and reload v2brute.

    [​IMG]

    We left the red value at the full 255, and removed all green and blue, so the particles all became red :)

    Lets do something a bit more funky.

    Change the value in column 64 (green) to 0,255

    Save, and reload v2brute.

    [​IMG]

    The particles in the centre (the 'younger' ones) are still red, whereas the ones further out become yellow.

    The Particles start out fully red, but as they go through their lifespan, the amount of green in them also increases, until they have an equal value of green and red (which makes them yellow :))

    Ok, now lets change their size.
     
  9. vampiricpuppy

    vampiricpuppy cuddly nosferatu

    Joined:
    Dec 4, 2006
    Messages:
    565
    Likes Received:
    0
    PARTICLE SCALE

    In protoed, find column 56. This is the 'particle scale x' field, and with respects to 2d particles, is the only one you need to worry about to scale your particles.

    Currently the field reads 30?60

    [​IMG]

    this means that particles range in size from 30% to 60% of the original tga.

    lets make them smaller. change the setting to 5?30

    save, and reload v2brute.

    [​IMG]

    Smaller sparkles :)

    now, in order to make them more sparkly, lets make them rotate.
     
  10. vampiricpuppy

    vampiricpuppy cuddly nosferatu

    Joined:
    Dec 4, 2006
    Messages:
    565
    Likes Received:
    0
    PARTICLE ROTATION

    find column 59. This is the 'particle yaw' column, and with respect to 2d particles, is again, the only one you need to worry about, this time when it comes to particle rotation.

    currently it is set to 0?360

    this means that each particle is assigned one random static value of 0-360 degree rotation.

    lets change this to 0,360.

    Save, and reload v2brute.

    The particles all now do one full rotation across their lifespan. Its a pretty slow rotation though, so lets make them do another turn.

    in column 59, change the value to 0,720

    save, and reload v2brute.

    The particles now do two full turns during their lifespan.

    The particle system accepts rotational values of greater than 360, each additional 360 is simply another turn.

    You can also use negative values if you want, for rotation in the opposite direction.

    Now, lets say for instance, we like the size of our effect as a whole, but want the particles to move faster from centre to edge.
     
  11. vampiricpuppy

    vampiricpuppy cuddly nosferatu

    Joined:
    Dec 4, 2006
    Messages:
    565
    Likes Received:
    0
    PARTICLE LIFESPAN

    For this, we are going to modify the 'particle life-span' column, column 16.

    sp-Test Cloud currently has a particle lifespan of 200. Lets make this lifespan 50, which will cause the particles to live out their lives (position, rotation, colour change etc) 4 times faster.

    change the column 16 value to 50.

    save, and reload v2brute.

    [​IMG]

    Ok, so the animations and rotations and such all play out much faster, but because the amount of particles has stayed the same, and they 'die out' faster, it looks like we have less particles on the screen

    :(.

    So, we're going to increase the rate to compensate, and make the cloud more dense.
     
  12. vampiricpuppy

    vampiricpuppy cuddly nosferatu

    Joined:
    Dec 4, 2006
    Messages:
    565
    Likes Received:
    0
    PARTICLE RATE

    Column 5 is 'particle rate'. Sp-Test Cloud's particle rate is currently 20. Lets make it 200 - meaning we're going to have 10 times as many particles being created as we did before.

    [​IMG]

    yay! lots more sparkles.

    Now, the original fog cloud spell makes use of a permanent emitter (basically as long as the fog cloud spell hangs around, the emitter will keep spewing out particles).
     
  13. vampiricpuppy

    vampiricpuppy cuddly nosferatu

    Joined:
    Dec 4, 2006
    Messages:
    565
    Likes Received:
    0
    EMITTER LIFE SPAN

    Lets say that we only want to have a short burst of particles, like an explosion.

    For this, we use column 4 'emitter life span'.

    Currently, the emitter for sp-Test Cloud is set to perm.

    Lets change this to a value of 30.

    [​IMG]

    See how now the particle system is only emitting for a short period, before it stops.
     
  14. vampiricpuppy

    vampiricpuppy cuddly nosferatu

    Joined:
    Dec 4, 2006
    Messages:
    565
    Likes Received:
    0
    PARTICLE POSITION VARIATION

    Now, lets say that we want to create a wave of particles that spreads both outwards, as well as upwards.

    Find the particle positional value fields, 53, 54, and 55. Also look at the coordinate system field, column 13, and note that this effect uses polar coordinates (discussed above).

    [​IMG]

    x values are set to 0?360, meaning they are emitted from all 360 degrees around the emitter.

    There is no Y value, so the particles stay traveling along the ground as they go outward.

    The Z value, distance from emitter, starts at 0, and then finishes at 360.

    Lets make the particle effect into a sphere of particles that rises upward.

    Change the y value, column 54, to read

    0,90

    this will mean that particles will finish their lifespan 90 degrees above the emitter, at a distance (z) of 360 still.

    save, and reload v2brute.

    [​IMG]
     
  15. vampiricpuppy

    vampiricpuppy cuddly nosferatu

    Joined:
    Dec 4, 2006
    Messages:
    565
    Likes Received:
    0
    CREATING A NEW PARTICLE SPRITE

    To create a new particle sprite, you will need a program such as photoshop, and notepad++ to edit the mdf file.

    The best way to create this sprite, is to start a new file, of equal width and height, ie. 56pixels x 56pixels.

    [​IMG]

    Then, fill the image with white.

    [​IMG]

    Then, select the 'channels' palette, and create a new channel.

    [​IMG]

    This channel will automatically be called 'alpha' and will hide your RGB channels, leaving you with a black alpha channel showing.

    On this alpha channel, paint your sprite in shades of white, black is transparent, white is opaque, greys are semi-transparent.

    [​IMG]

    Save the image as a 32bit tga file, and copy it into your toee/data/art/meshes/particle folder.

    In that folder you should find an mdf file. open it in notepad++

    [​IMG]

    replace the tga filename with your new tga file name, and save it as your new file name.mdf:

    eg. my file is smile.tga, so ill save the mdf as smile.mdf in the same folder.

    The new sprite is now available to use in your particle systems.

    [​IMG]

    [​IMG]
     
    Last edited: Jun 16, 2009
Our Host!