Header menu logo Mibo

Draw3D Module

Pipe-friendly drawing DSL for 3D rendering. Each function takes a RenderBuffer3D as its last argument, adds the corresponding command, and returns the buffer for chaining.

Commands are built via Command3D and added to the buffer.

Usage:

 buffer
 |> Draw3D.beginCamera worldCamera
 |> Draw3D.drawModel model transform
 |> Draw3D.addPointLight { Position = pos; Color = Color.White; Intensity = 1f; Radius = 10f; CastsShadows = false; ShadowBias = ValueNone }
 |> Draw3D.endCamera
 |> Draw3D.drop
union case ValueOption.ValueNone: ValueOption<'T>

Functions and values

Function or value Description

addDirectionalLight light buffer

Full Usage: addDirectionalLight light buffer

Parameters:
Returns: RenderBuffer3D
Modifiers: inline

Adds a directional light to the scene.

light : DirectionalLight3D
buffer : RenderBuffer3D
Returns: RenderBuffer3D

addPointLight light buffer

Full Usage: addPointLight light buffer

Parameters:
Returns: RenderBuffer3D
Modifiers: inline

Adds a point light to the scene.

light : PointLight3D
buffer : RenderBuffer3D
Returns: RenderBuffer3D

addSpotLight light buffer

Full Usage: addSpotLight light buffer

Parameters:
Returns: RenderBuffer3D
Modifiers: inline

Adds a spot light to the scene.

light : SpotLight3D
buffer : RenderBuffer3D
Returns: RenderBuffer3D

beginCamera camera buffer

Full Usage: beginCamera camera buffer

Parameters:
Returns: RenderBuffer3D
Modifiers: inline

Begins a 3D camera transform.

camera : Camera3D
buffer : RenderBuffer3D
Returns: RenderBuffer3D

beginCameraWith config buffer

Full Usage: beginCameraWith config buffer

Parameters:
Returns: RenderBuffer3D
Modifiers: inline

Begins a 3D camera with explicit rendering config (viewport, clear, post-process).

config : Camera3DConfig
buffer : RenderBuffer3D
Returns: RenderBuffer3D

beginEffect shader buffer

Full Usage: beginEffect shader buffer

Parameters:
Returns: RenderBuffer3D
Modifiers: inline

Opens a per-group shading scope: draws between this and Draw3D.endEffect are shaded by shader instead of the default PBR shader. The shader inherits the gathered scene data (camera matrices, lights, material, bones, time) — not the PBR shader itself: it need only declare the uniform subset it consumes, and absent uniforms are skipped. This lets a toon/cel/wireframe shader reuse the scene's camera + lighting without re-implementing the gather. The scope closes at Draw3D.endEffect or automatically at the next Draw3D.endCamera (scopes do not persist across cameras).

