WEBVTT
Kind: captions
Language: en

00:00:02.000 --> 00:00:06.480
This image you’re looking at was&nbsp;
rendered completely on a TI84 calculator.&nbsp;&nbsp;

00:00:06.480 --> 00:00:10.480
No tricks, no “I rendered it on my&nbsp;
PC and copied to the calculator.”&nbsp;&nbsp;

00:00:10.480 --> 00:00:15.120
This is the real deal, a raytracing engine that&nbsp;
runs on a calculator that supports textures,&nbsp;&nbsp;

00:00:15.120 --> 00:00:19.600
reflection, HDR, gamma-correct rendering,&nbsp;
dithering, and global illumination.&nbsp;

00:00:20.560 --> 00:00:24.320
Now, most people familiar with my older catalog&nbsp;
of videos probably know that a while back,&nbsp;&nbsp;

00:00:24.320 --> 00:00:28.080
I already wrote a raytracing program on a&nbsp;
graphing calculator. But that one had a few&nbsp;&nbsp;

00:00:28.080 --> 00:00:33.360
limitations that I’d like to address. Mainly,&nbsp;
my first raytracer wasn’t all that fast. It&nbsp;&nbsp;

00:00:33.360 --> 00:00:39.600
took almost 6 hours to render this image&nbsp;
here, which works out to about .0000485 FPS,&nbsp;&nbsp;

00:00:40.160 --> 00:00:44.880
and less than 5 pixels per second. To be fair,&nbsp;
raytracing is not something that can easily be&nbsp;&nbsp;

00:00:44.880 --> 00:00:49.456
pulled off in realtime. Each pixel involves a&nbsp;
whole boatload of computations to determine what&nbsp;&nbsp;

00:00:49.456 --> 00:00:54.160
is visible and how it should be illuminated. Even&nbsp;
now, you need a beefy GPU to pull it off. But,&nbsp;&nbsp;

00:00:54.160 --> 00:00:59.520
even for the cheap little CPU in these&nbsp;
calculators, 6 hours for this is just pitiful.&nbsp;

00:00:59.520 --> 00:01:03.760
The reason everything is so slow is because&nbsp;
TI-BASIC, the built-in language I used,&nbsp;&nbsp;

00:01:03.760 --> 00:01:08.000
is interpreted. In short, the processor&nbsp;
in the calculator doesn’t run my program,&nbsp;&nbsp;

00:01:08.000 --> 00:01:12.480
it runs a program that runs my program. This&nbsp;
makes sense for a calculator, since the whole&nbsp;&nbsp;

00:01:12.480 --> 00:01:17.200
process is sandboxed, and a lot harder to crash,&nbsp;
but for my code, it means every math operation I&nbsp;&nbsp;

00:01:17.200 --> 00:01:21.360
do involves more work than it really needs to,&nbsp;
and this overhead adds up. TI-BASIC also limits&nbsp;&nbsp;

00:01:21.360 --> 00:01:25.440
you to 15 colors over a fraction of the full&nbsp;
screen, and probably the biggest killer for&nbsp;&nbsp;

00:01:25.440 --> 00:01:30.880
a project like this: TI-BASIC only lets you use&nbsp;
single letter variable names. There are only 26&nbsp;&nbsp;

00:01:30.880 --> 00:01:34.720
places to store values in the program, and the&nbsp;
code is practically unreadable because of it.&nbsp;

00:01:35.360 --> 00:01:38.320
This time, instead of TiBASIC,&nbsp;
I’ll be writing this project in C++&nbsp;&nbsp;

00:01:39.040 --> 00:01:43.040
using the toolchain provided by Matt Waltz and the&nbsp;
other contributors to the CE Programming project.&nbsp;&nbsp;

00:01:43.680 --> 00:01:48.800
C is really nice compared to BASIC. It’s compiled&nbsp;
so the programs run directly on the CPU, code is&nbsp;&nbsp;

00:01:48.800 --> 00:01:53.440
a lot easier to document and reuse, and I can&nbsp;
poke around in memory basically anywhere I want,&nbsp;&nbsp;

