News for hackers. Stuff that matters.
Re:Recursive raytracer in 35 lines of JavaScript by gumuz on Tuesday November 19, 2013 @04:50AM (#6760160)
Awesome! I tried to look into building a simple raytracer many times, but the either math gets me everytime or I just didn't come across the right "raytracer for dummies" tutorials.

Any suggestions?

Re:Recursive raytracer in 35 lines of JavaScript by ohwp on Tuesday November 19, 2013 @05:48AM (#6760341)
For many year I also tried to build a simple ray tracer. The math got me to, but in the end I was able to write different types of render engines.

What helped me:

  learn about vectors
  learn about (vector) normalization
  learn about camera models http://www.ventrella.com/Ideas/Camera/Arm_Camera.pdf
  learn about pixels (pixels are just dots without size)
  use a 3D coordinate-system that works for you (mine is: x = right, y = forward, z = up)
  start with a simple camera model (always looking forward)
  normalize all direction vectors
  place the screen of pixels 1 unit in front of the camera
  normalize the screen of pixels
  know that the center pixel is on the forward vector of the camera
  try to calculate a vector from the camera position to the left top of the pixel screen in front of the camera
Re:Recursive raytracer in 35 lines of JavaScript by ggambetta on Tuesday November 19, 2013 @05:30AM (#6760291)
The fully commented (but not entirely clean) code is here: http://www.gabrielgambetta.com/tiny_raytracer_full.js

Also, I'm halfway through writing a Computer Graphics textbook, half of it dedicated to raytracing.

Re:Recursive raytracer in 35 lines of JavaScript by jamiek88 on Tuesday November 19, 2013 @09:06AM (#6761193)
I'd buy it, please post the link once its done, or if you want any proof readers or people to type in the code to check for typos I'd be happy to help.
Re:Recursive raytracer in 35 lines of JavaScript by tripzilch on Wednesday November 20, 2013 @04:45PM (#6771403)
Possibly more than you asked for, but it's great material:

http://scratchapixel.com/

(on a not-particularly-raytracing-related note, I can really recommend to anyone interested the lesson about colour spaces, first time the point of CIExy and sRGB became clear to me. also for anyone wondering why the colours in F.lux / Redshift shift the way they do, check the "blackbody radiation" chapter)