Monday, November 23, 2015

Faux Photometric Stereo Part III: Bare Minimum Material Building with Unreal Engine 4

     Hello Everyone! Sorry for the delay. This section should be pretty short and fairly easy if you have any knowledge of Unreal Engine. Unreal Engine 4 (UE4) is being used to make/render the material for a few reasons: A) It is free.* (*for development) B) It is an incredibly powerful real-time engine that is very deep and feature rich, and mostly user friendly. C) A massive, highly talented community that is willing to help if you get stuck.

     If you do not have any experience in UE4, please go watch the very informative series provided by Epic Games on their Youtube channel. Most of these videos were made before version 4.7 and they maybe inconsistent with how things are done now. Don't get frustrated if something isn't working, Check the Answers Hub first, for a solution. I will be using Version 4.10 for this quick demo.

Material Building in UE4


Bringing Everything Into the Engine

     Now that all the maps have been generated, launch UE4 and start a new project.  I generally start with the default map and Starter Content for testing materials.  I've set up my viewing area with a Material Preview Mesh which is available in the Starter Content folder (Content Browser Tab>Starter Content Folder>Props Folder>SM_MatPreviewMesh_02) and just copied and adjusted one of the floor static meshes to be a wall.

(Fig. 1) Start a basic environment to test materials

  1. In the Content Browser Tab, create a new folder and name it appropriately. I chose PAPERBAG.
  2. Create a new material in the folder by right clicking and selecting "Material".
  3. Select "Import" from the top of the Content Browser tab and navigate to the proper files to import them into the folder.
  4. Double click the material to open the  Material Editing tab, then tare the tab off into its own window (Left Click>Drag).
  5. Select all of the texture maps and drag them into the Material editing tab.


    (Fig. 2) Import texture maps then drag them into the Material Editing tab.
  6. Connect the textures to their proper node buttons on the Output Node.


  7. (Fig. 3) Textures connected to their proper node buttons on the Output Node.
  8. Done. Apply to any and all surfaces and stare in wonder.


  9. (Fig. 4) WHEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE.

     This is pretty much as basic as the process can get.  I do want to point out that there is a TON of work that can go into making this material look better during the Photoshop stages.  The first and most obvious would be making the texture map tileable. UE4 really likes maps that are a power of two, the engine will be able to ensure the texture looks good in many different situations. Another big improvement would be adjusting the images used to create the normal maps. It is a relatively small detail that the average person may not be able to pick out but most video game artists will view it as a huge glaring error. Take a look at the specular and normal map, then the rendered material to see if you can spot the problem:


The paper bag used for the capture was uniformly flat where the ink touches the paper. But because there was such a high contrast between the black ink and the light brown paper, the ink in the rendered material looks embossed which has lead to exaggerated highlights on the ink and the surrounding edges.
   
     It is very important to remember: the more care used during the Photoshop phase of this process, the better the end result will be. Again, this is by no means a "cheat" to make PRB materials without having to use a Photometric stereo capture system.  Photometric Stereo, depending on the amount of lights and the quality of the equipment used, will always be able to produce better quality maps, quicker. But this is another way to produce some materials inside of a real-time engine while having a lot of control over tweaking the texture during the processing stages.  I have been messing around with different filter stacks in Photoshop to produce better results and will probably share this information at sometime in the future.

Some things to remember whenever texture maps are being generated by hand:


  • Make them a power of two (2x2, 4x4, 8x8,, 16x16, etc).
  • Make them tileable.
  • Remove gradient lighting to improve repeatability.
  • Even out contrast/brightness on flat surfaces when generating normal and specular maps.
     Thank you for taking the time to read this and if you enjoyed reading the process please let me know!