{"id":"recipe--shader-checker","name":"Example · A checker material","owner":"dolphin","package":"dolphin.spatial3d","kind":"recipe","signature":"start.yh · Dolphin material example","description":"Turn a continuous position into alternating cells.","context":"A checkerboard asks which cell a point belongs to. Multiply a coordinate to choose cell density, round down to get the cell number, and alternate between two colors using whether the sum of two cell numbers is even or odd. Here we use X and Y, so the pattern is planar. On a sphere it stretches toward the edges of that projection. This is a deliberate first mapping, not an automatic solution for every mesh's texture coordinates.","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":["Change both density multipliers from 4.0 to 2.0. Then try using X and Z instead of X and Y."],"examples":[{"id":"program","title":"Example · A checker material","description":"Turn a continuous position into alternating cells.","code":"using dolphin.materials\nusing dolphin.math\nusing dolphin.spatial3d\n\nSurface(Vector3 position) -> dolphinSurface\n{\n    int cellX = Math.FloorToInt(position.x * 4.0)\n    int cellY = Math.FloorToInt(position.y * 4.0)\n    Vector3 color = Vector3(0.04, 0.06, 0.1)\n    if (cellX + cellY) / 2 * 2 == cellX + cellY\n    {\n        color = Vector3(0.1, 0.9, 0.7)\n    }\n    return DolphinSurface(color, 0.7, 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_checker\"\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.1, 0.9, 0.7","verification":"type checked","sha256":"649b134f8564768d29aeecddae8baf1b60e9ec73dbb92b9fb42b3d9041eb4fb7","checked":"2026-09-09","diagnostic":"","observedOutput":null,"checkedBackend":null}],"searchTerms":[],"url":"https://demonhunterlabs.com/academy/api?item=recipe--shader-checker","json":"https://demonhunterlabs.com/reference/items/recipe--shader-checker.json","markdown":"https://demonhunterlabs.com/reference/text/recipe--shader-checker.md"}
