Pages

Friday, February 1, 2013

UDK Ice Material with Tessellation and Reflections

Note: This is not a step by step tutorial but an explanation of a few key features

A few days ago my friend, Paul Tran and I explored different features in the UDK material editor. We decided to make an ice material so we did some research, played with a few nodes can came up with this base functionality shown below.

The node network show below plugs into the Emissive input to light the object from all angles (see animated gif above) or the diffuse and light it externally. The Reflection Vector and Vector Transform plug into a cube map (the Texture Sample node) to make the ice reflect the environment.

A stretched normal map plugs into the Distortion input on the material and into the Fresnel for the outer color.

The un-stretched normal map plugs straight into the Normal map input. That same un-stretched normal map also plugs into a Fresnel which then plugs into the Opacity input to make the ice transparent and bumpy in the middle.

After accomplishing this I decided to adopt some ideas from George Sokol's tessellated icicle material.

Below, the simple stone shader (textures are property of Epic) textures plug into the A slot of their respective Lerps and their ice equivalents into the B slots.

The Blue channel of a VertexColor node plugs into the Alpha inputs of the Lerps. This allows the user to lerp between stone and ice by vertex painting blue onto an object with this material.

Opacity is not used since it will be frozen over solid stone, no longer a frozen ball of water.

A displacement map multiplied by the Red Channel of a VertexColor node plugs into the Alpha input of a Lerp between a 0,0,0 vector (no displacement) and 0,0,-60 (a down vector). This Lerp plugs into the WorldDisplacement input. (See image below) This allows the user to add downward facing icicles by vertex painting red onto an object with this material.

A WorldNormal node allows the vertices to displace based on the object's face normals. This WorldNormal and down vector plug into a SwitchParam to allow the user to pick whether they want the height map to push out based on the face normals of the mesh or a set down vector.

A Camera World Position and Object World Position plug into a Distance node. This will find the distance between those 2 objects. That distance multiplies by a vector parameter to tessellate the mesh more when the camera gets close to it. This node network (shown below) plugs into the TessellationMultiplier.

Also make sure to use a VectorParameter instead of a TexCoord node or else there will be holes in the mesh. See below:

That's it for the material. A Material Instance Constant of this material allows the user to change it's parameters on the fly such as the ice color, icicle length, amount of icicles, direction of icicles, tessellation amount etc. Like this: