Beginning WebGL for HTML5 Expert s Voice in Web Development 1st ed. Edition Danchilla download
Beginning WebGL for HTML5 Expert s Voice in Web Development 1st ed. Edition Danchilla download
https://ebookfinal.com/download/beginning-webgl-for-html5-expert-
s-voice-in-web-development-1st-ed-edition-danchilla/
https://ebookfinal.com/download/beginning-google-sketchup-
for-3d-printing-expert-s-voice-in-3d-printing-1st-ed-edition-sandeep-
singh/
https://ebookfinal.com/download/foundations-of-qt-development-expert-
s-voice-in-open-source-1st-ed-edition-thelin/
HTML5 Games Creating Fun with HTML5 CSS3 and WebGL 1st
Edition Jacob Seidelin
https://ebookfinal.com/download/html5-games-creating-fun-with-
html5-css3-and-webgl-1st-edition-jacob-seidelin/
https://ebookfinal.com/download/html5-games-2nd-edition-creating-fun-
with-html5-css3-and-webgl-jacob-seidelin/
https://ebookfinal.com/download/beginning-nokia-apps-development-qt-
and-html5-for-symbian-and-meego-1st-edition-ray-rischpater/
https://ebookfinal.com/download/linux-kernel-networking-
implementation-and-theory-expert-s-voice-in-open-source-1st-ed-
edition-rosen/
https://ebookfinal.com/download/html5-for-web-designers-1st-edition-
jeremy-keith/
Beginning WebGL for HTML5 Expert s Voice in Web
Development 1st ed. Edition Danchilla Digital Instant
Download
Author(s): Danchilla, Brian
ISBN(s): 9781430239963, 1430239964
Edition: 1st ed.
File Details: PDF, 9.74 MB
Year: 2012
Language: english
Beginning WebGL
for HTML5
Brian Danchilla
Beginning WebGL for HTML5
Copyright © 2012 by Brian Danchilla
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material
is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting,
reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval,
electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter
developed. Exempted from this legal reservation are brief excerpts in connection with reviews or scholarly
analysis or material supplied specifically for the purpose of being entered and executed on a computer system,
for exclusive use by the purchaser of the work. Duplication of this publication or parts thereof is permitted only
under the provisions of the Copyright Law of the Publisher’s location, in its current version, and permission
for use must always be obtained from Springer. Permissions for use may be obtained through RightsLink at the
Copyright Clearance Center. Violations are liable to prosecution under the respective Copyright Law.
ISBN-13 978-1-4302-3996-3
ISBN-13 978-1-4302-3997-0 (eBook)
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every
occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial
fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are
not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to
proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication,
neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or
omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material
contained herein.
President and Publisher: Paul Manning
Lead Editor: Ben Renow-Clarke
Technical Reviewer: Massimo Nardone
Editorial Board: Steve Anglin, Ewan Buckingham, Gary Cornell, Louise Corrigan, Morgan Ertel, Jonathan
Gennick, Jonathan Hassell, Robert Hutchinson, Michelle Lowman, James Markham, Matthew
Moodie, Jeff Olson, Jeffrey Pepper, Douglas Pundick, Ben Renow-Clarke, Dominic Shakeshaft,
Gwenan Spearing, Matt Wade, Tom Welsh
Coordinating Editor: Jennifer Blackwell, Anamika Panchoo
Copy Editor: Nancy Sixsmith
Compositor: SPi Global
Indexer: SPi Global
Artist: SPi Global
Cover Designer: Anna Ishchenko
Distributed to the book trade worldwide by Springer Science + Business Media New York, 233 Spring Street, 6th
Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348–4505, e-mail orders-ny@springer-sbm.com,
or visit www.springeronline.com.
For information on translations, please e-mail rights@apress.com, or visit www.apress.com.
Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use.
eBook versions and licenses are also available for most titles. For more information, reference our Special Bulk
Sales–eBook Licensing web page at www.apress.com/bulk-sales.
Any source code or other supplementary materials referenced by the author in this text is available to readers at
www.apress.com. For detailed information about how to locate your book’s source code, go to
www.apress.com/source-code.
For Tressa, as fierce as she is delicate.
Contents at a Glance
iv
Contents
v
N CONTENTS
Three-Dimensional Rendering.............................................................................................. 26
2D Models in a 3D World ............................................................................................................................. 26
An Example with Depth ............................................................................................................................... 28
Summary .............................................................................................................................. 32
N Chapter 2: Shaders 101 .............................................................................................33
Graphics Pipelines ................................................................................................................ 33
Fixed Functionality or Programmable Shaders............................................................................................ 33
Why Shaders?.............................................................................................................................................. 34
The WebGL Graphics Pipeline ...................................................................................................................... 34
Basic Usage.......................................................................................................................... 37
Setting Up a Shader Program ...................................................................................................................... 37
Clean Up ...................................................................................................................................................... 38
Loading Shaders with Ajax .......................................................................................................................... 39
vi
N CONTENTS
Lighting ................................................................................................................................ 75
Light Components........................................................................................................................................ 75
Types of Lights............................................................................................................................................. 75
Normal Vectors ............................................................................................................................................ 76
vii
N CONTENTS
viii
N CONTENTS
ix
N CONTENTS
x
N CONTENTS
xi
N CONTENTS
Antialiasing......................................................................................................................... 282
Nonphotorealistic Rendering .............................................................................................. 283
Cartoon Shading ........................................................................................................................................ 283
Technical Diagrams ................................................................................................................................... 285
xii
N CONTENTS
N Index ........................................................................................................................323
xiv
About the Author
xv
About the Technical Reviewer
xvi
Acknowledgments
I would like to thank my family: mom, dad, Robert, Karen, Tressa. Longtime friends: Vince, Nick, and Tim. It was
not always a smooth journey during this book project and I am very grateful for your support along the way.
Thank you to everyone on the Apress team who was involved with this book. I would especially like to thank
Ben Renow-Clarke for getting this book title off the ground, Louise Corrigan for valuable editing advice, Anamika
Panchoo for her coordinating skills, and the technical reviewing of Massimo Nardone.
Thank you to my university professor David Mould for introducing me to OpenGL,and my high school art
teacher Mrs. Robinson for helping develop my artistic side.
I am thankful for having a good set of headphones and a great music collection that enabled me to zone in
and work. Thanks to late, late night Super Mario Galaxy 2 sessions for inspiration and coffee, lots of coffee.
Several years ago, I first read computer graphics books and thoroughly enjoyed the experience. Now I am
blessed to have been able to write my own book about an exciting new technology, WebGL.
xvii
Introduction
WebGL (Web-based Graphics Language) is a wonderful and exciting new technology that lets you create
powerful 3D graphics within a web browser. The way that this is achieved is by using a JavaScript API that
interacts with the Graphics Processing Unit (GPU). This book will quickly get you on your way to demystify
shaders and render realistic scenes. To ensure enjoyable development, we will show how to use debugging tools
and survey libraries which can maximize productivity.
Audience
Beginning WebGL for HTML5 is aimed at graphics enthusiasts with a basic knowledge of computer graphics
techniques. A knowledge of OpenGL, especially a version that uses the programmable pipeline, such as OpenGL
ES is beneficial, but not essential. We will go through all the relevant material. A JavaScript background will
certainly help.
When writing a book of this nature, we unfortunately cannot cover all the prerequisite material. Baseline
assumptions about the reader need to be made. The assumptions that I have made are that the reader has a
basic knowledge of 2D and 3D computer graphics concepts such as pixels, colors, primitives, and transforms.
Appendix B quickly refreshes these concepts. It is also assumed that the reader is familiar (though need not be an
expert) with HTML, CSS, and JavaScript. Although much of the book makes use of plain “vanilla” JavaScript, we
will use some jQuery. Appendix A discusses newer HTML5 concepts and a quick jQuery crash course that will be
essential for properly understanding the text. Appendix D provides a complete reference for further reading on
topics that are presented throughout the book.
xviii
N INTRODUCTION
Book Structure
It is recommended that you start by reading the first two chapters before moving on to other areas of the book.
Even though the book does follow a fairly natural progression, you may choose to read the book in order or skip
around as desired. For example, the debugging section of Chapter 9 is not strictly essential, but is very useful
information to know as soon as possible.
Chapter 5: Physics
This chapter shows how to model gravity, elasticity, and friction. We detect and react to collisions, model
projectiles and explore both the conservation of momentum and potential and kinetic energy.
xix
Discovering Diverse Content Through
Random Scribd Documents
On Morris’s return to the Base Camp, the party was completed.
One of the difficulties in having so large an outfit as ours was the
difficulty of obtaining transport when necessary. Therefore, as soon
as we saw signs of the monsoon, it was necessary to make
arrangements for our return, as at least fifteen days were required
to collect the still large number of animals required for our moving.
These animals have to be searched for all down the Dzakar Chu,
collected, and brought up; nor when once collected could they be
kept waiting for very long, as the supply of fodder in the upper
valley was absolutely nil—fodder did not exist. When we sent off the
previous party they travelled as lightly as possible, but even then the
small number of animals which was required for their transport had
not been obtained with any great ease. Fortunately, John Macdonald
was with us and was free, and it was owing to his help (for he
speaks Tibetan as well as Nepali, and is thoroughly accustomed to
deal with the people) that the two parties of Strutt and Norton were
able to proceed with such little delay. It had required a full fifteen
days to collect enough animals to move the main body. I had
arranged for a latitude of one or two days, which meant that they
should have spare food up to that extent, but beyond that it would
be quite impossible, naturally, to make provision. Of course, as one
of our secondary objects we had hoped, if our party had not been
exhausted, to have explored the West Rongbuk and the great glens
on the Western faces of Everest. And besides this most interesting
piece of exploration, of which really not very much more than
glimpses were obtained during 1921, there is the prodigious and
fascinating group of Cho Uyo and Gyachang Kang to be explored.
Watching the Dancers, Rongbuk Monastery.
As I before pointed out, of course, not only was our major work
and the whole object of the Expedition the tackling of the great
mountain, but also it was a race against the weather, so we could let
nothing interfere with our main object. It was quite clear now, as we
were situated, that an exploration of the West Rongbuk was entirely
beyond consideration. Not only was the whole party fairly played
out, but to get up enthusiasm in a new direction after what we had
gone through was pretty nearly out of the question. Somervell, the
absolutely untireable, had very strong yearnings in that direction,
but it would have been nothing more than a scramble in the dark if
he had gone. The weather was broken and was getting worse and
worse every day. Snow fell occasionally even at our camp. Further
up everything was getting smothered. Everest, when we had
glimpses of it, was a smother of snow from head to foot, and no one
who saw it in these days could ever imagine that it was a rock peak.
I am afraid also that most of us had only one real idea at the time,
and that was to get out of the Rongbuk Valley. However, during our
wait for the transport the annual fête of the Rongbuk Monastery
occurred. There was a great pilgrimage to the monastery to receive
the blessing of the Lama and to witness the annual dances. Most of
our party went down to see dances, and Noel especially to
cinematograph the whole ceremony, dances as well as religious
ceremonies. I have not done justice up to this point to Noel’s work.
He was quite indefatigable from the start, and had lost no
opportunity during our march up, not only of taking many pictures of
the country and Expedition, both with his ordinary camera and with
his cinema camera, but of studying Tibetan life as well. He had in
the Rongbuk Valley pitched his developing tents near the only
available clear water at the moment, and had there been untiring in
developing his cinema photographs. He had made two expeditions to
the head of the East Rongbuk Glacier, and had even taken his
cameras and his cinema outfit on to the North Col itself where he
remained for no less than four days—a most remarkable tour de
force. On the last occasion he had accompanied the evacuation
party, and had been actually taking pictures of the start of the last
attempt to get to the North Col and to climb Everest. Of course, his
performances with the camera are entirely unprecedented. The
amount of work he carried out was prodigious, and the enthusiasm
he displayed under the most trying conditions of wind and weather
was quite wonderful. We now feel that we can produce a real
representation of our life and of life in Tibet in a manner in which it
has never hitherto been brought before people’s eyes, and this gives
a reality to the whole Expedition which I hope will make all those
who are interested in mountain exploration understand the
wonderful performances and the great difficulties under which the
climbing members of this Expedition and the transport officers
laboured.
After the news of the accident had been received, we immediately
got in touch with the great Lama of Rongbuk, who was intensely
sympathetic and kind over the whole matter. It is very strange to
have to deal with these curious people; they are an extraordinary
mixture of superstition and nice feelings. Buddhist services were
held in the monasteries for the men who had been lost and for the
families; and all the porters, and especially the relations of the men
who were killed, were received and specially blessed by the Rongbuk
Lama himself. All the Nepalese tribes who live high up in the
mountains, and also the Sherpa Bhotias, have a belief that when a
man slips on the mountains and is killed, or when he slips on a cliff
above a river and falls into it and is drowned, that this is a sacrifice
to God, and especially to the god of the actual mountain or river.
They further believe that anyone whosoever who happens to be on
the same cliff or on the same mountain at the same place, exactly at
the same time of year, on the same date and at the same hour, will
also immediately slip and be killed.
I also received during our return a very kind letter from the
Maharajah of Nepal condoling with us on the loss of our porters. He
writes as follows:—
“Personally, and as a member of the Royal Geographical Society, I
share with you the grief that must have resulted from the frustration
of the keen hope entertained by you and the party. My heartiest
sympathies go to you and to the families of the seven men who lost
their lives in the attempt. This puts in my mind the curious belief
that persistently prevails with the people here, and which I came to
learn so long ago in the time of our mutual friend, Colonel Manners
Smith, when the question of giving permission for the project of
climbing the King of Heights through Nepal was brought by you and
discussed in a council of Bharadars. It is to the effect that the height
is the abode of the god and goddess Shiva and Parvati, and any
attempt to invade the privacy of it would be a sacrilege fraught with
disastrous consequences to this Hindu country and its people, and
this belief or superstition, as one may choose to call it, is so firm and
strong that people attribute the present tragic occurrence to the
divine wrath which on no occasion they would draw on their heads
by their actions.”
This, I must point out, is, of course, the Southern and Hindu
people’s tradition, and did not in the same way affect all the porters
whom we employed, as they were Buddhists by faith. The whole of
our people, however, took the view common to both and dismissed
their troubles very rapidly and very lightly, holding simply that the
men’s time had come, and so there was no more to be said about it.
If their time had not come, they would not have died. It had come,
and they had died and that was all. What need to say any more? As
a matter of fact, this philosophic way of looking on everything also
allowed them to say that they were perfectly ready to come back for
the next attempt, because if it was written that they should die on
Everest, they should die on Everest; if it was written that they would
not die on Everest, they would not, and that was all there was to be
said in the matter.
CHAPTER III
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookfinal.com