Thursday, September 22, 2011

Until the new year

Hello,
I'm going to be off line for a little bit. I'm moving this week then heading out of the U.S. for a couple months. I'm starting a job at Avalanche Studios, doing VFX. To say I'm excited is a bit of an understatement. After I get back I'm going to start a series of VFX called Magic Show. I don't get to do a lot of magic type effects, so I wanted to stretch my legs a bit with this project. I'm working up the concepts now, and convincing some of my animator friends to help with the character animations. I'll be posting more about that in the new year. Thanks for coming by and until next time. Have a good holiday!

Fred 

Tuesday, September 6, 2011

Basic FX Materials in Unreal

VFX Materials
The Material system in Unreal is an amazing tool, since it has so many options and ways to achieve the same result. VFX rely on slick looking materials to achieve their visual target. Today, I'm going to go over the basic materials I use for sprites in Cascade.These are the three work horse materials: Additive, Traslucent and Modulate materials. This post will not be going over lit (sprite) or model materials for cascade as I'll be doing that in a later post. You should have a basic understanding of Unreal's material system.

Material links to the UDN
FX Artist Home 
UDN Materials Tutorals
UDN Materials Compendium
Depth Bias Alpha

Definitions and uses:
Additive Materials: Fire, motes, energy, glowy bits: Additive materials add the sprite against the scene, similar to a Screen blend in Photoshop.
Translucent Materials: For smokes, and faked debris bits: Translucent materials use the source color of the sprite and adds opacity (alpha) to it, then blends it against the scene color.
Modulate Materials: Dark smoke, decals, and some smaller debris: Modulative materials multiply the sprite against the scene, similar to the multiply blend mode in Photoshop.

Before we start
Import textures into unreal that you can use for this test. Make sure all textures are targa and are power of 2.
Additive texture: Black is knocked out, so anything black will not display in an additive blend mode. Remember to make sure the texture uses the space well since the sprite will still need to calculate the unseen areas. This can have an alpha texture but is not necessary for this case. 
Translucent texture: This can be any kind of texture, with an alpha channel that will serve as the knock out. For example if you wanted to have a leaf texture. the RGB would support the color and the alpha would serve as the transparency.
Modulate texture: This is the polar opposite of the Additive. White is knocked out and colors are multiplied against the scene. This can have an alpha texture. 



Additive Material Base
The basic material will be set up in the emissive, and to get anything in game you'll need very little. The following material will have static switch set ups for UV distortion and near fade and a control for depth bias alpha. This will look like this when we're done.

 I'll be breaking down each commented section while we go.

First, In Material make sure the blend mode is set to Additive and the Lighting Model is unlit. In Usage make sure the Used with Particle Sprites and Used with Particle SubUV is checked, otherwise the sprite will not display when you get it to Cascade.


Next drop a Param2d (name it Emissive), a Vertex color and a multiply module near the Emissive hook up. String the modules up like this

Vertex color mult by the texture equals Dynamic color changes in Cascade
This set up will allow you to change the color of the RGB values of the texture in Cascade dynamically. I use this for 99.9% of all FX materials that I use unless I know for sure the color of this will never be changed. At this point you can start working with the sprite in Cascade. This is really all you need. I usually add a couple other properties to the material, since I tend to need them in most particle systems. (Note: Make sure you string this into the Emissive, if you hook it into the diffuse it will appear solid black).

Save your material and package.

Distorting the UVs
Sometimes you'll want to distort the UVs of the texture for fire or to give the surface some extra motion. Set up the following like this and string it into the UV hook of the Param2d Emissive module.


  • The Panner moves your texture in the U and V space as well as controls time. 
  • This is hooked into the UV in of the Param2d UVDisort Texture. The green channel is multiplied against a parameter to control the intensity of the distort and is added to a texture coordinate module (I used the green channel since it had the most contrast). 
  • This creates a surface that can be distorted against the Emissive texture. 

The Switch parameter is set up in case we want to use the distortion. The A channel is the UV Distort option while the B channel is no distortion and is the default in this case. The switch parameter is an if/then statement and will show up in INST materials.

DepthBiasAlpha
One of the functions of Depth Bias Alpha is to remove hard lines of sprites crashing into geometry. The set up is really simple. All you'd need to do is set up the DepthBiasAlpha module and string it into opacity. The lower the number in the depth bias the less smooth the blend and also the larger the blend. Experiment with this until you get a result you like (defaults to 250). The UDN has more info on this magic module here.


