Raycasting

from Wikipedia, the free encyclopedia

Raycasting (mostly ray casting in English ) is a term from computer graphics . It describes techniques for the rapid representation ( rendering ) of a three-dimensional scene , but is now mainly used in the context of volume visualization . The exact definition of the term varies depending on the context.

Raycasting in volume visualization

Raycasting is a method of visualizing scalar functions in a three-dimensional volume that occur in many scientific applications . In the medical field, examples are: Computed tomography (CT), magnetic resonance tomography (MRT) or positron emission tomography (PET). In the field of numerical simulation, with a finite element method (FEM) for Computational Fluid Dynamics (CFD), in which the flow behavior of gases and liquids is calculated. The scalar data obtained here, for example density or temperature , can be visualized using various methods, including raycasting. A distinction is made between direct and indirect methods. Indirect methods visualize the volume with the help of a polygonal intermediate representation. Marching cubes is one of these indirect methods. Direct methods visualize the volume without generating such intermediate data. These techniques include ray casting and splatting . A further distinction is made between image-space-oriented processes (image order) and object-space-oriented processes (object order).

Raycasting as a process in volume visualization

The basic idea is how volume data can be visualized with the help of raycasting. The theoretical basis is the volume rendering equation, a combination of emission and absorption . Raycasting solves ( approximates ) this problem.

Skull visualized from a voxel dataset using raycasting

Raycasting process

Raycasting sends a visual ray (primary rays) through the volume for each pixel of the viewer (of the image to be calculated). The ray is tracked within the volume and the color and opacity values ​​are determined at regular intervals at the sampling points on the ray. The shading at all sampling points is also calculated for the color values. The vector thus obtained, for the line of sight, contains the ordered sample values ​​(color, opacity values), the color values ​​corresponding to the source term and the opacity values ​​corresponding to the extinction coefficient. In a final step, compositing , the color and opacity values ​​are combined and the pixel resulting from the line of sight is calculated in the image plane.

Raycasting as simple ray tracing

Raycasting often refers to a simple form of raytracing , a well-known rendering process. The three-dimensional scene is regularly scanned in accordance with specified specifications such as the viewer's position and perspective, so that a two-dimensional image of a section is created. In contrast to extended ray tracing variants, the scanning of a ray ends when the ray and the object meet, so only an occlusion calculation takes place. The color determined at this intersection forms the pixel color value. Reflections, refractions and transmissions of the object are not taken into account. This technique enables a very quick preview of a scene.

Raycasting is sometimes used synonymously with ray tracing.

Raycasting in computer games

Raycasting in computer games: scanning a two-dimensional map with regular rays

In computer game development , the term raycasting refers to the calculation of a pseudo-3D view based on a two-dimensional map. On the basis of the distance to an object hit by a "ray of vision", on the one hand the object color is displayed centered vertically and on the other hand the proportion of the ceiling or floor of the corresponding pixel column is calculated. In contrast to normal ray tracing technology, only a single image line is scanned in order to calculate the entire image; the occlusion calculation takes place only in one plane and not in space. This type of raycasting is used, for example, in the Wolfenstein 3D computer game .

The pixel color is determined according to the graphic above (upper "stripe") and a vertical area is drawn in this color according to the distance. All other areas are sky or ceiling or floor.

Since this technology does not correspond to a real 3D, it is subject to various restrictions: no three-dimensional objects such as people and objects can be displayed, floor and ceiling are always the same height and slopes are not possible.

Various workarounds have been found that are supposed to create the impression of three-dimensionality. Two-dimensional graphics, so-called sprites , are used for any objects that are scaled and inserted into the calculated image. In advanced games like Duke Nukem 3D, these were selected depending on the angle, so that an object looks different from the front than from the back.

Textures for walls, floors and sky were built in that depict three-dimensional structures. Sky or ceiling and floor were made independently adjustable for sections of a map so that stairs, passages and the like were possible (for example in Doom ). With Duke Nukem 3D, sloping floors, skylights or ceilings were finally made possible and the viewpoint could be rotated vertically so that you could look up or down. However, this distorts the display strongly and unnaturally. Even with the best extensions, no superimposed three-dimensional objects such as bridges are possible. Representations of the same are always "faked" with the help of sprites or other tricks.

Raycasting became popular with the early first-person shooters Catacomb , Wolfenstein 3D, Doom, Heretic and Duke Nukem 3D, as it requires considerably less calculation time than real 3D.

Related to raycasting is the VoxelSpace algorithm introduced with the game Comanche for the visualization of height fields . Graphics engines based on this are often simply referred to as voxel engines, although no voxels are visualized.

Web links

Wikibooks: game worlds with raycasting  - learning and teaching materials

Individual evidence

  1. ^ Alan Watt, Mark Watt: Advanced Animation and Rendering Techniques Theory and Practice, pp. 305-312. Addison-Wesley, Reading 1992, ISBN 0-201-54412-1
  2. a b James Foley et al: Computer Graphics: Principles and Practice, p. 701. Addison-Wesley, Reading 1995, ISBN 0-201-84840-6
  3. Stefan Becker: "Representing virtual worlds with raycasting technology", c't 2/1996, p. 246, ISSN  0724-8679
  4. Boris Bert Elson include: PC Underground. Data Becker, Düsseldorf 1995, ISBN 3-8158-1185-6