INIGO THE DRAGON
================

Inigo is a complete procedural dragon character represented by signed-distance
functions (SDFs).  The geometry, colors, materials, pores, scales, belly and
tail plates, eyes, horns, claws, wings, and lighting are evaluated
analytically in GLSL.  There is no triangle mesh, texture map, displacement
map, normal map, scan, or baked distance field.

The model was an experiment in turning a 2D image (reference.png) into a closed
form signed distance function.  Though this conversion was assisted by a vision
language model, it still required substantial iteration and human feedback, over
the course of several days, to obtain a model that captured the spirit of the
original image.

The model is named in honor of Inigo Quilez, who has done substantial
and beautiful work on developing and explaining signed-distance modeling.

Created by Keenan Crane, 2026.


CONTENTS
--------

preview.png
    A full-detail preview rendered from the front.

construction.mp4
    A turntable render, showing how the model is built from basic primitives.

dragon-shadertoy.glsl
    A complete, commented ShaderToy-compatible shader.  Paste the entire file
    into an Image tab; it needs no iChannel textures.  Drag in the image to
    orbit.  DRAGON_LOD selects geometric detail from 0 through 3, and
    DRAGON_MODE selects beauty or diagnostic shading.

dragon-viewer.html
    A self-contained WebGL 2 viewer.  It embeds the current shaders directly:
    there are no network requests or external assets.  Open it in a current
    browser, drag to orbit, scroll to zoom, and use the controls to inspect
    levels of detail, materials, normals, sphere-tracing steps, or a field
    slice.  The Save PNG button exports the current view.

dragon-structure.png
    A diagram of the analytic construction: primitive blocking, CSG
    composition, coordinate charts, levels of detail, and material layers.

shaders/
    The same source factored for reuse:

      sdf.glsl           analytic primitives, CSG, noise, and materials
      dragon.glsl        Inigo's geometry and surface model
      render.glsl        sphere tracing, camera, lighting, and diagnostics
      construction.glsl construction-animation helpers

    The static model is sdf.glsl + dragon.glsl + render.glsl.  The
    construction turntable inserts construction.glsl and instruments the
    model so that the actual component SDFs grow into the finished dragon.

dragon-meshed.obj
    A triangle mesh approximation of the smooth surface defined by the SDF.
    The mesh was extracted using the subgrid marching tetrahedra method from
    https://github.com/hbaktash/subgrid-marching
    Colors were then sampled onto vertices, and the mesh was simplified using
    the color-adapted simplification method of Garland & Heckbert 1998,
    “Simplifying Surfaces with Color and Texture using Quadric Error Metrics”
    Vertex colors are stored via lines of the form
       v x y z r g b
    where (x,y,z) gives the vertex location, and (r,g,b) gives the color.
    Note that this format is not supported by all OBJ loaders/viewers.

LICENSE.txt
    CC0 1.0 public-domain dedication.


MODEL CONVENTIONS
-----------------

The model uses Y as up and +Z as front.  Its main entry point is

    Field mapDragon(vec3 p, int lod)

where Field contains a conservative distance value and a Material.  LOD 0 is
the main silhouette, LOD 1 adds facial and anatomical pieces, LOD 2 adds
geometric scales and plates, and LOD 3 adds fine filtered surface treatment.

The returned field is deliberately conservative under smooth CSG and
deformation so it can be sphere traced robustly.  It should not be assumed to
be an exact Euclidean signed distance everywhere.  See dragon-structure.png
and the comments in shaders/ for details.


LICENSE
-------

All material in this archive was created by Keenan Crane, and is dedicated to the public domain under CC0 1.0.  See LICENSE.txt.
