Jason McKesson avatar Jason McKesson committed b053f84

Rewrote the preface, and expanded on the texturing section.

Comments (0)

Files changed (7)

Documents/Basics/Tutorial 00.xml

             math operations will be introduced and explained as needed when they are first used. And
             unlike the math operations introduced here, most of them are not component-wise
             operations.</para>
+        <formalpara>
+            <title>Range Notation</title>
+            <para>This book will frequently use standard notation to specify that a value must be
+                within a certain range.</para>
+        </formalpara>
+        <para>If a value is constrained between 0 and 1, and it may actually have the values 0 and
+            1, then it is said to be <quote>on the range</quote> [0, 1]. The square brackets mean
+            that the range includes the value next to it.</para>
+        <para>If a value is constrained between 0 and 1, but it may not actually have a value of 0,
+            then it is said to be on the range (0, 1]. The parenthesis means that the range does not
+            include that value.</para>
+        <para>If a value is constrained to 0 or any number greater than zero, then the infinity
+            notation will be used. This range is represented by [0, ∞). Note that infinity can never
+            be reached, so it is always exclusive. A constraint to any number less than zero, but
+            not including zero would be on the range (-∞, 0).</para>
     </section>
     <section>
         <title>Graphics and Rendering</title>
-        <para>This is an overview of the process of rendering. Don't worry if you don't understand
+        <para>This is an overview of the process of rendering. Do not worry if you don't understand
             everything right away; every step will be covered in lavish detail in later
             tutorials.</para>
         <para>Everything you see on your computer's screen, even the text you are reading right now
                 complicated.</para>
         </note>
         <para>An object is made out of a series of adjacent triangles that define the outer surface
-            of the object. Such serieses of triangles are often called
-                <glossterm>geometry</glossterm>, a <glossterm>model</glossterm> or a
+            of the object. Such series of triangles are often called
+            <glossterm>geometry</glossterm>, a <glossterm>model</glossterm> or a
                 <glossterm>mesh</glossterm>. These terms are used interchangeably.</para>
         <para>The process of rasterization has several phases. These phases are ordered into a
             pipeline, where triangles enter from the top and a 2D image is filled in at the bottom.
                 </mediaobject>
             </figure>
             <para>To make it easier to use this, OpenGL also offers the guarantee that if you pass
-                the same input vertex data through same vertex processor, you will get identical
+                the same input vertex data through the same vertex processor, you will get identical
                 output; this is called the <glossterm>invariance guarantee</glossterm>. So the onus
                 is on the user to use the same input vertices in order to ensure gap-less scan
                 conversion.</para>
             <para>Shaders for OpenGL are run on the actual rendering hardware. This can often free
                 up valuable CPU time for other tasks, or simply perform operations that would be
                 difficult if not impossible without the flexibility of executing arbitrary code. A
-                downside of this is that they must live within certain limits, some of them quite
-                il-defined, that CPU code does not have to.</para>
+                downside of this is that they must live within certain limits that CPU code would
+                not have to.</para>
             <para>There are a number of shading languages available to various APIs. The one used in
                 this tutorial is the primary shading language of OpenGL. It is called,
                 unimaginatively, the OpenGL Shading Language, or <acronym>GLSL</acronym>. for short.
                 API.</para>
             <para>The API, in C, is defined by a number of typedefs, #defined enumerator values, and
                 functions. The typedefs define basic GL types like <type>GLint</type>,
-                    <type>GLfloat</type> and so forth.</para>
+                    <type>GLfloat</type> and so forth. These are defined to have a specific bit
+                depth.</para>
             <para xml:id="OpenGLObjects">Complex aggregates like structs are never directly exposed
                 in OpenGL. Any such constructs are hidden behind the API. This makes it easier to
                 expose the OpenGL API to non-C languages without having a complex conversion
             <title>The OpenGL Specification</title>
             <para>To be technical about it, OpenGL is not an API; it is a specification. A document.
                 The C API is merely one way to implement the spec. The specification defines the
