Roi Atalla avatar Roi Atalla committed b464f6f

Example 13.1 fully ported.

Comments (0)

Files changed (24)

.idea/workspace.xml

 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
   <component name="ChangeListManager">
-    <list default="true" id="3bd3582b-975a-4915-888d-8e2c52d85938" name="Default" comment="">
-      <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter12/example3/Example12_3.java" />
-      <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter12/example3/example12.3.DiffuseOnlyGamma.frag" />
-      <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter12/example3/example12.3.DiffuseOnlyMtlGamma.frag" />
-      <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter12/example3/example12.3.DiffuseSpecularGamma.frag" />
-      <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter12/example3/example12.3.DiffuseSpecularMtlGamma.frag" />
-      <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter12/example3/example12.3.PCN.vert" />
-      <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter12/example3/example12.3.PN.vert" />
-      <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter12/example3/example12.3.PosTransform.vert" />
-      <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter12/example3/example12.3.UniformColor.frag" />
-      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/com/ra4king/opengl/util/interpolators/TimedLinearInterpolatorf.java" afterPath="$PROJECT_DIR$/src/com/ra4king/opengl/util/interpolators/TimedLinearInterpolatorf.java" />
+    <list default="true" id="3bd3582b-975a-4915-888d-8e2c52d85938" name="Default" comment="Example 12.3 fully ported.">
+      <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter13/example1/Example13_1.java" />
+      <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter13/example2/Example13_2.java" />
+      <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/src/com/ra4king/opengl/util/UniformBlockArray.java" />
+      <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter13/example1/example13.1.BasicImpostor.frag" />
+      <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter13/example1/example13.1.BasicImpostor.vert" />
+      <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter13/example1/example13.1.DepthImpostor.frag" />
+      <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter13/example1/example13.1.DepthImpostor.vert" />
+      <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter13/example1/example13.1.LargePlane.xml" />
+      <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter13/example1/example13.1.Lighting.frag" />
+      <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter13/example1/example13.1.PN.vert" />
+      <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter13/example1/example13.1.PerspImpostor.frag" />
+      <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter13/example1/example13.1.PerspImpostor.vert" />
+      <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter13/example1/example13.1.UnitCube.xml" />
+      <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter13/example1/example13.1.UnitSphere.xml" />
+      <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter13/example1/example13.1.Unlit.frag" />
+      <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter13/example1/example13.1.Unlit.vert" />
+      <change type="DELETED" beforePath="E:\Roi Atalla\Documents\Programming Files\Java Files\Personal Projects\OpenGL\src\com\ra4king\opengl\superbible\README.md" afterPath="" />
+      <change type="DELETED" beforePath="E:\Roi Atalla\Documents\Programming Files\Java Files\Personal Projects\OpenGL\src\com\ra4king\opengl\arcsynthesis\README.md" afterPath="" />
+      <change type="DELETED" beforePath="E:\Roi Atalla\Documents\Programming Files\Java Files\Personal Projects\OpenGL\src\com\ra4king\opengl\redbook\README.md" afterPath="" />
+      <change type="DELETED" beforePath="E:\Roi Atalla\Documents\Programming Files\Java Files\Personal Projects\OpenGL\src\com\ra4king\opengl\util\README.md" afterPath="" />
+      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter12/LightManager.java" afterPath="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter12/LightManager.java" />
+      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/com/ra4king/opengl/util/math/Matrix4.java" afterPath="$PROJECT_DIR$/src/com/ra4king/opengl/util/math/Matrix4.java" />
+      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/com/ra4king/opengl/util/MousePoles.java" afterPath="$PROJECT_DIR$/src/com/ra4king/opengl/util/MousePoles.java" />
       <change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
     </list>
     <ignored path="OpenGL.iws" />
     <ignored path=".idea/workspace.xml" />
     <file path="/a.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362444430804" ignored="false" />
-    <file path="/fragment.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362435023120" ignored="false" />
+    <file path="/fragment.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362456584258" ignored="false" />
     <file path="/a.xml" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1361850040520" ignored="false" />
     <file path="/a.html" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1361850041808" ignored="false" />
     <file path="/a.groovy" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1361850042481" ignored="false" />
-    <file path="/Dummy.txt" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362445100029" ignored="false" />
+    <file path="/Dummy.txt" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362463188818" ignored="false" />
     <file path="/Example12_1.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362027020824" ignored="false" />
     <file path="/example12.1.DiffuseSpecular.frag" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1361702005810" ignored="false" />
-    <file path="/LightManager.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1361856937559" ignored="false" />
+    <file path="/LightManager.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362461124226" ignored="false" />
     <file path="/sample.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362443659696" ignored="false" />
     <file path="/Scene.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362029076804" ignored="false" />
     <file path="$PROJECT_DIR$/bin/com/ra4king/opengl/arcsynthesis/gl33/chapter8/example1/example8.1.Ship.xml" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1361777249769" ignored="false" />
     <file path="/CommonCodeStyleSettings.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1361943912554" ignored="false" />
     <file path="$PROJECT_DIR$/../../../../../Downloads/Downloaded Folders/IntelliJ IDEA/java/java-impl/src/com/intellij/application/options/JavaIndentOptionsEditor.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1361943925808" ignored="false" />
     <file path="/JavaIndentOptionsEditor.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1361943925425" ignored="false" />
-    <file path="/a.dummy" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362025132920" ignored="false" />
+    <file path="/a.dummy" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362620809769" ignored="false" />
     <file path="$PROJECT_DIR$/../../../../../Downloads/Downloaded Folders/IntelliJ IDEA/platform/platform-resources-en/src/messages/ApplicationBundle.properties" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1361942803305" ignored="false" />
     <file path="/ApplicationBundle.properties" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1361942802444" ignored="false" />
     <file path="$PROJECT_DIR$/../../../../../Downloads/Downloaded Folders/IntelliJ IDEA/system/conversion/Test4fc3a780.xml" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1361942830409" ignored="false" />
     <file path="/WeightedLinearInterpolatorf.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362028194113" ignored="false" />
     <file path="/LinearInterpolatorf.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362028206784" ignored="false" />
     <file path="/TimedLinearInterpolatorf.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362446224654" ignored="false" />
-    <file path="/Example12_2.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362443744230" ignored="false" />
+    <file path="/Example12_2.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362460014781" ignored="false" />
     <file path="/Quaternion.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362099952877" ignored="false" />
     <file path="/Utils.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362100285272" ignored="false" />
-    <file path="/Matrix4.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362205256256" ignored="false" />
-    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/superbible/osb4/chapter3/Example3_4.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362205585877" ignored="false" />
-    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/superbible/osb4/chapter3/Example3_5.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362205585877" ignored="false" />
-    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/superbible/osb4/chapter3/Example3_6.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362205585877" ignored="false" />
-    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/superbible/osb4/chapter3/Example3_7.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362205585877" ignored="false" />
-    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/superbible/osb4/chapter3/Example3_8.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362205585877" ignored="false" />
-    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/superbible/osb4/chapter3/Example3_13.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362205585877" ignored="false" />
-    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/superbible/osb4/chapter3/Example3_14.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362205585877" ignored="false" />
-    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/superbible/osb4/chapter3/Example3_2.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362205585877" ignored="false" />
-    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/superbible/osb4/chapter3/Example3_3.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362205585877" ignored="false" />
-    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/redbook/chapter2/Circle.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362205585877" ignored="false" />
-    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/redbook/chapter2/Example2_1.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362205585877" ignored="false" />
-    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/redbook/chapter2/Example2_3.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362205585877" ignored="false" />
-    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/superbible/osb4/chapter2/Example2_1.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362205585877" ignored="false" />
-    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/superbible/osb4/chapter2/Example2_2.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362205585877" ignored="false" />
-    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/superbible/osb4/chapter2/Example2_3.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362205585877" ignored="false" />
-    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter9/example3/Example9_3.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362205585877" ignored="false" />
-    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/superbible/osb4/chapter3/Example3_11.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362205585877" ignored="false" />
-    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/redbook/chapter1/Example1_1.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362205585877" ignored="false" />
-    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/redbook/chapter1/Example1_2.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362205585877" ignored="false" />
-    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/redbook/chapter1/Example1_3.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362205585877" ignored="false" />
-    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter9/example2/Example9_2.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362205585877" ignored="false" />
-    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter9/example1/Example9_1.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362205585877" ignored="false" />
-    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter8/example2/Example8_2.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362205585877" ignored="false" />
-    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter8/example3/Example8_3.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362205585877" ignored="false" />
-    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter8/example1/Example8_1.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362205585878" ignored="false" />
-    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter7/example1/Example7_1.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362205585877" ignored="false" />
-    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter7/example2/Example7_2.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362205585878" ignored="false" />
-    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter11/example1/Example11_1.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362205585878" ignored="false" />
-    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter10/example3/Example10_3.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362205585879" ignored="false" />
-    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter10/example1/Example10_1.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362205585879" ignored="false" />
+    <file path="/Matrix4.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362630104620" ignored="false" />
+    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/redbook/chapter2/Circle.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362463155786" ignored="false" />
+    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/redbook/chapter2/Example2_1.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362463155786" ignored="false" />
+    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/redbook/chapter2/Example2_3.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362463155786" ignored="false" />
+    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter9/example3/Example9_3.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362463155786" ignored="false" />
+    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/redbook/chapter1/Example1_1.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362463155786" ignored="false" />
+    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/redbook/chapter1/Example1_2.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362463155786" ignored="false" />
+    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/redbook/chapter1/Example1_3.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362463155786" ignored="false" />
+    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter9/example2/Example9_2.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362463155786" ignored="false" />
+    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter9/example1/Example9_1.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362463155786" ignored="false" />
+    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter8/example2/Example8_2.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362463155786" ignored="false" />
+    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter8/example3/Example8_3.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362463155786" ignored="false" />
+    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter8/example1/Example8_1.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362463155786" ignored="false" />
+    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter7/example1/Example7_1.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362463155786" ignored="false" />
+    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter7/example2/Example7_2.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362463155786" ignored="false" />
+    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter10/example3/Example10_3.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362463155787" ignored="false" />
     <file path="$PROJECT_DIR$/../SmallGame/src/com/ra4king/smallgame/SmallGame.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362384652824" ignored="false" />
     <file path="/SmallGame.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362384638290" ignored="false" />
     <file path="$PROJECT_DIR$/../SmallGame/.idea/misc.xml" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362384634878" ignored="false" />
     <file path="$PROJECT_DIR$/../SmallGame/.idea/workspace.xml" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362433066891" ignored="false" />
     <file path="/example12.2.DiffuseSpecularMtlHDR.frag" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362444771007" ignored="false" />
