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!