-                initial OpenGL state, what each function does, and what is supposed to happen when
-                you call a rendering function.</para>
+                initial OpenGL state, what each function does to change or retrieve that state, and
+                what is supposed to happen when you call a rendering function.</para>
             <para>The specification is written by the OpenGL <glossterm>Architectural Review
                     Board</glossterm> (<acronym>ARB</acronym>), a group of representatives from
                 companies like Apple, NVIDIA, and AMD (the ATI part), among others. The ARB is part
                 implementation. Just because the spec says that X will happen does not mean that it
                 actually does. What it means is that the user should not be able to tell the
                 difference. If a piece of hardware can provide the same behavior in a different way,
-                then the specification allows this, so long as the user can never tell.</para>
+                then the specification allows this, so long as the user can never tell the
+                difference.</para>
             <formalpara>
                 <title>OpenGL Implementations</title>
                 <para>While the OpenGL ARB does control the specification, it does not control
                     <para>Deprecation only means marking those functions as to be removed in later
                         functions. They are still available for use in 3.0.</para>
                 </footnote>. This also divided the specification into 2 variations (called
-                profiles): core and compatibility. The compatibility profile has all of the
+                profiles): core and compatibility. The compatibility profile retains all of the
                 functions removed in 3.1, while the core profile does not. Theoretically, OpenGL
                 implementations could implement just the core profile; this would leave software
                 that relies on the compatibility profile non-functional on that

Documents/Building the Tutorials.xml

     <title>Building the Tutorials</title>
     <para>These tutorials require a number of external libraries in order to function. The specific
         version of these libraries that the tutorials use are distributed with the tutorials. The
-        tutorial source distribution can be found <link
-            xlink:href="http://bitbucket.org/alfonse/gltut/downloads">here</link>. This section will
-        describe each of the external libraries, how to build them, and how to build the tutorials
-        themselves.</para>
+        tutorial <link xlink:href="http://bitbucket.org/alfonse/gltut/downloads">source
+            distribution</link> can be found online. This section will describe each of the external
+        libraries, how to build them, and how to build the tutorials themselves.</para>
     <para>You will need minimal familiarity with using the command line in order to build these
         tutorials. Also, any mention of directories is always relative to where you unzipped this
         distribution.</para>
                 <filename>framwork/framework.cpp</filename>; it and all of the other source files in
             the <filename>framework</filename> directory is shared by every tutorial. It does the
             basic boilerplate work: creating a FreeGLUT window, etc. This allows the tutorial source
-            files to contain the useful OpenGL-specific code.</para>
+            files to focus on the useful OpenGL-specific code.</para>
     </simplesect>
 </article>

Documents/Texturing.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<?oxygen RNGSchema="http://docbook.org/xml/5.0/rng/docbookxi.rng" type="xml"?>
+<?oxygen SCHSchema="http://docbook.org/xml/5.0/rng/docbookxi.rng"?>
+<part xmlns="http://docbook.org/ns/docbook" xmlns:xi="http://www.w3.org/2001/XInclude"
+    xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0">
+    <?dbhtml filename="Texturing.html" dir="Texturing" ?>
+    <info>
+        <title>Texturing</title>
+    </info>
+    <partintro>
+        <para>If you are at all familiar with 3D graphics, you have probably heard the term
+                <quote>texture</quote> before. And if you look at virtually any instruction material
+            on 3D graphics, they will introduce textures in the earliest parts of the work.
+            Typically, this happens well before lighting is introduced.</para>
+        <para>This book is approximately halfway over and only now do we introduce textures. There
+            is a good reason for this.</para>
+        <para>Consider everything you have learned up until now. You have learned how to transfer
+            arbitrary data to vertex shaders, how to pass them to fragment shaders, and how to
+            compute colors from them. You have learned how to transform positions of triangles and
+            use this ability to provide a perspective projection of a world as well as to position
+            objects and have a mobile camera. You have learned how lighting works and how to
+            generate a lighting model. In the very last tutorial, we were able to convincingly
+            render a mathematically perfect representation of a sphere simply by rendering two
+            triangles.</para>
+        <para>All without textures. Thus, the first lesson this book has to teach you about textures
+            is that they aren't <emphasis>that</emphasis> important. What you have learned is how to
+            think about solving graphics problems without textures.</para>
+        <para>Many graphics texts overemphasize the importance of textures. This is mostly a legacy
+            of the past. In the older days, before real programmable hardware, you needed textures
+            to do anything of real importance in graphics rendering. Textures were used to simulate
+            lighting and various other effects. If you wanted to do anything like per-fragment
+            lighting, you had to use textures to do it.</para>
+        <para>Yes, textures are important for creating details in rendered images. They are
+            important for being able to vary material parameters over a polygonal surface. And they
+            have value in other areas as well. But there is so much more to rendering than textures,
+            and this is especially true with programmable hardware.</para>
+        <para>A texture is a look-up table; an array. There is a lot of bits of minutiae about
+            accessing them, but at their core, a texture is just a large array of some
+            dimensionality that you can access from a shader. Perhaps the most important lesson you
+            could learn is that textures are tools. Use them where appropriate, but do not let them
+            become your primary solution to any rendering problem.</para>
+    </partintro>
+</part>