00:01:53.440 --> 00:01:57.680
including writing to every pixel. Best of&nbsp;
all, I can write and test code right on my&nbsp;&nbsp;

00:01:57.680 --> 00:02:01.680
computer through emulation, which has the added&nbsp;
bonus of being faster than the real hardware.&nbsp;

00:02:02.400 --> 00:02:06.080
After taking a look at some of the sample code&nbsp;
in the toolchain repository, I figured the best&nbsp;&nbsp;

00:02:06.080 --> 00:02:10.160
way to get started would be to rewrite the&nbsp;
original version of the program, so I more or&nbsp;&nbsp;

00:02:10.160 --> 00:02:16.880
less ported it over. Here’s a fun fact, did you&nbsp;
know that these calculators have a 32,768 color&nbsp;&nbsp;

00:02:16.880 --> 00:02:23.200
320x240 display? That’s on par with the Super&nbsp;
Nintendo, and a whole lot better than the TiBASIC&nbsp;&nbsp;

00:02:23.200 --> 00:02:28.080
graphical specs. Even this recreation of the old&nbsp;
program already looks a whole lot better than the&nbsp;&nbsp;

00:02:28.080 --> 00:02:34.080
original. As for speed? Well, the old version&nbsp;
took just under 6 hours to draw this image.&nbsp;&nbsp;

00:02:34.080 --> 00:02:40.000
The new version takes about 3 minutes. That’s&nbsp;
nearly 400 pixels per second or an 80x speedup.&nbsp;&nbsp;

00:02:40.000 --> 00:02:45.280
It’s a great start, but this video would be pretty&nbsp;
short if I just stopped here. We can go faster.&nbsp;

00:02:46.160 --> 00:02:50.800
At its core, raytracing is really just a bunch of&nbsp;
math to model how light travels through a scene,&nbsp;&nbsp;

00:02:50.800 --> 00:02:54.480
and to do all that rendering math in my&nbsp;
code, I’m using floating point numbers,&nbsp;&nbsp;

00:02:54.480 --> 00:02:59.760
which are like scientific notation but for binary&nbsp;
numbers. Floats are a lot better than integers for&nbsp;&nbsp;

00:02:59.760 --> 00:03:04.240
general purpose computation since they can work&nbsp;
on really big numbers and really small numbers,&nbsp;&nbsp;

00:03:04.240 --> 00:03:08.240
but the tradeoff is that generally math&nbsp;
operations on floating point numbers are a lot&nbsp;&nbsp;

00:03:08.240 --> 00:03:13.200
slower than integers, and on the Z80 processor&nbsp;
inside the TI84 this is definitely the case.&nbsp;&nbsp;

00:03:13.840 --> 00:03:16.720
There aren’t any hardware optimizations&nbsp;
for floats like you would find on any&nbsp;&nbsp;

00:03:16.720 --> 00:03:20.480
modern processor or GPU, which means that&nbsp;
even for something as simple as adding two&nbsp;&nbsp;

00:03:20.480 --> 00:03:24.800
numbers together: integers take 2 CPU&nbsp;
cycles, and floats take a few thousand.&nbsp;

00:03:25.520 --> 00:03:29.120
One of the reasons floats are so expensive is&nbsp;
because you have to account for the fact that the&nbsp;&nbsp;

00:03:29.120 --> 00:03:33.760
decimal in two floating point numbers might not be&nbsp;
in the same place. Before we can add two numbers,&nbsp;&nbsp;

00:03:33.760 --> 00:03:38.000
we have to make sure all their digits are lined up&nbsp;
properly, but if we can be sure that the decimals&nbsp;&nbsp;

00:03:38.000 --> 00:03:42.240
are always in the same spot, we can treat these&nbsp;
numbers like integers. This approach is called&nbsp;&nbsp;

00:03:42.240 --> 00:03:47.120
Fixed Point, since instead of floating around, the&nbsp;
decimal point is always in the same place. A great&nbsp;&nbsp;

00:03:47.120 --> 00:03:51.920
example is US Dollars. As long as we assume you&nbsp;
can’t have a fraction of a cent, you can write&nbsp;&nbsp;

