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; Falloff = 2f; 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

animatedModelWith am transform material buffer

Full Usage: animatedModelWith am transform material buffer

Parameters:
Returns: RenderBuffer3D
Modifiers: inline

Draws an animated model with a whole-model Material3D override. Bone palette is derived internally from the state, same as drawAnimatedModel.

am : AnimatedModel
transform : Matrix
material : Material3D
buffer : RenderBuffer3D
Returns: RenderBuffer3D

animatedModelWithPerMesh am transform resolver buffer

Full Usage: animatedModelWithPerMesh am transform resolver buffer

Parameters:
Returns: RenderBuffer3D
Modifiers: inline

Draws an animated model with a per-mesh-part material resolver (flat index over model.Meshes × MeshParts). Bone palette is derived internally from the state.

am : AnimatedModel
transform : Matrix
resolver : int -> Material3D
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 effect buffer

Full Usage: beginEffect effect buffer

Parameters:
Returns: RenderBuffer3D
Modifiers: inline

Opens a per-group shading scope: draws between this and Draw3D.endEffect are shaded by effect instead of the default PBR effect. The effect inherits the gathered scene data (camera matrices, lights, material, bones) — 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 effect 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 effect by name via SceneUpload: an effect that declares the matching uniforms (e.g. dirLightDir, boneMatrices, shadowViewProjs, shadowAtlas, 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.drawInstanced inside a scope is shaded by the user effect when it exposes an Instanced technique (the instancing opt-in); an effect that doesn't falls back to the PBR instanced path. Skinned + instanced draws are not supported. See docs/graphics3d/instancing.md.

effect : Effect
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

drawAnimatedModel am transform buffer

Full Usage: drawAnimatedModel am transform buffer

Parameters:
Returns: RenderBuffer3D

Draws an animated model. The 3D analog of the 2D litAnimatedSprite: takes the runtime state value (AnimatedModel) + a transform, derives the bone palette internally from the state, and emits a DrawAnimatedModel command. Auto-PBR + lights + shadows; skinned parts use the PBR Skinned technique. The caller never handles a Matrix[] — bone computation happens here, at draw-recording time.

am : AnimatedModel
transform : Matrix
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 raw device access AND the scene data the pipeline gathered this frame. The callback receives a SceneContext — the graphics device, the active camera (view/projection/config), the accumulated lights, the shadow pass output, and the elapsed time — so a custom effect (water/refraction, screen-space, multi-pass) can read the scene without re-implementing the gather. The pipeline restores the viewport + camera scope around the callback; any other device state you mutate is your responsibility.

action : SceneContext -> unit

A callback invoked once with the frame's SceneContext.

buffer : RenderBuffer3D
Returns: RenderBuffer3D

drawInstanced mesh transforms material instanceCount buffer

Full Usage: drawInstanced mesh transforms material instanceCount buffer

Parameters:
Returns: RenderBuffer3D
Modifiers: inline

Draws static instanced bulk (terrain/props) of an effectless PrimitiveMesh. Auto-PBR + lights + shadows. Used by CellGridRenderer3D/HexGrid3DRenderer after camera culling.

mesh : PrimitiveMesh
transforms : Matrix[]
material : Material3D
instanceCount : int
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

drawMeshEffect meshPart transform effect buffer

Full Usage: drawMeshEffect meshPart transform effect buffer

Parameters:
Returns: RenderBuffer3D
Modifiers: inline

Draws a mesh part with a user-supplied Effect (escape hatch). The pipeline sets World from the transform and View/Projection from the active camera, applies the effect's current technique pass, and draws the part. The caller owns lighting and material parameters on the effect.

meshPart : ModelMeshPart
transform : Matrix
effect : Effect
buffer : RenderBuffer3D
Returns: RenderBuffer3D

drawModel model transform buffer

Full Usage: drawModel model transform buffer

Parameters:
Returns: RenderBuffer3D
Modifiers: inline

Draws a static model with a world transform. Auto-PBR + lights + shadows; the model's baked native effect is read via Material3D.fromModelMeshPart so the model keeps its authored look when the pipeline swaps to the PBR effect.

model : Model
transform : Matrix
buffer : RenderBuffer3D
Returns: RenderBuffer3D

drawPrimitive mesh transform material buffer

Full Usage: drawPrimitive mesh transform material buffer

Parameters:
Returns: RenderBuffer3D
Modifiers: inline

Draws an effectless PrimitiveMesh with a PBR material. Auto-PBR + lights + shadows.

mesh : PrimitiveMesh
transform : Matrix
material : Material3D
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 static model with a whole-model Material3D override — every mesh part uses material instead of its authored material. Auto-PBR + lights + shadows.

model : Model
transform : Matrix
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 static model with a per-mesh-part material resolver. resolver is indexed by a flat counter over model.Meshes × MeshParts in pipeline iteration order. Auto-PBR + lights + shadows.

model : Model
transform : Matrix
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 carrying the scene texture, a fullscreen quad, and the device. Context.Depth is ValueNone — no scene-depth pass runs. The action binds its effect, sets model-derived parameters, binds Source to the sampler, and calls Quad.Draw(effect). Emit it conditionally from the view based on game state. 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) so the framework skips depth production entirely. 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 also renders scene depth to an R32F target and exposes it 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, so the depth pass is skipped.

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.