top of page
Dota 2 Character Item Mask Shader

Unity Shaderlab/HLSL/CG

Overview

This is the practice of writing a Dota 2 character item mask shader from scratch. It is an art-directable shader that combines the necessary light source with all kinds of character masks: Color mask, normal map, metalness mask, self-illumination mask, specular mask, rim light mask, base tint mask, specular exponent mask, and diffuse warp mask. It calculates the blending options of these masks, which also allows artists to pick the color, intensity, and exponent of each different body part.

Dota2 Character Item Mask Shader.jpg

Model Source: Dota 2 Workshop

Packing Various Texture Maps & Masks

Basecolor + Transparent Map 

​R:  Basecolor.r

G: Basecolor.g

B: Basecolor.b

A: Translucency Mask

It is a challenge to arrange more than 60+ texture maps at once. So I did make some channel packing according to their usage.

Specular + Rim + Tint + Specular Exponent 

​R:  Specular.r

G: Rim Light.g

B: Tint by Base.b

A: Specular Exponent

FresnelWarp + Rim +WarpSpec

​R:  FresnelWarp

G: FresnelRim

B: FresnelWarpSpec

Properties Panel

Texture Sampling part + Light Setting part

The Texture sampling part is straight forward as seen below. The Light Setting part is more complicated with Direct/Indirect Light, Rim Light, and Emissive Light, which are art-directable for artists to adjust according to different needs.

bandicam 2022-05-21 17-01-03-512.jpg
bandicam 2022-05-21 17-06-35-980.jpg
bandicam 2022-05-21 17-06-46-297.jpg

       Part 1: Texture Sampling                              Part 2: Lighting Adjustments

Lighting & Mask Blending

Before getting started, some preparation work has to be made to ensure how to blend between these masks to combine the specular and diffuse light together. Here I made a flowchart of how I am going to add these lights.

flowchart.png
bandicam 2022-05-21 17-44-19-889.jpg
Fragment shader based on the flowchart above

Getting Texture sampling based on the channel packing.

bandicam 2022-05-21 17-44-40-042.jpg

Getting Environment & Direct Diffuse and Environment & Direct Specular with sampling masks & texture

Art-directable Light Setting adjustments

While the demo videos below showcases how these setting could affect the model all at once, the setting could be adjusted separately on each material instance: head, arms, body, and weapon.

bottom of page