00:03:51.920 --> 00:03:56.080
out any amount of money as an integer number of&nbsp;
cents rather than a fractional number of dollars.&nbsp;

00:03:57.280 --> 00:04:02.000
Fun fact time again! I actually lied about the&nbsp;
processor that these calculators use. I said&nbsp;&nbsp;

00:04:02.000 --> 00:04:07.520
that they use the Zilog Z80, which is an 8-bit&nbsp;
processor from all the way back in 1974. Well,&nbsp;&nbsp;

00:04:07.520 --> 00:04:13.040
that’s partially true. Up to and including the&nbsp;
Plus C Silver Edition, everything in the TI84 line&nbsp;&nbsp;

00:04:13.040 --> 00:04:18.320
was using a groovy 70s-era architecture, which,&nbsp;
fair enough, for what they do these calculators&nbsp;&nbsp;

00:04:18.320 --> 00:04:24.160
don’t need to be all that powerful. But, the model&nbsp;
I’m using here, the 2015 skinny-legend TI84 Plus&nbsp;&nbsp;

00:04:24.160 --> 00:04:30.800
CE finally gave the CPU an update. Now, it has&nbsp;
a Zilog eZ80 under the hood. A whole lot faster,&nbsp;&nbsp;

00:04:30.800 --> 00:04:36.960
plus a better instruction set AND 24-bit wide&nbsp;
registers. Yes, you heard me right, 24-bit,&nbsp;&nbsp;

00:04:36.960 --> 00:04:44.240
not something more typical like 16, 32 or 64, this&nbsp;
thing is 24-bit. Your guess is as good as mine.&nbsp;

00:04:45.200 --> 00:04:50.480
Anyways, I can make my fixed point numbers have&nbsp;
24 bits, 12 below the decimal, and 12 above.&nbsp;&nbsp;

00:04:50.480 --> 00:04:58.400
This can represent numbers as large as 2047.999,&nbsp;
and as small as .0002, not perfectly precise,&nbsp;&nbsp;

00:04:58.400 --> 00:05:03.280
but good enough for graphics. Plus, these&nbsp;
fixed point numbers are way fast. I was able&nbsp;&nbsp;

00:05:03.280 --> 00:05:07.680
to render one test scene in less than&nbsp;
a quarter of the time! An improvement&nbsp;&nbsp;

00:05:07.680 --> 00:05:13.200
to be sure, but still, not good enough…
Besides speed, one thing I really wanted to&nbsp;&nbsp;

00:05:13.200 --> 00:05:17.120
improve in this raytracer was the complexity&nbsp;
of the scenes it draws. The first one had&nbsp;&nbsp;

00:05:17.120 --> 00:05:21.280
a reflective sphere, a tile floor, and a&nbsp;
single shadow, all centered in the view.&nbsp;&nbsp;

00:05:21.280 --> 00:05:24.800
Simple scenes like that can offer some&nbsp;
mathematical shortcuts, but this time I&nbsp;&nbsp;

00:05:24.800 --> 00:05:29.680
want to make things more complicated. So let's&nbsp;
add a few walls, a ceiling, and another sphere.&nbsp;

00:05:31.200 --> 00:05:35.440
The whole idea for ray-tracing is that we take&nbsp;
some sight ray, and figure out what objects in the&nbsp;&nbsp;

00:05:35.440 --> 00:05:40.400
scene it intersects with. Depending on the answer,&nbsp;
we shade that pixel in the output a certain way.&nbsp;&nbsp;

00:05:40.400 --> 00:05:43.840
But, if we have an efficient way to find out&nbsp;
if a ray intersects something in the scene,&nbsp;&nbsp;

00:05:43.840 --> 00:05:47.360
we can use this information to figure&nbsp;
out other ways light is traveling.&nbsp;&nbsp;

00:05:47.360 --> 00:05:50.960
For example, if there’s something in the way of&nbsp;
a ray pointing from a surface to a light source,&nbsp;&nbsp;

00:05:50.960 --> 00:05:55.280
we know that that point will be in shadow.
There are two other properties of light that we’ll&nbsp;&nbsp;

