Developing Graphics Frameworks with Python and OpenGL
eBook - ePub

Developing Graphics Frameworks with Python and OpenGL

Lee Stemkoski, Michael Pascale

Condividi libro
  1. 334 pagine
  2. English
  3. ePUB (disponibile sull'app)
  4. Disponibile su iOS e Android
eBook - ePub

Developing Graphics Frameworks with Python and OpenGL

Lee Stemkoski, Michael Pascale

Dettagli del libro
Anteprima del libro
Indice dei contenuti
Citazioni

Informazioni sul libro

Developing Graphics Frameworks with Python and OpenGL shows you how to create software for rendering complete three-dimensional scenes. The authors explain the foundational theoretical concepts as well as the practical programming techniques that will enable you to create your own animated and interactive computer-generated worlds.

You will learn how to combine the power of OpenGL, the most widely adopted cross-platform API for GPU programming, with the accessibility and versatility of the Python programming language. Topics you will explore include generating geometric shapes, transforming objects with matrices, applying image-based textures to surfaces, and lighting your scene. Advanced sections explain how to implement procedurally generated textures, postprocessing effects, and shadow mapping. In addition to the sophisticated graphics framework you will develop throughout this book, with the foundational knowledge you will gain, you will be able to adapt and extend the framework to achieve even more spectacular graphical results.

Domande frequenti

Come faccio ad annullare l'abbonamento?
È semplicissimo: basta accedere alla sezione Account nelle Impostazioni e cliccare su "Annulla abbonamento". Dopo la cancellazione, l'abbonamento rimarrà attivo per il periodo rimanente già pagato. Per maggiori informazioni, clicca qui
È possibile scaricare libri? Se sì, come?
Al momento è possibile scaricare tramite l'app tutti i nostri libri ePub mobile-friendly. Anche la maggior parte dei nostri PDF è scaricabile e stiamo lavorando per rendere disponibile quanto prima il download di tutti gli altri file. Per maggiori informazioni, clicca qui
Che differenza c'è tra i piani?
Entrambi i piani ti danno accesso illimitato alla libreria e a tutte le funzionalità di Perlego. Le uniche differenze sono il prezzo e il periodo di abbonamento: con il piano annuale risparmierai circa il 30% rispetto a 12 rate con quello mensile.
Cos'è Perlego?
Perlego è un servizio di abbonamento a testi accademici, che ti permette di accedere a un'intera libreria online a un prezzo inferiore rispetto a quello che pagheresti per acquistare un singolo libro al mese. Con oltre 1 milione di testi suddivisi in più di 1.000 categorie, troverai sicuramente ciò che fa per te! Per maggiori informazioni, clicca qui.
Perlego supporta la sintesi vocale?
Cerca l'icona Sintesi vocale nel prossimo libro che leggerai per verificare se è possibile riprodurre l'audio. Questo strumento permette di leggere il testo a voce alta, evidenziandolo man mano che la lettura procede. Puoi aumentare o diminuire la velocità della sintesi vocale, oppure sospendere la riproduzione. Per maggiori informazioni, clicca qui.
Developing Graphics Frameworks with Python and OpenGL è disponibile online in formato PDF/ePub?
Sì, puoi accedere a Developing Graphics Frameworks with Python and OpenGL di Lee Stemkoski, Michael Pascale in formato PDF e/o ePub, così come ad altri libri molto apprezzati nelle sezioni relative a Informatica e Grafica per computer. Scopri oltre 1 milione di libri disponibili nel nostro catalogo.

Informazioni

Editore
CRC Press
Anno
2021
ISBN
9781000407976
Edizione
1
Argomento
Informatica

CHAPTER 1

Introduction to Computer Graphics
DOI: 10.1201/9781003181378-1
The importance of computer graphics in modern society is illustrated by the great quantity and variety of applications and their impact on our daily lives. Computer graphics can be two-dimensional (2D) or three-dimensional (3D), animated, and interactive. They are used in data visualization to identify patterns and relationships, and also in scientific visualization, enabling researchers to model, explore, and understand natural phenomena. Computer graphics are used for medical applications, such as magnetic resonance imaging (MRI) and computed tomography (CT) scans, and architectural applications, such as creating blueprints or virtual models. They enable the creation of tools such as training simulators and software for computer-aided engineering and design. Many aspects of the entertainment industry make use of computer graphics to some extent: movies may use them for creating special effects, generating photorealistic characters, or rendering entire films, while video games are primarily interactive graphics-based experiences. Recent advances in computer graphics hardware and software have even helped virtual reality and augmented reality technology enter the consumer market.
The field of computer graphics is continuously advancing, finding new applications, and increasing in importance. For all these reasons, combined with the inherent appeal of working in a highly visual medium, the field of computer graphics is an exciting area to learn about, experiment with, and work in. In this book, you’ll learn how to create a robust framework capable of rendering and animating interactive three-dimensional scenes using modern graphics programming techniques.
Before diving into programming and code, you’ll first need to learn about the core concepts and vocabulary in computer graphics. These ideas will be revisited repeatedly throughout this book, and so it may help to periodically review parts of this chapter to keep the overall process in mind. In the second half of this chapter, you’ll learn how to install the necessary software and set up your development environment.

1.1 Core Concepts and Vocabulary

Our primary goal is to generate two-dimensional images of three-dimensional scenes; this process is called rendering the scene. Scenes may contain two- and three-dimensional objects, from simple geometric shapes such as boxes and spheres, to complex models representing real-world or imaginary objects such as teapots or alien lifeforms. These objects may simply appear to be a single color, or their appearance may be affected by textures (images applied to surfaces), light sources that result in shading (the darkness of an object not in direct light) and shadows (the silhouette of one object's shape on the surface of another object), or environmental properties such as fog. Scenes are rendered from the point of view of a virtual camera, whose relative position and orientation in the scene, together with its intrinsic properties such as angle of view and depth of field, determine which objects will be visible or partially obscured by other objects when the scene is rendered. A 3D scene containing multiple shaded objects and a virtual camera is illustrated in Figure 1.1. The region contained within the truncated pyramid shape outlined in white (called a frustum) indicates the space visible to the camera. In Figure 1.1, this region completely contains the red and green cubes, but only contains part of the blue sphere, and the yellow cylinder lies completely outside of this region. The results of rendering the scene in Figure 1.1 are shown in Figure 1.2.
FIGURE 1.1 Three-dimensional scene with geometric objects, viewing region (white outline) and virtual camera (lower right).
FIGURE 1.2 Results of rendering the scene from Figure 1.1
From a more technical, lower-level perspective, rendering a scene produces a raster—an array of pixels (picture elements) which will be displayed on a screen, arranged in a two-dimensional grid. Pixels are typically extremely small; zooming in on an image can illustrate the presence of individual pixels, as shown in Figure 1.3.
FIGURE 1.3 Zooming in on an image to illustrate individual pixels.
On modern computer systems, pixels specify colors using triples of floating-point numbers between 0 and 1 to represent the amount of red, green, and blue light present in a color; a value of 0 represents no amount of that color is present, while a value of 1 represents that color is displayed at full (100%) intensity. These three colors are typically used since photoreceptors in the human eye take in those particular colors. The triple (1, 0, 0) represents red, (0, 1, 0) represents green, and (0, 0, 1) represents blue. Black and white are represented by (0, 0, 0) and (1, 1, 1), respectively. Additional colors and their corresponding triples of values specifying the amounts of red, green, and blue (often called RGB values) are illustrated in Figure 1.4.
FIGURE 1.4 Various colors and their corresponding (R, G, B) values.
The quality of an image depends in part on its resolution (the number of pixels in the raster) and precision (the number of bits used for each pixel). As each bit has two possible values (0 or 1), the number of colors that can be expressed with N-bit precision is 2N. For example, early video game consoles with 8-bit graphics were able to display 28=256 different colors. Monochrome displays could be said to have 1-bit graphics, while modern displays often feature “high color” (16-bit, 65,536 color) or “true color” (24-bit, more than 16 million colors) graphics. Figure 1.5 illustrates the same image rendered with high precision but different resolutions, while Figure 1.6 illustrates the same image rendered with high resolution but different precision levels.
FIGURE 1.5 A single image rendered with different resolutions.
FIGURE 1.6 A single image rendered with different precisions.
In computer science, a buffer (or data buffer, or buffer memory) is a part of a computer's memory that serves as temporary storage for data while it is being moved from one location to another. Pixel data is stored in a region of memory called the framebuffer. A framebuffer may contain multiple buffers that store different types of data for each pixel. At a minimum, the framebuffer must contain a color buffer, which stores RGB values. When rendering a 3D scene, the framebuffer must also contain a depth buffer, which stores distances from points on scene objects to the virtual camera. Depth values are used to determine whether the various points on each object are in front of or behind other objects (from the camera’s perspective), and thus whether they will be visiblewhen the scene is rendered. If one scene object obscures another and a transparency effect is desired, the renderer makes use of alpha values: floating-point numbers between 0 and 1 that specifies how overlapping colors should be blended together; the value 0 indicates a fully transparent color, while the value 1 indicates a fully opaque color. Alpha values are also stored in the color buffer along with RGB color values; the combined data is often referred to as RGBA color values. Finally, framebuffers may contain a buffer called a stencil buffer, which may be used to store values used in generating advanced effects, such as shadows, reflections, or portal rendering.
In addition to rendering three-dimensional scenes, another goal in computer graphics is to create animated scenes. Animations consist of a sequence of images displayed in quick enough succession that the viewer interprets the objects in the images to be continuously moving or changing in appearance. Each image that is displayed is called a frame. The speed at which these images appear is called the frame rate and is measured in frames per second (FPS). The standard frame rate for movies and television is 24 FPS. Computer monitors typically display graphics at 60 FPS. For virtual reality simulations, developers aim to attain 90 FPS, as lower frame rates may cause disorientation and other negative side effects in users. Since computer graphics must render these images in real time, often in response to user interaction, it is vital that computers be able to do so quickly.
In the early 1990s, computers relied on the central processing unit (CPU) circuitry to perform the calculations needed for graphics. As real-time 3D graphics became increasingly common in video game platforms (inc...

Indice dei contenuti