Your own look with shaders

A map can replace how the engine draws units and terrain with its own shader files. The editor's 3D view reloads a saved file within half a second, so you see every change as you type; the engine applies the map's shaders when a game starts and goes back to the defaults after.

The shaders are WESL, WGSL with imports, the language of the GPU in the browser and in W4 Omicron. If you have written GLSL or HLSL, it reads like them.

The Shaders module

Shaders (Ctrl 6) shows two slots, Units and Terrain. Each says what the map uses: the engine's default, or the map's file with its size and last change, or the file with a compile error and the message.

  • Make my own copies the engine's default shader to shaders/unit.wesl or shaders/terrain.wesl in the map and opens it in your editor. You start from the real thing, not a stub.
  • Open in editor opens the file again.
  • Back to the default (click twice) deletes the map's file.

A first change

Make your own unit shader. In the file, find where the final colour is written and tint it:

// ... the default's lighting ...
var color = base.rgb * light;
// Tint everything towards sepia.
let grey = dot(color, vec3<f32>(0.3, 0.59, 0.11));
color = mix(color, vec3<f32>(grey * 1.1, grey * 0.95, grey * 0.7), 0.6);
return vec4<f32>(color, base.a);

Save. The 3D view shows the sepia units at once, in every module, not only Shaders. The Activity panel logs a compile error if you make one, and the view keeps the last working shader until you fix it; a failing shader falls back to the default in the game too.

What the defaults do

  • w4_unit.wesl is the Warcraft III look for models: the texture, team colour on the parts the model marks for it, the sun's light and a shadow from the terrain's shadow map, the model's own transparency filters.
  • w4_terrain.wesl blends the ground tiles softly between neighbours, draws the cliff walls in stone with an outline, and takes the same light and shadows.
  • w4_light.wesl is what both import for the light: the sun's direction and colour from the map's settings (Morning, Noon, Evening in the Terrain module).

Keep the imports at the top of your copy; the engine binds the same textures and uniforms to your shader as to its own, so the inputs you see in the default are what you have.

Shipping it

The map's shaders/ folder is packed into the .a4m with everything else; a player needs nothing but the file. A map without its own shaders uses the engine's, so an engine update can improve the look of maps that did not touch it, while a map with its own keeps its look.

Not yet

An effects slot (particles and ribbons), vertex shaders for units, and a set of starter looks to pick from are planned.