Saturday, October 24, 2015

Faux Photometric Stereo Part II Processing the Captured Images.

Processing the Raw Images

      I'm going to switch over to bullet points to make this part of the process easier to follow. This process can be done in Photoshop or GIMP (I use GIMP for the manual normal map generation only because I haven't used PS in so long that certain procedures don't work like they used to back in the CS2 days).
(Fig. 4 RAW image import and correction)
  1. Bulk import the RAW images into Photoshop for a couple of corrections (Fig 4). 
  2. Select the "White Balance dropper" from the upper tool bar and click a medium gray color.  Adjust exposure if necessary 
  3. Select the Lens correction tab (under the histogram, sixth from the left) and check "Enable Lens Profile Corrections".  If the lens used was a standard one, then all adjustments will be done automagically. This is an important step for a texture map that has features which run to the edge of the map. Lens correction will remove barrel distortion, which makes straight lines have a curve to them due to the multiple glass/plastic lenses that make up the final lens.
  4. If the subject was shot with a single light it is OK to synchronize all the RAW images and Save.
  5. If the subject was shot with different lights, it is probably better to adjust per RAW image.
  6. Copy all the images onto one canvas.
  7. Rotate Canvas, if  needed.
  8. Check images for alignment issues. If there aren't any alignment issues skip to step 8.
    • Hide all layers but one, then set that layer to 50% opacity and move it to the top of the stack. This is the alignment layer.
    • Unhide one of the hidden layers below the alignment layer and set it as the active layer. 
    • Look for misalignments, they will be pretty obvious.
    • Using the grid on the cutting mat, or text on the subject/color chart, Move the active later around using the arrow keys to push it into alignment.
    • If it becomes hard to tell if the layer is really in alignment with the top layer, turn the Alignment layer to 100% opacity and flick the viability off and on.
    • Do this for all layers.
    • Crop Canvas to what will eventually become the texture.

      (Fig. 5) Check alignment from image to image

Creating the Color map

  1. Place all non-specular images in a folder and place all specular images into a separate folder then hide that folder.
  2. Rename files to correlate with the light direction (Top, Bottom, Left, Right).
  3. Select all layers in the non-specular folder and set the layer style to "Lighten". (Fig. 6)  This filter only allows the lighter parts of the layer to transfer down, making it a powerful tool to eliminate most of the shadows from the final image.
  4. Duplicate all the layers and merge the duplicates into a single layer and rename it to "Color".
  5. Duplicate the "Color" layer and Desaturate (Image>Adjustments>Desaturate)
  6. Invert the colors of the duplicate (Image>Adjustments>Invert), then set the layer style to "Overlay". This step ensures nearly all the light information from our color map has been removed.
  7. Save out TARGA file as Paperbag_color. (You may have to change the Image mode to 8bit, Image>Mode>8bit).
    • This will create a very simple color map that will have some problems.  I am currently messing around with generating a more accurate map.
(Fig. 6) Color Map Creation.

     

Creating the Specular Map

  1. Hide the Color Folder and unhide the Specular Folder.
  2. Rename files in the Specular folder to correlate with the light direction.
  3. Select all layers in the non-specular folder and set the layer style to "Lighten".
  4. Duplicate all the layers and merge the duplicates into a single layer and rename it to "Spec".
  5. Desaturate the created layer and save out Spec map.
    • This will create a very simple specular map that will have some problems.  I am currently messing around with generating a more accurate map.


(Fig. 7) Specular Map Creation.


Creating the Normal Map

     I will be following Ryan Clark's  Normal Map Photography article and switching over to GIMP to complete the Normal Map generation.

Photoshop Prep:
  1. Right Click on a layer under the "Color" folder and select "Duplicate Layer". (Fig. 8)
  2. In the popup menu under "Document:" select "New" in the drop down menu.
  3. Name the file something that will be easy to sort such as "NORM_RIGHT" so that you know that this file is lit from the right and for the normal map process.
  4. In the new window desaturate the layer and save out as a TARGA file.
  5. Repeat steps 1-4 for the other 3 files.
(Fig. 8) Prepping the Normal Map Files.
GIMP:
  1. In Gimp select File>Open As Layers and select the Top and Left lit images. (Fig. 9)
  2. Change the image mode to "Grayscale" Image>Mode>Grayscale.
  3. Select Color>Components>Compose. This is where to define which layer will represent a color channel.
    • The Left lit image will be the Red Channel.
    • The Top lit image will be the Green Channel.
    • The Blue channel will be set to "Mask" with a value of "0".
    • Click "OK" and a new window will open with the layers as color channels.
  4. Select Color>Levels.
    • The Output Levels should be set to "127" on the black side, and "0" on the white side.
    • Click "OK".

      (Fig. 9) Creating the first part of the Normal Map.
  5. In Gimp select File>Open As Layers and select the Bottom and Right lit images. (Fig. 10)
  6. Change the image mode to "Grayscale" Image>Mode>Grayscale.
  7. Select Color>Components>Compose. This is where to define which layer will represent a color channel.
    • The Right lit image will be the Red Channel.
    • The Bottom lit image will be the Green Channel.
    • The Blue channel will be set to "Mask" with a value of "0".
    • Click "OK" and a new window will open with the layers as color channels.
  8. Select Color>Levels.
    • The Output Levels should be set to "128" on the black side, and "255" on the white side.
    • Click "OK".
    (Fig. 10) Creating the second part of the Normal Map.
  9. Copy the "Bottom+Right" result to a new layer in the "Top+Left". (Fig. 11)
  10. With the "Bottom+Right" at the top of the layer stack, set the layer style to "Overlay".
  11. Select Layer>New from Visible and hide the other layers.
  12. Go to the Channels tab and hide the Red And Green Channels.
  13. Also, make sure only the Blue Channel can be edited by clicking on the Red and Green Channels (if the channel is highlighted in blue then it cant be edited by clicking on them).
  14. Fill the layer with White.
    • White was already my foreground color so I just clicked Edit> Fill with Foreground Color.
  15. Unhide the red and Green Channels.
  16. Save the image, as it is now a complete normal map.
(Fig. 11) Finishing the Normal Map.

I will end Part II here as all the maps have been completed.  This is by no means the end of the amount of work that could be done to the images to improve how they will look in a real time engine, but those techniques are outside the scope of  this write up.  In the next section you will notice what could have been done to ensure the material looked beter, but hopefully these artifacts will give everyone a good idea of how to be more successful in their own adventures. See you soon!



No comments: