Image Synthesis Rabie A. Ramadan, PhD 6. 2 3D Images.

Slides:



Advertisements
Similar presentations
Creative Computing. \\ aims By the end of the session you will be able to: 1.Explain the difference between various image file formats 2.Load in and display.
Advertisements

Graphics Shapes. Setup for using graphics You have to import the graphics library You can use either “import graphics” or “from graphics import *” or.
This terms course Last term we both worked on learning 2 things –Processing –The concepts of graphics etc. This term will focus more on the basic concepts.
Working with images and scenes CS 5010 Program Design Paradigms “Bootcamp” Lesson 2.5 TexPoint fonts used in EMF. Read the TexPoint manual before you delete.
Glencoe Physics Ch 4 Remember…. When drawing vectors… length = magnitude (with scale) angle = direction of the vector quantity. When drawing and moving.
Copyright © 2010, 2007, 2004 Pearson Education, Inc. All Rights Reserved. Lecture Slides Elementary Statistics Eleventh Edition and the Triola.
12.6 Rotations and Symmetry Rotation- a transformation in which a figure is turned around a point Center of rotation- the point the figure is rotated around.
CAP4730: Computational Structures in Computer Graphics Visible Surface Determination.
CHAPTER 12 Height Maps, Hidden Surface Removal, Clipping and Level of Detail Algorithms © 2008 Cengage Learning EMEA.
Computer Graphics Visible Surface Determination. Goal of Visible Surface Determination To draw only the surfaces (triangles) that are visible, given a.
1 Computer Graphics Week6 –Basic Transformations- Translation & Scaling.
Lecture 5 Sept 10 Goals: 2-d arrays Image representation Image processing examples Stack data structure.
Graphics File Formats. 2 Graphics Data n Vector data –Lines –Polygons –Curves n Bitmap data –Array of pixels –Numerical values corresponding to gray-
Twelve painting with procedures. Overview Making shaded images with procedures Making a more elegant language Making textures with noise functions.
Four simple expressions in meta. Data objects Pieces of data in a computer are called objects Today, we’ll talk about four kinds of objects Numbers Pictures.
Eighteen painting with procedures. Review [bitmap-from-procedure procedure width height] Returns a bitmap width pixels by height pixels Obtains colors.
Introduction to 3D Graphics John E. Laird. Basic Issues u Given a internal model of a 3D world, with textures and light sources how do you project it.
How Images are Represented Bitmap images (Dots used to draw the image) Monochrome images 8 bit grey scale images 24 bit colour Colour lookup tables Vector.
1 Bitmap Graphics It is represented by a dot pattern in which each dot is called a pixel. Each pixel can be in any one of the colors available and the.
Computer Systems Nat 4.5 Computing Science Data Representation Lesson 4: Storing Graphics EXTENSION.
Image Synthesis Rabie A. Ramadan, PhD 3. 2 Our Problem.
Higher Computing Computer Systems S. McCrossan 1 Higher Grade Computing Studies 1. Data Representation Data Representation – Why do we use binary? simplicity,
Week 2 - Wednesday CS361.
Texture Mapping. Scope Buffers Buffers Various of graphics image Various of graphics image Texture mapping Texture mapping.
Buffers Textures and more Rendering Paul Taylor & Barry La Trobe University 2009.
PROCESSING & JAVA An Introduction to Computing. Objectives Be able to state and apply phases of development Be able to state and describe the goals of.
Graphics and Animation Multimedia Projects Part 2.
2.7: Dilations.
Computer Science 111 Fundamentals of Programming I Introduction to Graphics.
Image Representation. Objectives  Bitmaps: resolution, colour depth and simple bitmap file calculations.  Vector graphics: drawing list – objects and.
Image Synthesis Rabie A. Ramadan, PhD 1. 2 About my self Rabie A. Ramadan My website and publications
به نام خدا تنظیم کننده : فرانه حدادی استاد : مهندس زمانیان تابستان 92.
1 Graphics CSCI 343, Fall 2015 Lecture 2 Introduction to HTML, JavaScript and WebGL.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M
Intro. to Advanced Lighting, Basic Ray Tracing Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Monday, April.
Adobe InDesign CS2—Revealed PLACING AND LINKING GRAPHICS.
Bitmap and Vector Graphics Bitmap Graphics Pictures are made up of little dots called pixels The colour of each dot is saved –Examples: Binary code representing.
Digital Media Dr. Jim Rowan ITEC So far… We have compared bitmapped graphics and vector graphics We have discussed bitmapped images, some file formats.
OpenGL Shader Language Vertex and Fragment Shading Programs.
Lecture 7: Intro to Computer Graphics. Remember…… DIGITAL - Digital means discrete. DIGITAL - Digital means discrete. Digital representation is comprised.
Vector components and motion. There are many different variables that are important in physics. These variables are either vectors or scalars. What makes.
Computer Systems Nat 4.5 Computing Science Data Representation Lesson 4: Representing and Storing Graphics EXTENSION.
Image Synthesis Rabie A. Ramadan, PhD 4. 2 Review Questions Q1: What are the two principal tasks required to create an image of a three-dimensional scene?
COMPUTER GRAPHICS. Can refer to the number of pixels in a bitmapped image Can refer to the number of pixels in a bitmapped image The amount of space it.
1 Graphics CSCI 343, Fall 2015 Lecture 3 Introduction to WebGL.
Digital Media Lecture 5: Vector Graphics Georgia Gwinnett College School of Science and Technology Dr. Jim Rowan.
Shadows David Luebke University of Virginia. Shadows An important visual cue, traditionally hard to do in real-time rendering Outline: –Notation –Planar.
Object Orientated Programming in Perl Simulated Models of Termites.
Graphics and Image Data Representations 1. Q1 How images are represented in a computer system? 2.
Graphics Basic Concepts 1.  A graphic is an image or visual representation of an object.  A visual representation such as a photo, illustration or diagram.
8. G. 4 Understand two two-dimensional figures are similar if the second can be obtained from the first by a sequence of rotations, reflections, translations,
Unit 2.6 Data Representation Lesson 3 ‒ Images
2.2: Translations.
Pixels, Colors and Shapes
Ying Zhu Georgia State University
Binary Notation and Intro to Computer Graphics
Computer Science Higher
Module 2 Lesson 2 Reflections Reflections.
1.3 Vectors and Scalars Scalar: shows magnitude
Images in Binary.
Data Representation.
Bitmap, Vector, Pixels, Resolution, Metadata.
OOP Paradigms There are four main aspects of Object-Orientated Programming Inheritance Polymorphism Abstraction Encapsulation We’ve seen Encapsulation.
Representing Motion Chapter 2.
Digital Media Dr. Jim Rowan ITEC 2110.
Introduction to Shaders
Computer Graphics 4Practical Lesson
2-9 Combining Like Terms Bell Work Evaluate each expression for y = 3.
2-9 Combining Like Terms Bell Work Evaluate each expression for y = 3.
Presentation transcript:

