Help home · Beginner · Intermediate · Advanced authoring · Command reference · Samples
Shaders for Beginners
Explore the illustrated effect guide: 28 individual effects and eight material/image-quality studies, with playable samples, original models, screenshots and practical game uses.
A shader is a small program used by the graphics card to decide how something is drawn. A material shader controls the pixels on a model: whether it looks shiny, unlit, metallic, cartoon-like, or partly dissolved. A post-processing shader changes the camera's finished picture, producing effects such as bloom, grayscale, or a vignette.
You do not need to write shader code to use shaders in Blitz3D. The built-in library covers many common effects, and the Standard material provides modern lighting through normal BlitzBasic commands.
1. Which option should I use?
| You want to... | Use... |
|---|---|
| Improve a brush with metallic, rough, normal-mapped, or emissive surfaces | The built-in Standard material |
| Give selected models a stylised appearance | A built-in material shader |
| Change the whole camera image | A built-in post effect |
Common modern tasks
To project window patterns, coloured images or caustics through a light, see Light cookies and the playable interior sample.
| Task | Choose |
|---|---|
| Make bright objects glow | Enable HDRRendering and attach builtin:bloom. |
| Add contact depth | builtin:ssao, before fog and focus blur. |
| Create distance/height fog or focus blur | builtin:depth-fog or builtin:depth-of-field. |
| Outline objects | builtin:outline. |
| Animate plants | builtin:foliage. |
| Texture terrain without UV seams | builtin:triplanar. |
| Make water, glass, holograms, snow, or wet ground | Use the matching built-in surface alias. |
| Choose edge quality | FXAA for low cost, 4x MSAA for geometry edges, TAA for stable detail and motion. |
| Control HDR output | HDRRendering, ToneMapMode, and ToneMapExposure. |
2. Loading your first built-in shader
Built-in shaders have names beginning with builtin:. They are
packaged with Blitz3D, work in a standalone executable, and need no shader files
beside your program.
shader=LoadShader("builtin:toon") ShaderFloat shader,"Bands",4 EntityShader cube,shader
These three lines load the toon shader, set one of its named controls, and apply it to a model. That is enough to start. Parameter names are not case-sensitive, although copying the spelling from this guide makes code easier to read.
Built-in material shaders
| Name | What it does | Main controls |
|---|---|---|
builtin:unlit | Shows brush colour and texture without scene lighting. | Texture |
builtin:toon | Uses bands of light for a cartoon appearance. | Bands, ShadowColor, RimStrength, Texture |
builtin:rim-light | Adds a glow around edges facing away from the camera. | RimColor, RimPower, Strength, Texture |
builtin:dissolve | Removes a model gradually with a glowing edge. | Amount, EdgeWidth, EdgeColor, Texture, NoiseMap |
The modern material set adds foliage, triplanar,
parallax, hologram, wet-surface, snow,
water, glass, and force-field. See the
complete built-in catalogue for exact controls and costs.
EntityShader applies the appearance to every surface on one
model. Pass zero to restore its normal brush or classic appearance:
EntityShader robot,shader ; Later... EntityShader robot,0
Changing controls
Each control has a type. Use the matching command:
| Value | Command | Example |
|---|---|---|
| A decimal number | ShaderFloat | ShaderFloat shader,"Strength",.8 |
| A red, green, blue colour | ShaderColor | ShaderColor shader,"RimColor",40,140,255 |
| A Blitz texture | ShaderTexture | ShaderTexture shader,"Texture",brick |
A misspelled name or wrong setter is reported as a runtime error. If this happens, check the control's spelling and type in the table or sample.
3. Built-in camera effects
| Name | What it does | Main controls |
|---|---|---|
builtin:grayscale | Blends the image towards black and white. | Strength |
builtin:vignette | Darkens or colours the edges of the image. | Strength, Radius, Softness, Color |
builtin:bloom | Adds a soft glow around bright pixels. | Intensity, Threshold, Radius |
builtin:color-adjust | Adjusts exposure, contrast, saturation, and tint. | Exposure, Contrast, Saturation, Tint |
Depth fog, AO, focus blur, outlines, LUT grading, sharpening, lens treatment, motion blur, screen-space reflections, volumetric fog, and light shafts are also packaged aliases. Their catalogue entries state the required inputs and intended stage.
A camera effect is loaded in the same way, but attached to a camera:
effect=LoadShader("builtin:vignette") ShaderFloat effect,"Strength",.7 ShaderFloat effect,"Radius",.5 CameraEffect camera,effect
Material shaders go on entities or brushes; post effects go on cameras. 2D
drawing performed after RenderWorld is not changed by a camera
effect.
4. The built-in Standard material
The Standard material is the easiest way to give a brush modern, physically-based lighting. It is controlled directly through brush commands:
brush=CreateStandardBrush(220,140,60) BrushPBR brush,0,.35 PaintEntity sphere,brush
The first BrushPBR value is metallic, from 0 to 1. Use 0
for paint, plastic, stone, wood, or skin, and 1 for bare metal. The second is
roughness, also from 0 to 1. Low roughness gives sharp highlights; high
roughness gives broad, soft highlights.
You can also turn an ordinary brush into a Standard material. Standard property commands attach it automatically:
brush=CreateBrush(190,60,35) BrushStandard brush,True BrushPBR brush,0,.55
BrushStandard brush,False returns the brush to classic rendering.
Commands such as BrushColor, BrushAlpha,
PaintEntity, and PaintSurface continue to work normally.
Adding texture maps
| Command | Texture contents |
|---|---|
BrushBaseColorMap | Surface colour and optional transparency. |
BrushNormalMap | Small surface-direction details such as grooves and bumps. |
BrushMetallicRoughnessMap | glTF layout: roughness in green and metallic in blue. |
BrushOcclusionMap | Ambient occlusion in the red channel. |
BrushEmissiveMap | Areas which appear to emit light, multiplied by BrushEmissive. |
Each map command accepts an ordinary Blitz texture and optional animation frame. Pass texture zero to remove a map. Tangents needed by a normal map are generated automatically.
Transparency and two-sided surfaces
BrushAlphaMode selects opaque (0), hard cut-out or mask (1), or
soft alpha blending (2). Use BrushDoubleSided for thin leaves,
cloth, cards, and similar meshes; leave it off for normal closed objects.
Environment lighting and skyboxes
BrushEnvironmentMap adds ambient light and reflections from a
normal 2:1 equirectangular image. CreateSkyBox displays the same
kind of image behind the scene:
environment=LoadTexture("sunset.jpg",1+8+32) sky=CreateSkyBox(environment) SkyBoxIntensity sky,.8 BrushEnvironmentMap brush,environment,0,1.2
The sky and material lighting are independent. Imported glTF/GLB materials already use this same Standard material system.
Layered Standard materials
BrushClearcoat, BrushClearcoatNormalMap,
BrushTransmission, BrushVolume, BrushSheen,
BrushAnisotropy, and BrushIridescence add common glTF
material layers. The importer maps the matching KHR_materials_*
extensions automatically. Sample 15 compares every layer under one environment.
5. HDR and anti-aliasing
HDRRendering True ToneMapMode 2 ToneMapExposure 0 AntiAliasMode 3 ; TAA
HDR is opt-in, keeps emission above white for scene-linear effects, and applies one output transform. Existing programs remain LDR. TAA keeps per-target history; 4x MSAA instead resolves colour and depth before post effects. Switching modes is safe.
6. Adding shaders gradually
There is no global shader switch. Leave the world, particles, UI meshes, and old media alone, then try a shader on one character, water brush, or camera. Everything else continues through its configured Standard or classic rendering path.
7. Cleanup
When an entity, brush, or camera receives a shader, it retains the attached
instance. Calling FreeShader releases your script's handle but does
not break the attached effect:
shader=LoadShader("builtin:toon") EntityShader cube,shader FreeShader shader
Free handles you keep when they are no longer needed, just as you would free textures and brushes.
8. Where to go next
Open the shader sample gallery for complete working examples. The Shader group in the command reference has smaller examples for individual commands.
Continue with Using Shaders: Intermediate to learn brushes, multiple effects, parameters, copies, lifetime, asset loading, and deployment. When you want to write HLSL, use the Advanced Shader Authoring Guide.
Built-in shaders · Standard materials · Extended mode