diff --git a/Home.md b/Home.md index a43da02..217c879 100644 --- a/Home.md +++ b/Home.md @@ -55,13 +55,13 @@ So, the goal of this step is to make sure that we can a) create an image in memo -

Этап второй, самый сложный: непосредственно трассировка лучей

-Это самый важный и сложный этап из всей цепочки. Я хочу определить в моём коде одну сферу и показать её на экране, не заморачиваясь ни материалами, ни освещением. Вот так должен выглядеть наш результат: +

Step 2, the crucial one: ray tracing

+This is the most important and difficult step of the whole chain. I want to define one sphere in my code and show it on the screen without being obsessed with materials or lighting. This is how our result should look like: -Для удобства в моём репозитории по одному коммиту на каждый этап; Github позволяет очень удобно просматривать внесённые изменения. Вот, например, что изменилось во втором коммите по сравнению с первым. +For the sake of convenience, I have one commit per step in my repository; Github makes it very easy to view the changes made. Here, for instance, what was changed by the second commit. -Для начала: что нам нужно, чтобы в памяти компьютера представить сферу? Нам достаточно четырёх чисел: трёхмерный вектор с центром сферы и скаляр, описывающий радиус: +To begin with, what do we need to represent the sphere in the computer's memory? Four numbers are enough: a three-dimensional vector for the center of the sphere and a scalar describing the radius: ```c++ struct Sphere { Vec3f center; @@ -84,9 +84,9 @@ struct Sphere { }; ``` -Единственная нетривиальная вещь в этом коде - это функция, которая позволяет проверить, пересекается ли заданный луч (исходящий из orig в направлении dir) с нашей сферой. Детальное описание алгоритма проверки пересечения луча и сферы можно прочитать тут, очень рекомендую это сделать и проверить мой код. +The only non-trivial thing in this code is a function that allows you to check if a given ray (originating from orig in the direction of dir) intersects with our sphere. A detailed description of the algorithm for the ray-sphere intersection can be found here, I highly recommend you to do this and check my code. -Как работает трассировка лучей? Очень просто. На первом этапе мы просто замели картинку градиентом: +How does the ray tracing work? It is pretty simple. At the first step we just filled the picture with a gradient of colors: ```c++ for (size_t j = 0; j -Если пересечения со сферой нет, то мы поставим цвет1, иначе цвет2: +If there is no intersection with sphere we draw the pixel with color1, otherwise with color2: ```c++ Vec3f cast_ray(const Vec3f &orig, const Vec3f &dir, const Sphere &sphere) { float sphere_dist = std::numeric_limits::max();