Assignment Goals

The primary goals of this assignment are:

  1. Extend the core Unreal Engine code.
  2. Create a new UE4 material node.
  3. Get experience with the strategy of finding and replicating an example, then changing it to suit your needs.

For this assignment, you'll be creating an new MaterialExpression node for the UE4 material editor. Material editor nodes are part of the "Engine" module, and adding a new one requires editing the code in that module.

You will create a native material editor node implementing the random tiling UV transformation described in a chapter of GPU Gems 2, and in slides from the Graphics Hardware Conference. As is typical of real-life instances when you want to implement an existing technique into an engine, these sources do have some snippets of shader code. You can use these, but will need to modify them a bit to make them work within UE4. You will also have to look to examples within UE4 for the material node plumbing necessary to get it into the engine.

Details

Test your project using the following two source textures

2-color tiling 3-color tiling
tile1.png (2 edge colors) tile2.png (3 edge colors)

Creating results that will look something like this:

2-color test material 3-color test material

Create a project

  1. Create a a Blank Blueprint project with no starter content called assn6.
    • Since you'll only be working with C++ code in the engine itself, you do not need a C++ project
    • As usual, put the project at the top level of your git repository

Create a new material node

  1. Find a reasonably uniquely named material node. Replicate its code with a new name.
    • Since the Engine module is widely used, recompiles for minor edits will take a while as it relinks all of the dependent shared libraries (5 minutes for a single cpp change on my laptop). You can usually recompile the Engine module in the running editor without having to quit and restart, which will at least reduce waiting for the engine startup time.
  2. Modify your node to implement the texture tiling method.
    • You should have one UV input pin, and integer parameters in the detail panel for the number of edge "colors" in X and Y.
    • Use one of the hash functions at the top of Random.ush to convert integer x/y edge position to a random edge color (rather than using a texture as described in the article).
    • Output the tiled UV to plug into a TextureSample node.
    • When debugging shader changes, set the r.ShaderDebugMode console variable to 1

Test your node

  1. Create a test material using tile1.png with 2 for both x and y edge "colors".
  2. Create a second test material using tile2.png, with 3 for x and y edge "colors".

Submission

For full credit, you must commit multiple times during your development.

Add an assn6.txt. Tell us what works and what doesn't, and anything else you think we should know for grading.

Include a screen shot of the material editor for each of your two test materials, with the new material node selected so we can see what is set in the detail panel. You can capture a screen shot of the full material editor window with the "EditorScreenShot" console command (By default, EditorScreenShot captures the main editor window to the Saved/Screenshots directory. Dock the material editor window with the main UE4 window, or use "EditorScreenShot Name=window-name" to capture an image of the material editor). Scale the coordinate input to your node so we can see the randomized tiling in the material editor preview window in those screen shots.

Push to your repository, and tag your final commit with an assn6 tag.