Near Screen fade. 
This next set fades sprites based on its camera position. This keeps sprites from crashing into the camera. Set up the following and hook it into the DepthBiasAlpha Alpha entry:



  • This takes the screen position and masks the Z position, since most sprites are camera facing on the Z axis, then multiplies a distance from the position and clamps it 0-1 to avoid some visual artifacts. 
  • This is then hooked into a switch parameter in case we want to use this functionality. 
From here create an instance of this that you can use for material variations.

That's the additive base in a nutshell. All the other materials are similar to this so I'll be working on the exceptions from here on out.

Translucent Material Base
This is the easiest to change since the base of the additive is most of the work. There are a couple things you'll need to add and change.

First make sure you make a copy, rename the material and change the blend mode to Translucent


Next Add in 2 multiply modules, a Vertex color and a constant clamp and set it up like the following:


  • Hook the alpha (white connector) if the Param2d Emissive to one of the multiply nodes A and connect the DepthBiasAlpha to B. 
  • To make the alpha dynamic in Cascade hook the Vertex color module and the other multiply. Then set up the constant clamp from 0-1 (default) and hook it up to the opacity node. 
  • This will keep the alpha multiplies within a 0-1 range.
You can now use this in Cascade as a translucent material. You can control the color and alpha of the sprite using the color modules. The rest of the material should look like this:


Modulate Material Base
This one will be a little different. The base is still the Additive material, but we're going to need to treat this as everything is blending to white instead of black, since this multiplies its values against the scene. (Note: as of this post I was getting an error with the modulate blend mode against the DepthBiasAlpha node, so it will be absent from the material. I'm looking onto it and will hopefully have an update to it soon)

First thing you'll need to do is change the blend mode to modulate


Next you'll need to re-string a couple entries to make the modulate blend mode work. Change the texture to the modulate texture and add in a Lerp(linearinterp), a constant, an add a constant clamp module. Set it up like this:



This is what this is set up to do. Again we're blending to white, since its a modulate texture
  • The Lerp is using the vertex color (alpha) to blend the texture from its surface to 1 (white)
  • The vertex color is also set up to control the color of the texture (black node to mult B)
  • The alpha of the modulate texture is masking the edging of the surface so if you change the color in Cascade it only covers the circle (in this case)
  • The Add module combines the mask and the lerp controls
  • the Constant clamp keeps it within a 0-1 range
The near fade:
The way the near fade is set up now is to blend to black, so we're going to need to change that. Drop a oneminus near the fade and set it up like this:


  • Place the one minus module between the multiply and the constant clamp to switch the black to white.
  • Then change the constant from 1 to 0 out of the Switch parameter, otherwise the base material will appear as black
  • String switch parameter into the add and then hook the whole thing into the Emissive. 
That should give you a modulate texture, that you can start to use in Cascade. I hope this helped and wasn't too confusing. I'm going to try to get at least one more post out before I am out til the new year. Thanks and until next time.

Fred

Thursday, September 1, 2011

FX Optimization and where have I been

This post is about FX optimization... the good thing is, I'm not going to write it. Tim Elek over at Epic posted a great Wiki on particle system optimization with an easy to use link system based on potential problems and whatnot. If you work on particle systems and manage overdraw at all in Unreal this is an essential read.

UDN FX Home

Direct link to UDN FX Optimization

Tim's blog is here, it has some good insight on Epic and everything FX and Tim!

http://derelict-compendium.blogspot.com/

So where have I been?
The reason I haven't been around a lot is I'd been let go in the lay offs at Kaos, and I'd been looking for work for the last couple months. I will be working for Avalanche Studios starting in October. I'll be out of the country learning their tech and helping out until December, so I'm going to post a couple things before I go.Also I have plans for a series that will cover a number of non realistic fx from concept to completion. I will tentatively be calling it Magic show. The plan (for now) is to pick an element and build a set  of meshes, materials and particles from each type. I have a concept for Ice and fire, but after that building from the ground up and work it step by step in Unreal.

The next post will be more or less a basic materials set up for particle system types. This will not cover some of the more recent additions to Unreal's Cascade, but it will have the base that is necessary.

Until next time.