00:05:55.280 --> 00:06:00.000
also want to model here. The first is Lambert’s&nbsp;
Law: light intensity on an object falls off the&nbsp;&nbsp;

00:06:00.000 --> 00:06:04.400
more a surface points away from the light source.&nbsp;
And the second is the inverse-square law, light&nbsp;&nbsp;

00:06:04.400 --> 00:06:08.960
intensity falls off the further away you get from&nbsp;
the source. The two of these have to do with the&nbsp;&nbsp;

00:06:08.960 --> 00:06:13.600
angular size of the surface from the perspective&nbsp;
of the light source. If we assume the lamp gives&nbsp;&nbsp;

00:06:13.600 --> 00:06:17.920
out equal energy in all directions, the bigger&nbsp;
the solid angle our surface takes up, the more&nbsp;&nbsp;

00:06:17.920 --> 00:06:22.800
light it’s gonna reflect. Turn the surface away&nbsp;
from the lamp, and the solid angle gets smaller.&nbsp;&nbsp;

00:06:22.800 --> 00:06:26.880
Move the object twice as far away, and now it&nbsp;
takes 4 times as much area to take up the same&nbsp;&nbsp;

00:06:26.880 --> 00:06:31.520
angular space. In both cases, the surface&nbsp;
will get less light, and appear dimmer.&nbsp;

00:06:32.080 --> 00:06:36.080
When you put these two effects together with the&nbsp;
shadows, things already look a whole lot better.&nbsp;&nbsp;

00:06:36.080 --> 00:06:40.000
But, computer renders have this awkward&nbsp;
tendency to look a little too clean,&nbsp;&nbsp;

00:06:40.000 --> 00:06:44.160
and you can’t get much cleaner than a room with&nbsp;
two perfect spheres and solid-color planes, so,&nbsp;&nbsp;

00:06:44.160 --> 00:06:48.480
let’s look into texturing. All we have to do is&nbsp;
to take an existing picture, and to project it&nbsp;&nbsp;

00:06:48.480 --> 00:06:52.880
down onto an object in the scene when rendering.&nbsp;
In our case, whenever we’re rendering a pixel on&nbsp;&nbsp;

00:06:52.880 --> 00:06:57.120
the floor, we’ll want to use the color from a&nbsp;
pixel in some image like these hardwood planks.&nbsp;&nbsp;

00:06:57.120 --> 00:07:00.560
Since the floor is an axis-aligned&nbsp;
plane, that task is pretty simple:&nbsp;&nbsp;

00:07:00.560 --> 00:07:04.080
just take the x and z coordinates where&nbsp;
we hit, use those to pick a pixel in the&nbsp;&nbsp;

00:07:04.080 --> 00:07:07.920
texture, and then interpolate between any&nbsp;
neighboring pixels to hide any jagged edges.&nbsp;

00:07:08.800 --> 00:07:12.640
But here’s something else that doesn’t look&nbsp;
too great. If you look closely at any surface,&nbsp;&nbsp;

00:07:12.640 --> 00:07:17.760
you’ll see bands of color rather than a smooth&nbsp;
gradient. As unnecessarily good as the display&nbsp;&nbsp;

00:07:17.760 --> 00:07:22.560
hardware in these calculators is, we are still&nbsp;
bound by 15-bit color. In the red, green, and&nbsp;&nbsp;

00:07:22.560 --> 00:07:27.440
blue channels there are only 32 different levels&nbsp;
of brightness to choose from, and so in areas&nbsp;&nbsp;

00:07:27.440 --> 00:07:31.360
where color is changing slowly, the transition&nbsp;
between the two closest colors stands out.&nbsp;

00:07:32.160 --> 00:07:36.720
Thankfully, dithering is an easy fix to this&nbsp;
problem. By mixing together a few pixels of each&nbsp;&nbsp;

00:07:36.720 --> 00:07:40.800
color along a transition, we can get the illusion&nbsp;
of a bigger palette at the expense of a little&nbsp;&nbsp;

00:07:40.800 --> 00:07:45.360
pixel noise. There’s no shortage of dithering&nbsp;
algorithms to choose from depending on if you want&nbsp;&nbsp;