-    <file path="/Example12_3.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362455192649" ignored="false" />
+    <file path="/Example12_3.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362462662795" ignored="false" />
     <file path="/example12.3.DiffuseOnlyGamma.frag" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362454999719" ignored="false" />
     <file path="/example12.3.DiffuseOnlyMtlGamma.frag" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362455044354" ignored="false" />
     <file path="/example12.3.DiffuseSpecularGamma.frag" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362455100183" ignored="false" />
     <file path="/example12.3.DiffuseSpecularMtlGamma.frag" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362455113040" ignored="false" />
+    <file path="/Example13_1.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362630395179" ignored="false" />
+    <file path="/UniformBlockArray.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362460808991" ignored="false" />
+    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/test/Test.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362463155785" ignored="false" />
+    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/superbible/osb5/chapter2/example1/Example2_1.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362463155786" ignored="false" />
+    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/superbible/osb5/chapter2/example3/Example2_3.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362463155785" ignored="false" />
+    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/superbible/osb5/chapter2/example2/Example2_2.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362463155786" ignored="false" />
+    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/redbook/chapter2/Example2_2.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362463155786" ignored="false" />
+    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/redbook/chapter2/Example2_4.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362463155786" ignored="false" />
+    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter8/example4/Example8_4.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362463155786" ignored="false" />
+    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter6/example4/Example6_4.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362463155786" ignored="false" />
+    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter6/example3/Example6_3.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362463155786" ignored="false" />
+    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter5/example3/Example5_3.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362463155786" ignored="false" />
+    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter6/example1/Example6_1.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362463155786" ignored="false" />
+    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter5/example4/Example5_4.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362463155786" ignored="false" />
+    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter6/example2/Example6_2.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362463155786" ignored="false" />
+    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter5/example5/Example5_5.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362463155786" ignored="false" />
+    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter4/example1/Example4_1.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362463155786" ignored="false" />
+    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter4/example2/Example4_2.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362463155786" ignored="false" />
+    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter3/example3/Example3_3.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362463155786" ignored="false" />
+    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter5/example1/Example5_1.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362463155786" ignored="false" />
+    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter4/example3/Example4_3.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362463155786" ignored="false" />
+    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter3/example4/Example3_4.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362463155786" ignored="false" />
+    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter5/example2/Example5_2.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362463155786" ignored="false" />
+    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter4/example4/Example4_4.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362463155786" ignored="false" />
+    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter12/example2/Example12_2.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362463155787" ignored="false" />
+    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter3/example1/Example3_1.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362463155786" ignored="false" />
+    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter2/example1/Example2_1.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362463155786" ignored="false" />
+    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter3/example2/Example3_2.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362463155786" ignored="false" />
+    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter2/example2/Example2_2.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362463155786" ignored="false" />
+    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter12/example1/Example12_1.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362463155787" ignored="false" />
+    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter11/example1/Example11_1.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362463155787" ignored="false" />
+    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter11/example2/Example11_2.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362463155787" ignored="false" />
+    <file path="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter10/example2/Example10_2.java" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362463155787" ignored="false" />
+    <file path="/example13.1.DepthImpostor.frag" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362629355300" ignored="false" />
+    <file path="/example13.1.BasicImpostor.frag" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362629856716" ignored="false" />
+    <file path="/example13.1.PerspImpostor.frag" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362629503462" ignored="false" />
+    <file path="/example13.1.PN.vert" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362629589022" ignored="false" />
+    <file path="/example13.1.Lighting.frag" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362629642934" ignored="false" />
+    <file path="/example13.1.Unlit.frag" changelist="3bd3582b-975a-4915-888d-8e2c52d85938" time="1362629803134" ignored="false" />
     <option name="TRACKING_ENABLED" value="true" />
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
     <disable_hints />
   </component>
   <component name="DebuggerManager">
-    <ui_properties default_suspend_policy="SuspendAll" default_condition_enabled="true" />
     <line_breakpoints default_suspend_policy="SuspendAll" default_condition_enabled="true">
       <breakpoint url="file://$PROJECT_DIR$/src/com/ra4king/opengl/util/MousePoles.java" line="385" class="com.ra4king.opengl.util.MousePoles.ViewPole" package="com.ra4king.opengl.util">
         <option name="ENABLED" value="true" />
         <option name="LOG_MESSAGE" value="&#13;&#13;JAVA" />
       </breakpoint>
     </breakpoint_any>
+    <ui_properties default_suspend_policy="SuspendAll" default_condition_enabled="true" />
     <breakpoint_rules />
     <ui_properties />
   </component>
   <component name="IdeDocumentHistory">
     <option name="changedFiles">
       <list>
-        <option value="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter12/example2/Example12_TEST.java" />
-        <option value="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter12/example1/Example12_1.java" />
-        <option value="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter12/example2/Example12_2.java" />
-        <option value="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter12/example2/example12.2.DiffuseOnlyMtlHDR.frag" />
-        <option value="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter12/example2/example12.2.DiffuseOnlyHDR.frag" />
-        <option value="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter12/example1/example12.1.DiffuseOnly.frag" />
-        <option value="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter12/example1/example12.1.DiffuseOnlyMtl.frag" />
-        <option value="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter12/example2/example12.2.DiffuseSpecularHDR.frag" />
-        <option value="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter12/example2/example12.2.DiffuseSpecularMtlHDR.frag" />
-        <option value="$PROJECT_DIR$/src/com/ra4king/opengl/util/interpolators/TimedLinearInterpolatorf.java" />
-        <option value="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter12/example3/Example12_2.java" />
-        <option value="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter12/example3/example12.3.DiffuseOnlyGamma.frag" />
-        <option value="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter12/example3/example12.3.DiffuseOnlyMtlGamma.frag" />
-        <option value="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter12/example3/example12.3.DiffuseSpecularGamma.frag" />
-        <option value="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter12/example3/example12.3.DiffuseSpecularMtlGamma.frag" />
-        <option value="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter12/example3/Example12_3.java" />
+        <option value="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter13/example1/example13.1.LargePlane.xml" />
+        <option value="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter13/example1/example13.1.UnitCube.xml" />
+        <option value="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter13/example1/example13.1.UnitSphere.xml" />
+        <option value="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter13/example1/example13.1.DepthImpostor.vert" />
+        <option value="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter13/example1/example13.1.BasicImpostor.vert" />
+        <option value="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter13/example1/example13.1.DepthImpostor.frag" />
+        <option value="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter13/example1/example13.1.PerspImpostor.vert" />
+        <option value="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter13/example1/example13.1.PerspImpostor.frag" />
+        <option value="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter13/example1/example13.1.PN.vert" />
+        <option value="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter13/example1/example13.1.Lighting.frag" />
+        <option value="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter13/example1/example13.1.Unlit.vert" />
+        <option value="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter13/example1/example13.1.BasicImpostor.frag" />
+        <option value="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter13/example1/example13.1.Unlit.frag" />
+        <option value="$PROJECT_DIR$/src/com/ra4king/opengl/util/math/Matrix4.java" />
+        <option value="$PROJECT_DIR$/src/com/ra4king/opengl/util/MousePoles.java" />
+        <option value="$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter13/example1/Example13_1.java" />
       </list>
     </option>
   </component>
     <OptionsSetting value="true" id="Status" />
     <OptionsSetting value="true" id="Edit" />
     <ConfirmationsSetting value="2" id="Add" />
-    <ConfirmationsSetting value="0" id="Remove" />
+    <ConfirmationsSetting value="2" id="Remove" />
   </component>
   <component name="ProjectReloadState">
     <option name="STATE" value="0" />
   </component>
   <component name="ProjectView">
     <navigator currentView="ProjectPane" proportions="" version="1" splitterProportion="0.5">
-      <flattenPackages />
-      <showMembers />
+      <flattenPackages ProjectPane="false" />
+      <showMembers ProjectPane="false" />
       <showModules />
       <showLibraryContents />
       <hideEmptyPackages />
       <abbreviatePackageNames />
-      <autoscrollToSource />
-      <autoscrollFromSource />
+      <autoscrollToSource ProjectPane="false" />
+      <autoscrollFromSource ProjectPane="false" />
       <sortByType />
     </navigator>
     <panes>
-      <pane id="PackagesPane">
-        <subPane />
-      </pane>
-      <pane id="Scope" />
       <pane id="ProjectPane">
         <subPane>
           <PATH>
               <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
             </PATH_ELEMENT>
             <PATH_ELEMENT>
-              <option name="myItemId" value="arcsynthesis" />
+              <option name="myItemId" value="util" />
               <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
             </PATH_ELEMENT>
           </PATH>
               <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
             </PATH_ELEMENT>
             <PATH_ELEMENT>
-              <option name="myItemId" value="arcsynthesis" />
-              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
-            </PATH_ELEMENT>
-            <PATH_ELEMENT>
               <option name="myItemId" value="gl33" />
               <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
             </PATH_ELEMENT>
             <PATH_ELEMENT>
-              <option name="myItemId" value="chapter12" />
+              <option name="myItemId" value="chapter13" />
               <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
             </PATH_ELEMENT>
           </PATH>
               <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
             </PATH_ELEMENT>
             <PATH_ELEMENT>
-              <option name="myItemId" value="arcsynthesis" />
-              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
-            </PATH_ELEMENT>
-            <PATH_ELEMENT>
               <option name="myItemId" value="gl33" />
               <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
             </PATH_ELEMENT>
             <PATH_ELEMENT>
-              <option name="myItemId" value="chapter12" />
+              <option name="myItemId" value="chapter13" />
               <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
             </PATH_ELEMENT>
             <PATH_ELEMENT>
-              <option name="myItemId" value="example3" />
+              <option name="myItemId" value="example1" />
               <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
             </PATH_ELEMENT>
           </PATH>
               <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
             </PATH_ELEMENT>
             <PATH_ELEMENT>
-              <option name="myItemId" value="arcsynthesis" />
-              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
-            </PATH_ELEMENT>
-            <PATH_ELEMENT>
               <option name="myItemId" value="gl33" />
               <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
             </PATH_ELEMENT>
           </PATH>
         </subPane>
       </pane>
+      <pane id="Scope" />
+      <pane id="PackagesPane">
+        <subPane />
+      </pane>
     </panes>
   </component>
   <component name="PropertiesComponent">
     <property name="project.structure.last.edited" value="Facets" />
     <property name="project.structure.proportion" value="0.15" />
     <property name="options.splitter.main.proportions" value="0.3" />
+    <property name="recentsLimit" value="5" />
+    <property name="MemberChooser.sorted" value="false" />
     <property name="FileHistory.org.zmlx.hg4idea.provider.HgHistoryProvider_treeWidth1" value="282" />
