dolphin.spatial3d · recipe ·

Example · A sky-colored gradient

Map height into a smooth color blend.

cpudolphin.materialsdolphin.mathdolphin.spatial3drecipe

We have mixed two colors with a constant weight and with a wave. Now let's make a gradient: a gradual change from one color to another. A point near the bottom should choose the first color; a point near the top should choose the second. The preview sphere spans heights from -1 to 1. Adding one and multiplying by one half maps that height into the zero-to-one blend range. This is a coordinate conversion, not a special shader keyword.

start.yh · Dolphin material example

Status: complete-program

Example · A sky-colored gradient

Map height into a smooth color blend.

cpu · type checked

using dolphin.materials
using dolphin.math
using dolphin.spatial3d

Surface(Vector3 position) -> dolphinSurface
{
    float height = (position.y + 1.0) * 0.5
    Vector3 dusk = Vector3(0.1, 0.0, 0.3)
    Vector3 dawn = Vector3(0.9, 0.6, 0.1)
    Vector3 color = DolphinSurfaceMix(dusk, dawn, height)
    return DolphinSurface(color, 0.65, 0.0, 0.0)
}

dolphinSurface center = Surface(Vector3(0.0, 0.0, 0.0))
Console.Log(Text.Format("{0}, {1}, {2}", center.color.x, center.color.y, center.color.z))
project.mech
manifestVersion = "2"
package = "api.example.recipe__shader_gradient"
version = "0.1.0"
languageEdition = "yeho-core-2026.1"

[app]
kind = "headless"

[[dependencies]]
package = "dolphin.materials"
version = "0.1.0"
path = "../../../dolphin/packages/materials"

[[dependencies]]
package = "dolphin.math"
version = "0.1.0"
path = "../../../dolphin/packages/math"

[[dependencies]]
package = "dolphin.spatial3d"
version = "0.1.0"
path = "../../../dolphin/packages/spatial3d"
Expected output
0.5, 0.3, 0.2
Notes and source

Replace position.y with position.x. Then reverse the two endpoint colors.

demonhunterlabs/app/lib/yeho-walkthrough.ts