00:07:45.360 --> 00:07:50.720
to prioritize speed, image quality, or noise, but&nbsp;
here, I’m doing arguably the simplest technique.&nbsp;&nbsp;

00:07:50.720 --> 00:07:54.320
Taking whatever error there is from the last&nbsp;
pixel, and just adding it onto the next one in&nbsp;&nbsp;

00:07:54.320 --> 00:07:58.560
the row. Even though there’s not much to it, this&nbsp;
technique helps a lot to smooth out the colors.&nbsp;

00:07:59.120 --> 00:08:03.200
While we’re on the subject of color, I gotta&nbsp;
confess, my renderer still is a little bit&nbsp;&nbsp;

00:08:03.200 --> 00:08:08.400
entirely wrong. My code all operates on the&nbsp;
assumption that light intensity in the renderer&nbsp;&nbsp;

00:08:08.400 --> 00:08:13.360
scales linearly with the RGB value I set the&nbsp;
pixels to. But in the real world, that’s not the&nbsp;&nbsp;

00:08:13.360 --> 00:08:18.800
case. There’s a great MinutePhysics video talking&nbsp;
about why this is, but long story short, standard&nbsp;&nbsp;

00:08:18.800 --> 00:08:23.200
RGB values are grouped so that darker colors&nbsp;
are very close together in terms of brightness,&nbsp;&nbsp;

00:08:23.200 --> 00:08:27.520
but brighter colors are more spread out. If&nbsp;
we’re assuming a linear mapping from actual&nbsp;&nbsp;

00:08:27.520 --> 00:08:32.320
intensity to sRGB, things are going to look&nbsp;
darker than they should. There is a conversion&nbsp;&nbsp;

00:08:32.320 --> 00:08:37.520
function between the two, but, well, that looks&nbsp;
hard. So instead, I added it as a lookup table.&nbsp;&nbsp;

00:08:38.160 --> 00:08:42.160
The nice thing about the lookup table, is&nbsp;
that I can use it to add Tone Mapping for HDR&nbsp;&nbsp;

00:08:42.160 --> 00:08:45.520
at no extra cost, by adjusting the&nbsp;
values according to this function.&nbsp;&nbsp;

00:08:46.320 --> 00:08:50.320
Now the renderer preserves detail in&nbsp;
areas that would normally appear too dim,&nbsp;&nbsp;

00:08:50.320 --> 00:08:55.040
or so bright that they look washed out.
Accurate color representation goes a long&nbsp;&nbsp;

00:08:55.040 --> 00:08:59.680
way towards photorealism, but there’s still&nbsp;
one glaring issue with this image. Anything&nbsp;&nbsp;

00:08:59.680 --> 00:09:05.520
in shadow isn’t just dark, it’s pitch black, and&nbsp;
in the real world, you don’t see this very often.&nbsp;&nbsp;

00:09:05.520 --> 00:09:09.280
Even if something isn’t being lit directly&nbsp;
by the sun, light can bounce off of something&nbsp;&nbsp;

00:09:09.280 --> 00:09:14.560
else into the shadow. This is called global&nbsp;
illumination, as opposed to direct illumination,&nbsp;&nbsp;

00:09:14.560 --> 00:09:20.400
and it shows up all over the place. Under trees,&nbsp;
along sidewalks, inside a room on a sunny day.&nbsp;&nbsp;

00:09:20.400 --> 00:09:25.440
But compared to direct illumination, global&nbsp;
illumination is a lot harder to simulate. Instead&nbsp;&nbsp;

00:09:25.440 --> 00:09:29.920
of just one or two light sources, the illumination&nbsp;
an object receives comes in from all directions.&nbsp;

00:09:30.560 --> 00:09:33.840
Professional renderers generally use&nbsp;
random sampling, since if you take the&nbsp;&nbsp;

00:09:33.840 --> 00:09:37.120
average of enough light samples, you’ll&nbsp;
eventually get close to the right answer,&nbsp;&nbsp;

00:09:37.680 --> 00:09:41.680
but, since I’m not in the mood to wait a week for&nbsp;
the render, I’m gonna use a different technique&nbsp;&nbsp;