-    <property name="MemberChooser.sorted" value="false" />
-    <property name="recentsLimit" value="5" />
     <property name="FileHistory.org.zmlx.hg4idea.provider.HgHistoryProvider_treeWidth2" value="288" />
     <property name="last_opened_file_path" value="$PROJECT_DIR$/.idea/workspace.xml" />
     <property name="FileHistory.org.zmlx.hg4idea.provider.HgHistoryProvider_treeWidth0" value="293" />
     <property name="FileHistory.org.zmlx.hg4idea.provider.HgHistoryProvider_flatWidth2" value="289" />
     <property name="FileHistory.org.zmlx.hg4idea.provider.HgHistoryProvider_flatWidth1" value="289" />
     <property name="FileHistory.org.zmlx.hg4idea.provider.HgHistoryProvider_flatWidth0" value="289" />
-    <property name="options.lastSelected" value="preferences.fileTypes" />
+    <property name="options.lastSelected" value="reference.settingsdialog.IDE.editor.colors.Java" />
     <property name="FileHistory.org.zmlx.hg4idea.provider.HgHistoryProvider_flatOrder1" value="1" />
+    <property name="FileHistory.org.zmlx.hg4idea.provider.HgHistoryProvider_flatOrder0" value="0" />
     <property name="project.structure.side.proportion" value="0.2" />
-    <property name="FileHistory.org.zmlx.hg4idea.provider.HgHistoryProvider_flatOrder0" value="0" />
     <property name="FileHistory.org.zmlx.hg4idea.provider.HgHistoryProvider_flatOrder3" value="3" />
+    <property name="FileHistory.org.zmlx.hg4idea.provider.HgHistoryProvider_flatOrder2" value="2" />
     <property name="MemberChooser.copyJavadoc" value="false" />
-    <property name="FileHistory.org.zmlx.hg4idea.provider.HgHistoryProvider_flatOrder2" value="2" />
     <property name="restartRequiresConfirmation" value="true" />
+    <property name="options.searchVisible" value="true" />
     <property name="dynamic.classpath" value="false" />
-    <property name="options.searchVisible" value="true" />
   </component>
   <component name="RecentsManager">
     <key name="CopyClassDialog.RECENTS_KEY">
+      <recent name="com.ra4king.opengl.arcsynthesis.gl33.chapter13.example1" />
       <recent name="com.ra4king.opengl.arcsynthesis.gl33.chapter12.example2" />
     </key>
     <key name="CopyFile.RECENT_KEYS">
+      <recent name="E:\Roi Atalla\Documents\Programming Files\Java Files\Personal Projects\OpenGL\src\com\ra4king\opengl\arcsynthesis\gl33\chapter13\example1" />
       <recent name="E:\Roi Atalla\Documents\Programming Files\Java Files\Personal Projects\OpenGL\src\com\ra4king\opengl\arcsynthesis\gl33\chapter12\example3" />
       <recent name="E:\Roi Atalla\Documents\Programming Files\Java Files\Personal Projects\OpenGL\src\com\ra4king\opengl\arcsynthesis\gl33\chapter12\example2" />
       <recent name="E:\Roi Atalla\Documents\Programming Files\Java Files\Personal Projects\OpenGL\files\natives" />
       <recent name="E:\Roi Atalla\Documents\Programming Files\Java Files\Personal Projects\OpenGL\files" />
     </key>
   </component>
-  <component name="RunManager" selected="Application.Example12_3">
+  <component name="RunManager" selected="Application.Example13_1">
     <configuration default="false" name="Example12_2" type="Application" factoryName="Application" temporary="true">
       <option name="MAIN_CLASS_NAME" value="com.ra4king.opengl.arcsynthesis.gl33.chapter12.example2.Example12_2" />
       <option name="VM_PARAMETERS" value="-Djava.library.path=files/natives/" />
       <ConfigurationWrapper RunnerId="Run" />
       <method />
     </configuration>
+    <configuration default="false" name="Example13_1" type="Application" factoryName="Application" temporary="true">
+      <option name="MAIN_CLASS_NAME" value="com.ra4king.opengl.arcsynthesis.gl33.chapter13.example1.Example13_1" />
+      <option name="VM_PARAMETERS" value="-Djava.library.path=files/natives/" />
+      <option name="PROGRAM_PARAMETERS" value="" />
+      <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
+      <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
+      <option name="ALTERNATIVE_JRE_PATH" value="" />
+      <option name="ENABLE_SWING_INSPECTOR" value="false" />
+      <option name="ENV_VARIABLES" />
+      <option name="PASS_PARENT_ENVS" value="true" />
+      <module name="OpenGL" />
+      <envs />
+      <RunnerSettings RunnerId="Run" />
+      <ConfigurationWrapper RunnerId="Run" />
+      <method />
+    </configuration>
     <configuration default="true" type="#org.jetbrains.idea.devkit.run.PluginConfigurationType" factoryName="Plugin">
       <module name="" />
       <option name="VM_PARAMETERS" value="-Xmx512m -Xms256m -XX:MaxPermSize=250m" />
       <option name="PROGRAM_PARAMETERS" />
       <method />
     </configuration>
+    <configuration default="true" type="AndroidTestRunConfigurationType" factoryName="Android Tests">
+      <module name="" />
+      <option name="TESTING_TYPE" value="0" />
+      <option name="INSTRUMENTATION_RUNNER_CLASS" value="" />
+      <option name="METHOD_NAME" value="" />
+      <option name="CLASS_NAME" value="" />
+      <option name="PACKAGE_NAME" value="" />
+      <option name="TARGET_SELECTION_MODE" value="EMULATOR" />
+      <option name="PREFERRED_AVD" value="" />
+      <option name="COMMAND_LINE" value="" />
+      <option name="WIPE_USER_DATA" value="false" />
+      <option name="DISABLE_BOOT_ANIMATION" value="false" />
+      <option name="NETWORK_SPEED" value="full" />
+      <option name="NETWORK_LATENCY" value="none" />
+      <option name="CLEAR_LOGCAT" value="false" />
+      <method />
+    </configuration>
     <configuration default="true" type="MavenRunConfiguration" factoryName="Maven">
       <MavenSettings>
         <option name="myGeneralSettings" />
       </MavenSettings>
       <method />
     </configuration>
-    <configuration default="true" type="AndroidTestRunConfigurationType" factoryName="Android Tests">
-      <module name="" />
-      <option name="TESTING_TYPE" value="0" />
-      <option name="INSTRUMENTATION_RUNNER_CLASS" value="" />
-      <option name="METHOD_NAME" value="" />
-      <option name="CLASS_NAME" value="" />
-      <option name="PACKAGE_NAME" value="" />
-      <option name="TARGET_SELECTION_MODE" value="EMULATOR" />
-      <option name="PREFERRED_AVD" value="" />
-      <option name="COMMAND_LINE" value="" />
-      <option name="WIPE_USER_DATA" value="false" />
-      <option name="DISABLE_BOOT_ANIMATION" value="false" />
-      <option name="NETWORK_SPEED" value="full" />
-      <option name="NETWORK_LATENCY" value="none" />
-      <option name="CLEAR_LOGCAT" value="false" />
-      <method />
-    </configuration>
     <configuration default="true" type="Remote" factoryName="Remote">
       <option name="USE_SOCKET_TRANSPORT" value="true" />
       <option name="SERVER_MODE" value="false" />
       <option name="PORT" value="5005" />
       <method />
     </configuration>
-    <configuration default="true" type="Applet" factoryName="Applet">
-      <module name="" />
-      <option name="MAIN_CLASS_NAME" />
-      <option name="HTML_FILE_NAME" />
-      <option name="HTML_USED" value="false" />
-      <option name="WIDTH" value="400" />
-      <option name="HEIGHT" value="300" />
-      <option name="POLICY_FILE" value="$APPLICATION_HOME_DIR$/bin/appletviewer.policy" />
-      <option name="VM_PARAMETERS" />
-      <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
-      <option name="ALTERNATIVE_JRE_PATH" />
-      <method />
-    </configuration>
     <configuration default="true" type="TestNG" factoryName="TestNG">
       <module name="" />
       <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
       <listeners />
       <method />
     </configuration>
+    <configuration default="true" type="Applet" factoryName="Applet">
+      <module name="" />
+      <option name="MAIN_CLASS_NAME" />
+      <option name="HTML_FILE_NAME" />
+      <option name="HTML_USED" value="false" />
+      <option name="WIDTH" value="400" />
+      <option name="HEIGHT" value="300" />
+      <option name="POLICY_FILE" value="$APPLICATION_HOME_DIR$/bin/appletviewer.policy" />
+      <option name="VM_PARAMETERS" />
+      <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
+      <option name="ALTERNATIVE_JRE_PATH" />
+      <method />
+    </configuration>
     <configuration default="true" type="Application" factoryName="Application">
       <option name="MAIN_CLASS_NAME" value="" />
       <option name="VM_PARAMETERS" value="-Djava.library.path=files/natives/" />
       <option name="CLEAR_LOGCAT" value="false" />
       <method />
     </configuration>
-    <list size="3">
+    <list size="4">
       <item index="0" class="java.lang.String" itemvalue="Application.Example12_2" />
       <item index="1" class="java.lang.String" itemvalue="Application.Example12_1" />
       <item index="2" class="java.lang.String" itemvalue="Application.Example12_3" />
+      <item index="3" class="java.lang.String" itemvalue="Application.Example13_1" />
     </list>
     <recent_temporary>
-      <list size="3">
-        <item index="0" class="java.lang.String" itemvalue="Application.Example12_3" />
-        <item index="1" class="java.lang.String" itemvalue="Application.Example12_2" />
-        <item index="2" class="java.lang.String" itemvalue="Application.Example12_1" />
+      <list size="4">
+        <item index="0" class="java.lang.String" itemvalue="Application.Example13_1" />
+        <item index="1" class="java.lang.String" itemvalue="Application.Example12_3" />
+        <item index="2" class="java.lang.String" itemvalue="Application.Example12_2" />
+        <item index="3" class="java.lang.String" itemvalue="Application.Example12_1" />
       </list>
     </recent_temporary>
     <configuration name="&lt;template&gt;" type="WebApp" default="true" selected="false">
       <created>1362445103210</created>
       <updated>1362445103210</updated>
     </task>
-    <option name="localTasksCounter" value="9" />
+    <task id="LOCAL-00009" summary="Example 12.3 fully ported.">
+      <created>1362455413134</created>
+      <updated>1362455413134</updated>
+    </task>
+    <option name="localTasksCounter" value="10" />
     <servers />
   </component>
   <component name="TodoView" selected-index="0">
       <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.18366013" sideWeight="0.17250325" order="1" side_tool="true" content_ui="tabs" />
       <window_info id="Maven Projects" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32977587" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
       <window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="SLIDING" type="SLIDING" visible="false" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
