CCG V3-1 Conversion:Part 9 Visual Effects
From NWN1 Custom Content Guide
Contents |
Visual Effects
So you want to create your own visual effects? I talked about innovative ways to get NWN to do things it was never designed to do. Visual effects can be used to great success in this area. They have already been used to give creatures wings, to provide a sort of horse-riding feature, and other ideas. So let’s talk about how we create visual effects.
Let me start by describing what a visual effect is. It is, like many other things in the game, a 3D model. The interesting part is that it can be any type of 3D model. Many visual effects are emitters – representing a particle system in NWN. Emitters can be used to produce clouds, smoke, fire, lighting and other special effects. Visual effects models can also be normally rendered 3D models. This is what makes them so versatile.
You invoke a visual effect in the game in different ways.
- You can place a visual effect directly in your module (used to create a dust plume, for example).
- Some are tied to spells (remember the audio and visual effects we discussed in spells.2da?)
- You can also call up visual effects through scripting, tying them to creatures or objects.
There are two main types of effects to keep in mind:
- Duration Effects – these last for a specified length of time (you specify the duration).
- Fire and Forget Effects – these are fired off, they run through their animation, and they go away automatically (duration is specified in the model file).
So we want to create a new effect. It is going to be a waving seaweedy thing similar to the wavy pseudopod namesake of Evard’s Black Tentacles. There are really two things we need:
- a visual effect model file
- an updated visualeffects.2da file to tell the game about the new effect
Where do we start? With something similar to what we already want, of course!
Part 1: The Model File
There are, of course, naming standards for visual effects. These aren’t strict naming standards but some effects look like this:
Duration Effects
- VFX_DUR_* (Duration)
- VFX_BEAM_* (Beam)
Fire and Forget Effects
- VFX_COM_* (Combat)
- VFX_FNF_* (Fire and Forget)
- VFX_IMP_* (Impact)
There are other naming standards for special effects tied to spells. Browse through the special effects reference guide at the end of this tutorial for details on those.
Like most other models, the name of a VFX model should not have more than 16 characters. You can find the Bioware VFX models in models01.bif. Open up NWN Explorer and export the model for Evard’s Black Tentacles (VPS_TENTACLE.mdl). Now open the model in gmax.
Note that VFX models have 3 – and only 3 – animations:
- impact (plays at start of effect)
- duration (looping)
- cessation (plays at end)
They can have any of the components or features of a regular model (multiple parts, etc.) When you create the Aurabase object, set the classification on the edit rollout to “Effect”.
Part 2: Emitters
|
In the case of our seaweedy thing, our model has a series of emitters. Emitters can now be used directly in Gmax – Joco’s updates to Wayland’s scripts now import and export emitters.
However, there is a workaround for this and it is important to understand emitters because so many visual effects use them. The key observation to make is that emitters are just custom nodes. They are nodes in 3ds Max that have custom-defined attributes tied to them – nothing more, nothing less. The reason you cannot use them in Gmax is simply that Wayland’s scripts were not written to import or export them. The 3ds max scripts can read and write emitter files. However, because emitters are just custom nodes, you cannot actually view the effect in 3DS Max. All you can do is change the parameters.
So let’s open up the file in 3ds max. It looks like this:
If you select one of the arrows you will see that it is an emitter. The edit rollout looks like this:
If you wanted to add a new emitter in 3DS Max you would go to Helpers, change the dropdown to MDL Suite and select Emitter. On the edit rollout you can change the detailed characteristics of the emitter. These are the characteristics that you can modify:
| Attribute | Meaning | Values |
| – Styles | ||
| Update (update, update_sel) | How the emitter is updated with new particles. | Fountain - a constant flow of particles based on the other settings. This is used for smoke, flames, water and etc.
Explosion - occurs when an animation has a detonate event set on a frame. This is used mainly to 'blow something up – to blow it up real good'. An explosion emitter generates one pulse of particles based on the other settings every time the detonate event occurs. To add a detonate event skip over to where you want it to occur in your animation. Under the animation settings on the model base, add an event on the frame where you want the pulse to happen. Use 'detonate (not sure if CaSe matters but lower works). Single - creates a single particle at the center of emitter instead of spouting out multiple particles over time. Lightning - (assumption) generates a lightning effect with the particles. |
| Render (render, render_sel) | How to render the emitter.
Determines how the particles are sent into the world. | Normal - a simple render of the emitter effects.
Linked - rotates particle so the end of each particle will touch the start of previous particle. This can be used for rope-like effects – a very good example of this is one of the spells distributed with model viewer, with dusty pit surrounded by a few vines. Billboard - means that the particles are aligned with 'something'. Usually in 3D animation this is used so that you can get a good effect without a lot of polygons. Example rather than creating a model for a particle, you map a bitmap to a flat plane and set it to always face the camera. You can get the same effect as a modeled particled but it saves on polys and you don't have to worry about it turning sideways and revealing its 2D status. Aligned - I assume does what it says, makes sure the particles don't rotate or come out in the same way. It is possible to use this for something like a dart trap VFX because you would want all the darts to come out the same way. |
| Blend (blend, blend_sel) | Describes how to blend the particles with the rest of the scene. | Normal – does no blending.
Lighten - used with alpha masked particles such as smoke or flame. If you just put them as normal they would appear like big, obvious particles. Lighten takes the particle and uses its colors and alpha to XOR with the objects between it and the camera and generally give you a more realistic, ephemeral effect. Rule of thumb use Normal for 'chunk' emitters and Lighten for smoke, mist, fog, water. |
| Spawn Type (spawnType) | Describes how the particles are spawned. | Normal – does no blending.
Trail – Presumably spawns with a trail following the effect. |
| – Parameters | ||
| Icon Size | Affects the display size of the emitter helper object. This has no impact in-game. | |
| Emitter Size (xsize, ysize) | Yields the size of the area that generates the particles. | |
| Inherit properties (inherit, inherit_local, inherit_part, inheritvel) | This tells the particles to inherit or assume certain properties of the emitter. | If you check inherit, the particle emitter should move with whatever object it is parented to.
If you check velocity, if the particle emitter is moving the particles will inherit that velocity and add it to their own velocity. This can be used to create a trail of particles left behind by something moving. Note that for this to work it requires a huge number of particles or you get individual 'puffs' of particles. |
| Miscellaneous (deadspace, threshold, combinetime, renderorder) | Renderorder is for when you have multiple emitters in a scene. It represents the order that this particular emitter will be rendered in relative to the others. If 2 emitters share the same order number there will be a flickering as the engine trys to render both at the same level - even if one is behind the other in 3d space. Lower numbers are rendered first and higher numbers are rendered overtop of them. | |
| – Particles | ||
| Color (colorStart and colorEnd) | The color the particle starts out as and ends as. | For example, to build a smoke effect, you would set the Color from white to gray, the alpha to start high and go to 0, size to start low and go high. This would have the smoke come off the fire white and small and as the particle aged it would get darker, more transparent and larger to simulate the cooling off of the smoke and it being spread out.
The RGB colour values of the effect are decimal values in the model file so divide each of the RGB values by 256. |
| Alpha (alphaStart and alphaEnd) | How transparent the particle is at start and end. | |
| Size (sizeStart, sizeEnd, sizeStart_y and sizeEnd_y) | How big the particle is at start and end. | |
| Birthrate (birthrate) | How many particles are born in X units of time. | |
| Life expectancy (lifeExp) | How long the particle lasts in X units of time. | |
| Mass (mass) | Does it fall down and how fast. | If the mass is positive gravity will pull the particles down. If it is negative they flow upwards. |
| Spread (spread) | How far do the particles spread or what's the range of their angle of departure. | An angle of 10 means a very thin cone. An angle of 180 means all directions. |
| Particle Rotation (particleRot) | Does the particle rotate as it leaves and how much. | A high number for a chunky emitter would have the chunks flipping end over end. |
| Velocity (velocity) | How fast does the particle leave the emitter. | |
| Random velocity (randvel) | What is the variation range based on the velocity. | A velocity of .5 and a random velocity of .2 yields a particle that will have a velocity of .3 to .7 when it leaves the emitter. |
| Bounce Coefficient (bounce_co) | How much does the particle bounce. You wouldn't want your smoke to bounce but a fountain of superballs should bounce rather well. | |
| Blur length (blurlength) | How much motion blur is created for the particles. | |
| Loop (loop) | Not sure | |
| Bounce (bounce) | Makes particles bounce | |
| Tinted (m_isTinted) | Particles that are texture mapped will be tinted the start and end colors. Much like you change the color of skin or armor. The underlying texture will remain but it will be shifted towards the start end colors. | |
| Splat (Splat) | Splat tosses particles out as if they were tumbling – like you would throw a handful of coins. They can bounce with the bounce settings, but when they land they are generally aligned facing out with the normal of the polygon they land on. Not sure how this behaviour mixes with the various Alignment settings, but they seem to always come out aligned to the direction of the Z axis of the emitter, i.e., in the direction the emitter is pointing. | |
| Affected by wind (affectedbyWind) | The particles will inherit velocity from wind speed in areas that have wind. | |
| – Texture and Chunk | ||
| Texture (texture) | What texture is mapped to the particle or what model is used instead? | A standard 32-bit tga file. |
| Two-Sided (twosidedtex) | This would avoid the particle from disappearing when it rotated because there was nothing on the back side. It allows you to keep the particles simple. | |
| Animation – Grid Width and Grid Height(xgrid, ygrid) | The animation settings let you create a texture image consisting of a grid of multiple, equally-sized frames. The width and height numbers tell the emitter how the grid is laid out. | These have interesting effects on the particles and how they're generated. For example, playing around with this you can get a circular whirlpool effect. |
| Animation – Speed (fps) | During a particle's lifetime, it will animate through the frames of the animation. The Speed setting tells the emitter how quickly to animate them. | |
| Animation – First Frame, Last Frame (frameStart and frameEnd) | Tells the emitter which frame to start and end on during the animation cycle. | |
| Animation – Random Playback (random) | Will cause the emitter to choose random frames during playback instead of cycling through them in order. | |
| Chunk (chunk) | The model or chunk that's used for the particle rather than a flat poly. | |
| – Advanced | ||
| Lightning properties (lightningDelay, lightningRadius, lightningScale) | No idea. | |
| Blast properties (blastRadius, blastScale) | No idea. | |
| P2P properties (p2p, p2p_sel, p2p_type, p2p_bezier2, p2p_bezier3, drag, grav) | No idea. |
You can animate some of these properties so that they change during the course of the animation playing (e.g., birthrate). All the value spinners including the color values in the particle menu roll down can be animated. However, the Loop, Tinted, Bounce and Wind check boxs cannot be animated.You will have to play around with others because there may be more which can be adjusted through animation.
So what is the magic workaround I promised for Gmax users? It is this:
- Open your model in Gmax.
- Insert a simple node where you want the emitter to be (in the Create tab, select the Helpers button and create a dummy node). Give it a unique name.
- Make sure you have an Aurabase object. Link the dummy node to it or to an object that is linked to the Aurabase (otherwise it will not export in the next step).
- Save your model.
- Select the Aurabase object and export the model.
- Now open the resulting model file. Look for a line like this:
node dummy <whatever you called your dummy node> parent vps_tentacle position 0 0 -0.065378 orientation 0 1 0 -3.14159 wirecolor 0.425781 0.425781 0.425781 endnode
- Replace the first line with:
node emitter <whatever you called your dummy node>
- Insert the following text right before the endnode line:
colorStart 0 0 0
colorEnd 0 0 0
alphaStart 1
alphaEnd 1
sizeStart 0.1
sizeEnd 0.01
sizeStart_y 0
sizeEnd_y 0
frameStart 0
frameEnd 0
birthrate 0
spawnType 0
lifeExp 1
mass 0.1
spread 0
particleRot 0
velocity 3
randvel 0
fps 0
random 0
inherit 0
inherit_local 1
inherit_part 0
inheritvel 0
xsize 0
ysize 0
bounce 0
bounce_co 0
loop 0
update Fountain
render Linked
Blend Normal
update_sel 1
render_sel 2
blend_sel 1
deadspace 0
opacity 0.5
blurlength 10
lightningDelay 0
lightningRadius 0
lightningScale 0
blastRadius 0
blastLength 0
twosidedtex 0
p2p 1
p2p_sel 2
p2p_type Gravity
p2p_bezier2 0
p2p_bezier3 0
combinetime 0
drag 0.8
grav 3
threshold 0
texture fxpa_vine2
xgrid 1
ygrid 1
affectedByWind 0
m_isTinted 0
renderorder 0
Splat 0
- Use the descriptions above and this template to set your own emitter values.
- Save and close your model.
- Keep your fingers crossed that you did it right.
For my example I’m going to turn the emitter upside down and then change the texture to be more like seaweed than a black tentacle. I’m going to use this base and attach it to the upper body of a dryad to make a Kelpie. More on that in the next version of this tutorial.
Part 3: The Visual Effects Resource File
Now that we have created an emitter, we need to get NWN to recognize it. Like other custom content we do that with a resource file (.2da). VisualEffects.2da describes which visual effects are available. This is a breakdown of all the column headings for visualeffects.2da.
| Column | Description | Values |
| The first column is the ID of this entry | ||
| Label | The internal name of the effect. | |
| Type_FD | The type of effect. |
F = Fire and forget D = Duration |
| OrientWithGround | Orient the effect with the ground plane | All Bioware effects are set to 0.
0 = False 1 = True |
| Imp_HeadCon_Node
Imp_Impact_Node Imp_Root_S_Node Imp_Root_M_Node Imp_Root_L_Node Imp_Root_H_Node | Name of the effect model that will be animated at the appropriate node. | These effects will play respectively at the Head node (just at the top of the head on most models), the Impact node (near the center of body in front), or the rootdummy node for different sizes of creatures. Bioware does not use S but these are for Small, Medium, Large, and Huge models respectively. |
| ProgFX_Impact | A number referencing an internal programmed effect upon impact of the spell with the creature. These are effects for which there is no model and they are used to create special effects such as invisible, ethereal, stoneskin, etc. | |
| SoundImpact | A sound file played at start of effect. | From the soundset.2da file. |
| ProgFX_Duration | Duration for which the programmed effect plays. | |
| SoundDuration | A (usually different) sound file that plays throughout the duration of the effect. | From the soundset.2da file. |
| ProgFX_Cessation | Programmed effect that is applied at the end of the effect. | |
| SoundCessastion (sic) | A third sound file that plays at the end of the effect. | From the soundset.2da file. |
| Ces_HeadCon_Node
Ces_Impact_Node Ces_Root_S_Node Ces_Root_M_Node Ces_Root_L_Node Ces_Root_H_Node | These appear to be effects that would be played at the end (cessation) of the effect. However, Bioware doesn't use them and nothing appears to happen when tested. |
**** |
| ShakeType | Should the effect shake the screen? | 0 = No
1 = A quick bump 2 = A timed effect using the next 3 parameters. |
| ShakeDelay | Delay in seconds before start of the screen shake | |
| ShakeDuration | Duration of the screen shake in seconds. | |
| LowViolence | A programmed effect number is used instead of the combat blood models for Low Gore video settings. | These are only used by Bioware for the combat blood spattering (all colors). |
| LowQuality | An alternate, less detailed effect model for low quality video settings. | These are typically used for lower quality explosions and other fancy, CPU-intensive effects. |
Now open up nwscript.nss. This is where the predefined constants are. Add a new constant for your new visual effect by finding the list of effects and add your entry. For example, it typically looks like this:
int VFX_DUR_DARKNESS = 1;
Just list the name and your entry number from visualeffects.2da.
« Custom Races | Visual Effects | Other Tutorials »