00:09:41.680 --> 00:09:46.800
called radiosity. The radiosity algorithm computes&nbsp;
a lightmap for each object in the scene, which&nbsp;&nbsp;

00:09:46.800 --> 00:09:50.480
is like a texture that keeps track of how much&nbsp;
light is hitting the object at a couple points.&nbsp;&nbsp;

00:09:51.200 --> 00:09:54.560
First, we get the direct illumination for&nbsp;
every patch, and then we simulate light&nbsp;&nbsp;

00:09:54.560 --> 00:09:58.800
bouncing around the scene by adding up the light&nbsp;
contributed to each patch by all the others.&nbsp;&nbsp;

00:09:58.800 --> 00:10:01.760
Repeat that enough times to account for&nbsp;
the light paths with multiple bounces,&nbsp;&nbsp;

00:10:01.760 --> 00:10:05.120
and we’ll eventually converge on a more&nbsp;
accurate representation of how the scene is lit.&nbsp;

00:10:05.760 --> 00:10:09.680
I still render direct illumination individually&nbsp;
for every pixel, since the resolution of the&nbsp;&nbsp;

00:10:09.680 --> 00:10:14.000
lightmaps make shadows look a bit chunky. But,&nbsp;
I can also turn off the direct illumination&nbsp;&nbsp;

00:10:14.000 --> 00:10:18.880
completely and render the scene with just light&nbsp;
that’s reflected off the walls. One effect I&nbsp;&nbsp;

00:10:18.880 --> 00:10:23.120
think helps with photorealism is color bleeding.&nbsp;
You can see in the global image that the red wall&nbsp;&nbsp;

00:10:23.120 --> 00:10:26.960
contributes a bit of red light to everything else,&nbsp;
and so does the blue wall and the wood floor.&nbsp;&nbsp;

00:10:27.520 --> 00:10:30.720
When we look in the fully rendered image, this&nbsp;
means that the spheres have a bit of a colored&nbsp;&nbsp;

00:10:30.720 --> 00:10:35.040
tint on the sides. And this is something we can&nbsp;
also see in the real world. If a brightly colored&nbsp;&nbsp;

00:10:35.040 --> 00:10:39.120
object like this box reflects a lot of light,&nbsp;
things around it will have a similar color.&nbsp;&nbsp;

00:10:39.120 --> 00:10:42.080
It’s a subtle effect, but once you know&nbsp;
about it, you’ll see it everywhere…&nbsp;

00:10:42.960 --> 00:10:47.280
For one last cherry on top, it wouldn’t be&nbsp;
a raytracing demo without a mirror ball,&nbsp;&nbsp;

00:10:47.280 --> 00:10:50.800
so I threw together some code to reflect a&nbsp;
sight ray off of the one sphere, and then&nbsp;&nbsp;

00:10:50.800 --> 00:10:55.840
render the scene from that direction. This is one&nbsp;
of the things raytracing gives almost for free.&nbsp;&nbsp;

00:10:55.840 --> 00:10:59.280
We already have all the code necessary&nbsp;
to render sight rays from the camera,&nbsp;&nbsp;

00:10:59.280 --> 00:11:01.680
all we have to do now is change&nbsp;
the direction of the ray.&nbsp;

00:11:03.120 --> 00:11:08.720
And, there you have it. A raytraced scene with&nbsp;
reflection, global illumination, HDR, gamma&nbsp;&nbsp;

00:11:08.720 --> 00:11:14.720
correct rendering, point lights and textures, all&nbsp;
still on a TI84 calculator, in case you forgot.&nbsp;&nbsp;

00:11:15.280 --> 00:11:19.040
For fun, I tried my best to recreate the scene in&nbsp;
Blender and did a quick render on my computer to&nbsp;&nbsp;

00:11:19.040 --> 00:11:24.160
compare. For the most part the calculator isn’t&nbsp;
that far off. I noticed in some areas of the&nbsp;&nbsp;

00:11:24.160 --> 00:11:28.640
image, the Blender illumination is a bit different&nbsp;
from the calculator’s, notice how the mirror ball&nbsp;&nbsp;

