Material Blend Shader

After watching Ben Cloward’s Shaders 101 talk, I wanted to have a go at one of the examples he’d shown. I’ve created a material blend shader, which blends between two sets of albedo and normals, putting the second material (moss, snow ect) on top. I created a mask to use as a interpolator between the […]

Shaders 101

I recently watched a great GDC talk by Ben Cloward on the basics of shaders. He talks about why each part does what it does really well, and is a great introduction if you’re new to shaders, or a good refresher if you’re coming back to them after a while.

I was lucky enough to be able to access the full talk at work, but the slides are still available without a GDC vault account.

So without further ado, here’s what I learned…

What is a Shader?

A shader is a piece of code, generally running on the gpu, that controls the colour of a pixel on screen. Or, as Ben called it, “art with math” – I do like that one!

PBR Shaders

In a PBR workflow, shading is seperated into two categories – surface properties and light properties.

Before PBR, shaders combined the two sets of properties though techniques like baked lighting in diffuse maps and specific reflection maps. This would cause issues with changing light setups and placing props in different environments.

This also allows us to use differed rendering, as surface properties are rendered into the g-buffer before the lighting properties are calculated.

Ben’s talk focused on surface properties, as light properties tend to be in the realm of graphics programming, rather than tech art.

Data Types

Float = Single decimal point value

Float2 = 2 decimal point values – often used for UV coords.

Float3 = 3 decimal point values – often used for vectors or colours.

Float4 = 4 decimal point values – often used for vectors with w or colours with alpha.

Distortion Shader Example

Ben used the example of a distortion shader to bring up some key techniques.

Multiplying Tex Coords = Scaling Coords

Adding Tex Coords = Offsetting/Scrolling Coords

Time can be used for constant updates/animation.

Speeds can be controlled with a multiply node.

Append (in UE4) = Combine 2 floats into a float2.

Adding together your movement and a copy of your movement, with different times and values, will create a random effect, as they will never overlap in the same way.

Atlas Walk Example

The atlas walk example showed how to go though a flipbook texture. After watching this, I may replace the camera target in my security feed shader with something similar.

Floor Node = Rounds a decimal down to the number before the decimal point, meaning it                               steps up to each number in a stair case shape.

Frac Node = If value is greater than 1, make it equal 0. This allows for the atlas to loop.

Environment Blend Example

This shader example was really cool – definitely something I want to try!

Lerp = Linear interpolation, alpha = how much to blend each input.

Getting Up Direction = Normal map is in tangent space(offset of normal dir) in UE4, so in                                                order to get world up, we need to convert to world space. This can                                                  be done using the TransformVector node.

Mask = Get specific channel/component of input.

Saturate Function = Clamp between 0 and 1 at no computational cost. Achieved with a                                                  clamp node in unreal.

Sharpen Operation = Subtract 0.5, Multiply by Sharpen value, add 0.5, clamp.


Now I need to make some shaders with what I learned!


Security Feed Material

I got started on a security feed material this week! I’ve wanted to do a little unreal material editor work for a while, so taking a break from the exporter project to make some funky shaders!


This took me a couple of hours on Saturday afternoon – I’ve been out of UE4 for a while and I don’t do shaders regularly at work, so I figured this would be a slog. Not at all -the basic set up was really fun!


Fish Eye Distortion

I’d never created anything like a fish eye distortion before, so this was really interesting. It is created by distorting the UVs based on something.

The tex coords are first multiplied by 2, to give us the whole texture, as the distortion will change its size, and then 1 is subtracted from it to remove the appearance of tiling.

To create the actual distortion, we have to multiply a normalized version of the uv coordinate (a single number representing the vector) and the length of the vector, squared. The image below shows how the two values combine to create a rounded appearance.


The add and divide are to fix the tiling after the multiplication, other wise the image would be offset by a quarter of its size. We are very close to undoing the coordinate changes we made in the beginning.



Can’t wait to do more on this!


AmesyExport V0.3

Multi object exporting is in! V0.3 of AmesyExport has been released at

Export V3


The main questions I asked myself on this version were:

  • How do I take multiple objects as a single list entry?
  • How do I group exports at export time only?

The first was much easier than expected – I did not previously realize that a list of lists is completely possible in python!

The second was more of a challenge, but  not one I predicted. I struggled for a bit with getting my new group to move to world origin, as when a group is created with an object center pivot, it still has zeroed translations. My eventual answer was to use the rpr flag.

cmds.move(0,0,0, rpr = True)

The rotatePivotRelative flag moves the object relative to the objects rotate pivot point. To be perfectly honest I’m not sure how this relates to moving in absolute world space, but if I find out I’ll post it up!