All example project files for this and future tutorials can be found here https://www.dropbox.com/s/e3kio1s5q3hlvp7/Unreal_Tutorials.zip?dl=0

Please download and follow along with the examples and experiment - always the best way to learn!

 

Today we're going to be using the things we've already learned about Math and Vectors and applying them to a very powerful input node in the Unreal Material Editor - World Position Offset.  

Move

Here we've just simply plugged a Vector3 into our WPO input.  Notice how the preview cube moves up in the Z axis?  Basically whatever Vector3 we plug in here will offset our vertices in the X,Y,Z axis.  Pretty cool and incredibly powerful for VFX work.   

Sine

So moving things is a good start but what we really want is some animation - here I've just taken a simple Time>Sine setup and multiplied by 0,0,50 to just get movement in the Z axis.  The result - a very simple bouncing box!  This kind of procedural animation is incredibly cheap compared to regular skinned animation and really powerful.  If you remember back to our discussion regarding the difference between the pixel and vertex shader, this animation is happening in the vertex shader, so we're limited by the number of verts in our mesh - basically if you want smoother curves you need more geometry.  

Note there is a World Displacement input that does a very similar thing to World Position Offset but using tessellation to dynamically create intermediate verts when required and then a Heightmap to control the movement, but that's out of scope of this tutorial.  (https://docs.unrealengine.com/latest/INT/Resources/ContentExamples/MaterialNodes/1_11/)

Sine Wave

So the Sine Wave is a good start but what if we want some variation across our mesh?  Well we know a technique for creating variation from our Vector tutorial - World Position.  If we mask off a channel and add that to our Time we get a nice Sine wave motion moving through the world. 

Vertex Normal

So far we've just been moving things in the World Space axes - what about something more specific to the object?  Here we're just using the Vertex Normals as our multiplier to our Sine Node - an oscillating exploding box!  Maybe not super realistic but could make for some sort of cool Sci-Fi hologram.  What about if we Abs our Sine input?  or Frac it?  or combine it with the World Space technique from above?  There's almost infinite combinations of things we can do and results we can achieve, we just have to work out the Maths!

Texture

Well actually we don't always have to do that Math - we can use a texture!  Since DX11 we've been able to use Textures in the Vertex shader and here we're scrolling a simple Clouds Noise through our object - not that impressive but hopefully you can see the potential in authoring Heightmaps for your models - combining this with masks you can create all sorts of effects.  

Vertex Paint

Finally the last common input for the WPO node is Vertex Painting - here we've just multiplied the Red channel by the Vertex Normal (the preview cube defaults to White vertex colour or 1,1,1).  Try applying this to plane and painting it in engine - basically what we've created is a very simple sculpting tool!  Now we're not about to start replacing Zbrush but this is great for things like ground surfaces or water surfaces where you just want to make a few little adjustments in engine.  

Hopefully that gives you a few ideas for how we can control our Vertex offsets and animations and inspires you in your effects work - recently Unreal has started developing tools for baking Vertex animation (such as fluid or cloth simulations) into a Texture and reading that back like a flipbook, which is incredibly exciting for the future of Vertex animation.  (https://docs.unrealengine.com/latest/INT/Engine/Animation/Tools/VertexAnimationTool/).