Documents/Tutorials.xml

         <xi:include href="Illumination/tutorial 10.xml"/>
         <xi:include href="Illumination/tutorial 11.xml"/>
     </part>
-    <part>
-        <?dbhtml filename="Texturing.html" dir="Texturing" ?>
-        <info>
-            <title>Texturing</title>
-        </info>
-        <partintro>
-            <para>Lookup tables in rendering are usually called textures. This is due to the fact
-                that the main use for them is to modify the appearance of a surface. Even so,
-                textures have many uses.</para>
-        </partintro>
-    </part>
+    <xi:include href="Texturing.xml"/>
     <part>
         <?dbhtml filename="Framebuffer.html" dir="Framebuffer" ?>
         <title>Framebuffer</title>

Documents/preface.xml

     xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0">
     <?dbhtml filename="About these Tutorials.html" ?>
     <title>About this Book</title>
-    <para>This book is structured as a series of programming tutorials. Most chapters of the book
-        represent a series of tutorials on a particular subject. These tutorials build on one
-        another, demonstrating various 3D graphics programming techniques.</para>
-    <para>This book is designed for a beginning graphics programmer. To make use of this book, you
-        are expected to know the following</para>
-    <itemizedlist>
-        <listitem>
-            <para>C/C++ programming. You should be able to read C and mild C++. If <quote>Hello,
-                world!</quote> is the extent of your C/C++ knowledge, then perhaps you
-                should write some more substantial code before proceeding with trying to render
-                images.</para>
-            <para>These tutorials should be transferable to other languages as well. If you can
-                read C/C++, that is enough to understand what the code is doing. The text
-                descriptions that explain what the code does are also sufficient to get
-                information out of these tutorials.</para>
-        </listitem>
-        <listitem>
-            <para>Basic geometry and algebra math. The tutorials will present the more advanced
-                math needed for graphics, but you should have at least a working knowledge of
-                geometry and algebra. Linear algebra is not required, though it would be
-                helpful.</para>
-        </listitem>
-    </itemizedlist>
-    <note condition="web">
-        <title>Browser Note</title>
-        <para>This website and these tutorials make extensive use of SVG images. Basic SVG
-            support is in all major browsers except any version of Internet Explorer. And even
-            though IE has the dominant marketshare, I'm afraid that these images will remain SVG
-            images. If you are content with Internet Explorer, consider installing the Google
-            Chrome Frame add-on for IE8. This will allow you to see the images correctly.</para>
-    </note>
+    <para>Three dimensional graphics hardware is fast becoming, not merely a staple of computer
+        systems, but an indispensable component. Many operating systems directly use and even
+        require some degree of 3D rendering hardware. Even in the increasingly relevant mobile
+        computing space, 3D graphics hardware is a standard feature of all but the lowest power
+        devices.</para>
+    <para>Understanding how to make the most of that hardware is a difficult challenge, particularly
+        for someone new to graphics and rendering.</para>
     <section>
