RDG PSD2Mat – a Pipeline Tool

Abstract

RDG PSD2Mat is a production proven connection between Adobe PhotoShop® and Autodesk 3D Studio MAX®.
This maxscript converts layered PSD Files into a Scanline or VRay, Brazil or Mental Ray Material. Named layers are converted to bitmap files and assigned to their respective material slots.

Download

You can download the current version 099j (2007-04-13) of RDG PSD2Mat here.
See Appendix V for a changes.

Alternative Download Sites

RDG PSD2Mat is and will be free of charge for both private and commercial users.
To support the development you can make a donate of 5,00 € via paypal:

*** NOTE: Be sure to remove all previous versions before installing an updated version of RDG PSD2Mat. If you are unsure consult Appendix III vor file locations.

*** STATS: 2007-03-29 to 2007-04-13: 5,566 visits, 897 downloads, 1 donation.
*** STATS: 2007-03-29 to 2008-04-01: 12,427 unique views, 1,858 installer downloads, 2 donations
*** Articles and Referrers

An short introduction to materials

RDG PSD2Mat allows you to use the sophisticated layer management of Adobe Photoshop to layout your materials in 3dsmax and finetune the details.

A complex material consists of many 'layers' called maps that define the relationship of different material properties such as diffuse color, glossiness and roughness. Each map is usally a bitmap or procedural texturemap that describes these attributes using color information.

Depending on the UV-Projection we use each pixel of the bitmap points to a specific 'point' on the surface of the object. In some special cases the pixel refers to a 'point' in 3D space like inside the volume of the objects, which is beyond the scope of this article.

While some attributes use bitmaps of various bitdepths to describe the color of the object, other maps are black&white bitmaps that define a ratio using 256 grayscale values. A value of '0/black' usually says "this attribute has no affect at this point" and a value of '255/white' is synonymic to "this attribute has full effect at this point". The values inbetween are interpolated accordingly. Some applications (like ZBrush) interpret the colors to define values from -1 (full negative effect) to +1(full positiv effect).

*** Note: It is essential that we are familiar with the maptype we are using and how this map interprets the color.

From Photoshop Layers to 3D Studio Maps

The layer tools of Photoshop are a great help if it comes to defining and refining materials to become 'realistic'. But converting a layered PSD File into a 3D Studio Material tends to be a tedious and error-prone task.

We could use the complete PSD as a bitmap in all available maps slots. But this results in a huge memory footprint especially if you are using many PSD Files on objects in numbers.

This is where RDG PSD2Mat comes into play: It maps named Photoshop Layers to the map slots of a 3D Studio Material. Currently Standard Scanline, VRay-Advanced Materials, Brazil r/s v1 (Default), Brazil r/s v2 (Default) and Mental Ray Fast SSS Materials are supported by the default installation..

*** Note: As MentalRay on-the-fly converts Standard Materials it is possible to use RDG PSD2Mat in a MR pipeline. To take advantage of the native MentalRay Material with all its expections and special maps it would require a lot more knowledge than I can provide at this point. I don't have a native MR pipeline.

The tool takes care of converting the layers into bitmaps and assigning them to their map slots. It provides a rudimentarily versoning system and can be lokalised or configured using textfiles.

Installation

*** NOTE: Be sure to remove all previous versions before installing an updated version of RDG PSD2Mat. If you are unsure consult Appendix III vor file locations.

After downloading you need to install the tool:
Execute the automatic installer and point it to your 3D Studio MAX root directory, it should copy all the files.

*** Note: The installer doesn't take Autodesk's new sympathy to standard Windows directory structures into account. It still uses #maxroot/scripts as the center of the world. See Appendix II for a explanation of the used scripts and how they interact. You can manually deploy the tool to fit your environment.