-      <window_info id="Project" active="true" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.21184632" sideWeight="0.8187633" order="0" side_tool="false" content_ui="combo" />
-      <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.18123667" sideWeight="0.9898039" order="2" side_tool="false" content_ui="tabs" />
+      <window_info id="Project" active="true" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.21184632" sideWeight="0.96588486" order="0" side_tool="true" content_ui="combo" x="2394" y="136" width="397" height="768" />
+      <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.03411514" sideWeight="0.9898039" order="2" side_tool="false" content_ui="tabs" />
       <window_info id="Documentation" active="true" anchor="right" auto_hide="false" internal_type="DOCKED" type="FLOATING" visible="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" x="2005" y="109" width="1736" height="896" />
       <window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
       <window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
     <option name="MAXIMUM_HISTORY_ROWS" value="1000" />
     <option name="FORCE_NON_EMPTY_COMMENT" value="false" />
     <option name="CLEAR_INITIAL_COMMIT_MESSAGE" value="false" />
-    <option name="LAST_COMMIT_MESSAGE" value="Example 12.2 fully ported." />
+    <option name="LAST_COMMIT_MESSAGE" value="Example 12.3 fully ported." />
     <option name="MAKE_NEW_CHANGELIST_ACTIVE" value="false" />
     <option name="OPTIMIZE_IMPORTS_BEFORE_PROJECT_COMMIT" value="false" />
     <option name="CHECK_FILES_UP_TO_DATE_BEFORE_COMMIT" value="false" />
     <MESSAGE value="Silly typo." />
     <MESSAGE value="*HUGE* error in my Matrix4.toQuaternion class that caused  buggy 3D movement in Example12.1. Also, completely reformat with Eclipse Formatter plugin for IDEA." />
     <MESSAGE value="Example 12.2 fully ported." />
+    <MESSAGE value="Example 12.3 fully ported." />
   </component>
   <component name="XDebuggerManager">
     <breakpoint-manager>
     <option name="FILTER_TARGETS" value="false" />
   </component>
   <component name="editorHistoryManager">
-    <entry file="file://$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter12/example2/example12.2.DiffuseSpecularHDR.frag">
+    <entry file="file://$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter13/example1/example13.1.UnitCube.xml">
       <provider selected="true" editor-type-id="text-editor">
-        <state line="39" column="18" selection-start="784" selection-end="784" vertical-scroll-proportion="0.73493975">
+        <state line="113" column="0" selection-start="1719" selection-end="1719" vertical-scroll-proportion="0.9177632">
           <folding />
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter12/example2/example12.2.DiffuseSpecularMtlHDR.frag">
+    <entry file="file://$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter13/example1/example13.1.UnitSphere.xml">
       <provider selected="true" editor-type-id="text-editor">
-        <state line="40" column="0" selection-start="812" selection-end="812" vertical-scroll-proportion="0.90361446">
+        <state line="282" column="0" selection-start="10528" selection-end="10528" vertical-scroll-proportion="0.9013158">
           <folding />
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter12/example2/example12.2.DiffuseOnlyMtlHDR.frag">
+    <entry file="file://$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter13/example1/example13.1.BasicImpostor.vert">
       <provider selected="true" editor-type-id="text-editor">
-        <state line="40" column="0" selection-start="812" selection-end="812" vertical-scroll-proportion="0.90361446">
+        <state line="42" column="0" selection-start="753" selection-end="753" vertical-scroll-proportion="0.69078946">
           <folding />
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter12/example2/example12.2.DiffuseOnlyHDR.frag">
+    <entry file="file://$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter13/example1/example13.1.DepthImpostor.vert">
       <provider selected="true" editor-type-id="text-editor">
-        <state line="41" column="0" selection-start="834" selection-end="834" vertical-scroll-proportion="0.60993975">
+        <state line="44" column="0" selection-start="878" selection-end="878" vertical-scroll-proportion="0.7236842">
           <folding />
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/com/ra4king/opengl/util/interpolators/TimedLinearInterpolatorf.java">
+    <entry file="file://$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter13/example1/example13.1.PerspImpostor.vert">
       <provider selected="true" editor-type-id="text-editor">
-        <state line="16" column="8" selection-start="475" selection-end="475" vertical-scroll-proportion="0.28985506">
+        <state line="44" column="0" selection-start="861" selection-end="861" vertical-scroll-proportion="0.7236842">
           <folding />
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/com/ra4king/opengl/util/interpolators/TimedLinearInterpolatorVector.java">
+    <entry file="file://$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter13/example1/example13.1.PN.vert">
       <provider selected="true" editor-type-id="text-editor">
-        <state line="28" column="0" selection-start="744" selection-end="744" vertical-scroll-proportion="0.4710145">
+        <state line="26" column="0" selection-start="551" selection-end="551" vertical-scroll-proportion="0.4276316">
           <folding />
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/com/ra4king/opengl/util/interpolators/LinearInterpolatorf.java">
+    <entry file="file://$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter13/example1/example13.1.Lighting.frag">
       <provider selected="true" editor-type-id="text-editor">
-        <state line="4" column="13" selection-start="90" selection-end="90" vertical-scroll-proportion="0.072463766">
+        <state line="76" column="0" selection-start="1949" selection-end="1949" vertical-scroll-proportion="1.25">
           <folding />
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/com/ra4king/opengl/util/interpolators/ConstVelLinearInterpolatorf.java">
+    <entry file="file://$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter13/example1/example13.1.Unlit.vert">
       <provider selected="true" editor-type-id="text-editor">
-        <state line="4" column="13" selection-start="90" selection-end="90" vertical-scroll-proportion="0.072463766">
+        <state line="17" column="0" selection-start="260" selection-end="260" vertical-scroll-proportion="0.27960527">
           <folding />
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/com/ra4king/opengl/util/interpolators/WeightedLinearInterpolatorf.java">
+    <entry file="file://$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter13/example1/example13.1.BasicImpostor.frag">
       <provider selected="true" editor-type-id="text-editor">
-        <state line="9" column="15" selection-start="197" selection-end="197" vertical-scroll-proportion="0.16304348">
+        <state line="82" column="6" selection-start="2035" selection-end="2035" vertical-scroll-proportion="0.29438543">
           <folding />
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter12/example2/Example12_2.java">
+    <entry file="file://$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter13/example1/example13.1.Unlit.frag">
       <provider selected="true" editor-type-id="text-editor">
-        <state line="197" column="4" selection-start="9981" selection-end="9981" vertical-scroll-proportion="0.6702899">
-          <folding>
-            <element signature="imports" expanded="true" />
-          </folding>
-        </state>
-      </provider>
-    </entry>
-    <entry file="file://$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter12/LightManager.java">
-      <provider selected="true" editor-type-id="text-editor">
-        <state line="367" column="4" selection-start="13097" selection-end="13097" vertical-scroll-proportion="0.13596492">
-          <folding>
-            <element signature="imports" expanded="true" />
-          </folding>
-        </state>
-      </provider>
-    </entry>
-    <entry file="file://$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter12/example3/example12.3.DiffuseOnlyMtlGamma.frag">
-      <provider selected="true" editor-type-id="text-editor">
-        <state line="79" column="0" selection-start="1838" selection-end="1838" vertical-scroll-proportion="0.9013158">
+        <state line="3" column="0" selection-start="40" selection-end="40" vertical-scroll-proportion="0.06828528">
           <folding />
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter12/example3/example12.3.DiffuseOnlyGamma.frag">
+    <entry file="file://$PROJECT_DIR$/src/com/ra4king/opengl/util/math/MatrixStack.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state line="80" column="0" selection-start="1843" selection-end="1843" vertical-scroll-proportion="0.9013158">
+        <state line="13" column="19" selection-start="265" selection-end="265" vertical-scroll-proportion="0.2215909">
           <folding />
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter12/example3/example12.3.DiffuseSpecularGamma.frag">
+    <entry file="file://$PROJECT_DIR$/src/com/ra4king/opengl/util/math/Matrix4.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state line="85" column="4" selection-start="2128" selection-end="2128" vertical-scroll-proportion="0.8519737">
+        <state line="190" column="4" selection-start="4280" selection-end="4280" vertical-scroll-proportion="0.46931818">
           <folding />
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter12/example3/example12.3.DiffuseSpecularMtlGamma.frag">
+    <entry file="file://$PROJECT_DIR$/src/com/ra4king/opengl/util/MousePoles.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state line="84" column="4" selection-start="2114" selection-end="2114" vertical-scroll-proportion="0.8519737">
+        <state line="515" column="102" selection-start="13478" selection-end="13478" vertical-scroll-proportion="0.38636363">
           <folding />
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter12/example3/Example12_3.java">
+    <entry file="file://$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter13/example1/example13.1.DepthImpostor.frag">
       <provider selected="true" editor-type-id="text-editor">
-        <state line="202" column="4" selection-start="9217" selection-end="9217" vertical-scroll-proportion="0.5053908">
+        <state line="89" column="4" selection-start="2346" selection-end="2346" vertical-scroll-proportion="0.33522728">
+          <folding />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter13/example1/example13.1.PerspImpostor.frag">
+      <provider selected="true" editor-type-id="text-editor">
+        <state line="102" column="0" selection-start="2636" selection-end="2636" vertical-scroll-proportion="0.625">
+          <folding />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/src/com/ra4king/opengl/arcsynthesis/gl33/chapter13/example1/Example13_1.java">
+      <provider selected="true" editor-type-id="text-editor">
+        <state line="251" column="4" selection-start="9518" selection-end="9518" vertical-scroll-proportion="0.8615917">
           <folding>
             <element signature="imports" expanded="true" />
           </folding>

src/com/ra4king/opengl/arcsynthesis/README.md

-# README #
-
-XXX TODO

src/com/ra4king/opengl/arcsynthesis/gl33/chapter12/LightManager.java

 			buffer.clear();
 			buffer.put(ambientIntensity.toBuffer());
 			buffer.put(lightAttenuation);
-			buffer.put(0).put(0).put(0);
+			buffer.put(new float[3]);
 			
 			for(PerLight light : lights)
 				buffer.put(light.toBuffer());
 			buffer.put(ambientIntensity.toBuffer());
 			buffer.put(lightAttenuation);
 			buffer.put(maxIntensity);
-			buffer.put(0).put(0);
+			buffer.put(new float[2]);
 			
 			for(PerLight light : lights)
 				buffer.put(light.toBuffer());

src/com/ra4king/opengl/arcsynthesis/gl33/chapter13/example1/Example13_1.java

