aboutsummaryrefslogtreecommitdiff
path: root/index.html
blob: 3d3db083492be8941439a2cb05d297b233cc9b6b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>Raytracer</title>
    <link rel="stylesheet" href="https://unpkg.com/spectre.css/dist/spectre.min.css">
    <link rel="stylesheet" href="style.css">
  </head>
  <body>

    <div class="container">
      <div class="columns">
        <div class="column col-xl-12">
          <div id="output-wrapper" class="p-centered">
            <canvas id="render-output"></canvas>
          </div>
        </div>
      </div>
    <div class="container grid-xl">
      <div class="columns controls">
        <div class="column">
          <div class="columns">
            <div class="column col-3">
              <p>A minimal ray tracing engine written from scratch in JS. No graphics APIs or libraries are used, only a single HTML5 canvas call to draw the generated bitmap image.</p>
              <p>Various effects are supported, including recursive optical reflections and refractions, and <a href="https://en.wikipedia.org/wiki/Phong_reflection_model">Phong shading</a>. Basic multi-threading is implemented using the <a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API" target="_blank">Web Workers API</a>.</p>
              <p>The source is on <a href="https://github.com/jamesbarnett91/js-raytracer" target="_blank">GitHub</a>.</p>
            </div>
            <div class="divider-vert"></div>
            <div class="column col-2">
              <span>Render options</span>
              <div class="form-group">
                <label class="form-switch">
                  <input id="diffuse-toggle" type="checkbox" checked>
                  <i class="form-icon"></i> Diffuse lighting
                </label>
              </div>
              <div class="form-group">
                <label class="form-switch">
                  <input id="specular-toggle" type="checkbox" checked>
                  <i class="form-icon"></i> Specular lighting
                </label>
              </div>
              <div class="form-group">
                <label class="form-switch">
                  <input id="shadows-toggle" type="checkbox" checked>
                  <i class="form-icon"></i> Shadows
                </label>
              </div>
              <div class="form-group">
                <label class="form-switch">
                  <input id="reflections-toggle" type="checkbox" checked>
                  <i class="form-icon"></i> Reflections
                </label>
              </div>
              <div class="form-group">
                <label class="form-switch">
                  <input id="refractions-toggle" type="checkbox" checked>
                  <i class="form-icon"></i> Refractions
                </label>
              </div>
            </div>
            <div class="column col-3">
              <span>Performance options</span>
              <div class="form-group">
                <label class="form-switch">
                  <input id="buffer-draw" type="checkbox" checked>
                  <i class="form-icon"></i> Buffer draw calls
                </label>
              </div>
              <div class="form-group">
                <label class="form-switch">
                  <input id="direct-transfer" type="checkbox" checked>
                  <i class="form-icon"></i> Zero-copy array transfer
                </label>
              </div>
              <div class="form-group">
                <label class="form-switch">
                  <input id="enable-threads-toggle" type="checkbox" checked>
                  <i class="form-icon"></i> Multi-threaded rendering
                </label>
              </div>
              <div class="form-group nested-slider">
                <label class="form-label label-sm" for="threads">Render threads</label>
                <!-- TODO style -->
                <div class="input-group"> 
                  <input id="threads" class="slider" type="range" min="2" max="32" value="4" step="2">
                  <span id="threads-value" class="input-group-addon">4</span>
                </div>
              </div>
            </div>
            <div class="column col-4">
              <div class="form-group">
                <label id="res-label" class="form-label label-sm" for="res">Resolution</label>
                <select id="res" class="form-select select-sm">
                  <option value="360p">360p</option>
                  <option value="480p">480p</option>
                  <option value="720p" selected >720p</option>
                  <option value="1080p">1080p</option>
                  <option value="1440p">1440p</option>
                  <option value="4k">4k</option>
                </select>
              </div>
              <button id="render" class="btn btn-primary">Render</button>
              <button id="view-full" class="btn btn-link">View full image</button>
              <pre class="code"><code id="console"></code></pre>
            </div>
          </div>
        </div>
      </div>
    </div>
   
    <script src="./bundle.js"></script>
  </body>
</html>