Header menu logo Mibo

ShaderLoader Module

Loads compiled MonoGame effect (.mgfx) files from embedded resources.

The Mibo.MonoGame.fsproj embeds four compiled shader variants: LitSprite.dx.mgfx, LitSprite.ogl.mgfx, LitSpriteNormalMap.dx.mgfx, LitSpriteNormalMap.ogl.mgfx.

Platform detection uses MonoGame.Framework.Utilities.PlatformInfo.MonoGamePlatform to pick the DirectX (.dx.mgfx) or OpenGL (.ogl.mgfx) variant.

Compiled shader bytes are cached; a new Effect is instantiated per call so each LightContext2D owns and disposes its own instance.

Functions and values

Function or value Description

loadEffect gd name

Full Usage: loadEffect gd name

Parameters:
    gd : GraphicsDevice - The graphics device to create the effect on.
    name : string - Base name of the effect (e.g. "LitSprite" or "LitSpriteNormalMap").

Returns: Effect voption A new Effect, or ValueNone if the resource is missing.

Loads a compiled MonoGame effect from an embedded .mgfx resource.

Each call returns a fresh Effect owned by the caller; cached bytes are reused.

gd : GraphicsDevice

The graphics device to create the effect on.

name : string

Base name of the effect (e.g. "LitSprite" or "LitSpriteNormalMap").

Returns: Effect voption

A new Effect, or ValueNone if the resource is missing.

Type something to start searching.