Wolfenstein 3D (1992) drew its walls by casting one ray per screen column: a 2D ray tracer running on a 1992 PC.id Software, Wolfenstein 3D, 1992
A ray tracer that writes pixels: the primary ray through a pixel, the two intersections every scene needs, the reflection, and a trace that adds a shadow ray and one mirror bounce. The scene is a closed Cornell box, 96 × 72, lit directly by one point light, with a diffuse sphere and a mirror sphere. Four pixels are checked: a lit floor, a shadowed floor, the red wall seen in the mirror, and the red wall.
| JavaScript | C# | What it computes |
|---|---|---|
cameraRay | CameraRay | The unit ray through the center of pixel (px, py), top-left origin: screen x in [−1, 1] × tan(fov/2) × aspect, screen y × tan(fov/2), d = normalize(sx u + sy v − w). |
hitSphere | HitSphere | The smallest t > 10−6 of the quadratic; null (C#: −1) on a miss. |
hitTriangle | HitTriangle | Möller–Trumbore: (t, u, v) with u weighting b and v weighting c; null (C#: false) on a miss, |det| < 10−12, or t ≤ 10−6. |
reflect | Reflect | d − 2 (d · n) n. |
trace | Trace | Miss: black. P = hit + 10−4 N. Mirror: black at depth ≥ maxDepth, else mirror × trace of the reflected ray. Diffuse: albedo × (ka + (1 − ka) V max(0, N·L)), V = 0 when a hit lies closer than the light along P → light. |
intersect (the closest hit over the scene, normal flipped to face the ray) and render are given and use your functions.Each row is one check, run on your functions with the published inputs below. The same table appears under the scene in the runner and in the Unity Console.
| # | Check | Expected | Tolerance | Points |
|---|---|---|---|---|
| 1 | cameraRay through pixel (89, 62) of 150 × 150: direction | (-0.372, -0.3696, -0.8515) | 0.001 | 12 |
| 2 | hitSphere: nearest t on the radius-1.2 sphere | 6.2281 | 0.001 | 12 |
| 3 | hitTriangle (Möller–Trumbore): t, u, v | (1, 0.25, 0.25) | 0.001 | 12 |
| 4 | hitTriangle: the ray from (1.5, 1.5, 1) misses (null) while the one from (0.5, 0.5, 1) hits | (true, true) | exact | 6 |
| 5 | reflect (0.6, −0.8, 0) about (0, 1, 0) | (0.6, 0.8, 0) | 0.000001 | 6 |
| 6 | Cornell box, pixel (24, 63): lit floor | (0.6933, 0.6933, 0.6933) | 0.002 | 12 |
| 7 | Cornell box, pixel (36, 66): floor in the diffuse sphere’s shadow | (0.08, 0.08, 0.08) | 0.002 | 14 |
| 8 | Cornell box, pixel (54, 56): the red wall seen in the mirror sphere | (0.456, 0.0912, 0.073) | 0.002 | 14 |
| 9 | Cornell box, pixel (6, 30): the red wall | (0.5834, 0.1167, 0.0933) | 0.002 | 12 |
{
"cam": {
"eye": [ 3, 3, 6 ],
"at": [ 0, 0, 0 ],
"up": [ 0, 1, 0 ],
"fov": 28
},
"size": 150,
"pixel": [ 89, 62 ],
"sphere": {
"c": [ 0, 0, 0 ],
"r": 1.2
},
"tri": {
"a": [ 0, 0, 0 ],
"b": [ 2, 0, 0 ],
"c": [ 0, 2, 0 ],
"o": [ 0.5, 0.5, 1 ],
"d": [ 0, 0, -1 ],
"missO": [ 1.5, 1.5, 1 ]
},
"reflect": {
"d": [ 0.6, -0.8, 0 ],
"n": [ 0, 1, 0 ]
},
"cornell": {
"cam": {
"eye": [ 0, 1, 2.8 ],
"at": [ 0, 1, 0 ],
"up": [ 0, 1, 0 ],
"fov": 40
},
"width": 96,
"height": 72,
"lit": [ 24, 63 ],
"shadow": [ 36, 66 ],
"mirror": [ 54, 56 ],
"wall": [ 6, 30 ]
}
}Build each function from primitives (dot, cross, normalize, length, component access, sqrt, tan.) and use the engine's own helper, where one exists, only to check your result. These are off limits in your submission:
| Track | Off limits |
|---|---|
| WebGL (JavaScript) | THREE.Raycaster; Ray.intersectSphere, intersectTriangle, intersectBox; Vector3.reflect; anything that renders the scene for you. |
| Unity (C#) | Physics.Raycast and every collider; Ray, Plane and Bounds helpers; Vector3.Reflect; Camera.ScreenPointToRay, ViewportPointToRay. The image is a Texture2D written in C#. |
git clone https://github.com/mgav-uwb/UWB-CSS-551-AU26-homework.git, or Code, then Download ZIP. It gains each homework the day it goes out; git pull fetches it.python3 -m http.server 8000 and open http://localhost:8000/homework/run.html?hw=hw06.lib/skeletons/hw06.js, the only file you change, and reload: the Checks table under the scene compares your numbers with the ones below.The unfilled skeleton runs on this site too, so you can see the page before you start. The setup, the blank page a file opened from disk gives, and how to read the Checks table are in WebGL and three.js for This Course.
homework/hw06/unity/ into Assets/HW06/.Checks component (namespace CSS551.HW06), and press Play: the Console lists every check with your value and the expected one.HW06.cs; the other files are given.The Unity files compile against a stand-in for the UnityEngine API and pass their checks with the reference solution, but they are new this quarter and have not yet been opened in the Unity editor. If one does not compile in 6000.3.11f1, post the error on the Canvas board and use the WebGL track meanwhile.
hw06.js.Library/, Temp/, Logs/ and obj/.Grading runs your functions twice: on the published inputs above and on a second set of inputs that is not published. A check earns its points only when your value is within its tolerance on both, so the numbers have to come from the math. The rubric score is the sum of the points earned, out of 100; it counts as 25 course points (the rubric score divided by 4). A submission that does not load or compile earns no check points. Name any collaborators and tools in the submission comment.