Header menu logo Mibo

Shaders

Shaders are GPU programs that transform vertices and determine pixel colors. They run on the graphics card in parallel, making them efficient for complex visual effects.

What They Are

Why Use Them

Use shaders when you need visual effects beyond what built-in rendering provides:

When to Write Them

You don't need custom shaders to start. Mibo's built-in renderers work without them:

Write shaders when: - You have specific visual requirements - You need performance optimizations for your target hardware - You're building advanced rendering features

Loading Shaders

Shaders are .fx HLSL files compiled to .xnb via the MonoGame Content Pipeline.

// Load an effect from your Content directory
let myEffect = ctx.Content.Load<Effect>("shaders/MyEffect")

Asset paths are relative to your Content directory without extension.

Setting Parameters

Set shader parameters before drawing:

effect.Parameters["World"].SetValue(worldMatrix)
effect.Parameters["Color"].SetValue(color)

// Or use Mibo's SafeSetParam (ignores missing parameters)
effect.SafeSetParam("World", worldMatrix)

Where to Learn More

Shader binding contracts (what parameters each shader type expects) are documented in the rendering sections:

See also: MonoGame Effects Documentation

val myEffect: obj

Type something to start searching.