Creating PBR materials

From Valve Developer Community
Jump to: navigation, search
English (en)Translate (Translate)
A roadmap with the materials necessary for PBR materials

Physically Based Rendering is an excellent shading technique that gives modders the ability to create amazing photorealistic maps. However, the creation process for PBR materials is much different from that of standard Source Source materials, and many modders new to the PBR workflow may not know how to create them. This article will review the process of creating a PBR material.

Overview

A PBR material consists of 3 main files:

  • A Diffuse (base) texture
  • A Normal map (optionally with a Heightmap embedded in the Alpha channel
  • A MRAO map, containing information on the Metalness and Roughness data as well as Ambient Occlusion

While the Diffuse and Normal map textures may already be part of the standard Source texture workflow, the MRAO map may present some difficulty to create, as standard image editing programs do not have ways to create the textures needed to make an MRAO texture. Modeling programs, such as Blender Blender, and image-to-texture programs, such as Materialize Materialize can create such materials.

Creating an MRAO texture

Note.pngNote:If the program you are using utilizes "smoothness" or "glossiness" maps, make sure to invert the colors of the smoothness/glossiness map before proceeding

There are a couple of methods used to port PBR textures to an MRAO texture. Here are two methods known to work for Strata Source Strata Source based games and also with Thexa4's PBR shader.

Confirm:Do these methods work for other PBR-supported games?

GIMP

First, create a new image with the same resolution as your PBR maps. Next, open your PBR maps with the "Open as Layers..." button. This will open your PBR maps as layers to the current image, and not as separate image files.

Note.pngNote:
Click to enlarge
The images you import must be grayscale. Even if they are visibly grayscale, GIMP may still read them as RGB images. If you are unsure if your images are using the grayscale format, navigate to Image→Mode and make sure that the Grayscale option is checked.

Next, navigate to Colors→Components→Compose and set the Red, Green, and Blue channels to the Metalness, Roughness, and AO layers respectively. Once you are done, export the image to a PNG or TGA file, convert it to a VTF, and then place it in the same folder as your diffuse and normalmap textures.

Next, create a blank VMT file. Copy-Paste the following text:

"PBR"

{ $basetexture "<insert path to diffuse texture>" $bumpmap "<insert path to normal map>" $mraotexture "<insert path to MRAO map>"

$envmap "env_cubemap" $normalmapalphaenvmapmask 1

}

Change the parameters to your specified filepaths, and you are done!

PBR-2-Source

Main article:  PBR-2-Source

Open the program and select "PBR(<desired use>)" in the dropdown on the right. Open each texture in their respective box on the left, select which reflections you want and click "Export".

Icon-Important.pngImportant:You must know what normal map style your material creation program used and set the "Flip Normal Y" box appropriately. If the program you use uses the 3DS Max style, uncheck the box. Otherwise, keep it checked.

Substance Painter

If you have made your textures in Substance Painter, you can export an MRAO texture using a custom Output Template.

Create a new template by pressing the '+' next to Presets in the 'Output Presets' tab of the 'Export Textures' window and create a new 'R+G+B' output map.

Drag the Metallic input map to the R slot, the Roughness input map to the G slot, and the Ambient Occlusion Mesh Map to the B slot. When exported, this will automatically create an MRAO map.

While in this window, you may also add 2 more Output maps, one 'RGB' map for 'Normal DirectX' and one 'RGB+A' map for 'Base Color' and 'Opacity'. This way, you can export all the basic maps you'll need to make a PBR texture in one export window.

SubstancePBRExport.png


Embedding the Heightmap

Confirm:What other games support heightmaps?

Strata Source Strata Source games and mods with Thexa4's PBR shader support embedding a Height map into the alpha channel of the Normal map, which is used for Parallax mapping, giving more depth to the material without the need for unnecessary brushwork or complicated models. This can be done through GIMP very easily.
First, open both your Normal and Height maps as separate images. Next, click once on the height map and copy (Ctrl+c) the image. Next, go to your Normal map, find the layers box, and right-click on the active layer. Click "Add layer mask", then click OK (the type is not important). Finally, with the layer mask selected, paste (Ctrl+v) your Height map. Your Normal map should now appear transparent, this is intended. Export your image as a PNG (so the transparency persists) and convert it into a VTF. Next, add the following to your VMT file:

Strata Source/Thexa4 games

//Parallax mapping $parallax "1" $parallaxcenter "0.5" //controls the height of the highest point on your heightmap. Higher values = Closer to the applied face. Make sure this is adjusted so the highest point is flush with the floor/wall! $parallaxdepth "0.10" //controls the intensity of the heightmap. Higher values = more depth

Black Mesa

//Parallax mapping "$pomscale" "0.07" //controls scale of parallax mapping "$pomminsamples" "0" //controls min depth of parallax mapping. "$pommaxsamples" "300" //controls max depth of parallax mapping.

For full details on these parameters, see this page

Adjusting the parameters

You can adjust the parameters to your liking to get the effect you want. Remember, if you emphasize the effect too much, it can look ugly.

If your game runs on Strata, you will be adjusting two main parameters. The first is $parallaxdepth, which controls the depth of the lowest point of the material, or the strength of the Heightmap. This parameter does accept precision up to the hundredths place, on a scale of 0 (no depth) to 1 (maximum depth) so you can adjust this to the precision of your liking. This parameter will do most of the work of how your material will appear.

The second and most important parameter is $parallaxcenter, which controls the depth of the highest point of the material. This parameter also accepts precision up to the hundredths place as well, on a scale of 0 (closest to face) to 1 (farthest away from face). This parameter needs to be adjusted until the highest point of your material is "touching" the face, otherwise it will appear to extend past the neighboring faces very unrealistically.

Examples
No Parallax

Properly adjusted parallax

Improper $parallaxcenter

Improper $parallaxdepth
Todo: BMS

Conclusion

If you followed all these steps correctly, parallax mapping should now be enabled on your material. Don't be afraid to experiment, and remember that if your material doesn't quite work with parallax mapping, you can always turn it off.