Not so easy to find the right function for a pattern or an animation in a shader... Until now!
With WkFunctionDrawer you can visualize the curve of your functions. All you have to do is to import the WkFunctionDrawer function node into your shader and plug them.
Version 2.1 is faster to compile, simpler to use and comes with function examples.

This shader can be used either as a standalone material to view the curve of some functions you know the equation or its main nodes can be imported into a shader you are working on to check the value of some variables.
It is intended to be used primarly as a tool, not as an in-game shader. Although the code shouldn't be resource consuming, I didn't really check the performances.


  • WkFunctionDrawer_Overview

Features and notes

  • Displays up to 3 function curves
  • User-defined graphic range on X and Y axis
  • Supports animated curves
  • Can be used in any material or material function

There is room for improvements:

  • The graduations values are only in the range [-2,2] and are part of the grid texture.
  • The grid comes from a texture. It could be procedural (see this post in the blog of Oliver M-H for more)
  • Currently the shader supports only linear map functions. In his post Oliver M-H also presents a method to draw parametric functions.



Download the package and unzip the content (be careful not to create a folder with the name of the archive) directly at the root of the Content directory of an UE4 project.

Then launch the UE4 project. You should find the WkFunctionDrawer data in the following folder:



WkFunctionDrawer use

  • Standalone material: Open the material M_WkFunctionDrawer, add the equation of the functions into the green Comment node and plug them as in the examples.

  • Viewer of variables in a material or a function material: In the shader you are working on right click to call the functions lister dialog box and instantiate the function MF_WkFunctionDrawer. Then plug the output X of this node into the branch of the shader you are interested in and the output of this branch into one of the 3 functions input. Now to display the graph connect the output of the Lerp node in the Emissive plug of the material.



One of the first thing you may notice when playing with the function drawer is the look of the sine and cosine. Indeed, as I did with some surprise, you will discover that these functions are periodic on a [-1,1] range instead of [-Pi,Pi].

Why is that? Mystery. The sine documentation says nothing about this strange range, it says input should be in radians.

There is a "linear sine" though:


Sample functions

WkFunctionDrawer now comes with a set of sample functions such as a modified modulo or several periodic signals. It is easy to experiment with them and, as they proved to be quite useful, to encapsulate them in material functions for an easy reuse.

All these functions are in the material located here:



  • FunctionSamples


Code overview

Material M_WkFunctionDrawer

Open the material M_WkFunctionDrawer provided as an example to see how nodes and material functions are related toghether.



Among the material functions used in WkfunctionDrawer this one is interesting because it can also be used as a standalone texture to draw a segment or a line based on 2 points.

MF_WkDrawLineBetween2Coords is just a repack of a function written by RynaB, from Epic, in the following thread: UE4 Forum - Drawing a line between 2 coordinates
It is quite useful and you can download it as is here:


  • WkFunctionDrawer_MF_WkDrawLineBetween2Coord


  • math_hall

In spite of that working on those functions was very instructive for me and I find my implementation quite flexible. 




Change log

     - V2.1 (18/11/2015):    UE 4.10
            - Moved the script folder from WkLibrary\WkFunctionDrawer to WkLibrary\WkMaterials\WkFunctionDrawer
            - Added several examples of useful periodic functions

     - V2.0 (18/10/2015):    UE 4.9
            - Created a function MF_WkFunctionDrawer that encapsulate MF_WkFunctionDrawerControls
              MF_WkFunctionDrawerDisplay in order to have only 1 node to copy and paste in the user functions
            - Removed some If nodes in the code for shorter compilation time           

     - V1.0 (10/09/2015):    UE 4.9
            - basic version