{"id":"recipe--shader-gradient","name":"Example · A sky-colored gradient","owner":"dolphin","package":"dolphin.spatial3d","kind":"recipe","signature":"start.yh · Dolphin material example","description":"Map height into a smooth color blend.","context":"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.","parameters":[],"returns":"","members":[],"tags":["cpu","dolphin.materials","dolphin.math","dolphin.spatial3d","recipe"],"updated":"2026-09-09","source":{"repository":"demonhunterlabs","path":"app/lib/yeho-walkthrough.ts"},"status":"complete-program","notes":["Replace position.y with position.x. Then reverse the two endpoint colors."],"examples":[{"id":"program","title":"Example · A sky-colored gradient","description":"Map height into a smooth color blend.","code":"using dolphin.materials\nusing dolphin.math\nusing dolphin.spatial3d\n\nSurface(Vector3 position) -> dolphinSurface\n{\n    float height = (position.y + 1.0) * 0.5\n    Vector3 dusk = Vector3(0.1, 0.0, 0.3)\n    Vector3 dawn = Vector3(0.9, 0.6, 0.1)\n    Vector3 color = DolphinSurfaceMix(dusk, dawn, height)\n    return DolphinSurface(color, 0.65, 0.0, 0.0)\n}\n\ndolphinSurface center = Surface(Vector3(0.0, 0.0, 0.0))\nConsole.Log(Text.Format(\"{0}, {1}, {2}\", center.color.x, center.color.y, center.color.z))","manifest":"manifestVersion = \"2\"\npackage = \"api.example.recipe__shader_gradient\"\nversion = \"0.1.0\"\nlanguageEdition = \"yeho-core-2026.1\"\n\n[app]\nkind = \"headless\"\n\n[[dependencies]]\npackage = \"dolphin.materials\"\nversion = \"0.1.0\"\npath = \"../../../dolphin/packages/materials\"\n\n[[dependencies]]\npackage = \"dolphin.math\"\nversion = \"0.1.0\"\npath = \"../../../dolphin/packages/math\"\n\n[[dependencies]]\npackage = \"dolphin.spatial3d\"\nversion = \"0.1.0\"\npath = \"../../../dolphin/packages/spatial3d\"\n","tags":["cpu"],"run":"cpu-oracle","expected":"0.5, 0.3, 0.2","verification":"type checked","sha256":"5cf9dff37a1996e32cd977d2c508f88980225f433adb3ed1a3b04c1341f798a4","checked":"2026-09-09","diagnostic":"","observedOutput":null,"checkedBackend":null}],"searchTerms":[],"url":"https://demonhunterlabs.com/academy/api?item=recipe--shader-gradient","json":"https://demonhunterlabs.com/reference/items/recipe--shader-gradient.json","markdown":"https://demonhunterlabs.com/reference/text/recipe--shader-gradient.md"}
