DOC

Using Texture Mapping Techniques to Simulate Lights and ...

By Walter Marshall,2014-06-12 17:27
9 views 0
Using Texture Mapping Techniques to Simulate Lights and ...Usin

    Light and Shadow Mapping

    Using Texture Mapping Techniques to Simulate Lights and Shadows in

    Real Time Computer Graphics

    Author: Tomasz Zaniewski

    November 2000

    1

    Light and Shadow Mapping

    Using Texture Mapping Techniques to

    Simulate Lights and Shadows in Real Time

    Computer Graphics

    Author: Tomasz Zaniewski

    Supervisor: Professor Shaun Bangay

    November 2000

    Submitted in partial fulfillment of the

    requirements for the Bachelor of

    Science (Honours) degree in the

    Department of Computer Science at

    Rhodes University.

    2

    Light and Shadow Mapping

    Acknowledgements Acknowledgements

    Firstly, I would like to thank my supervisor, Shaun Bangay, for his assistance in this project and for finding some serious bugs in my code.

    Secondly, I would also like to thank my parents, for giving me all the support that made it possible for me to engage in postgraduate studies.

    I would also like to than the Computer Science Department of Rhodes University for providing and giving access to all the resources necessary for completing the project.

    3

    Light and Shadow Mapping

    Table of contents Table of contents

    Chapter 1: Introductory Chapter ………………………………………………………………….1 1.1 Abstract….………………………………………………………………..………….1

    1.2 Development tools …………………………………………………………………………………2 1.3 Layout of document ...……………………………………………………………………………...2

    Chapter 2: Background to Lighting and Texture mapping…………………………………….4 2.1 Introduction………………………………………………………………………………………….4 2.2 Light………………………………………………………………………………………………….4 2.3 Shading………………………………………………………………………………………………7

    2.3.1 Flat shading……………………………………………………………………………...7

    2.3.2 Gouraud shading………………………………………………………………………..7

    2.3.3 Phong Shading…………………………………………………………………………..8 2.4 Texture Mapping…………………………………………………………………………………….8 2.5 Other mapping techniques…………………………………………………………………………10

    2.5.1 Affine Mapping…………………………………………………………………………..11

    2.5.2 Perspective texture mapping…………………………………………………………..11

    2.5.3 Bump Mapping…………………………………………………………………………..11

    2.5.4 Environment mapping…………………………………………………………………..11 2.6 Summary……………………………………………………………………………………………..12

    Chapter 3 Light Mapping: Background and Design……………………………………………..13 3.1 Introduction…………………………………………………………………………………………..13

    3.1.1 Problem statement………………………………………………………………………13 3.2 Introduction to light mapping ……………………………………………………………………….14 3.2.1 Why use light maps?………………………………………………………………………………15

    3.2.3 Static light mapping………………………………………………………………………16

    3.2.3.1 Disadvantages of using static light maps …………………………………22

    3.2.4 Dynamic light maps………………………………………………………………………22

    3.2.4.1 Disadvantages of using dynamic light maps………………………………23

    3.2.5 Three-dimensional light maps…………………………………………………………..23 3.3 Related work………………………………………………………………………………………….24

    3.3.1 The H-Test………………………………………………………………………………..24

    3.3.2 Generalization of the shading Model…………………………………………………..28 3.4 Design…………………………………………………………………………………………………29

    4

    Light and Shadow Mapping

    3.4.1 Goal of the model……………………………………………………………………….29

    3.4.2 The concept……………………………………………………………………………...30

    3.4.3 The mapping function…………………………………………………………………...31

    3.4.4 Structure of spherical light map………………………………………………………..32

    Rectangular co ordinates…………………………………………………………….32

    Spherical co ordinates………………………………………………………………..32

    3.4.4.1 Structure of light map using rectangular co ordinates……………………33

    3.4.4.2 Structure of light map using spherical co ordinates………………………33

    3.4.5 The light object……………………………………………………………………………35

    3.4.6 Generating the light map………………………………………………………………..35

    3.4.7 Combining light maps……………………………………………………………………35

    3.4.8 Rotating the light map……………………………………………………………………36

    3.4.9 Using the light map……………………………………………………………………….36

    3.4.10 Design of experimental work…………………………………………………………..36

    3.4.10.1 Correctness………………………………………………………………….37

    3.4.10.2 Speed…………………………………………………………………………37

    3.4.10.3 Accuracy……………………………………………………………………...38 3.5 Summary………………………………………………………………………………………………38

    Chapter 4 :Light Mapping: Implementation…………………………………………………………39 4.1 Introduction……………………………………………………………………………………………39 4.2 Object representation………………………………………………………………………………..39 4.3 The Transformation System…….…………………………………………………………………..42 4.4 Transformation of normal vectors…………………………………………………………………..43 4.5 The light object………………………………………………………………………………………..45 4.6 Generating the light map…………………………………………………………………………….46 4.7 The mapping function………………………………………………………………………………..48 4.8 Rotating the light maps………………………………………………………………………………50 4.9 Combining light maps………………………………………………………………………………..53 4.10 Summary………………………………………………………………………………………….….53

    Chapter 5: Results and conclusion…………………………………………………………………..54 5.1 Results…………………………………………………………………………………………………54

    5.1.1 Correctness………………………………………………………………………………..54

    5.1.2 Speed………………………………………………………………………………………59

    5.1.3 Accuracy…………………………………………………………………………………..60 5.2 Conclusion…………………………………………………………………………………………….61

    5

    Light and Shadow Mapping

    Chapter 6 Shadow mapping: Background and related work……………………………………63 6.1 Problem statement……………………………………………………………………………………63 6.2 Introduction……………………………………………………………………………………………63 6.3 Shadow algorithms…………………………………………………………………………………...64

    6.3.1 The scan line algorithm…………………………………………………………………..64

    6.3.2 The transformation algorithm……………………………………………………………65

    6.3.3 The shadow volume algorithm…………………………………………………………..65

    6.3.4 The shadow buffer algorithm…………………………………………………………….67

    6.3.5 Projected Shadows……………………………………………………………………….67 6.4 Related work…………………………………………………………………………………………..68

    6.4.1 Generating soft shadows using the shadow volume algorithm……………………...68

    6.4.2 Speeding up the shadow buffer…………………………………………………………69

    6.4.3 Incorporating the shadow buffer into real time graphics……………………………..70 6.5 Examples of shadows in real time graphics……………………………………………………….70

    Chapter 7: Shadow mapping: Design……………………………………………………………….72 7.1 Introduction and problem statement……………………………………………………………….72 7.2 Design…………………………………………………………………………………………………73

    7.2.1 The shadow map…………………………………………………………………………73

    7.2.2 Transforming into light co ordinates……………………………………………………73

    7.2.3 Silhouette extraction……………………………………………………………………..74

    7.2.4 Superimposing the texture………………………………………………………………75

    7.2.5 The texture mapper………………………………………………………………………75

    7.2.6 Testing…………………………………………………………………………………….75 7.3 Summary………………………………………………………………………………………………75

    Chapter 8: Shadow mapping: Implementation……………………………………………………..76 8.1 Introduction……………………………………………………………………………………………76 8.2 The Shadow map…………………………………………………………………………………….76 8.3 Creating the transformation matrix………………………………………………………………….77 8.4 Drawing the silhouette……………………………………………………………………………….78 8.5 Superimposing the shadow map on the texture…………………………………………………..79 8.6 The texture mapper…………………………………………………………………………………..81

    Chapter 9: Results and conclusions…………………………………………………………………82 9.1 Results…………………………………………………………………………………………………82

    6

    Light and Shadow Mapping

    9.2 Conclusions………………………………………………………………………………………….83

    list of references ………………………………………………………………………………………84

    Appendix

    A…………………………………………………………………………….87

    Appendix

    B…………………………………………………………………………….92

    7

    Light and Shadow Mapping

    Chapter 1 Chapter 1

    Introductory Chapter Introductory Chapter

