Displacement Alpha Blending

Posted Dec 29, 2015
Last Updated Jul 26, 2017

This document explains alpha blending on Wall Worm Displacements. It covers some functionality released in Wall Worm 2.75.

Alpha Blending

Alpha Blending on displacements is the way by which you blend two materials on a displacement. This blending is stored in Max with the Vertex Alpha Channel (Map Channel -2) on the displacements.  The way you generally work with this is the Vertex Paint Modifier, which is what Wall Worm applies to your displacements when you press the Paint Alpha button in Anvil or in a displacement's modify tab.

This blending information will export into the VMF when exported into Source. It controls how much of Material 1 or Material 2 in a WorldVertexTransition appears at any point on the surface of a displacement. The WorldVertexTransition material is derived from a Blend Material inside 3ds Max. Unfortunately, there are limitations in 3ds Max that do not allow a Blend Material to use Vertex Alpha for blending.

Blend Materials

Although the information about a WorldVertexTransition shader is stored in a Blend Material (and it's underlying Standard Materials), the display of a blend material in the viewport is currently controlled by a DirectX Shader. As of Wall Worm 2.75, there are three available blending shaders you can use.

Wall Worm Direct X Shaders for Displacement Materials

You can set which shader WW uses when creating a display shader from blend materials.  Which shader is used is controlled by the Displacement Material setting in the Materials group of the global settings dialog. When changing to a new shader, it will only affect new materials. Existing materials will continue to use the DirectX Shader they currently have.

It is hoped that a future version of Max will support viewport display of Blend Materials using Vertex Alpha, in which case these shaders will have less need.

The current shaders are described below:

Native DX Shaders

This group is called native because they are shaders that come packaged with 3ds Max. Which version your system will use is determined by the version of Max you are using and the display driver you are using. Unless you have stripped files from 3ds Max, one of these files will be used:

  • #maxRoot/maps/blend_dxsas.fx (older versions of Max or Nitrous not used)
  • #maxRoot/maps/fx/StandardFX11.fx (new versions of Max with Nitrous)

The native shaders are probably the best case unless you need to use blendmodulate in the Black Mesa shader below.

blend_dxsas11_nitrous

This shader has the same functionality of the native blend_dxsas.fx file for older versions of Max, except it works in 3ds Max 2014+. This is packaged in Wall Worm.

Black Mesa

The Black Mesa shader is a new shader currently being developed for the Black Mesa production. This shader is still under development, but offers viewport display of $blendmodulatetexture with the alpha blending, as well as some other useful settings. It is not finished and has some quirks with lighting based on the angle of view on the scene. This shader is now packaged in Wall Worm. Requires Max 2015+ in Nitrous.

Creating a Display Shader from an Existing Blend Material

You can create a display shader from any object with a blend material in the scene. See here for converting a Composite Material to a 4way Blend shader.

  1. Select an object with a Blend Material
  2. Click Wall Worm > Wall Worm Level Design > Anvil
  3. Open the Miscellaneous tab
  4. Click Convert Blend to DX Blend

Now a new DirectX shader is applied to the object where the original material is that material's Render Material.

Exporting Alpha Blending

Over the years of developing Wall Worm, there were changes in Source (sometimes temporary glitches in mods I was testing in) that inadvertantly switched the order of materials used in Hammer. This influenced my development of the shaders and created some confusion in how I was developing the functions in Wall Worm.

Some of the convoluted settings remain. But there are now settings to allow you to control how the blending works.

VMF Exporter Setting

The latest versions of the WW VMF exporter now have a checkbox in the Export group labeled Default Alpha. Toggling this will invert all alphas in the exported VMF. This is a quick way to swap all the alphas in an exported file if all the alphas are inverted identically.

DirectX Shader tools

If you open a DirectX Shader in Slate that Wall Worm created from  blend, you'll see that there is a rollout at the bottom of the material editor named Wall Worm Functions. These buttons will update either the current DirectX Shader or its Render Material (the blend material).

  • Swap Textures: This function swaps the textures in the Display Shader (the DX Shader).
  • Update Render Material: This function updated the order of the materials in the Blend Material to match that of the display material.
  • Update From Render Material: This function updates the textures in the display material from the blend material.
  • Update Name from Render Material: This function updates the display texture name to match the render material's name.
  • Select Objects Using: Selects all the objects in the scene that use the current display material.

Troubleshooting

Display Textures are Too Dark or Too Bright

You may sometimes need to manually set the gamma values on the bitmaps used in the directx shader. To do this, open the DirectX Shader in the material editor and click on the button for the texture. Now you can change the gamma value to what is needed. Often, if your bitmap is too dark in the viewport, manually changing it's gamma to 1.0 will solve this problem. If it's too bright and the gamma is set to manual 1.0, try changing it to Auto or manually setting the gamma to 2.2 (or the gamma appropriate for the bitmap). 

You may need to do this for multiple textures. Note that bitmaps for normal maps should almost always use gamma 1.0.

In the future, WW will try to automate this.

Displacements Display Solid Black (or White)

The DirectX Shaders are dependent on both being compatible with the current display driver and by the object enabling Vertex Colors. If your display driver doesn't support the current display shader, you may have to try another shader.

Setting the Object to Display Vertex Colors

Sometimes some objects won't display properly with the default settings with which WW creates them. You can try changing the object's display properties:

  1. Select the object
  2. Right-Click the object
  3. Toggle the Vertex Channel Display checkbox and/or change the display channel to Vertex Alpah
  4. Click OK

If this does not help you, you may need to switch to one of the other DX shaders in WW.

DX Display Shaders

Information on the DX shaders used by Wall Worm.

  1. Displacement Alpha Blending
  2. Using 4Way Blends

Newsletter Subscription