+package com.ra4king.opengl.arcsynthesis.gl33.chapter13.example1;
+
+import static org.lwjgl.opengl.GL11.*;
+import static org.lwjgl.opengl.GL15.*;
+import static org.lwjgl.opengl.GL20.*;
+import static org.lwjgl.opengl.GL30.*;
+import static org.lwjgl.opengl.GL31.*;
+import static org.lwjgl.opengl.GL32.*;
+
+import java.nio.FloatBuffer;
+
+import org.lwjgl.BufferUtils;
+import org.lwjgl.input.Keyboard;
+
+import com.ra4king.opengl.GLProgram;
+import com.ra4king.opengl.util.Mesh;
+import com.ra4king.opengl.util.MousePoles.MouseButton;
+import com.ra4king.opengl.util.MousePoles.ViewData;
+import com.ra4king.opengl.util.MousePoles.ViewPole;
+import com.ra4king.opengl.util.MousePoles.ViewScale;
+import com.ra4king.opengl.util.ShaderProgram;
+import com.ra4king.opengl.util.Timer;
+import com.ra4king.opengl.util.Timer.Type;
+import com.ra4king.opengl.util.UniformBlockArray;
+import com.ra4king.opengl.util.UniformBlockArray.UniformBlockObject;
+import com.ra4king.opengl.util.Utils;
+import com.ra4king.opengl.util.math.Matrix3;
+import com.ra4king.opengl.util.math.Matrix4;
+import com.ra4king.opengl.util.math.MatrixStack;
+import com.ra4king.opengl.util.math.Quaternion;
+import com.ra4king.opengl.util.math.Vector3;
+import com.ra4king.opengl.util.math.Vector4;
+
+public class Example13_1 extends GLProgram {
+	public static void main(String[] args) {
+		new Example13_1().run(true);
+	}
+	
+	private ProgramMeshData litMeshProgram;
+	private ProgramImposData[] litImpPrograms = new ProgramImposData[Impostors.values().length];
+	private UnlitProgramData unlit;
+	
+	private ViewPole viewPole;
+	
+	private Impostors currentImpostor = Impostors.BASIC;
+	private boolean[] drawImpostor = new boolean[4];
+	
+	private Timer sphereTimer = new Timer(Type.LOOP, 6);
+	
+	private int impostoreVAO;
+	
+	private Mesh planeMesh;
+	private Mesh sphereMesh;
+	private Mesh cubeMesh;
+	
+	private int materialUniformBuffer;
+	private int lightUniformBuffer;
+	private int projectionUniformBuffer;
+	
+	private int materialBlockOffset;
+	
+	private int materialBlockIndex = 0;
+	private int lightBlockIndex = 1;
+	private int projectionBlockIndex = 2;
+	
+	private final float halfLightDistance = 25;
+	private final float lightAttenuation = 1f / (halfLightDistance * halfLightDistance);
+	
+	private boolean drawCameraPos, drawLights = true;
+	
+	private static final int NUMBER_OF_LIGHTS = 2;
+	
+	public Example13_1() {
+		super("Example 13.3 - Basic Impostor", 500, 500, true);
+	}
+	
+	@Override
+	public void init() {
+		glClearColor(0.75f, 0.75f, 1, 1);
+		glClearDepth(1);
+		
+		ViewData viewData = new ViewData(new Vector3(0, 30, 25), new Quaternion(0.3826834f, 0, 0, 0.92387953f), 10, 0);
+		ViewScale viewScale = new ViewScale(3, 70, 3.5f, 1.5f, 5, 1, 90 / 250f);
+		
+		viewPole = new ViewPole(viewData, viewScale, MouseButton.LEFT_BUTTON, false);
+		
+		litMeshProgram = loadLitMeshProgram("example13.1.PN.vert", "example13.1.Lighting.frag");
+		
+		String[] impShaderNames = {
+				"BasicImpostor.vert", "BasicImpostor.frag",
+				"PerspImpostor.vert", "PerspImpostor.frag",
+				"DepthImpostor.vert", "DepthImpostor.frag"
+		};
+		
+		for(int a = 0; a < impShaderNames.length / 2; a++)
+			litImpPrograms[a] = loadLitImposProgram("example13.1." + impShaderNames[a * 2], "example13.1." + impShaderNames[a * 2 + 1]);
+		
+		unlit = loadUnlitProgram("example13.1.Unlit.vert", "example13.1.Unlit.frag");
+		
+		try {
+			planeMesh = new Mesh(getClass().getResource("example13.1.LargePlane.xml"));
+			sphereMesh = new Mesh(getClass().getResource("example13.1.UnitSphere.xml"));
+			cubeMesh = new Mesh(getClass().getResource("example13.1.UnitCube.xml"));
+		} catch(Exception exc) {
+			exc.printStackTrace();
+			destroy();
+		}
+		
+		glEnable(GL_CULL_FACE);
+		glCullFace(GL_BACK);
+		glFrontFace(GL_CW);
+		
+		glEnable(GL_DEPTH_TEST);
+		glDepthMask(true);
+		glDepthFunc(GL_LEQUAL);
+		glDepthRange(0, 1);
+		glEnable(GL_DEPTH_CLAMP);
+		
+		lightUniformBuffer = glGenBuffers();
+		glBindBuffer(GL_UNIFORM_BUFFER, lightUniformBuffer);
+		glBufferData(GL_UNIFORM_BUFFER, LightBlock.SIZE, GL_DYNAMIC_DRAW);
+		
+		projectionUniformBuffer = glGenBuffers();
+		glBindBuffer(GL_UNIFORM_BUFFER, projectionUniformBuffer);
+		glBufferData(GL_UNIFORM_BUFFER, 16 * 4, GL_DYNAMIC_DRAW);
+		
+		glBindBufferRange(GL_UNIFORM_BUFFER, lightBlockIndex, lightUniformBuffer, 0, LightBlock.SIZE);
+		glBindBufferRange(GL_UNIFORM_BUFFER, projectionBlockIndex, projectionUniformBuffer, 0, 16 * 4);
+		
+		glBindBuffer(GL_UNIFORM_BUFFER, 0);
+		
+		impostoreVAO = glGenVertexArrays();
+		
+		createMaterials();
+	}
+	
+	private UnlitProgramData loadUnlitProgram(String vertexShader, String fragmentShader) {
+		UnlitProgramData data = new UnlitProgramData(new ShaderProgram(readFromFile(vertexShader), readFromFile(fragmentShader)));
+		data.modelToCameraMatrixUniform = glGetUniformLocation(data.program.getProgram(), "modelToCameraMatrix");
+		data.objectColorUniform = glGetUniformLocation(data.program.getProgram(), "objectColor");
+		
+		int projectionBlock = glGetUniformBlockIndex(data.program.getProgram(), "Projection");
+		glUniformBlockBinding(data.program.getProgram(), projectionBlock, projectionBlockIndex);
+		
+		return data;
+	}
+	
+	private ProgramMeshData loadLitMeshProgram(String vertexShader, String fragmentShader) {
+		ProgramMeshData data = new ProgramMeshData(new ShaderProgram(readFromFile(vertexShader), readFromFile(fragmentShader)));
+		data.modelToCameraMatrixUniform = glGetUniformLocation(data.program.getProgram(), "modelToCameraMatrix");
+		data.normalModelToCameraMatrixUniform = glGetUniformLocation(data.program.getProgram(), "normalModelToCameraMatrix");
+		
+		int materialBlock = glGetUniformBlockIndex(data.program.getProgram(), "Material");
+		int lightBlockBlock = glGetUniformBlockIndex(data.program.getProgram(), "Light");
+		int projectionBlock = glGetUniformBlockIndex(data.program.getProgram(), "Projection");
+		
+		glUniformBlockBinding(data.program.getProgram(), materialBlock, materialBlockIndex);
+		glUniformBlockBinding(data.program.getProgram(), lightBlockBlock, lightBlockIndex);
+		glUniformBlockBinding(data.program.getProgram(), projectionBlock, projectionBlockIndex);
+		
+		return data;
+	}
+	
+	private ProgramImposData loadLitImposProgram(String vertexShader, String fragmentShader) {
+		ProgramImposData data = new ProgramImposData(new ShaderProgram(readFromFile(vertexShader), readFromFile(fragmentShader)));
+		data.sphereRadiusUniform = glGetUniformLocation(data.program.getProgram(), "sphereRadius");
+		data.cameraSpherePosUniform = glGetUniformLocation(data.program.getProgram(), "cameraSpherePos");
+		
+		int materialBlock = glGetUniformBlockIndex(data.program.getProgram(), "Material");
+		int lightBlockBlock = glGetUniformBlockIndex(data.program.getProgram(), "Light");
+		int projectionBlock = glGetUniformBlockIndex(data.program.getProgram(), "Projection");
+		
+		glUniformBlockBinding(data.program.getProgram(), materialBlock, materialBlockIndex);
+		glUniformBlockBinding(data.program.getProgram(), lightBlockBlock, lightBlockIndex);
+		glUniformBlockBinding(data.program.getProgram(), projectionBlock, projectionBlockIndex);
+		
+		return data;
+	}
+	
+	private void createMaterials() {
+		UniformBlockArray<MaterialBlock> array = new UniformBlockArray<>(MaterialBlock.SIZE, MaterialNames.values().length);
+		materialBlockOffset = array.getArrayOffset();
+		
+		array.setBlockMember(MaterialNames.TERRAIN.ordinal(), new MaterialBlock(new Vector4(0.5f, 0.5f, 0.5f, 1), new Vector4(0.5f, 0.5f, 0.5f, 1), 0.6f));
+		array.setBlockMember(MaterialNames.BLUE_SHINY.ordinal(), new MaterialBlock(new Vector4(0.1f, 0.1f, 0.8f, 1), new Vector4(0.8f, 0.8f, 0.8f, 1), 0.1f));
+		array.setBlockMember(MaterialNames.GOLD_METAL.ordinal(), new MaterialBlock(new Vector4(0.803f, 0.709f, 0.15f, 1), new Vector4(0.803f, 0.709f, 0.15f, 1).mult(0.75f), 0.18f));
+		array.setBlockMember(MaterialNames.DULL_GREY.ordinal(), new MaterialBlock(new Vector4(0.4f, 0.4f, 0.4f, 1), new Vector4(0.1f, 0.1f, 0.1f, 1), 0.8f));
+		array.setBlockMember(MaterialNames.BLACK_SHINY.ordinal(), new MaterialBlock(new Vector4(0.05f, 0.05f, 0.05f, 1), new Vector4(0.95f, 0.95f, 0.95f, 1), 0.3f));
+		
+		materialUniformBuffer = array.createBufferObject();
+	}
+	
+	@Override
+	public void resized() {
+		super.resized();
+		
+		glBindBuffer(GL_UNIFORM_BUFFER, projectionUniformBuffer);
+		glBufferSubData(GL_UNIFORM_BUFFER, 0, new Matrix4().clearToPerspectiveDeg(45, getWidth(), getHeight(), 1, 1000).toBuffer());
+		glBindBuffer(GL_UNIFORM_BUFFER, 0);
+	}
+	
+	@Override
+	public void update(long deltaTime) {
+		sphereTimer.update(deltaTime);
+		
+		Utils.updateMousePoles(viewPole, null);
+		
+		viewPole.charPress(deltaTime);
+	}
+	
+	@Override
+	public void keyPressed(int key, char c) {
+		switch(key) {
+			case Keyboard.KEY_P:
+				sphereTimer.togglePause();
+				break;
+			case Keyboard.KEY_MINUS:
+				sphereTimer.rewind(0.5f);
+				break;
+			case Keyboard.KEY_EQUALS:
+				sphereTimer.fastForward(0.5f);
+				break;
+			case Keyboard.KEY_T:
+				drawCameraPos = !drawCameraPos;
+				break;
+			case Keyboard.KEY_G:
+				drawLights = !drawLights;
+				break;
+			case Keyboard.KEY_1:
+				drawImpostor[0] = !drawImpostor[0];
+				break;
+			case Keyboard.KEY_2:
+				drawImpostor[1] = !drawImpostor[1];
+				break;
+			case Keyboard.KEY_3:
+				drawImpostor[2] = !drawImpostor[2];
+				break;
+			case Keyboard.KEY_4:
+				drawImpostor[3] = !drawImpostor[3];
+				break;
+			case Keyboard.KEY_L:
+				currentImpostor = Impostors.BASIC;
+				break;
+			case Keyboard.KEY_J:
+				currentImpostor = Impostors.PERSPECTIVE;
+				break;
+			case Keyboard.KEY_H:
+				currentImpostor = Impostors.DEPTH;
+				break;
+		}
+	}
+	
+	private Vector4 calcLightPosition() {
+		float currTime = sphereTimer.getAlpha();
+		
+		Vector4 ret = new Vector4(0, 20, 0, 1);
+		ret.x((float)Math.cos(currTime * 2 * Math.PI) * 20);
+		ret.z((float)Math.sin(currTime * 2 * Math.PI) * 20);
+		
+		return ret;
+	}
+	
+	@Override
+	public void render() {
+		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+		
+		MatrixStack modelMatrix = new MatrixStack();
+		modelMatrix.setTop(viewPole.calcMatrix());
+		
+		Matrix4 worldToCamMatrix = modelMatrix.getTop();
+		
+		LightBlock lightData = new LightBlock(new Vector4(0.2f, 0.2f, 0.2f, 1), lightAttenuation);
+		
+		lightData.lights[0] = new PerLight(worldToCamMatrix.mult(new Vector4(0.707f, 0.707f, 0, 0)), new Vector4(0.6f, 0.6f, 0.6f, 1));
+		lightData.lights[1] = new PerLight(worldToCamMatrix.mult(calcLightPosition()), new Vector4(0.4f, 0.4f, 0.4f, 1));
+		
+		glBindBuffer(GL_UNIFORM_BUFFER, lightUniformBuffer);
+		glBufferSubData(GL_UNIFORM_BUFFER, 0, lightData.toBuffer());
+		glBindBuffer(GL_UNIFORM_BUFFER, 0);
+		
+		{
+			glBindBufferRange(GL_UNIFORM_BUFFER, materialBlockIndex, materialUniformBuffer, MaterialNames.TERRAIN.ordinal() * materialBlockOffset, MaterialBlock.SIZE);
+			
+			litMeshProgram.program.begin();
+			glUniformMatrix4(litMeshProgram.modelToCameraMatrixUniform, false, modelMatrix.getTop().toBuffer());
+			glUniformMatrix3(litMeshProgram.normalModelToCameraMatrixUniform, false, new Matrix3(modelMatrix.getTop()).inverse().transpose().toBuffer());
+			planeMesh.render();
+			litMeshProgram.program.end();
+			
+			glBindBufferBase(GL_UNIFORM_BUFFER, materialBlockIndex, 0);
+		}
+		
+		drawSphere(modelMatrix, new Vector3(0, 10, 0), 4, MaterialNames.BLUE_SHINY, drawImpostor[0]);
+		drawSphereOrbit(modelMatrix, new Vector3(0, 10, 0), new Vector3(0.6f, 0.8f, 0), 20, sphereTimer.getAlpha(), 2, MaterialNames.DULL_GREY, drawImpostor[1]);
+		drawSphereOrbit(modelMatrix, new Vector3(-10, 1, 0), new Vector3(0, 1, 0), 10, sphereTimer.getAlpha(), 1, MaterialNames.BLACK_SHINY, drawImpostor[2]);
+		drawSphereOrbit(modelMatrix, new Vector3(10, 1, 0), new Vector3(0, 1, 0), 10, sphereTimer.getAlpha() * 2, 1, MaterialNames.GOLD_METAL, drawImpostor[3]);
+		
+		if(drawLights) {
+			modelMatrix.pushMatrix();
+			
+			modelMatrix.getTop().translate(new Vector3(calcLightPosition()));
+			modelMatrix.getTop().scale(0.5f);
+			
+			unlit.program.begin();
+			glUniformMatrix4(unlit.modelToCameraMatrixUniform, false, modelMatrix.getTop().toBuffer());
+			glUniform4(unlit.objectColorUniform, new Vector4(1).toBuffer());
+			cubeMesh.render("flat");
+			unlit.program.end();
+			
+			modelMatrix.popMatrix();
+		}
+		
+		if(drawCameraPos) {
+			modelMatrix.pushMatrix();
+			
+			modelMatrix.getTop().clearToIdentity();
+			modelMatrix.getTop().translate(0, 0, -viewPole.getView().radius);
+			
+			unlit.program.begin();
+			
+			glDisable(GL_DEPTH_TEST);
+			glDepthMask(false);
+			glUniformMatrix4(unlit.modelToCameraMatrixUniform, false, modelMatrix.getTop().toBuffer());
+			glUniform4f(unlit.objectColorUniform, 0.25f, 0.25f, 0.25f, 1);
+			cubeMesh.render("flat");
+			
+			glDepthMask(true);
+			glEnable(GL_DEPTH_TEST);
+			glUniform4f(unlit.objectColorUniform, 1, 1, 1, 1);
+			cubeMesh.render("flat");
+			
+			unlit.program.end();
+		}
+	}
+	
+	private void drawSphere(MatrixStack modelMatrix, Vector3 position, float radius, MaterialNames material, boolean drawImpostor) {
+		glBindBufferRange(GL_UNIFORM_BUFFER, materialBlockIndex, materialUniformBuffer, material.ordinal() * materialBlockOffset, MaterialBlock.SIZE);
+		
+		if(drawImpostor) {
+			litImpPrograms[currentImpostor.ordinal()].program.begin();
+			glUniform3(litImpPrograms[currentImpostor.ordinal()].cameraSpherePosUniform, modelMatrix.getTop().mult(new Vector4(position, 1)).toBuffer());
+			glUniform1f(litImpPrograms[currentImpostor.ordinal()].sphereRadiusUniform, radius);
+			
+			glBindVertexArray(impostoreVAO);
+			glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+			glBindVertexArray(0);
+			
+			litImpPrograms[currentImpostor.ordinal()].program.end();
+		}
+		else {
+			modelMatrix.pushMatrix();
+			modelMatrix.getTop().translate(position);
+			modelMatrix.getTop().scale(radius * 2);
+			
+			litMeshProgram.program.begin();
+			glUniformMatrix4(litMeshProgram.modelToCameraMatrixUniform, false, modelMatrix.getTop().toBuffer());
+			glUniformMatrix3(litMeshProgram.normalModelToCameraMatrixUniform, false, new Matrix3(modelMatrix.getTop()).inverse().transpose().toBuffer());
+			sphereMesh.render("lit");
+			litMeshProgram.program.end();
+			
+			modelMatrix.popMatrix();
+		}
+		
+		glBindBufferBase(GL_UNIFORM_BUFFER, materialBlockIndex, 0);
+	}
+	
+	private void drawSphereOrbit(MatrixStack modelMatrix, Vector3 orbitCenter, Vector3 orbitAxis, float orbitRadius, float orbitAlpha, float sphereRadius, MaterialNames material, boolean drawImpostor) {
+		modelMatrix.pushMatrix();
+		
+		modelMatrix.getTop().translate(orbitCenter);
+		modelMatrix.getTop().rotateDeg(360 * orbitAlpha, orbitAxis);
+		
+		Vector3 offsetDir = orbitAxis.copy().cross(new Vector3(0, 1, 0));
+		if(offsetDir.length() < 0.001f)
+			offsetDir = orbitAxis.copy().cross(new Vector3(1, 0, 0));
+		
+		offsetDir.normalize();
+		
+		modelMatrix.getTop().translate(offsetDir.mult(orbitRadius));
+		
+		drawSphere(modelMatrix, new Vector3(0), sphereRadius, material, drawImpostor);
+		
+		modelMatrix.popMatrix();
+	}
+	
+	private static enum Impostors {
+		BASIC, PERSPECTIVE, DEPTH
+	}
+	
+	private static enum MaterialNames {
+		TERRAIN, BLUE_SHINY, GOLD_METAL, DULL_GREY, BLACK_SHINY
+	}
+	
+	private static class ProgramMeshData {
+		private ShaderProgram program;
+		
+		private int modelToCameraMatrixUniform;
+		private int normalModelToCameraMatrixUniform;
+		
+		public ProgramMeshData(ShaderProgram program) {
+			this.program = program;
+		}
+	}
+	
+	private static class ProgramImposData {
+		private ShaderProgram program;
+		
+		private int sphereRadiusUniform;
+		private int cameraSpherePosUniform;
+		
+		public ProgramImposData(ShaderProgram program) {
+			this.program = program;
+		}
+	}
+	
+	private static class UnlitProgramData {
+		private ShaderProgram program;
+		
+		private int objectColorUniform;
+		private int modelToCameraMatrixUniform;
+		
+		public UnlitProgramData(ShaderProgram program) {
+			this.program = program;
+		}
+	}
+	
+	private static class PerLight {
+		private Vector4 cameraSpaceLightPos;
+		private Vector4 lightIntensity;
+		
+		public static final int SIZE = 2 * 4 * 4;
+		
+		public PerLight(Vector4 cameraSpaceLightPos, Vector4 lightIntensity) {
+			this.cameraSpaceLightPos = cameraSpaceLightPos;
+			this.lightIntensity = lightIntensity;
+		}
+		
+		private static final FloatBuffer buffer = BufferUtils.createFloatBuffer(SIZE / 4);
+		
+		public FloatBuffer toBuffer() {
+			buffer.clear();
+			buffer.put(cameraSpaceLightPos.toBuffer());
+			buffer.put(lightIntensity.toBuffer());
+			buffer.flip();
+			return buffer;
+		}
+	}
+	
+	private static class LightBlock {
+		private Vector4 ambientIntensity;
+		private float lightAttenuation;
+		private PerLight[] lights = new PerLight[NUMBER_OF_LIGHTS];
+		
+		public static final int SIZE = 2 * 4 * 4 + NUMBER_OF_LIGHTS * PerLight.SIZE;
+		
+		public LightBlock(Vector4 ambientIntensity, float lightAttenuation) {
+			this.ambientIntensity = ambientIntensity;
+			this.lightAttenuation = lightAttenuation;
+		}
+		
+		private static final FloatBuffer buffer = BufferUtils.createFloatBuffer(SIZE / 4);
+		
+		public FloatBuffer toBuffer() {
+			buffer.clear();
+			buffer.put(ambientIntensity.toBuffer());
+			buffer.put(lightAttenuation);
+			buffer.put(new float[3]);
+			
+			for(PerLight light : lights)
+				buffer.put(light.toBuffer());
+			
+			buffer.flip();
+			return buffer;
+		}
+	}
+	
+	private static class MaterialBlock implements UniformBlockObject {
+		private Vector4 diffuseColor;
+		private Vector4 specularColor;
+		private float specularShininess;
+		
+		public static final int SIZE = 3 * 4 * 4;
+		
+		public MaterialBlock(Vector4 diffuseColor, Vector4 specularColor, float specularShininess) {
+			this.diffuseColor = diffuseColor;
+			this.specularColor = specularColor;
+			this.specularShininess = specularShininess;
+		}
+		
+		private static final FloatBuffer buffer = BufferUtils.createFloatBuffer(SIZE / 4);
+		
+		public FloatBuffer toBuffer() {
+			buffer.clear();
+			buffer.put(diffuseColor.toBuffer());
+			buffer.put(specularColor.toBuffer());
+			buffer.put(specularShininess);
+			buffer.put(new float[3]);
+			buffer.flip();
+			return buffer;
+		}
+	}
+}