Shadows + lights + animation are inherited by declaration. The scene gather (camera, lights, the shadow pass output, material, bones, and the frame's elapsed time) is uploaded to the user shader by name via SceneUpload: a shader that declares the matching uniforms (e.g. dirLightDir, boneMatrices, shadowViewProjs, time) inherits and samples them; one that declares none of them is unaffected. So a toon/water scope can opt into shadows, skinned animation, and a shader animation clock simply by declaring those uniforms.

Draw3D.drawMeshInstanced inside a scope is shaded by the user shader when it declares in mat4 instanceTransform; (the instancing opt-in); a shader that doesn't declare it falls back to the PBR instanced path. Skinned + instanced draws are not supported. See docs/graphics3d/instancing.md.

shader : Shader
buffer : RenderBuffer3D
Returns: RenderBuffer3D

disableShadows buffer

Full Usage: disableShadows buffer

Parameters:
Returns: RenderBuffer3D
Modifiers: inline

Disables shadow casting for subsequent geometry until re-enabled.

buffer : RenderBuffer3D
Returns: RenderBuffer3D

drawBillboard texture position size color buffer

Full Usage: drawBillboard texture position size color buffer

Parameters:
Returns: RenderBuffer3D
Modifiers: inline

Draws a billboard (camera-facing quad) with a texture.

texture : Texture2D
position : Vector3
size : Vector2
color : Color
buffer : RenderBuffer3D
Returns: RenderBuffer3D

drawBillboardBatch textures positions sizes colors count buffer

Full Usage: drawBillboardBatch textures positions sizes colors count buffer

Parameters:
Returns: RenderBuffer3D
Modifiers: inline

Draws multiple billboards in a single batch. Prefer this over individual drawBillboard calls for many sprites at once.

textures : Texture2D[]
positions : Vector3[]
sizes : Vector2[]
colors : Color[]
count : int
buffer : RenderBuffer3D
Returns: RenderBuffer3D

drawImmediate action buffer

Full Usage: drawImmediate action buffer

Parameters:
Returns: RenderBuffer3D
Modifiers: inline

Runs a fully-custom draw with the scene data the pipeline gathered this frame. The callback receives a SceneContext — the active camera (view/projection/config), the accumulated lights, the shadow pass output, and the elapsed time — so a custom shader (water/refraction, screen-space, multi-pass) can read the scene without re-implementing the gather. The pipeline restores the camera scope around the callback; any other raylib device state you mutate is your responsibility.

action : SceneContext -> unit

A callback invoked once with the frame's SceneContext.

buffer : RenderBuffer3D
Returns: RenderBuffer3D

drawLine3D start finish color buffer

Full Usage: drawLine3D start finish color buffer

Parameters:
Returns: RenderBuffer3D
Modifiers: inline

Draws a 3D line between two points.

start : Vector3
finish : Vector3
color : Color
buffer : RenderBuffer3D
Returns: RenderBuffer3D

drawMesh mesh transform material buffer

Full Usage: drawMesh mesh transform material buffer

Parameters:
Returns: RenderBuffer3D
Modifiers: inline

Draws a mesh with a world transform and material.

mesh : Mesh
transform : Matrix4x4
material : Material3D
buffer : RenderBuffer3D
Returns: RenderBuffer3D

drawMeshInstanced mesh transforms material instanceCount buffer

Full Usage: drawMeshInstanced mesh transforms material instanceCount buffer

Parameters:
Returns: RenderBuffer3D
Modifiers: inline

Draws multiple instances of the same mesh with different transforms. Prefer this over individual drawMesh calls for many copies of the same mesh.

mesh : Mesh
transforms : Matrix4x4[]
material : Material3D
instanceCount : int
buffer : RenderBuffer3D
Returns: RenderBuffer3D

drawModel model transform buffer

Full Usage: drawModel model transform buffer

Parameters:
Returns: RenderBuffer3D
Modifiers: inline

Draws a raylib model with a world transform. Each sub-mesh is drawn with its corresponding raylib material, converted to Material3D automatically.

model : Model
transform : Matrix4x4
buffer : RenderBuffer3D
Returns: RenderBuffer3D

drawSkinnedMesh mesh transform material bones buffer

Full Usage: drawSkinnedMesh mesh transform material bones buffer

Parameters:
Returns: RenderBuffer3D
Modifiers: inline

Draws a skinned mesh with bone matrix data.

mesh : Mesh
transform : Matrix4x4
material : Material3D
bones : Matrix4x4[]
buffer : RenderBuffer3D
Returns: RenderBuffer3D

drop _buffer

Full Usage: drop _buffer

Parameters:
Modifiers: inline

Terminal function that discards the buffer, silencing the unused-value warning. Does nothing.

_buffer : RenderBuffer3D

enableShadows buffer

Full Usage: enableShadows buffer

Parameters:
Returns: RenderBuffer3D
Modifiers: inline

Enables shadow casting for subsequent geometry until disabled.

buffer : RenderBuffer3D
Returns: RenderBuffer3D

endCamera buffer

Full Usage: endCamera buffer

Parameters:
Returns: RenderBuffer3D
Modifiers: inline

Ends the current 3D camera transform.

buffer : RenderBuffer3D
Returns: RenderBuffer3D

endEffect buffer

Full Usage: endEffect buffer

Parameters:
Returns: RenderBuffer3D
Modifiers: inline

Closes the shading scope opened by Draw3D.beginEffect; subsequent draws revert to the default PBR path. No-op if no scope is open.

buffer : RenderBuffer3D
Returns: RenderBuffer3D

modelWith model transform material buffer

Full Usage: modelWith model transform material buffer

Parameters:
Returns: RenderBuffer3D
Modifiers: inline

Draws a raylib model with a whole-model Material3D override — every sub-mesh uses material instead of its authored material.

model : Model
transform : Matrix4x4
material : Material3D
buffer : RenderBuffer3D
Returns: RenderBuffer3D

modelWithPerMesh model transform resolver buffer

Full Usage: modelWithPerMesh model transform resolver buffer

Parameters:
Returns: RenderBuffer3D
Modifiers: inline

Draws a raylib model with a per-sub-mesh material resolver. resolver is indexed by mesh index (0..model.MeshCount-1) in pipeline iteration order.

model : Model
transform : Matrix4x4
resolver : int -> Material3D
buffer : RenderBuffer3D
Returns: RenderBuffer3D

postProcess action buffer

Full Usage: postProcess action buffer

Parameters:
Returns: RenderBuffer3D
Modifiers: inline

Enqueues a color-only post-process pass. The action runs once, after the whole scene renders to an offscreen target; it receives a PostProcessContext3D with the scene texture. Context.Depth is ValueNone — no scene depth is exposed. The action must draw a fullscreen quad of Source. Emit it conditionally from the view based on game state (e.g. only while a hit-flash is active). Chain multiple passes — they ping-pong in buffer order, the last drawing to the back-buffer. Use this for effects that don't sample depth (desaturation, vignette, blur). For distance effects (fog, depth-of-field, SSAO) use Draw3D.postProcessWithDepth.

action : PostProcessContext3D -> unit

Invoked once per frame with the post-process context (Depth = ValueNone).

buffer : RenderBuffer3D
Returns: RenderBuffer3D

postProcessWithDepth action buffer

Full Usage: postProcessWithDepth action buffer

Parameters:
Returns: RenderBuffer3D
Modifiers: inline

Enqueues a post-process pass that needs camera-POV scene depth. Same lifecycle as Draw3D.postProcess (runs once after the scene renders, chains in buffer order), but when at least one such action is present the pipeline exposes the scene render target's depth attachment via Context.Depth. Sample it (linearize with the camera's near/far) for distance effects. Prefer plain postProcess for effects that don't read depth.

action : PostProcessContext3D -> unit

Invoked once per frame with the post-process context (Depth populated).

buffer : RenderBuffer3D
Returns: RenderBuffer3D

setAmbientLight light buffer

Full Usage: setAmbientLight light buffer

Parameters:
Returns: RenderBuffer3D
Modifiers: inline

Sets the ambient light for the scene.

light : AmbientLight3D
buffer : RenderBuffer3D
Returns: RenderBuffer3D

setShadowOrigin origin buffer

Full Usage: setShadowOrigin origin buffer

Parameters:
Returns: RenderBuffer3D
Modifiers: inline

Sets the shadow origin for this frame's shadow pass.

origin : Vector3
buffer : RenderBuffer3D
Returns: RenderBuffer3D

Type something to start searching.