Image Synthesis Rabie A. Ramadan, PhD 6

2 3D Images

3 Representing and Loading 3D Terrains One common feature in games and other 3D programs is the presence of a 3D terrain.

4 How do we represent a terrain? The most straightforward approach, and, as it turns out, one of the best approaches, is To make a 2D grid in the x-z plane and store the height of the terrain at each grid point. This does not work with every train

5 How do we represent a terrain? We could hard code every height into the program itself. But it's better to store the heights in a separate file. The most straightforward type of file we can use is a grayscale image, where White represents the maximum allowable height and black represents the minimum allowable height. Such an image file is called a "heightmap". it allows us to see what our terrain looks like, even without rendering it in 3D

6 How do we represent a terrain? heightmap Below is a zoomed-in version of the heightmap for our program.

7 Going Through The Code we have #include "vec3f.h“ This includes a special vector class called "Vec3f", A vector of three floats. It does everything you'd expect vectors to do. You can add and subtract using + and -, multiply and divide using * and /, get or set the components using vec[0], vec[1], and vec[2], and do some other stuff.

8 Going Through The Code It stores a width and length, indicating the number of grid points in the x and z directions respectively. It stores all of the heights and the normals at each point using two-dimensional arrays. it has a bool that tells us whether the normals array actually has the correct normals.

9 constructor for the Terrain class It initializes all of our variables.

10 Destructor for the Terrain class The destructor deletes the two-dimensional arrays hs and normals

11 Get the width and length of the terrain

12 set and get the height of the terrain at a particular grid point

13 Computes and returns the normal at each/some point

14 Load Terrain load a terrain from an image file. First, we call ' loadBMP function to load the bitmap from file. Then' we go through the pixels of the array and use them to set the heights of the terrain.

15 Load Terrain A color of 0 corresponds to a height of -height / 2, and a color of 255 corresponds to a height of height / 2. It doesn't matter which color component we use. The red component is used for no particular reason. Then, we delete the image and force the terrain to compute all of the normals.

16 scale our terrain it is at most 5 units wide and 5 units long. Then, we translate it so it's centered.

17 Here, we draw the terrain. GL_TRIANGLE_STRIP is new. It makes OpenGL draw a triangle at every three consecutive vertices that you indicate. If your vertices are v1, v2, v3,..., then OpenGL will draw the triangles (v1, v2, v3), (v2, v3, v4), (v3, v4, v5),.... To draw the terrain, for each z, we do a triangle strip with vertices (0, h1, z), (0, h2, z + 1), (1, h3, z), (1, h4, z + 1), (2, h5, z), (2, h6, z + 1),

18 Using triangle strips is not only more convenient than using triangles; it's faster, as there are fewer 3D vertices to send to the graphics card. So, our terrain is drawn as shown below:

19 Main

20

21 Rough and Smoothed

22 Smoothing How exactly are we going to smooth the normals? For each normal, let's average in a little bit of the surrounding normals.