-        <title>Yet Another OpenGL Tutorial?</title>
-        <para><phrase condition="web">If you are here, then you are clearly interested in 3D
-                graphics programming with OpenGL. </phrase>There are a lot of materials, online and
-            in book form, that you chould use. So why should you use this book instead of
-            another?</para>
-        <para>Programmable graphics cards have been around, in one form or another, for almost
-            10 years. Programmability as a core features has been around in OpenGL for almost 5
-            years; various vendor-specific API extensions have been around even longer.</para>
-        <para>Yet despite the ubiquity of programmability in the lives of most graphics developers,
-            using programmability is often considered advanced material. Many 3D graphics teaching
-            materials focus on doing what they consider the easy things: using the OpenGL
-            fixed-function pipeline.</para>
-        <para>This indeed makes it very easy to actually accomplish something. If you want to
-            have a camera with a perspective projection over a scene of objects in a
-            well-defined world, these tutorials can show you how. They give you an effective
-            list of rules and API commands to execute in a particular order to achieve a certain
-            effect. But what they are terrible at is actually imparting
-            <emphasis>knowledge</emphasis> upon the reader.</para>
-        <para>It is easy to show someone how to use <function>gluLookAt</function>,
-                <function>gluPerspective</function>, and other functions to make everything simply
-            come out right. But because these functions hide the details of what is going on under
-            the hood, what the reader is often left with is a set of rules for how to make things
-            work: put this line of code in this place, and you get this effect.</para>
-        <para>Without the foundation of knowledge of what these functions actually are
-            <emphasis>doing</emphasis>, the reader is effectively living in a world of
-            copy-and-paste code. The reader can parrot code they found in a tutorial, but they
-            don't know why it works. And if they should copy it incorrectly or use it in the
-            wrong circumstances, they do not have the foundation of knowledge to diagnose the
-            problem and find a solution.</para>
-        <para>Without a real body of knowledge, such persons will quickly find using the
-            programmable functionality in OpenGL to be confusing and disorienting. Stripped of all
-            of the convenience functionality, such persons are left to their own devices. This is
-            doubly so, considering that while there are a lot of OpenGL tutorials and books, very
-            few of them go into any real depth in terms of programmability.</para>
-        <para>This book is designed first and foremost to <emphasis>teach</emphasis> the reader
-            valuable information about how graphics works. To this end, each and every tutorials
-            will use the OpenGL Shading Language and all modern (as of OpenGL 3.3) features of the
-            API. This makes it impossible to gloss over seemingly minor yet critical information
-            about how various features of the language and graphics hardware actually work.</para>
-        <note>
-            <para>As a side-effect, these tutorials all require OpenGL 3.3-capable hardware and
-                drivers. This means any GeForce 8xxx or better, or any Radeon HD-class card.
-                These are also called <quote>Direct3D 10</quote> cards, but you do not need
-                Windows Vista or 7 to use their advanced features through OpenGL.</para>
+        <title>Why Read This Book?</title>
+        <para>There are many physical books for teaching graphics. There are many more online
+            repositories of knowledge, in the form of wikis, blogs, tutorials, and forums. So what
+            does this book offer that others do not?</para>
+        <para>Programmability. Virtually all of the aforementioned sources instruct beginners using
+            something called <quote>fixed functionality.</quote> This represents configurations in
+            older graphics processors that define how a particular rendering operation will proceed.
+            It is generally considered easiest to teach neophyte graphics programmers using the
+            fixed function pipeline.</para>
+        <para>This is considered true because it is easy to get something to happen with fixed
+            functionality. It's simpler to make pictures that look like something real. The fixed
+            function pipeline is like training wheels for a bicycle.</para>
+        <para>There are downsides to this approach. First, much of what is learned with this
+            approach must be inevitably abandoned when the user encounters a graphics problem that
+            must be solved with programmability. Programmability wipes out almost all of the fixed
+            function pipeline, so knowledge does not easily transfer.</para>
+        <para>A more insidious problem is that the fixed function pipeline can give the
+                <emphasis>illusion</emphasis> of knowledge. A user can think they understand what
+            they are doing, but they're really just copy-and-pasting code around. Programming thus
+            becomes akin to magical rituals: you put certain bits of code before other bits, and
+            everything seems to work.</para>
+        <para>This makes debugging nightmarish. Because the user never really understood what the
+            code does, the user is unable to diagnose what a particular problem could possibly mean.
+            And without that ability, debugging becomes a series of random guesses as to what the
+            problem is.</para>
+        <para>By contrast, you cannot use a programmable system successfully without first
+            understanding it. Confronting programmable graphics hardware means confronting issues
+            that fixed function materials often gloss over. This may mean a slower start overall,
+            but when you finally get to the end, you truly <emphasis>know</emphasis> how everything
+            works.</para>
+        <para>Another problem is that, even if you truly understand the fixed function pipeline, it
+            limits how you think about solving problems. Because of its inflexibility, it focuses
+            your mind along certain problem solving possibilities and away from others. It
+            encourages you to think of textures as images, vertex data as texture coordinates,
+            colors, or positions, and the like. By its very nature, it limits creativity and problem
+            solving.</para>
+        <para>Lastly, even on mobile systems, fixed functionality is generally not available in the
+            graphics hardware. Programmability is the order of the day for most graphics hardware,
+            and this will only become more true in the future.</para>
+        <para>What this book offers is beginner-level instruction on what many consider to be an
+            advanced concept. It teaches programmable rendering for beginning graphics programmers,
+            from the ground up.</para>
+        <para>This book also covers some important material that is often neglected or otherwise
+            relegated to <quote>advanced</quote> concepts. These concepts are not really advanced,
+            but they are often ignored by most introductory material because they do not work with
+            the fixed function pipeline.</para>
+        <para>This book is first and foremost about learning how to be a graphics programmer.
+            Therefore, whenever it is possible and practical, this book will present material in a
+            way that encourages the reader to examine what graphics hardware can do in new and
+            interesting ways. A good graphics programmer sees the graphics hardware as a set of
+            tools to fulfill their needs, and this book tries to encourage this kind of
+            thinking.</para>
+        <para>One thing this book is not, however, is a book on graphics APIs. While it does use
+            OpenGL and out of necessity teach rendering concepts in terms of OpenGL, it is not truly
+            a book that is <emphasis>about</emphasis> OpenGL. It is not the purpose of this book to
+            teach you all of the ins and outs of the OpenGL API.There will be parts of OpenGL
+            functionality that are not dealt with because they are not relevant to any of the
+            lessons that this book teaches. If you already know graphics and are in need of a book
+            that teaches modern OpenGL programming, this is not it. It may be useful to you in that
+            capacity, but that is not this book's main thrust.</para>
+    </section>
+    <section>
+        <title>What You Need</title>
+        <para>This is a book for beginning graphics programmers; it can also serve as a book for
+            those familiar with fixed functionality who want to understand programmable rendering
+            better. But this is not a book for beginning programmers.</para>
+        <para>You are expected to be able to read C and reasonable C++ code. If <quote>Hello,
+                world!</quote> is the extent of your C/C++ knowledge, then perhaps you should write
+            some more substantial code before proceeding with trying to render images. 3D graphics
+            rendering is simply not a beginner programming task; this is just as true for
+            traditional graphics learning as for modern graphics learning.</para>
+        <para>These tutorials should be transferable to other languages as well. If you can read
+            C/C++, that is enough to understand what the code is doing. The text descriptions that
+            explain what the code does are also sufficient to get information out of these
+            tutorials.</para>
+        <para>Any substantial discussion of 3D rendering requires a discussion of mathematics, which
+            are at the foundation of all 3D graphics. This book expects you to know basic geometry
+            and algebra.</para>
+        <para>The tutorials will present the more advanced math needed for graphics as it becomes
+            necessary, but you should have at least a working knowledge of geometry and algebra.
+            Linear algebra is not required, though it would be helpful.</para>
+        <para>The code tutorials in this book use OpenGL as their rendering API. You do not need to
+            know OpenGL, but to execute the code, you must have a programming environment that
+            allows OpenGL. Specifically, you will need hardware capable of running OpenGL version
+            3.3. This means any GeForce 8xxx or better, or any Radeon HD-class card. These are also
+            called <quote>Direct3D 10</quote> cards, but you do not need Windows Vista or 7 to use
+            their advanced features through OpenGL.</para>
+    </section>
+    <section>
+        <title>Organization of This Book</title>
+        <para>This book is broken down into a number of general subjects. Each subject contains
+            several numbered chapters called tutorials. Each tutorial describes several related
+            concepts. In virtually every case, each concept is demonstrated by a companion set of
+            code.</para>
+        <para>Each tutorial begins with an overview of the concepts that will be discussed and
+            demonstrated. At the end of each tutorial is a review section and a glossary of all
+            terms introduced in that tutorial. The review section will explain the concepts
+            presented in the tutorial. It will also contain suggestions for playing with the source
+            code itself; these are intended to further your understanding of these concepts. If the
+            tutorial introduced new OpenGL functions or functions for the OpenGL shading language,
+            they will be reviewed here as well.</para>
+        <note condition="web">
+            <title>Browser Note</title>
+            <para>This website and these tutorials make extensive use of SVG images. Basic SVG
+                support is in all major browsers except all Internet Explorer versions before
+                version 9. If you are content with these versions of Internet Explorer, consider
+                installing the Google Chrome Frame add-on for IE8. This will allow you to see the
+                images correctly.</para>
         </note>