Now start – or restart – 3D Studio MAX.
The tool is designed as a macroscript and can be assigned to a toolbar, quadmenu, keyboard shortcut and/or menu. Just open the Customize... Dialog by RMB on a toolbar or choose Customize -> Customize User Interface... to open the dialog. Choose the type of assignment, enter the "rdg::preset" category and find the script named "psd2mat[RDGrmx]". If you want to add it to toolbar drag and drop the script to it. Consult the 3D Studio MAX User Reference for additional information.

 

The Menus

RDG PSD2Mat should now be ready to convert your Photoshop files into materials.

interface

The left one is the interface for Standard materials, to the right we see the Vray-version.

Settings Menu
The Settings Menu covers the various options for this tool and should be openend first to ensure everything is setup the way you want.

Renderer
The submenu Renderer switches between the supported render engines "MAX Scanline" "VRay Advanced", "Brazil r/s v1 (Default)", "Brazil r/s v2 (Default)", "MR Fast SSS". The user interface will be redrawn on change and all settings will be lost! If the chosen renderer or materialtype is not installed the tool switches to MAX Scanline.

The tool is set to scanline by default. The selected renderer is saved in an ini file and the tool will always start with the last selected renderer/material type.

The "autoenable" option is no longer availiable (version 099i - 2007-04-12).

File Type
The File Type submenu sets the file type that will be used to save the extracted layers. RDG PSD2Mat ships with a preconfigured set of types – Jpeg, PNG, TIF, Targa and Bitmap. We can change the availiable file types by editing a textfile. This is explained in Appendix II.

Backup
The Backup option enables the versioning function of RDG PSD2Mat. For each PSD you process that is processed by the tool a subdirectory will be created that holds older version of the extracted bitmaps.
This subdirectory is called "backup" and hold numbered subdirectoried containing the previous map files.

*** TIP: If you go through many revisions of your file it is recomended to enable this option. If the material is cleared you can zipt the backup directory or delete the backup files to free disk space.

Bonus Menu
The Bonus Menu offers direct links to a collection of Photoshop scripts that help us in the process of creating layered files to use with RDG PSD2Mat. Photoshop will be started, if it isn't running already, and the choosen script is executed:

psd2mat - Template CS2
This CS2 script offers an interface to choose the renderer and the size of the bitmap. It then creates a new file with all named layers the chosen material supports.

psd2mat - Template Standard CS1
psd2mat - Template VRay CS1
psd2mat - Template VRay CS1
psd2mat - Template Brazil r/s 1 (Default) CS1
psd2mat - Template Brazil r/s 2 (Default) CS1

psd2mat - Template MR Fast SSS CS1

These scripts don't offer an interface and can be run under Photoshop CS1. If there is an open file it can add named layers to the existing file. If you want a blank file you need to create one first.

All scripts can be configured to reflect your pipeline regarding naming convetions or available layers. Please consult Appendix IV for details.

*** TIP: For even more comfort create Shortcuts to the jsx files in #scripts\rdg-preset\psd2mat\Bonus\ in your Photoshop scripts directory (usually in %programs%\Adobe\Adobe Photoshop CS2\Presets\Scripts). After doing this you can start the script(s) directly in Photoshop File-> Scripts -> [script].

Help Menu
The Help menu opens this help and tells you something about the makers of this tool.

The Main User Interface

The Main User Interface is divided in three sections that reflect the workflow:

The File
openPSD opens a File Dialog that lets you choose the PSD file you want to convert to a material.

*** NOTE: If it is the first time you are using the tool, a notice pops up informing you that you need to define your default imaging application. This is usually Adobe Photoshop. Just navigate to the directory Photoshop is installed, select 'Photoshop.exe' and confirm.

After the PSD File to processed has bee selected, the tool parses the file for available layers and tries to relate them to material maps.

The Maps
The Tool tries to match layer names to material slots. If you are not satisfied with this proposal you can fine tune the mapping by choosing a available layer from one of the dropdown menus and assign it manually to the corresponding map slot. Only maps slots that have a checked checkbox will be processed later.

