Computer Graphics with OpenGL · Computer Graphics Introduction To Computer Graphics Asst. Prof....

30
CCS6020 Computer Graphics Introduction To Computer Graphics Asst. Prof. Dr. Bujar Raufi Asst. Dr. Visar Shehu Computer Science Department Contemporary Sciences And Technologies South East European University

Transcript of Computer Graphics with OpenGL · Computer Graphics Introduction To Computer Graphics Asst. Prof....

Page 1: Computer Graphics with OpenGL · Computer Graphics Introduction To Computer Graphics Asst. Prof. Dr. Bujar Raufi Asst. Dr. Visar Shehu Computer Science Department Contemporary Sciences

CCS6020 Computer Graphics

Introduction To Computer Graphics

Asst. Prof. Dr. Bujar Raufi

Asst. Dr. Visar Shehu

Computer Science Department Contemporary Sciences And Technologies

South East European University

Page 2: Computer Graphics with OpenGL · Computer Graphics Introduction To Computer Graphics Asst. Prof. Dr. Bujar Raufi Asst. Dr. Visar Shehu Computer Science Department Contemporary Sciences

COURSE MATERIALS

Course Website:

Libri (https://libri.seeu.edu.mk)

Syllabus:

On Libri

Page 3: Computer Graphics with OpenGL · Computer Graphics Introduction To Computer Graphics Asst. Prof. Dr. Bujar Raufi Asst. Dr. Visar Shehu Computer Science Department Contemporary Sciences

A QUESTION?

Where did this image came from?

What hardware/software did we need to produce it?

Page 4: Computer Graphics with OpenGL · Computer Graphics Introduction To Computer Graphics Asst. Prof. Dr. Bujar Raufi Asst. Dr. Visar Shehu Computer Science Department Contemporary Sciences

WHAT IS COMPUTER GRAPHICS ? Computer graphics is concerned with producing

pictures and objects using the computer.

Creating objects & pictures (modelling)‏

Displaying objects & pictures (rendering)‏

Interacting with pictures

The field of computer graphics

Methods and Principles (geometry, physics, optics, etc.)‏

Algorithms and data structures

Software/hardware tools

Applications

Page 5: Computer Graphics with OpenGL · Computer Graphics Introduction To Computer Graphics Asst. Prof. Dr. Bujar Raufi Asst. Dr. Visar Shehu Computer Science Department Contemporary Sciences

COMPUTER GRAPHICS PARADIGMS Traditional (this course): modelling rendering

Other paradigms

Data visualization

Image-based rendering (Google 3D Warehouse)‏

Computer graphics vs. image processing/vision

Modeling Rendering

user interface

Models pictures

graphics

Image processing/vision

Page 6: Computer Graphics with OpenGL · Computer Graphics Introduction To Computer Graphics Asst. Prof. Dr. Bujar Raufi Asst. Dr. Visar Shehu Computer Science Department Contemporary Sciences

COMPUTER GRAPHICS APPLICATIONS

Entertainment: movie production, animation, special effects, games.

Presentation: Web, e-commerce, publishing, computer art, advertisement, education.

Design: CAD/CAM, ECAD, fashion design, architectural design.

Simulation: complex experiments, flight simulation, surgical simulation, traffic control, power plants, etc.

Graphical user interface(GUI): bitmap window systems, interface tools, VR systems.

Scientific visualization: biological image analysis, medical diagnosis, weather data, satellite data, remote sensing, NASA data, simulation data, etc.

Page 7: Computer Graphics with OpenGL · Computer Graphics Introduction To Computer Graphics Asst. Prof. Dr. Bujar Raufi Asst. Dr. Visar Shehu Computer Science Department Contemporary Sciences

DISPLAY DEVICES

Line-drawing displays (vector display)‏

Fast, accurate line drawing (e.g. plotter).

Early technology (vector graphics)‏

Cannot draw smooth & shaded surfaces

Raster display

Current technology (raster graphics)‏

Pixel based raster screen (CRT)‏

Supported by frame buffer

High quality realistic images

Page 8: Computer Graphics with OpenGL · Computer Graphics Introduction To Computer Graphics Asst. Prof. Dr. Bujar Raufi Asst. Dr. Visar Shehu Computer Science Department Contemporary Sciences

TYPICAL RASTER GRAPHICS SYSTEM

Graphics Processor (GPU)

Frame Buffer

Monitor (CRT/LCD)‏

Input devices Output device

Image formed in frame buffer

Page 9: Computer Graphics with OpenGL · Computer Graphics Introduction To Computer Graphics Asst. Prof. Dr. Bujar Raufi Asst. Dr. Visar Shehu Computer Science Department Contemporary Sciences

INPUT DEVICES‏ Physical Input Devices Mouse

Trackball

Data tablet

Joystick

Space ball

Logical Devices (from inside the application) Widget (menus, scrollbars, slidebars,

graphical buttons)

Other customizable graphical elements

Page 10: Computer Graphics with OpenGL · Computer Graphics Introduction To Computer Graphics Asst. Prof. Dr. Bujar Raufi Asst. Dr. Visar Shehu Computer Science Department Contemporary Sciences

GRAPHICS PROCESSOR UNIT (GPU)‏

‘Co-Processor’ dedicated to Display Operations

Can be emulated by CPU at the cost of speed

Vendor-Specific APIs common

Handle Matrix/Vector operations, texture mapping, shading, depth-buffering and more

Page 11: Computer Graphics with OpenGL · Computer Graphics Introduction To Computer Graphics Asst. Prof. Dr. Bujar Raufi Asst. Dr. Visar Shehu Computer Science Department Contemporary Sciences

FRAME BUFFER

Pixel: the smallest screen unit that can be lighted with a color value independently

Raster: 2D array of pixels

Frame buffer : a 2D array of memory cells made of high speed memory chips, corresponding one-to-one to the raster.

Frame buffer cell: the frame buffer memory cell (often called pixel as well)‏

Page 12: Computer Graphics with OpenGL · Computer Graphics Introduction To Computer Graphics Asst. Prof. Dr. Bujar Raufi Asst. Dr. Visar Shehu Computer Science Department Contemporary Sciences

1 1 1 1

1 1

1 1

1 1

0

0

0

0

0

0

4x4 Display - 8 bit-planes

8 bits of Colour Information Per Pixel

Resolution=width*height*bitplanes

FRAME BUFFER

Page 13: Computer Graphics with OpenGL · Computer Graphics Introduction To Computer Graphics Asst. Prof. Dr. Bujar Raufi Asst. Dr. Visar Shehu Computer Science Department Contemporary Sciences

COLOR DEPTH

N color bits per pixel = 2N colors

1 bit: 21 = 2 colors (black and white)‏

8 bits: 28 = 256 colors/color index values

24 bits: 224 colors (Typical RGB Display)‏

32 bits: 232 colors (Typical RGBA Display)‏

Different color systems assign different meanings to the available values

Page 14: Computer Graphics with OpenGL · Computer Graphics Introduction To Computer Graphics Asst. Prof. Dr. Bujar Raufi Asst. Dr. Visar Shehu Computer Science Department Contemporary Sciences

INDEXED COLOR WITH LOOK UP TABLE (LUT)‏

FrameBuffer LUT

0 1

1

RGB Index

011101011101101101 111

100100000101111001 110

000101110100111000 101

010000100101101001 100

011101010100000000 011

010001110101111001 010

100100100110101001 001

111101011101110001 000

Page 15: Computer Graphics with OpenGL · Computer Graphics Introduction To Computer Graphics Asst. Prof. Dr. Bujar Raufi Asst. Dr. Visar Shehu Computer Science Department Contemporary Sciences

WHY USE A “LUT”?

Page 16: Computer Graphics with OpenGL · Computer Graphics Introduction To Computer Graphics Asst. Prof. Dr. Bujar Raufi Asst. Dr. Visar Shehu Computer Science Department Contemporary Sciences

WHY USE A LUT? (cont.)‏

Display Size

RA

M U

sag

e

LUT

No-LUT

Assuming 24 bit color-depth 1024-entry LUT

Both grow exponentially in display size

LUT has smaller coefficient (Dx * Dy * Color Depth)

(Dx * Dy * LUT Depth) + LUT Size

Page 17: Computer Graphics with OpenGL · Computer Graphics Introduction To Computer Graphics Asst. Prof. Dr. Bujar Raufi Asst. Dr. Visar Shehu Computer Science Department Contemporary Sciences

MONITOR

Three electron beams: R, G, B beams

Electron beam refreshing rate: 60+ frames per second (HZ)‏

Flicker effect below ~30fps

Non-interlaced display: scanline by scanline, top to bottom, left to right, at stated refresh rate.

Interlaced display: odd rows and even rows are displayed alternately (effectively half non-interlaced rate)‏

In CRT There are three colored phosphors arranged in triangular groups called triads.

Page 18: Computer Graphics with OpenGL · Computer Graphics Introduction To Computer Graphics Asst. Prof. Dr. Bujar Raufi Asst. Dr. Visar Shehu Computer Science Department Contemporary Sciences

MONITOR

Page 19: Computer Graphics with OpenGL · Computer Graphics Introduction To Computer Graphics Asst. Prof. Dr. Bujar Raufi Asst. Dr. Visar Shehu Computer Science Department Contemporary Sciences

MONITOR

Page 20: Computer Graphics with OpenGL · Computer Graphics Introduction To Computer Graphics Asst. Prof. Dr. Bujar Raufi Asst. Dr. Visar Shehu Computer Science Department Contemporary Sciences

COMPLETE GRAPHICS SUBSYSTEM

Page 21: Computer Graphics with OpenGL · Computer Graphics Introduction To Computer Graphics Asst. Prof. Dr. Bujar Raufi Asst. Dr. Visar Shehu Computer Science Department Contemporary Sciences

GRAPHIC API's (Application Programming Interfaces)‏

A high level conceptual model of the graphics system, providing:

Object definitions View specification Lighting environment

We will study both sides of the OpenGL API: application programming, and the implementation of the API (graphics pipeline)‏

Application programs

Graphics API Low-level

graphics system

Page 22: Computer Graphics with OpenGL · Computer Graphics Introduction To Computer Graphics Asst. Prof. Dr. Bujar Raufi Asst. Dr. Visar Shehu Computer Science Department Contemporary Sciences

GRAPHIC API's

Purpose

Avoid system-dependent details

Platform-independent applications

Common graphics languages

2D standard: X-window, GKS, postscript

3D standard: PHIGS, PEX, OpenGL, Direct3D

Hardware-Level: CG, Glide

Common features: object description, attributes, viewing functions, transformations, interactions, controls, etc.

Page 23: Computer Graphics with OpenGL · Computer Graphics Introduction To Computer Graphics Asst. Prof. Dr. Bujar Raufi Asst. Dr. Visar Shehu Computer Science Department Contemporary Sciences

DISPLAY STACK

X Window MSCOM/.NET

Hardware

Hardware-Level Graphics APIs

UNIX Windows

OpenGL, OpenGL ES (WebGL) DirectX

Programming Environment

Page 24: Computer Graphics with OpenGL · Computer Graphics Introduction To Computer Graphics Asst. Prof. Dr. Bujar Raufi Asst. Dr. Visar Shehu Computer Science Department Contemporary Sciences

GRAPHICS PIPELINE Computer Graphic Development Cycle

Scene/Model: Geometric representation of shape information, material and

optical properties, and lighting conditions Model/View transform(s):

Transformation of objects from the scene coordinate system (world coordinate system) to camera coordinate system (viewing coordinate system)‏

Clipping: Removal of scene elements outside the viewing area

Projection: Mapping from 3D space to 2D viewing plane Rasterization:

Mapping from geometric model to discrete pixel values

Scene/Model Model/View

Transform Rasterization Projection Clipping

Page 25: Computer Graphics with OpenGL · Computer Graphics Introduction To Computer Graphics Asst. Prof. Dr. Bujar Raufi Asst. Dr. Visar Shehu Computer Science Department Contemporary Sciences

COMPUTER GRAPHICS: 1980-1990

Realism comes to computer graphics

smooth shading environment mapping

bump mapping

Page 26: Computer Graphics with OpenGL · Computer Graphics Introduction To Computer Graphics Asst. Prof. Dr. Bujar Raufi Asst. Dr. Visar Shehu Computer Science Department Contemporary Sciences

COMPUTER GRAPHICS: 1980-1990

Special purpose hardware

Silicon Graphics geometry engine

VLSI implementation of graphics pipeline

Industry-based standards

PHIGS

RenderMan

Networked graphics: X Window System

Human-Computer Interface (HCI)

Page 27: Computer Graphics with OpenGL · Computer Graphics Introduction To Computer Graphics Asst. Prof. Dr. Bujar Raufi Asst. Dr. Visar Shehu Computer Science Department Contemporary Sciences

Computer Graphics: 1990-2000

OpenGL API

Completely computer-generated feature-length movies (Toy Story) are successful

New hardware capabilities

Texture mapping

Blending

Accumulation, stencil buffers

Page 28: Computer Graphics with OpenGL · Computer Graphics Introduction To Computer Graphics Asst. Prof. Dr. Bujar Raufi Asst. Dr. Visar Shehu Computer Science Department Contemporary Sciences

Computer Graphics: 2000-

Photorealism

Graphics cards for PCs dominate market

Nvidia, ATI

Game boxes and game players determine direction of market

Computer graphics routine in movie industry: Maya, Lightwave

Programmable pipelines

Page 29: Computer Graphics with OpenGL · Computer Graphics Introduction To Computer Graphics Asst. Prof. Dr. Bujar Raufi Asst. Dr. Visar Shehu Computer Science Department Contemporary Sciences

READING MATERIALS?

Edward Angel, Interactive Computer Graphics: A Top-Down Approach With Shader Based OpenGL. 6th Edition. 2012

Chapter I

Page 30: Computer Graphics with OpenGL · Computer Graphics Introduction To Computer Graphics Asst. Prof. Dr. Bujar Raufi Asst. Dr. Visar Shehu Computer Science Department Contemporary Sciences

QUESTIONS?