Skip to content

Instantly share code, notes, and snippets.

View ianmackenzie's full-sized avatar

Ian Mackenzie ianmackenzie

View GitHub Profile
{
"folders":
[
{
"path": ".",
"folder_exclude_patterns": ["elm-stuff"]
}
],
"settings":
{
@ianmackenzie
ianmackenzie / Main.elm
Created April 1, 2019 13:39
elm-ui bullets
module Main exposing (main)
import Element exposing (Element)
import Html exposing (Html)
type Bullet
= Bullet String (List Bullet)
@ianmackenzie
ianmackenzie / shadows.md
Last active April 21, 2020 13:50
elm-3d-scene shadow internals

Transcribed from Slack:

  • Shadows in elm-3d-scene are implemented using shadow volumes: the basic idea is that you take the faces pointing away from the light and 'push' them away from the light, keep the faces pointing toward the light in the same place, and add connecting faces between the two (via some magic in the vertex shader)
  • This shape is then a 'shadow volume', and you can check whether a spot on a surface is in shadow by checking whether it is inside that volume (via some magic with the stencil buffer)
  • Initially I was just using a huge default offset value of 1.0e9 to push back the 'back' faces, but it turns out that's too big for the default precision float value used on iOS
  • So the first fix (that I'd been planning to do at some point anyways) was to figure out a more reasonable offset value by calculating a bounding box for the entire scene, and using the diameter of that bounding box as the offset value
  • Adding that logic in meant that I could also do something else that I'd been planni
@ianmackenzie
ianmackenzie / main.html
Created October 25, 2023 18:22
Working HTML
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>Main</title>
<style>body { padding: 0; margin: 0; }</style>
</head>
<body>