This allows you to reuse the bumpmap in a glossiness slot for example.

The tool make a simple string comparison to find a suitable layer. This is the default mapping:

Standart Material VRay Material
Material Slot Trigger Material Slot Trigger
Ambient Color amb Diffuse diff
Diffuse Color diff Reflect refl
Specular Color specmap HGlossiness hgloss
Specular Level speclevel RGlossiness rgloss
Glossiness gloss Fresnel IOR fresnel
Self-Illumination self Refract refr
Opacity opac Glossiness glossy
Filter Color filter IOR ior
Bump bump Translucent trans
Reflection refl Bump bump
Refraction refr Displace displ
Displacement displ Opacity opac
    Environment env


Brazil r/s v1 (Default) Brazil r/s v2 (Default)
Material Slot Trigger Material Slot Trigger
Color (Cs)
(Cs) Color (Cs)
(Cs)
Opacity (Os) (Os) Opacity (Os) (Os)
Extra Light extra light Extra Light extra light
Diffusion Diff Diffusion Diff
Bump Bump Bump Bump
Displacement displ Displacement displ
Environment environ Environment environ
Ambient amb Ambient amb
Luminosity Lumin Luminosity Lumin
Ka Ka Ka Ka
Kd Kd Kd Kd
Kl Kl Kl Kl
Reflect Reflect Reflectivity Reflectivity
Kr Kr Reflection Tint Reflection Tint
IOR IOR Kr Kr
Highlight Color Highlight IOR IOR
Spec Level Spec Level Highlight Color Highlight
Spec Gloss Spec Gloss Spec Level Spec Level
Soften Soften Spec Gloss Spec Gloss
Gain Gain Soften Soften
    Gain Gain

MR Fast SSS  
Material Slot Trigger Material Slot Trigger
Bump Bump    
Ambient Ambient    
Overall Diffuse Color Overall Diffuse Color    
Unscattered Diffuse Color Unscattered Diffuse Color    
Unscattered Diffuse Weight Unscattered Diffuse Weight    
Front Surface Scatter Front Surface Scatter    
Color Front Surface Color Front Surface    
Scatter Weight Front Scatter Weight Front    
Surface Scatter Radius Surface Scatter Radius    
Back Surface Scatter Color Back Surface Scatter Color    
Back Surface Scatter Weight Back Surface Scatter Weight    
Back Surface Scatter Radius Back Surface Scatter Radius    
Back Surface Scatter Depth Back Surface Scatter Depth    
Specular Color Specular Color    
Shininess Shininess    
Scale Conversion Scale Conversion    
Falloff Falloff    

*** TIP: you can change the layer names to maps slots mapping by editing the mapping files as described in Appendix I.

After you are satisfied with the assignments you go to the third and last step.

The Actions
By pressing "create Material" the tool starts extracting the chosen layers to seperate bitmaps and filling them into the appropriate map slots. The new material is placed in the active slot of the material editor overwritting the current material.

"open File in PS" opens the current PSD-file in Photoshop.

Under the Hood

The tool creates a new subdirectory at the location of your PSD file. This directory is called [filename]_files. It contains all currently used images files. The files are named [filename]_[mapslot].[ext]

If the backup option is enabled an backup directory is created the holds previous versions of your map files.

Conclusion

RDG PSD2Mat should be seen as what it is: a pipeline tool. Therefore the benefits from using it may vary.

It cannot automatically adapt to your personal pipeline. The process on how it does what it does was developed step by step in cooperation with Anselm v. Seherr-Thoß (Psychosilence) and tested in real world environments. We tried to make it as open and extendible as possible whitout loosing the track of its genuine purpose: Converting Photoshop files to materials.

We started developing this tool mid-october 2006. Today I would solve a lot stuff different, but everything has to find an end. We spent hours fixing bugs and flaws, but could't get hold every single one. Use it with care.

