📜 ⬆️ ⬇️

Tracing the path to the GPU, part 1

Iron and rendering
The most popular, to date, processor architecture - x86-64. They belong to the CISC. They have a huge set of commands, which led to a large area of ​​the core on the crystal. This, in turn, entailed the difficulty in implementing several cores on a chip. X86 processors are not ideal for multi-threaded computations that require multiple execution of a small instruction set (RISC).
In turn, the rendering is an algorithm that is perfectly parallelized on almost an unlimited number of cores.

Unbiased renders
In view of the fact that the productivity of iron is steadily increasing - technical issues (for example, sampling of reflections of materials in V-Ray, the number of bias during anti-aliasing, motion blur, depth of field, soft shadows) are increasingly shifting to iron. So, a few years ago the first commercial render “without assumptions” (unbiased render) - Maxwell Render appeared.
Its main advantage was the quality of the final image, a minimum of settings, all kinds of "bias". Over time, the quality of the image approaches the “ideal”. And the disadvantage was and is - the rendering time. It took a very long time to wait for the noise to come down, and many people immediately refused it after several tests. Things were even worse with animation (for obvious reasons).

image

Algorithm
1. A beam (the starting point corresponding to a specific pixel on the screen) is released from the camera.
2. Check whether the ray has crossed one of the geometry elements. If not, go to step 1.
3. Determine the point of intersection of the beam and the geometry nearest to the camera.
4. Release a new ray from the intersection point towards the light source.
5. If there is an obstacle in the beam between the intersection point and the light source, then go to step 7
6. Fill a pixel with color (simply, with the color of the surface at a given point multiplied by the intensity of the light source at the point of contact with the beam)
7. Release a new beam from the intersection point in an arbitrary direction, go to step 2, until the maximum number of reflections is reached (in most cases 4-8, if there are many reflections or refractions in the scene, then this number should be increased).
')
image
An example of "noisy" pictures.

The number of samples per pixel to achieve good quality can be measured in thousands. For example, 10 thousand (depending on the scene)
The number of rays per image FullHD 2mpix * 10 thousand - 20 billion
There are several ways to optimize the path tracing: Bi-Directional Path Tracing, Metropolis Light Transport, Energy Redistribution Path Tracing, designed to give off rays where necessary. Most CPU renders use the MLT algorithm for this purpose (Maxwell, Fry, Lux)

GPU role
The algorithm repeatedly uses floating point operations, and multithreading is vital for this algorithm. Therefore, this task is gradually accepted by the GPU.
Existing technologies: CUDA, FireStream, OpenCL, DirectCompute, and also there is the possibility of writing programs directly on shaders.

image

The situation is as follows:
CUDA - write to all who feel like it (iRay, Octane Render, Arion Render, Cycles, etc).
FireStream - nothing is visible at all.
OpenCL - SmallLuxGPU, Cycles, Indigo Render. It seems that no one takes seriously.
DirectCompute - can not see anything.
Shaders are just one example. WebGL implementation of tracing paths on shaders .

Comparison of renders will be in part 2.

Source: https://habr.com/ru/post/132862/


All Articles