1.1 Abstract

    Texture mapping was born as a technique to add realism to a scene by wrapping a bitmap onto a polygon and making it appear as though the bitmap is going through the same transformations as the polygon. From then it has grown considerably. Today it is used to simulate things like shiny surfaces (environment mapping), rough surfaces (bump mapping) without adding any additional geometry. Recently, texture mapping has been used to simulate lights and to a certain extent shadows.

    The research here shows just how applicable texture mapping techniques are to simulating lights and shadows. This is done by using texture mapping techniques to replace a light in the scene by a light map and than showing that the scene is still illuminated in the same manner as with the conventional light. The research also investigates the effects of combining light maps and rotating the light maps. It also shows that the light map does improve performance of the Phong shading algorithm.

    8

    Light and Shadow Mapping

    In the area of shadows, the paper examines some of the most popular shadow casting algorithms and then implements a simple shadow casting algorithm to show how texture mapping can be used to cast shadows onto multi planar surfaces.

1.2 Development tools

    The code written in this project needs to be able to modify the way in which polygons are rendered at pixel level. Tools such as OpenGL and DirectX do not allow the programmer to do this. Take lightning as an example, with these tools a programmer may select if the scene is to be rendered using the flat, Gouraud or Phong shading algorithm. A programmer may not however change the way these shading models are implemented and he/she cannot add her own shading model. For this reason OpenGL and DirectX were not used in the code written.

    What is necessary for this project, are tools that can do the following: open a window, plot a pixel at a point with co ordinates x and y, change the color of the point to be drawn and provide me with a drawing area in the form of a chunk of memory. The Qt 2.1.0 library that comes standard with Red Hat 6.2 Linux provides the necessary tools.

    The language used to develop the applications is C++. I chose this language because it is the language I am most familiar with. It is also the language of choice when it comes to programming computer graphics. Linux also has an efficient compiler for the language.

    The operating system used is Linux. I chose this because I saw it as an opportunity to learn more about the operating system, which is quickly becoming a serious competitor for Windows.

1.3 Layout of document

    This report is divided into nine chapters. Each chapter tackles an entirely new topic. I have aimed to write it in a way that has logical progression in it. The first chapter introduces the reader the basic knowledge required in order to understand lighting and texture mapping.

Chapter 1: Introductory chapter

    Chapter 2: This chapter provides the reader with some background knowledge in the field of lighting and texture mapping in computer graphics.

    9

    Light and Shadow Mapping

    Chapter 3: Deals with the concept of light mapping and also looks at work done by others in order to modify the conventional lighting model. It also outlines some of the design issues associated with the light mapping model implemented during the project

    Chapter 4: Deals with the implementation of the experimental light map model. It points out some of the most important algorithms and also focuses on problem areas in the implementation and how they were overcome.

    Chapter 5: Results of testing the light map model are presented in this chapter. Possible explanations for unexpected results are given and conclusions are drawn.

    Chapter 6: This chapter introduces some of the more popular shadow generation algorithms, it looks at extensions made by others to these algorithms and also looks at why they are not used in most real time graphics applications.

    Chapter 7: Design of the shadow algorithm implemented during the project is discussed

Chapter 8: The implementation of the shadow algorithm is discussed here.

    Chapter 9: Results of the algorithm are presented in this chapter. Conclusions are drawn and recommendations for improving the implementation are made.

    10

Report this document

For any questions or suggestions please email
cust-service@docsford.com