src/com/ra4king/opengl/arcsynthesis/gl33/chapter13/example1/example13.1.BasicImpostor.frag

+#version 330
+
+in vec2 mapping;
+
+out vec4 outputColor;
+
+uniform float sphereRadius;
+uniform vec3 cameraSpherePos;
+
+layout(std140) uniform;
+
+uniform Material
+{
+	vec4 diffuseColor;
+	vec4 specularColor;
+	float specularShininess;
+} Mtl;
+
+struct PerLight
+{
+	vec4 cameraSpaceLightPos;
+	vec4 lightIntensity;
+};
+
+const int numberOfLights = 2;
+
+uniform Light
+{
+	vec4 ambientIntensity;
+	float lightAttenuation;
+	PerLight lights[numberOfLights];
+} Lgt;
+
+uniform Projection
+{
+	mat4 cameraToClipMatrix;
+};
+
+float calcAttenuation(in vec3 cameraSpacePosition, in vec3 cameraSpaceLightPos, out vec3 lightDirection)
+{
+	vec3 lightDifference =  cameraSpaceLightPos - cameraSpacePosition;
+	float lightDistanceSqr = dot(lightDifference, lightDifference);
+	lightDirection = lightDifference * inversesqrt(lightDistanceSqr);
+	
+	return 1.0 / (1.0 + Lgt.lightAttenuation * lightDistanceSqr);
+}
+
+vec4 computeLighting(in PerLight lightData, in vec3 cameraSpacePosition, in vec3 cameraSpaceNormal)
+{
+	vec3 lightDir;
+	vec4 lightIntensity;
+	if(lightData.cameraSpaceLightPos.w == 0.0)
+	{
+		lightDir = vec3(lightData.cameraSpaceLightPos);
+		lightIntensity = lightData.lightIntensity;
+	}
+	else
+	{
+		float atten = calcAttenuation(cameraSpacePosition, lightData.cameraSpaceLightPos.xyz, lightDir);
+		lightIntensity = atten * lightData.lightIntensity;
+	}
+	
+	vec3 surfaceNormal = normalize(cameraSpaceNormal);
+	float cosAngIncidence = dot(surfaceNormal, lightDir);
+	cosAngIncidence = cosAngIncidence < 0.0001 ? 0.0 : cosAngIncidence;
+	
+	vec3 viewDirection = normalize(-cameraSpacePosition);
+	
+	vec3 halfAngle = normalize(lightDir + viewDirection);
+	float angleNormalHalf = acos(dot(halfAngle, surfaceNormal));
+	float exponent = angleNormalHalf / Mtl.specularShininess;
+	exponent = -(exponent * exponent);
+	float gaussianTerm = exp(exponent);
+	
+	gaussianTerm = cosAngIncidence != 0.0 ? gaussianTerm : 0.0;
+	
+	vec4 lighting = Mtl.diffuseColor * lightIntensity * cosAngIncidence;
+	lighting += Mtl.specularColor * lightIntensity * gaussianTerm;
+    	
+	return lighting;
+}
+
+void impostor(out vec3 cameraPos, out vec3 cameraNormal)
+{
+	float lensqr = dot(mapping, mapping);
+	if(lensqr > 1.0)
+		discard;
+	
+	cameraNormal = vec3(mapping, sqrt(1.0 - lensqr));
+	cameraPos = (cameraNormal * sphereRadius) + cameraSpherePos;
+}
+
+void main()
+{
+	vec3 cameraPos;
+	vec3 cameraNormal;
+	
+	impostor(cameraPos, cameraNormal);
+	
+	vec4 accumLighting = Mtl.diffuseColor * Lgt.ambientIntensity;
+	for(int light = 0; light < numberOfLights; light++)
+	{
+		accumLighting += computeLighting(Lgt.lights[light], cameraPos, cameraNormal);
+	}
+	
+	outputColor = sqrt(accumLighting);
+}

