From ec32c11d3bde6772ddd250d3b217e0541409e0ce Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Thu, 24 Jun 2021 21:44:18 -0700 Subject: . Switch html rendering to a white background. --- html/linux/raytracing/3.mu.html | 144 +++++++++++++++++++++------------------- 1 file changed, 75 insertions(+), 69 deletions(-) (limited to 'html/linux/raytracing/3.mu.html') diff --git a/html/linux/raytracing/3.mu.html b/html/linux/raytracing/3.mu.html index 66c9a495..e479d4cb 100644 --- a/html/linux/raytracing/3.mu.html +++ b/html/linux/raytracing/3.mu.html @@ -7,23 +7,29 @@ - + @@ -68,25 +74,25 @@ if ('onhashchange' in window) { 7 # $ ./a.elf > 3.ppm 8 9 fn ray-color _in: (addr ray), _out: (addr rgb) { - 10 var in/esi: (addr ray) <- copy _in - 11 var out/edi: (addr rgb) <- copy _out - 12 var dir/eax: (addr vec3) <- get in, dir + 10 var in/esi: (addr ray) <- copy _in + 11 var out/edi: (addr rgb) <- copy _out + 12 var dir/eax: (addr vec3) <- get in, dir 13 #? print-string 0, "r.dir: " 14 #? print-vec3 0, dir 15 #? print-string 0, "\n" 16 var unit-storage: vec3 - 17 var unit/ecx: (addr vec3) <- address unit-storage + 17 var unit/ecx: (addr vec3) <- address unit-storage 18 vec3-unit dir, unit 19 #? print-string 0, "r.dir normalized: " 20 #? print-vec3 0, unit 21 #? print-string 0, "\n" - 22 var y-addr/eax: (addr float) <- get unit, y + 22 var y-addr/eax: (addr float) <- get unit, y 23 # t = (dir.y + 1.0) / 2.0 24 var t/xmm0: float <- copy *y-addr - 25 var one/eax: int <- copy 1 + 25 var one/eax: int <- copy 1 26 var one-f/xmm1: float <- convert one 27 t <- add one-f - 28 var two/eax: int <- copy 2 + 28 var two/eax: int <- copy 2 29 var two-f/xmm2: float <- convert two 30 t <- divide two-f 31 #? print-string 0, "t: " @@ -94,7 +100,7 @@ if ('onhashchange' in window) { 33 #? print-string 0, "\n" 34 # whitening = (1.0 - t) * white 35 var whitening-storage: rgb - 36 var whitening/ecx: (addr rgb) <- address whitening-storage + 36 var whitening/ecx: (addr rgb) <- address whitening-storage 37 rgb-white whitening 38 var one-minus-t/xmm3: float <- copy one-f 39 one-minus-t <- subtract t @@ -103,7 +109,7 @@ if ('onhashchange' in window) { 42 #? print-rgb-raw 0, whitening 43 #? print-string 0, "\n" 44 # out = t * (0.5, 0.7, 1.0) - 45 var dest/eax: (addr float) <- get out, r + 45 var dest/eax: (addr float) <- get out, r 46 fill-in-rational dest, 5, 0xa 47 dest <- get out, g 48 fill-in-rational dest, 7, 0xa @@ -120,13 +126,13 @@ if ('onhashchange' in window) { 59 #? print-string 0, "\n" 60 } 61 - 62 fn main -> _/ebx: int { + 62 fn main -> _/ebx: int { 63 64 # image 65 # width = 400 66 # height = 400 * 9/16 = 225 67 var aspect: float - 68 var aspect-addr/eax: (addr float) <- address aspect + 68 var aspect-addr/eax: (addr float) <- address aspect 69 fill-in-rational aspect-addr, 0x10, 9 # 16/9 70 #? print-string 0, "aspect ratio: " 71 #? print-float-hex 0, aspect @@ -140,7 +146,7 @@ if ('onhashchange' in window) { 79 # camera 80 81 # viewport-height = 2.0 - 82 var tmp/eax: int <- copy 2 + 82 var tmp/eax: int <- copy 2 83 var two-f/xmm4: float <- convert tmp 84 var viewport-height/xmm7: float <- copy two-f 85 #? print-string 0, "viewport height: " @@ -172,25 +178,25 @@ if ('onhashchange' in window) { 111 112 # origin = point3(0, 0, 0) 113 var origin-storage: vec3 -114 var origin/edi: (addr vec3) <- address origin-storage +114 var origin/edi: (addr vec3) <- address origin-storage 115 # horizontal = vec3(viewport-width, 0, 0) 116 var horizontal-storage: vec3 -117 var dest/eax: (addr float) <- get horizontal-storage, x +117 var dest/eax: (addr float) <- get horizontal-storage, x 118 copy-to *dest, viewport-width -119 var horizontal/ebx: (addr vec3) <- address horizontal-storage +119 var horizontal/ebx: (addr vec3) <- address horizontal-storage 120 # vertical = vec3(0, viewport-height, 0) 121 var vertical-storage: vec3 122 dest <- get vertical-storage, y 123 copy-to *dest, viewport-height -124 var vertical/edx: (addr vec3) <- address vertical-storage +124 var vertical/edx: (addr vec3) <- address vertical-storage 125 # lower-left-corner = origin - horizontal/2 - vertical/2 - vec3(0, 0, focal-length) 126 # . lower-left-corner = origin 127 var lower-left-corner-storage: vec3 -128 var lower-left-corner/esi: (addr vec3) <- address lower-left-corner-storage +128 var lower-left-corner/esi: (addr vec3) <- address lower-left-corner-storage 129 copy-object origin, lower-left-corner 130 # . lower-left-corner -= horizontal/2 131 var tmp2: vec3 -132 var tmp2-addr/eax: (addr vec3) <- address tmp2 +132 var tmp2-addr/eax: (addr vec3) <- address tmp2 133 copy-object horizontal, tmp2-addr 134 vec3-scale-down tmp2-addr, two-f 135 vec3-subtract-from lower-left-corner, tmp2-addr @@ -199,7 +205,7 @@ if ('onhashchange' in window) { 138 vec3-scale-down tmp2-addr, two-f 139 vec3-subtract-from lower-left-corner, tmp2-addr 140 # . lower-left-corner -= vec3(0, 0, focal-length) -141 var dest2/ecx: (addr float) <- get lower-left-corner, z +141 var dest2/ecx: (addr float) <- get lower-left-corner, z 142 var tmp3/xmm0: float <- copy *dest2 143 tmp3 <- subtract focal-length 144 copy-to *dest2, tmp3 @@ -214,16 +220,16 @@ if ('onhashchange' in window) { 153 # vertical (edx) 154 # floating-point registers are all free 155 print-string 0, "P3\n400 225\n255\n" # 225 = image height -156 var tmp/eax: int <- copy 0x18f # image width - 1 +156 var tmp/eax: int <- copy 0x18f # image width - 1 157 var image-width-1/xmm7: float <- convert tmp 158 tmp <- copy 0xe0 # image height - 1 159 var image-height-1/xmm6: float <- convert tmp 160 # -161 var j/ecx: int <- copy 0xe0 # 224 +161 var j/ecx: int <- copy 0xe0 # 224 162 { 163 compare j, 0 164 break-if-< -165 var i/eax: int <- copy 0 +165 var i/eax: int <- copy 0 166 { 167 compare i, 0x190 # 400 = image width 168 break-if->= @@ -243,15 +249,15 @@ if ('onhashchange' in window) { 182 # . . so we'll just spill them in a block 183 { 184 # . r.orig = origin -185 var r/eax: (addr ray) <- address r-storage -186 var dest/ecx: (addr vec3) <- get r, orig +185 var r/eax: (addr ray) <- address r-storage +186 var dest/ecx: (addr vec3) <- get r, orig 187 copy-object origin, dest 188 # . r.dir = lower-left-corner 189 dest <- get r, dir 190 copy-object lower-left-corner, dest 191 # . r.dir += horizontal*u 192 var tmp-vec3: vec3 -193 var tmp/eax: (addr vec3) <- address tmp-vec3 +193 var tmp/eax: (addr vec3) <- address tmp-vec3 194 copy-object horizontal, tmp 195 vec3-scale-up tmp, u 196 vec3-add-to dest, tmp @@ -267,9 +273,9 @@ if ('onhashchange' in window) { 206 } 207 # pixel-color = ray-color(r) 208 var c-storage: rgb -209 var c/ecx: (addr rgb) <- address c-storage +209 var c/ecx: (addr rgb) <- address c-storage 210 { -211 var r/eax: (addr ray) <- address r-storage +211 var r/eax: (addr ray) <- address r-storage 212 ray-color r, c 213 # write color 214 print-rgb 0, c @@ -294,16 +300,16 @@ if ('onhashchange' in window) { 233 # We immediately normalize the direction vector so we don't have to keep doing 234 # so. 235 fn initialize-ray _self: (addr ray), o: (addr vec3), d: (addr vec3) { -236 var self/esi: (addr ray) <- copy _self -237 var dest/eax: (addr vec3) <- get self, orig +236 var self/esi: (addr ray) <- copy _self +237 var dest/eax: (addr vec3) <- get self, orig 238 copy-object o, dest 239 dest <- get self, dir 240 vec3-unit d, dest 241 } 242 243 fn ray-at _self: (addr ray), t: float, out: (addr vec3) { -244 var self/esi: (addr ray) <- copy _self -245 var src/eax: (addr vec3) <- get self, dir +244 var self/esi: (addr ray) <- copy _self +245 var src/eax: (addr vec3) <- get self, dir 246 copy-object src, out 247 vec3-scale-up out, t 248 src <- get self, orig @@ -319,15 +325,15 @@ if ('onhashchange' in window) { 258 259 # print translating to [0, 256) 260 fn print-rgb screen: (addr screen), _c: (addr rgb) { -261 var c/esi: (addr rgb) <- copy _c +261 var c/esi: (addr rgb) <- copy _c 262 var xn: float -263 var xn-addr/ecx: (addr float) <- address xn +263 var xn-addr/ecx: (addr float) <- address xn 264 fill-in-rational xn-addr, 0x3e7ff, 0x3e8 # 255999 / 1000 265 # print 255.999 * c->r 266 var result/xmm0: float <- copy xn -267 var src-addr/eax: (addr float) <- get c, r +267 var src-addr/eax: (addr float) <- get c, r 268 result <- multiply *src-addr -269 var result-int/edx: int <- truncate result +269 var result-int/edx: int <- truncate result 270 print-int32-decimal screen, result-int 271 print-string screen, " " 272 # print 255.999 * c->g @@ -347,9 +353,9 @@ if ('onhashchange' in window) { 286 } 287 288 fn print-rgb-raw screen: (addr screen), _v: (addr rgb) { -289 var v/esi: (addr rgb) <- copy _v +289 var v/esi: (addr rgb) <- copy _v 290 print-string screen, "(" -291 var tmp/eax: (addr float) <- get v, r +291 var tmp/eax: (addr float) <- get v, r 292 print-float-hex screen, *tmp 293 print-string screen, ", " 294 tmp <- get v, g @@ -361,10 +367,10 @@ if ('onhashchange' in window) { 300 } 301 302 fn rgb-white _c: (addr rgb) { -303 var c/esi: (addr rgb) <- copy _c -304 var one/eax: int <- copy 1 +303 var c/esi: (addr rgb) <- copy _c +304 var one/eax: int <- copy 1 305 var one-f/xmm0: float <- convert one -306 var dest/edi: (addr float) <- get c, r +306 var dest/edi: (addr float) <- get c, r 307 copy-to *dest, one-f 308 dest <- get c, g 309 copy-to *dest, one-f @@ -373,11 +379,11 @@ if ('onhashchange' in window) { 312 } 313 314 fn rgb-add-to _c1: (addr rgb), _c2: (addr rgb) { -315 var c1/edi: (addr rgb) <- copy _c1 -316 var c2/esi: (addr rgb) <- copy _c2 +315 var c1/edi: (addr rgb) <- copy _c1 +316 var c2/esi: (addr rgb) <- copy _c2 317 # c1.r += c2.r -318 var arg1/eax: (addr float) <- get c1, r -319 var arg2/ecx: (addr float) <- get c2, r +318 var arg1/eax: (addr float) <- get c1, r +319 var arg2/ecx: (addr float) <- get c2, r 320 var result/xmm0: float <- copy *arg1 321 result <- add *arg2 322 copy-to *arg1, result @@ -396,9 +402,9 @@ if ('onhashchange' in window) { 335 } 336 337 fn rgb-scale-up _c1: (addr rgb), f: float { -338 var c1/edi: (addr rgb) <- copy _c1 +338 var c1/edi: (addr rgb) <- copy _c1 339 # c1.r *= f -340 var dest/eax: (addr float) <- get c1, r +340 var dest/eax: (addr float) <- get c1, r 341 var result/xmm0: float <- copy *dest 342 result <- multiply f 343 copy-to *dest, result @@ -421,9 +427,9 @@ if ('onhashchange' in window) { 360 } 361 362 fn print-vec3 screen: (addr screen), _v: (addr vec3) { -363 var v/esi: (addr vec3) <- copy _v +363 var v/esi: (addr vec3) <- copy _v 364 print-string screen, "(" -365 var tmp/eax: (addr float) <- get v, x +365 var tmp/eax: (addr float) <- get v, x 366 print-float-hex screen, *tmp 367 print-string screen, ", " 368 tmp <- get v, y @@ -435,11 +441,11 @@ if ('onhashchange' in window) { 374 } 375 376 fn vec3-add-to _v1: (addr vec3), _v2: (addr vec3) { -377 var v1/edi: (addr vec3) <- copy _v1 -378 var v2/esi: (addr vec3) <- copy _v2 +377 var v1/edi: (addr vec3) <- copy _v1 +378 var v2/esi: (addr vec3) <- copy _v2 379 # v1.x += v2.x -380 var arg1/eax: (addr float) <- get v1, x -381 var arg2/ecx: (addr float) <- get v2, x +380 var arg1/eax: (addr float) <- get v1, x +381 var arg2/ecx: (addr float) <- get v2, x 382 var result/xmm0: float <- copy *arg1 383 result <- add *arg2 384 copy-to *arg1, result @@ -459,22 +465,22 @@ if ('onhashchange' in window) { 398 399 fn vec3-subtract-from v1: (addr vec3), v2: (addr vec3) { 400 var tmp-storage: vec3 -401 var tmp/eax: (addr vec3) <- address tmp-storage +401 var tmp/eax: (addr vec3) <- address tmp-storage 402 copy-object v2, tmp 403 vec3-negate tmp 404 vec3-add-to v1, tmp 405 } 406 407 fn vec3-negate v: (addr vec3) { -408 var negative-one/eax: int <- copy -1 +408 var negative-one/eax: int <- copy -1 409 var negative-one-f/xmm0: float <- convert negative-one 410 vec3-scale-up v, negative-one-f 411 } 412 413 fn vec3-scale-up _v: (addr vec3), f: float { -414 var v/edi: (addr vec3) <- copy _v +414 var v/edi: (addr vec3) <- copy _v 415 # v.x *= f -416 var dest/eax: (addr float) <- get v, x +416 var dest/eax: (addr float) <- get v, x 417 var result/xmm0: float <- copy *dest 418 result <- multiply f 419 copy-to *dest, result @@ -491,9 +497,9 @@ if ('onhashchange' in window) { 430 } 431 432 fn vec3-scale-down _v: (addr vec3), f: float { -433 var v/edi: (addr vec3) <- copy _v +433 var v/edi: (addr vec3) <- copy _v 434 # v.x /= f -435 var dest/eax: (addr float) <- get v, x +435 var dest/eax: (addr float) <- get v, x 436 var result/xmm0: float <- copy *dest 437 result <- divide f 438 copy-to *dest, result @@ -525,9 +531,9 @@ if ('onhashchange' in window) { 464 } 465 466 fn vec3-length-squared _v: (addr vec3) -> _/xmm0: float { -467 var v/esi: (addr vec3) <- copy _v +467 var v/esi: (addr vec3) <- copy _v 468 # result = v.x * v.x -469 var src/eax: (addr float) <- get v, x +469 var src/eax: (addr float) <- get v, x 470 var tmp/xmm1: float <- copy *src 471 tmp <- multiply tmp 472 var result/xmm0: float <- copy tmp -- cgit 1.4.1-2-gfad0