-        <para>This does not mean that you need to have read other tutorials first. As previously
-            stated, this book is intended primarily for the beginning graphics programmer. These
-            tutorials are in-depth, but they are also designed to break complex subjects down into
-            easily understood sections.</para>
-        <para>Because of this, these tutorials are not merely heavily commented source code. Indeed,
-            the source code is usually secondary, used only as a way to show how to implement the
-            concept that was previously discussed. In most cases, the entire source code for a
-            tutorial will not be shown within that tutorial; only the relevant new sections of code
-            will be described.</para>
+    </section>
+    <section>
+        <title>Conventions used in This Book</title>
+        <!--TODO: Have a list of conventions.-->
+        <para/>
     </section>
 </preface>

Meshes/ConvCollada.lua

 	
 	stride = tonumber(stride);
 	
-	return retType, stride, "([%+%-]?[%d%.]+)", valueElem:GetChildren();
+	return retType, stride, "([%+%-]?[%d%.]+e?[%+%-]?[%d%.]*)", valueElem:GetChildren();
 end
 
 local function WriteTextForArray(writer, valueArray, stride, indexList, indexOffset)
 		local indexIx = i + indexOffset;
 		local index = indexList[indexIx];
 		index = index * stride;
-		index = index + 1; --Convert to one-base index.
 		for j=1, stride do
+			index = index + 1;	--One-base index.
 			writer:AddText(valueArray[index], " ");
-			index = index + 1;
 		end
 		writer:AddText("\n");
 	end
 		writer:AddAttribute("size", tostring(stride));
 		
 		local valueArray = {};
+		local numberArray = {};
 		for value in valueText:GetContent():gmatch(pttrn) do
 			valueArray[#valueArray + 1] = value;
+			numberArray[#numberArray + 1] = tostring(tonumber(value));
 		end
-		
+
 		WriteTextForArray(writer, valueArray, stride, indexList, outputIndexOffset[semantic]);
 	writer:PopElement();
 end

Tut 11 Shinies/premake4.lua

 
 dofile("../framework/framework.lua")
 
-SetupSolution("Tutorial10")
+SetupSolution("Tutorial11")
 
 dofile("tutorials.lua")
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.