src/com/ra4king/opengl/arcsynthesis/gl33/chapter13/example1/example13.1.BasicImpostor.vert

+#version 330
+
+layout(std140) uniform;
+
+out vec2 mapping;
+
+uniform Projection
+{
+	mat4 cameraToClipMatrix;
+};
+
+uniform float sphereRadius;
+uniform vec3 cameraSpherePos;
+
+void main()
+{
+	vec2 offset;
+	switch(gl_VertexID)
+	{
+		case 0:
+			mapping = vec2(-1.0, -1.0);
+			offset = vec2(-sphereRadius, -sphereRadius);
+			break;
+		case 1:
+			mapping = vec2(-1.0, 1.0);
+			offset = vec2(-sphereRadius, sphereRadius);
+			break;
+		case 2:
+			mapping = vec2(1.0, -1.0);
+			offset = vec2(sphereRadius, -sphereRadius);
+			break;
+		case 3:
+			mapping = vec2(1.0, 1.0);
+			offset = vec2(sphereRadius, sphereRadius);
+			break;
+	}
+	
+	vec4 cameraCornerPos = vec4(cameraSpherePos, 1.0);
+	cameraCornerPos.xy += offset;
+	
+	gl_Position = cameraToClipMatrix * cameraCornerPos;
+}

src/com/ra4king/opengl/arcsynthesis/gl33/chapter13/example1/example13.1.DepthImpostor.frag

+#version 330
+
+in vec2 mapping;
+
+out vec4 outputColor;
+
+uniform float sphereRadius;
+uniform vec3 cameraSpherePos;
+
+layout(std140) uniform;
+
+uniform Material
+{
+	vec4 diffuseColor;
+	vec4 specularColor;
+	float specularShininess;
+} Mtl;
+
+struct PerLight
+{
+	vec4 cameraSpaceLightPos;
+	vec4 lightIntensity;
+};
+
+const int numberOfLights = 2;
+
+uniform Light
+{
+	vec4 ambientIntensity;
+	float lightAttenuation;
+	PerLight lights[numberOfLights];
+} Lgt;
+
+uniform Projection
+{
+	mat4 cameraToClipMatrix;
+};
+
+float calcAttenuation(in vec3 cameraSpacePosition, in vec3 cameraSpaceLightPos, out vec3 lightDirection)
+{
+	vec3 lightDifference =  cameraSpaceLightPos - cameraSpacePosition;
+	float lightDistanceSqr = dot(lightDifference, lightDifference);
+	lightDirection = lightDifference * inversesqrt(lightDistanceSqr);
+	
+	return 1.0 / (1.0 + Lgt.lightAttenuation * lightDistanceSqr);
+}
+
+vec4 computeLighting(in PerLight lightData, in vec3 cameraSpacePosition, in vec3 cameraSpaceNormal)
+{
+	vec3 lightDir;
+	vec4 lightIntensity;
+	if(lightData.cameraSpaceLightPos.w == 0.0)
+	{
+		lightDir = vec3(lightData.cameraSpaceLightPos);
+		lightIntensity = lightData.lightIntensity;
+	}
+	else
+	{
+		float atten = calcAttenuation(cameraSpacePosition, lightData.cameraSpaceLightPos.xyz, lightDir);
+		lightIntensity = atten * lightData.lightIntensity;
+	}
+	
+	vec3 surfaceNormal = normalize(cameraSpaceNormal);
+	float cosAngIncidence = dot(surfaceNormal, lightDir);
+	cosAngIncidence = cosAngIncidence < 0.0001 ? 0.0 : cosAngIncidence;
+	
+	vec3 viewDirection = normalize(-cameraSpacePosition);
+	
+	vec3 halfAngle = normalize(lightDir + viewDirection);
+	float angleNormalHalf = acos(dot(halfAngle, surfaceNormal));
+	float exponent = angleNormalHalf / Mtl.specularShininess;
+	exponent = -(exponent * exponent);
+	float gaussianTerm = exp(exponent);
+
+	gaussianTerm = cosAngIncidence != 0.0 ? gaussianTerm : 0.0;
+	
+	vec4 lighting = Mtl.diffuseColor * lightIntensity * cosAngIncidence;
+	lighting += Mtl.specularColor * lightIntensity * gaussianTerm;
+	
+	return lighting;
+}
+
+void impostor(out vec3 cameraPos, out vec3 cameraNormal)
+{
+	vec3 cameraPlanePos = vec3(mapping * sphereRadius, 0.0) + cameraSpherePos;
+	vec3 rayDirection = normalize(cameraPlanePos);
+	
+	float B = 2.0 * dot(rayDirection, -cameraSpherePos);
+	float C = dot(cameraSpherePos, cameraSpherePos) - (sphereRadius * sphereRadius);
+	
+	float det = (B * B) - (4 * C);
+	if(det < 0.0)
+		discard;
+		
+	float sqrtDet = sqrt(det);
+	float posT = (-B + sqrtDet)/2;
+	float negT = (-B - sqrtDet)/2;
+	
+	float intersectT = min(posT, negT);
+	cameraPos = rayDirection * intersectT;
+	cameraNormal = normalize(cameraPos - cameraSpherePos);
+}
+
+void main()
+{
+	vec3 cameraPos;
+	vec3 cameraNormal;
+	
+	impostor(cameraPos, cameraNormal);
+	
+	vec4 clipPos = cameraToClipMatrix * vec4(cameraPos, 1.0);
+	float ndcDepth = clipPos.z / clipPos.w;
+	gl_FragDepth = ((gl_DepthRange.diff * ndcDepth) + gl_DepthRange.near + gl_DepthRange.far) / 2.0;
+	
+	vec4 accumLighting = Mtl.diffuseColor * Lgt.ambientIntensity;
+	for(int light = 0; light < numberOfLights; light++)
+	{
+		accumLighting += computeLighting(Lgt.lights[light], cameraPos, cameraNormal);
+	}
+	
+	outputColor = sqrt(accumLighting);
+}

