— PROJECT NAME

Procedural Eye Shader


— ROLES

Unreal Blueprints Developer

Material Artist

3D Artist

This shader was created as a personal project to further enhance my skills within Technical Art.


The aim of this shader was to create an anatomically correct eye with customisable colours, size and intensities with the addition of a pupil that reacts to light within the Unreal Engine 5 game engine that could be used within a Character Customiser by a player, or a Technical Artist/3D Artist when creating a character.

Utilising Blender, I modelled the basics of an eye and an iris so we have an anatomically correct model to put the new shader onto. This model contained the data for the sclera and the cornea and will overlap the iris model with the transparency of the cornea.

The iris is a separate object to allow for cleaner UVs to manipulate; I noticed Unreal’s MetaHumans used a circular UV map for their iris, but I dictated that expanding the UVs width-ways would allow for further customisation in the shader I am creating.

The eye models were then taken into Substance and had the normal details painted onto the textures themselves. By doing this, I was able to create detailed and life-like details for the iris of the eye, as well as create normal maps for the veins on the sclera for added depth as an eyeball is not just an entirely flat sphere.

The textures were then exported from Substance and texture packed utilising Photoshop in order to increase performance and reduce draw calls. We can take each channel of the texture and use this for a different aspect of the iris colours.

The vein textures also followed the same method, and were packed onto the channels to allow us to manipulate multiple vein patterns from one texture.

Utilising refraction allows our cornea to warp things behind it when looked at from an angle, like a real cornea. World Position and Object Positions combined with a Fresnel node allowed for this effect to work realistically within UE5.

Taking the normals and roughness values from our material, we can now create a realistic bloodshot effect for our sclera and allow this to be customised by users within the engine.

Using a combination of our textures and material functions, we can now create customisable eyes utilising Material Instances.


Our material takes the texture packed textures, and applies colour to their channels to allow layering of colours and aspect of the eye which the user is then able to customise using a User Interface created within the engine.


All of these parameters are accessible to artists within the game engine as a tool inside of the Material Instance, and will allow those developing within UE5 to use the eye and customise it for a character or idea they may have.

I am able to create an expansion effect with the pupil by manipulating the tiling and size of the UVs. Combining this with the mask of the pupil utilised inside the material, it creates a convincing effect of a pupil opening and closing.


But how do we create a realistic pupil changing without manual input? Detecting the light’s intensity and direction.

By taking the Cross and Dot product of the eye and light source, we can determine how far away they are from each other as well as detecting the direction (forward vector) of the light in comparison to the direction of the iris. Once this is achieved, we compare the values of the output float and we can determine the direction.

With the pupils now being dynamic based on the light, we can now instantiate many eyes with moving lights and watch the pupils react based on the direction and distance.

Improving on this system further, we can include a Line Trace between the light and the eye and check if this is obstructed, by doing this we can force the float used to dictate the ‘direction’ and override with a set value to show minimal light affecting the eye.

Within the Blueprint itself, there are customisable options for a developer to adjust the pupil sizes and change rate to allow them to fine-tune the eye as they see fit.


Pupil Time to Scale – Dictates how long the transition between sizes is.

Direction Pupil Multipliers – Dictates the size for the pupil dependant on the direction found in comparison to the light: e.g. if it is facing the light, forward direction is used.

Combining these elements inside the logic and material, we now have a procedural eye shader that can work with the Directional Lights within an Unreal Engine 5 scene. By adding some sliders to the UI to test, we can see how the parameters can be changed through user input and allow a customised eye to be edited and changed for the users preference in-game!

The Iris has multiple colours and intensities for visual aspects of the eye available, including a custom Pattern node where you can override the default Iris with dots or another custom pattern.

The Sclera has multiple colours and intensities for the textures and normals of the material, and the Cornea includes options to adjust the Refraction if necessary.

Alongside the existing parameters inside the Material, developers can click Use in Sequencer? to use the parameters inside of the sequencer instead.


This utilises a Material Parameter Collection which stores all the Scalar and Vector parameters of both the Iris and Sclera materials and allows the developer to make changes here instead of inside the instances.

Developers are now able to animate the parameters inside of the sequencer for cinematics, game mechanics or just generic customisation over time.