I encourage you to spend some time to understand its internal workings . This will enable you to use it in the most efficient way and to apat it to your personal pipeline.

Last but not least we'd like to thank Keith Boshoff (Wahooney) whose PSD2Material was the cornerstone for developing this tool.

2007-03-29 Georg Dümlein

I'd like to thank Richard Annema (Splutterfish Director of Client Relations) for the big support while implementing the brazil port.

2007-04-13 Georg Dümlein

Appendix I - The Layer-Maps-Mapping Files

The mapping from layer names to material slot is done with a string comparesion: The tool analyses the PSD file's layernames and tries to match them to material slots. These 'trigger' - short parts of the map names are defined in text files.

#scripts\rdg-preset\psd2mat contains the default mapping schemes:
rdg_psd2mat_scanline.ms and rdg_psd2mat_vray.ms, ...

They are named this way: rdg_psd2mat_[preset_identifier].ms

These are maxscripts files and you can edit them inside 3D Studio Max or in your favourite texteditor.

struct theRenderer (

theName = [string name_of_renderer],
theMaps = #([string name_of_map], ...),
theMapNames = #([string display_name_of_map], ...),
theTests = #([string trigger_for_map], ...),
theMatFunc = [string maxscript_class_of_material]

)
rdg_renderOptions = theRenderer()

Each file defines a struct that is loaded and executed on change of the user interface.

theName is the name displayed in Settings->Renderer
theMaps is an array containing all supported maps of the current material. You can get them by executing:

showproperties (standard()) -- replace standard() by the material constructor of your renderer.

theMapNames is an array containing the display names of the maps. Change this strings to localise the user interface.
theTests array holds the trigger strings for the maps.
theMatFunc string is the class of the material of your renderer

Each map has to be defined in all three arrays and all three arrays need to be of the same lenght!

If your pipeline supports just diffuse and bumpmaps, just delete the entries for all the other maps in the file. The interface will now only show the entries for diffuse and bumpmaps.

***NOTE: the tool doesn't scan the directory for available renderer_definitions, though this would be possible.

To add a custom renderer/material you will have to add it to the validRenderer array in rdgPSD2Mat-src.ms.
An entry has two subkeys:

#( [string display_name_of_renderer], [string preset_identifier])

The display_name_of_renderer is the string displayed in "Settings -> Renderer".
The preset_identifier is the last part of the preset file name to be loaded.

Appendix II - The File Type File

The available filetypes are defined in a textfile. Again you can edit this file in 3D Studio MAX or in your favorite texteditor:

#scripts\rdg-preset\psd2mat\rdg_psd2mat_filetypes.ms

There should be only one line in the file:

rdgPSD2MATfunctions.validFileTypes = #(#([string display_ext], .[string extesion]))

For example: #("Bitmap", ".bmp") defines a filetype called "Bitmap" and saves it with the extension ".bmp".

You can add as many files types as you want. Most of the time you might want to restrict the availiable files type to one or three used in your pipeline.

*** NOTE: You must define at least one file type!

Appendix III - The scripts that make the tool

The tool was origanlly developed for MAX8 and doesn't respect the new directory structures of MAX9.
If you need to conform to these new structures you will have to deploy the tool manually.

This paragraph explains the directory structure and what scripts are used to form the tool:

rdg__preset-PSD2Mat.mcr calls rdgPSD2Mat-src.ms. If you move the source script you need to adjust the path in the macroscript. Also check the paths inside the source script as they are mostly hardcoded.

rolloutCreatorRDG.ms is used by many of my scripts. Do not remove it or others may break.

Appendix IV - The Photoshopscripts

The Photoshop scripts are javascripts written in Adobes Extendscript Language.

Currently they are not synced to the definitions of the tool. If you change/localise the tool you will also need to change the values insde these scripts or the tool will not recgonise the named layers.

Appendix V - The Changes