src/com/ra4king/opengl/arcsynthesis/gl33/chapter13/example1/example13.1.DepthImpostor.vert

+#version 330
+
+layout(std140) uniform;
+
+out vec2 mapping;
+
+uniform Projection
+{
+	mat4 cameraToClipMatrix;
+};
+
+uniform float sphereRadius;
+uniform vec3 cameraSpherePos;
+
+const float g_boxCorrection = 1.5;
+
+void main()
+{
+	vec2 offset;
+	switch(gl_VertexID)
+	{
+		case 0:
+			mapping = vec2(-1.0, -1.0) * g_boxCorrection;
+			offset = vec2(-sphereRadius, -sphereRadius);
+			break;
+		case 1:
+			mapping = vec2(-1.0, 1.0) * g_boxCorrection;
+			offset = vec2(-sphereRadius, sphereRadius);
+			break;
+		case 2:
+			mapping = vec2(1.0, -1.0) * g_boxCorrection;
+			offset = vec2(sphereRadius, -sphereRadius);
+			break;
+		case 3:
+			mapping = vec2(1.0, 1.0) * g_boxCorrection;
+			offset = vec2(sphereRadius, sphereRadius);
+			break;
+	}
+	
+	vec4 cameraCornerPos = vec4(cameraSpherePos, 1.0);
+	cameraCornerPos.xy += offset * g_boxCorrection;
+
+	gl_Position = cameraToClipMatrix * cameraCornerPos;
+}

src/com/ra4king/opengl/arcsynthesis/gl33/chapter13/example1/example13.1.LargePlane.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<?oxygen RNGSchema="../../Documents/meshFormat.rnc" type="compact"?>
+
+<mesh xmlns="http://www.arcsynthesis.com/gltut/mesh">
+	<attribute index="0" type="float" size="3">
+		30 0 -30
+		30 0 30
+		-30 0 30
+		-30 0 -30
+		30 0 -30
+		30 0 30
+		-30 0 30
+		-30 0 -30
+	</attribute>
+	<attribute index="2" type="float" size="3">
+		0 1 0
+		0 1 0
+		0 1 0
+		0 1 0
+		0 -1 0
+		0 -1 0
+		0 -1 0
+		0 -1 0
+	</attribute>
+	<indices cmd="triangles" type="ushort">
+		0 1 2
+		2 3 0
+		4 6 5
+		6 4 7
+	</indices>
+</mesh>

src/com/ra4king/opengl/arcsynthesis/gl33/chapter13/example1/example13.1.Lighting.frag

+#version 330
+
+in vec3 vertexNormal;
+in vec3 cameraSpacePosition;
+
+out vec4 outputColor;
+
+layout(std140) uniform;
+
+uniform Material
+{
+	vec4 diffuseColor;
+	vec4 specularColor;
+	float specularShininess;
+} Mtl;
+
+struct PerLight
+{
+	vec4 cameraSpaceLightPos;
+	vec4 lightIntensity;
+};
+
+const int numberOfLights = 2;
+
+uniform Light
+{
+	vec4 ambientIntensity;
+	float lightAttenuation;
+	PerLight lights[numberOfLights];
+} Lgt;
+
+float calcAttenuation(in vec3 cameraSpacePosition,
+	in vec3 cameraSpaceLightPos,
+	out vec3 lightDirection)
+{
+	vec3 lightDifference =  cameraSpaceLightPos - cameraSpacePosition;
+	float lightDistanceSqr = dot(lightDifference, lightDifference);
+	lightDirection = lightDifference * inversesqrt(lightDistanceSqr);
+	
+	return 1.0 / (1.0 + Lgt.lightAttenuation * lightDistanceSqr);
+}
+
+vec4 computeLighting(in PerLight lightData, in vec3 cameraSpacePosition, in vec3 cameraSpaceNormal)
+{
+	vec3 lightDir;
+	vec4 lightIntensity;
+	if(lightData.cameraSpaceLightPos.w == 0.0)
+	{
+		lightDir = vec3(lightData.cameraSpaceLightPos);
+		lightIntensity = lightData.lightIntensity;
+	}
+	else
+	{
+		float atten = calcAttenuation(cameraSpacePosition, lightData.cameraSpaceLightPos.xyz, lightDir);
+		lightIntensity = atten * lightData.lightIntensity;
+	}
+	
+	vec3 surfaceNormal = normalize(cameraSpaceNormal);
+	float cosAngIncidence = dot(surfaceNormal, lightDir);
+	cosAngIncidence = cosAngIncidence < 0.0001 ? 0.0 : cosAngIncidence;
+	
+	vec3 viewDirection = normalize(-cameraSpacePosition);
+	
+	vec3 halfAngle = normalize(lightDir + viewDirection);
+	float angleNormalHalf = acos(dot(halfAngle, surfaceNormal));
+	float exponent = angleNormalHalf / Mtl.specularShininess;
+	exponent = -(exponent * exponent);
+	float gaussianTerm = exp(exponent);
+
+	gaussianTerm = cosAngIncidence != 0.0 ? gaussianTerm : 0.0;
+	
+	vec4 lighting = Mtl.diffuseColor * lightIntensity * cosAngIncidence;
+	lighting += Mtl.specularColor * lightIntensity * gaussianTerm;
+	
+	return lighting;
+}
+
+void main()
+{
+	vec4 accumLighting = Mtl.diffuseColor * Lgt.ambientIntensity;
+	for(int light = 0; light < numberOfLights; light++)
+	{
+		accumLighting += computeLighting(Lgt.lights[light], cameraSpacePosition, vertexNormal);
+	}
+	
+	outputColor = sqrt(accumLighting); //2.0 gamma correction
+}

src/com/ra4king/opengl/arcsynthesis/gl33/chapter13/example1/example13.1.PN.vert

+#version 330
+
+layout(std140) uniform;
+
+layout(location = 0) in vec3 position;
+layout(location = 2) in vec3 normal;
+
+out vec3 vertexNormal;
+out vec3 cameraSpacePosition;
+
+uniform Projection
+{
+	mat4 cameraToClipMatrix;
+};
+
+uniform mat4 modelToCameraMatrix;
+uniform mat3 normalModelToCameraMatrix;
+
+void main()
+{
+	vec4 tempCamPosition = modelToCameraMatrix * vec4(position, 1.0);
+    gl_Position = cameraToClipMatrix * tempCamPosition;
+
+    vertexNormal = normalize(normalModelToCameraMatrix * normal);
+    cameraSpacePosition = vec3(tempCamPosition);
+}

src/com/ra4king/opengl/arcsynthesis/gl33/chapter13/example1/example13.1.PerspImpostor.frag

+#version 330
+
+in vec2 mapping;
+
+out vec4 outputColor;
+
+uniform float sphereRadius;
+uniform vec3 cameraSpherePos;
+
+layout(std140) uniform;
+
+uniform Material
+{
+	vec4 diffuseColor;
+	vec4 specularColor;
+	float specularShininess;
+} Mtl;
+
+struct PerLight
+{
+	vec4 cameraSpaceLightPos;
+	vec4 lightIntensity;
+};
+
+const int numberOfLights = 2;
+
+uniform Light
+{
+	vec4 ambientIntensity;
+	float lightAttenuation;
+	PerLight lights[numberOfLights];
+} Lgt;
+
+uniform Projection
+{
+	mat4 cameraToClipMatrix;
+};
+
+float calcAttenuation(in vec3 cameraSpacePosition, in vec3 cameraSpaceLightPos, out vec3 lightDirection)
+{
+	vec3 lightDifference =  cameraSpaceLightPos - cameraSpacePosition;
+	float lightDistanceSqr = dot(lightDifference, lightDifference);
+	lightDirection = lightDifference * inversesqrt(lightDistanceSqr);
+	
+	return 1.0 / (1.0 + Lgt.lightAttenuation * lightDistanceSqr);
+}
+
+vec4 computeLighting(in PerLight lightData, in vec3 cameraSpacePosition, in vec3 cameraSpaceNormal)
+{
+	vec3 lightDir;
+	vec4 lightIntensity;
+	if(lightData.cameraSpaceLightPos.w == 0.0)
+	{
+		lightDir = vec3(lightData.cameraSpaceLightPos);
+		lightIntensity = lightData.lightIntensity;
+	}
+	else
+	{
+		float atten = calcAttenuation(cameraSpacePosition, lightData.cameraSpaceLightPos.xyz, lightDir);
+		lightIntensity = atten * lightData.lightIntensity;
+	}
+	
+	vec3 surfaceNormal = normalize(cameraSpaceNormal);
+	float cosAngIncidence = dot(surfaceNormal, lightDir);
+	cosAngIncidence = cosAngIncidence < 0.0001 ? 0.0 : cosAngIncidence;
+	
+	vec3 viewDirection = normalize(-cameraSpacePosition);
+	
+	vec3 halfAngle = normalize(lightDir + viewDirection);
+	float angleNormalHalf = acos(dot(halfAngle, surfaceNormal));
+	float exponent = angleNormalHalf / Mtl.specularShininess;
+	exponent = -(exponent * exponent);
+	float gaussianTerm = exp(exponent);
+
+	gaussianTerm = cosAngIncidence != 0.0 ? gaussianTerm : 0.0;
+	
+	vec4 lighting = Mtl.diffuseColor * lightIntensity * cosAngIncidence;
+	lighting += Mtl.specularColor * lightIntensity * gaussianTerm;
+	
+	return lighting;
+}
+
+void impostor(out vec3 cameraPos, out vec3 cameraNormal)
+{
+	vec3 cameraPlanePos = vec3(mapping * sphereRadius, 0.0) + cameraSpherePos;
+	vec3 rayDirection = normalize(cameraPlanePos);