Open main menu

CDOT Wiki β

Changes

UnknownX

693 bytes added, 15:36, 11 April 2017
Assignment 1 Ray Tracing v2
[[File:Pycpu.PNG]]<br />
for (int y = 0; y < N; ++y) { for (int x = 0; x < N; ++x) { pix_col = black; const Ray ray(Vec3(x, y, 0), Vec3(0, 0, 1)); if (sphere.intersect(ray, t)) { const Vec3 pi = ray.o + ray.d*t; const Vec3 L = light.c - pi; const Vec3 N = sphere.getNormal(pi); const double dt = dot(L.normalize(), N.normalize()); pix_col = (red + white*dt) * 0.5; clamp255(pix_col); } pixs[3 * (y * N + x)] = (int)pix_col.x; pixs[3 * (y * N + x) + 1] = (int)pix_col.y; pixs[3 * (y * N + x) + 2] = (int)pix_col.z; } }
122
edits