三部曲:
http://www.realtimerendering.com/raytracing/Ray Tracing in a Weekend.pdf
http://www.realtimerendering.com/raytracing/Ray Tracing_ The Next Week.pdf
http://www.realtimerendering.com/raytracing/Ray Tracing_ the Rest of Your Life.pdf
source code:
https://github.com/RayTracing/raytracing.github.io/blob/master/index.html
i have taught many graphics classes over the years. often i do them in ray tracing, because u are forced to write all the code but u can still get cool images with no api. i decided to adapt 改编 my course notes into a how-to, to get u to a cool program as quickly as possible. it will not be a full-featured ray tracer, but it does have the indirect lighting which has made ray tracing a staple in movies.
follow these steps, and the architecture of the ray tracer u produce will be good for extending to a more extensive ray tracer if u get excited and want to purse that.
when somebody says “ray tracing” it could mean many things. what i am going to describe is technically a path tracer, and a fairly general one. while the code will be pretty simple (let the computer do the work!) i think u will be very happy with the images u can make.
i will take u through writing a ray tracer in the order i do it, along with some debugging tips. by the end, u will have a ray tracer that produces some great images. u should be able to do this in a weekend.
if u take longer, do not worry about it. i use C++ as the driving language, but u do not need to. however, i suggest u do, because it is fast, portable, and most production movie and video game renderers are written in C++. note that i avoid most “modern features” of C++, but inheritance and operator overloading are too useful for ray tracers to pass on. i do not provide the code online, but the code is real and i show all of it except for a few straightforward operators in the vec3 class.
i am a big believer in typing in code to learn it, but when code is available i use it, so i only practice what i preach when the code is not avaliable. so do not ask.
这作者脑子有点怀了吧,写的都是啥。
I have left that last part in because it is funny what a 180 I have done. Several readers ended up with subtle errors that were helped when we compared code. So please do type in the code, but if you want to look at mine it is at:
https://github.com/petershirley/raytracinginoneweekend
I assume a little bit of familiarity with vectors (like dot product and vector addition). If you don’t know that, do a little review. If you need that review, or to learn it for the first time, check out Marschner’s and my graphics text , Foley, Van Dam, et al ., or McGuire’s graphics codex .
chapter 1: output an image
whenever u start a renderer, u need a way to see an image. the most straightfoward way is to write it to a file.