00:11:28.640 --> 00:11:33.200
is dimmer here, and the back wall has a bit more&nbsp;
red reflecting from the side. It’s not perfect,&nbsp;&nbsp;

00:11:33.200 --> 00:11:37.440
but remember this is still night and day compared&nbsp;
to the graphics this calculator normally draws.&nbsp;

00:11:38.160 --> 00:11:42.080
On my computer, this render took a couple&nbsp;
minutes to perform using a modern multicore&nbsp;&nbsp;

00:11:42.080 --> 00:11:46.000
processor, but, how long does it take for the&nbsp;
calculator? Get ready for the quickness...&nbsp;&nbsp;

00:11:46.720 --> 00:11:52.560
14 minutes. Granted, the calculator is performing&nbsp;
a simpler algorithm than Blender, but time-wise,&nbsp;&nbsp;

00:11:52.560 --> 00:11:58.640
we’re in the same ballpark. The original version&nbsp;
took 6 hours for a lot less. This version runs at&nbsp;&nbsp;

00:11:58.640 --> 00:12:03.760
roughly 90 pixels per second which is almost&nbsp;
20 times faster. Altogether we’ve got better&nbsp;&nbsp;

00:12:03.760 --> 00:12:08.480
results in less time. I’d count that as a win.
As always, there are still ways it could be&nbsp;&nbsp;

00:12:08.480 --> 00:12:12.880
improved. When writing some of the more complex&nbsp;
fixed point functions, I got a little lazy&nbsp;&nbsp;

00:12:12.880 --> 00:12:16.240
and just used the floating point library&nbsp;
instead of writing it myself in assembly.&nbsp;&nbsp;

00:12:16.960 --> 00:12:21.120
I mean, I wrote my own fast multiplication and&nbsp;
squaring routines in ASM since those get used&nbsp;&nbsp;

00:12:21.120 --> 00:12:25.680
pretty often, but for something like square roots,&nbsp;
I only use it a few times per pixel, so garbage&nbsp;&nbsp;

00:12:25.680 --> 00:12:30.400
like this is good enough for me. There are a few&nbsp;
redundant calculations my renderer performs which&nbsp;&nbsp;

00:12:30.400 --> 00:12:34.720
could probably be stored and reused, mostly&nbsp;
during radiosity. Cutting out all this work&nbsp;&nbsp;

00:12:34.720 --> 00:12:38.720
would make things faster, but, there are memory&nbsp;
limits to consider, and what I have works for now.&nbsp;

00:12:39.760 --> 00:12:43.840
It’d be really cool to add support for triangle&nbsp;
meshes to render more complex shapes, but that&nbsp;&nbsp;

00:12:43.840 --> 00:12:48.640
comes at the cost of way more compute time per&nbsp;
pixel. Other forms of lighting like directional&nbsp;&nbsp;

00:12:48.640 --> 00:12:52.240
light and surface lights would also make for&nbsp;
some interesting renders, as would refractive&nbsp;&nbsp;

00:12:52.240 --> 00:12:56.880
materials like glass. I might get around to it&nbsp;
in the future and give this video a sequel (no…&nbsp;&nbsp;

00:12:57.440 --> 00:13:02.240
three-quel? idk) so uh, subscribe or whatever.&nbsp;
But, if you’re the impatient type, the source&nbsp;&nbsp;

00:13:02.240 --> 00:13:05.600
code is all going up on Github, and you’re more&nbsp;
than welcome to add these or other features.&nbsp;

00:13:07.040 --> 00:13:10.960
I’ve already spent enough time on this as is.&nbsp;
So, in the interest of getting this video out,&nbsp;&nbsp;

00:13:10.960 --> 00:13:16.240
I’m gonna have to be happy with what I’ve written.&nbsp;
Ti84 calculators can now do raytracing faster,&nbsp;&nbsp;

00:13:16.240 --> 00:13:21.360
and with more photorealistic results. I don’t&nbsp;
know about you, but I for one am excited that&nbsp;&nbsp;

00:13:21.360 --> 00:13:33.840
we’re now one step closer to real-time&nbsp;
raytraced Minecraft on a calculator...

