GAMES101 Review--Ray Tracing

Ray Tracing

Ray tracing

Implementation steps

  1. Ray Generation: The ray tracing algorithm emits a main ray from the observer's point of view (such as the camera position). The starting point of this ray is the camera position, and the direction is the ray from the camera position through the pixel position.

  2. Ray-Object Intersection: The intersection calculation between the emitted main ray and the objects in the scene is performed. The algorithm checks whether the ray intersects any object in the scene to determine whether the ray has encountered an object surface.

  3. Determine the closest intersection: If the ray intersects an object in the scene, the algorithm determines the closest intersection point with the ray. This intersection point is usually the point on the surface of the object closest to the observer.

  4. Lighting calculation (Shading): After determining the nearest intersection point, the algorithm will calculate the lighting attributes of the point. This includes considering factors such as the location of the light source, the color of the light, the reflective properties of the object's surface, etc. to determine the color and brightness at the intersection.

  5. Reflection and Refraction: If the surface of the object has reflection or refraction properties, the algorithm will calculate the reflected ray or refracted ray based on the material properties of the object. These rays will continue to propagate from the intersection point and the next round of ray tracing will be performed.

  6. Shadow Calculation: For each intersection point in the lighting calculation, the algorithm checks whether the point is in shadow. This involves firing a shadow ray from the intersection location to the light source location, checking to see if the ray intersects with other objects in the scene. If there is an intersection, the intersection point is blocked and in shadow.

  7. Recursive Tracing: If the light is reflected or refracted, the algorithm will recursively perform the next round of ray tracing. This means firing a new ray from the reflection or refraction point and repeating the previous steps until the set tracking depth is reached or the ray no longer intersects the object.

  8. Image Composition: During the process of completing ray tracing, the algorithm calculates the color value of each pixel based on the calculated lighting and shadow information. Eventually, these color values ​​are combined into the final image.

Insert image description here

Differences from rasterization

  1. Rasterization is a rendering technology based on geometry that converts geometry into pixels for rendering, while ray tracing is a rendering technology based on light that simulates the propagation and interaction of light in the scene.

  2. Rasterization is a real-time rendering technology suitable for interactive applications and real-time rendering, such as games. Ray tracing generally requires more computing resources and time and is suitable for generating high-quality still images or animations.

  3. Rasterization can have occlusion issues when dealing with complex scenes, requiring the use of techniques such as depth testing and occlusion culling to deal with them. Ray tracing can handle complex light interactions such as occlusions and reflections, resulting in more realistic renderings.

  4. Rasterization typically uses polygons as the basic geometry, while ray tracing can handle arbitrarily shaped objects, including surfaces and volumes.

Direct illumination and global illumination

  1. Direct Lighting:
    Only direct lighting contributions in the scene are considered. It calculates the direct illumination of light from the light source to the object surface to determine the color and brightness of the object surface based on the position and properties of the light source.

  2. Global Illumination:
    Consider indirect lighting and light interactions such as multiple reflections and refraction in the scene. The global illumination model not only considers the direct illumination of the light source, but also considers the propagation, reflection, refraction and other processes of light in the scene to simulate the lighting effects in the real world. Global illumination models usually use algorithms such as ray tracing to trace the path of light, calculate the intersection of light and object surfaces, reflection and refraction of light, etc., and consider the interaction of light and other objects in the scene to obtain more realistic lighting effects.

Whitted ray tracing

Whitted Style Ray Tracing is a classic ray tracing algorithm proposed by Turner Whitted in 1980. It is the basis of the ray tracing algorithm and the basis for various subsequent improvements and extensions.

The basic idea is
to emit a ray from the camera or observer position, and then find the point where the ray intersects the object by testing for intersection with the object in the scene. At the intersection point, the color value of the light is calculated by taking into account the way the light travels, such as reflection and refraction.

Basic equation:

L = L_e + k_d * L_d + k_s * L_s + k_r * L_r

Whitted style ray tracing mainly focuses on the simulation of local lighting effects, calculating the color of light by considering diffuse reflection and specular reflection. The color of diffusely reflected light is determined by the diffuse reflection coefficient of the object surface and the color of the light source, and the color of specularly reflected light is determined by the specular reflection coefficient of the object surface and the color of the reflected light.

path tracing

The basic equation of path tracing can be described as:

L(O, W) = L_e(O, W) + ∫[S] f_r(X, W, W’) * L(X, W’) * |cosθ| dA

Among them, L(O, W) represents the radiant brightness from the observation point O along the direction W, L_e(O, W) represents the self-illumination brightness at the observation point O, f_r(X, W, W') represents the surface of the object at The reflection function at point X, L(X, W') represents the radiance from point X along direction W', θ represents the angle between the incident light and the normal, and dA represents the differential area.

The basic idea is
to emit a ray from the camera or observer position, and then find the point where the ray intersects the object by testing for intersection with the object in the scene. Then, the propagation path of the light is traced through random sampling, including reflection, refraction, scattering, etc. Finally, the radiance of the light at the observation point is calculated by Monte Carlo integration of all paths.

The
difference between path tracing and traditional ray tracing algorithms is that path tracing considers multiple reflections and scattering of light, while traditional ray tracing algorithms usually only consider one reflection. Path tracing simulates the complex propagation and interaction process of light in the scene by tracing the propagation path of light, which can generate more realistic lighting effects and rendering results.

There is a problem with whittled style ray tracing

  • Diffuse reflection without lighting considerations
  • The difference between Mirror and Glossy

Guess you like

Origin blog.csdn.net/m0_51947486/article/details/132187616