Browse Source

Update examples;

Still to do:

- Spectator Camera
- Postprocessing
bjorn 6 years ago
parent
commit
dbf682aafb
75 changed files with 64 additions and 371 deletions
  1. 4 13
      examples/Animation/main.lua
  2. 1 1
      examples/Hud/main.lua
  3. BIN
      examples/PBR_Materials/env/m0_nx.png
  4. BIN
      examples/PBR_Materials/env/m0_ny.png
  5. BIN
      examples/PBR_Materials/env/m0_nz.png
  6. BIN
      examples/PBR_Materials/env/m0_px.png
  7. BIN
      examples/PBR_Materials/env/m0_py.png
  8. BIN
      examples/PBR_Materials/env/m0_pz.png
  9. BIN
      examples/PBR_Materials/env/m1_nx.png
  10. BIN
      examples/PBR_Materials/env/m1_ny.png
  11. BIN
      examples/PBR_Materials/env/m1_nz.png
  12. BIN
      examples/PBR_Materials/env/m1_px.png
  13. BIN
      examples/PBR_Materials/env/m1_py.png
  14. BIN
      examples/PBR_Materials/env/m1_pz.png
  15. BIN
      examples/PBR_Materials/env/m2_nx.png
  16. BIN
      examples/PBR_Materials/env/m2_ny.png
  17. BIN
      examples/PBR_Materials/env/m2_nz.png
  18. BIN
      examples/PBR_Materials/env/m2_px.png
  19. BIN
      examples/PBR_Materials/env/m2_py.png
  20. BIN
      examples/PBR_Materials/env/m2_pz.png
  21. BIN
      examples/PBR_Materials/env/m3_nx.png
  22. BIN
      examples/PBR_Materials/env/m3_ny.png
  23. BIN
      examples/PBR_Materials/env/m3_nz.png
  24. BIN
      examples/PBR_Materials/env/m3_px.png
  25. BIN
      examples/PBR_Materials/env/m3_py.png
  26. BIN
      examples/PBR_Materials/env/m3_pz.png
  27. BIN
      examples/PBR_Materials/env/m4_nx.png
  28. BIN
      examples/PBR_Materials/env/m4_ny.png
  29. BIN
      examples/PBR_Materials/env/m4_nz.png
  30. BIN
      examples/PBR_Materials/env/m4_px.png
  31. BIN
      examples/PBR_Materials/env/m4_py.png
  32. BIN
      examples/PBR_Materials/env/m4_pz.png
  33. BIN
      examples/PBR_Materials/env/m5_nx.png
  34. BIN
      examples/PBR_Materials/env/m5_ny.png
  35. BIN
      examples/PBR_Materials/env/m5_nz.png
  36. BIN
      examples/PBR_Materials/env/m5_px.png
  37. BIN
      examples/PBR_Materials/env/m5_py.png
  38. BIN
      examples/PBR_Materials/env/m5_pz.png
  39. BIN
      examples/PBR_Materials/env/m6_nx.png
  40. BIN
      examples/PBR_Materials/env/m6_ny.png
  41. BIN
      examples/PBR_Materials/env/m6_nz.png
  42. BIN
      examples/PBR_Materials/env/m6_px.png
  43. BIN
      examples/PBR_Materials/env/m6_py.png
  44. BIN
      examples/PBR_Materials/env/m6_pz.png
  45. BIN
      examples/PBR_Materials/env/m7_nx.png
  46. BIN
      examples/PBR_Materials/env/m7_ny.png
  47. BIN
      examples/PBR_Materials/env/m7_nz.png
  48. BIN
      examples/PBR_Materials/env/m7_px.png
  49. BIN
      examples/PBR_Materials/env/m7_py.png
  50. BIN
      examples/PBR_Materials/env/m7_pz.png
  51. BIN
      examples/PBR_Materials/env/m8_nx.png
  52. BIN
      examples/PBR_Materials/env/m8_ny.png
  53. BIN
      examples/PBR_Materials/env/m8_nz.png
  54. BIN
      examples/PBR_Materials/env/m8_px.png
  55. BIN
      examples/PBR_Materials/env/m8_py.png
  56. BIN
      examples/PBR_Materials/env/m8_pz.png
  57. BIN
      examples/PBR_Materials/env/nx.png
  58. BIN
      examples/PBR_Materials/env/ny.png
  59. BIN
      examples/PBR_Materials/env/nz.png
  60. BIN
      examples/PBR_Materials/env/px.png
  61. BIN
      examples/PBR_Materials/env/py.png
  62. BIN
      examples/PBR_Materials/env/pz.png
  63. 11 0
      examples/PBR_Materials/env/sphericalHarmonics.lua
  64. BIN
      examples/PBR_Materials/helmet/DamagedHelmet.bin
  65. BIN
      examples/PBR_Materials/helmet/DamagedHelmet.glb
  66. 0 204
      examples/PBR_Materials/helmet/DamagedHelmet.gltf
  67. BIN
      examples/PBR_Materials/helmet/Default_AO.jpg
  68. BIN
      examples/PBR_Materials/helmet/Default_albedo.jpg
  69. BIN
      examples/PBR_Materials/helmet/Default_emissive.jpg
  70. BIN
      examples/PBR_Materials/helmet/Default_metalRoughness.jpg
  71. BIN
      examples/PBR_Materials/helmet/Default_normal.jpg
  72. 39 98
      examples/PBR_Materials/main.lua
  73. 5 5
      examples/Physics/main.lua
  74. 0 44
      examples/Physics/shader.lua
  75. 4 6
      examples/Spectator_Camera/main.lua

+ 4 - 13
examples/Animation/main.lua

@@ -6,22 +6,13 @@
 
 function lovr.load()
   model = lovr.graphics.newModel('scytha/scene.gltf')
-  animator = lovr.graphics.newAnimator(model)
-  animation = animator:getAnimationNames()[1]
-  assert(animation, 'No animation found!')
-  animator:play(animation)
-  animator:setLooping(animation, true)
-  model:setAnimator(animator)
-
-  shader = lovr.graphics.newShader([[
-    vec4 position(mat4 projection, mat4 transform, vec4 vertex) {
-      return projection * transform * lovrPoseMatrix * vertex;
-    }
-  ]], nil)
+  shader = lovr.graphics.newShader('unlit', {
+    flags = { animated = true }
+  })
 end
 
 function lovr.update(dt)
-  animator:update(dt)
+  model:animate(1, lovr.timer.getTime())
 end
 
 function lovr.draw()

+ 1 - 1
examples/Hud/main.lua

@@ -38,7 +38,7 @@ local bannedcell = math.ceil(cells/2)               -- Do not allow clicks at th
 local fontscale = height/lovr.graphics.getHeight()  -- Scale argument to screen-space print() functions
 
 -- Screen-space coordinate system
-local matrix = lovr.math.mat4():orthographic(-aspect, aspect, -1, 1, -64, 64)
+local matrix = lovr.math.newMat4():orthographic(-aspect, aspect, -1, 1, -64, 64)
 
 -- State: We will store the blocks to draw as a 2D array of heights (nil for no block)
 local grid = {}

BIN
examples/PBR_Materials/env/m0_nx.png


BIN
examples/PBR_Materials/env/m0_ny.png


BIN
examples/PBR_Materials/env/m0_nz.png


BIN
examples/PBR_Materials/env/m0_px.png


BIN
examples/PBR_Materials/env/m0_py.png


BIN
examples/PBR_Materials/env/m0_pz.png


BIN
examples/PBR_Materials/env/m1_nx.png


BIN
examples/PBR_Materials/env/m1_ny.png


BIN
examples/PBR_Materials/env/m1_nz.png


BIN
examples/PBR_Materials/env/m1_px.png


BIN
examples/PBR_Materials/env/m1_py.png


BIN
examples/PBR_Materials/env/m1_pz.png


BIN
examples/PBR_Materials/env/m2_nx.png


BIN
examples/PBR_Materials/env/m2_ny.png


BIN
examples/PBR_Materials/env/m2_nz.png


BIN
examples/PBR_Materials/env/m2_px.png


BIN
examples/PBR_Materials/env/m2_py.png


BIN
examples/PBR_Materials/env/m2_pz.png


BIN
examples/PBR_Materials/env/m3_nx.png


BIN
examples/PBR_Materials/env/m3_ny.png


BIN
examples/PBR_Materials/env/m3_nz.png


BIN
examples/PBR_Materials/env/m3_px.png


BIN
examples/PBR_Materials/env/m3_py.png


BIN
examples/PBR_Materials/env/m3_pz.png


BIN
examples/PBR_Materials/env/m4_nx.png


BIN
examples/PBR_Materials/env/m4_ny.png


BIN
examples/PBR_Materials/env/m4_nz.png


BIN
examples/PBR_Materials/env/m4_px.png


BIN
examples/PBR_Materials/env/m4_py.png


BIN
examples/PBR_Materials/env/m4_pz.png


BIN
examples/PBR_Materials/env/m5_nx.png


BIN
examples/PBR_Materials/env/m5_ny.png


BIN
examples/PBR_Materials/env/m5_nz.png


BIN
examples/PBR_Materials/env/m5_px.png


BIN
examples/PBR_Materials/env/m5_py.png


BIN
examples/PBR_Materials/env/m5_pz.png


BIN
examples/PBR_Materials/env/m6_nx.png


BIN
examples/PBR_Materials/env/m6_ny.png


BIN
examples/PBR_Materials/env/m6_nz.png


BIN
examples/PBR_Materials/env/m6_px.png


BIN
examples/PBR_Materials/env/m6_py.png


BIN
examples/PBR_Materials/env/m6_pz.png


BIN
examples/PBR_Materials/env/m7_nx.png


BIN
examples/PBR_Materials/env/m7_ny.png


BIN
examples/PBR_Materials/env/m7_nz.png


BIN
examples/PBR_Materials/env/m7_px.png


BIN
examples/PBR_Materials/env/m7_py.png


BIN
examples/PBR_Materials/env/m7_pz.png


BIN
examples/PBR_Materials/env/m8_nx.png


BIN
examples/PBR_Materials/env/m8_ny.png


BIN
examples/PBR_Materials/env/m8_nz.png


BIN
examples/PBR_Materials/env/m8_px.png


BIN
examples/PBR_Materials/env/m8_py.png


BIN
examples/PBR_Materials/env/m8_pz.png


BIN
examples/PBR_Materials/env/nx.png


BIN
examples/PBR_Materials/env/ny.png


BIN
examples/PBR_Materials/env/nz.png


BIN
examples/PBR_Materials/env/px.png


BIN
examples/PBR_Materials/env/py.png


BIN
examples/PBR_Materials/env/pz.png


+ 11 - 0
examples/PBR_Materials/env/sphericalHarmonics.lua

@@ -0,0 +1,11 @@
+return {
+  { 0.375931705762083,  0.358656319030575,  0.308453761543167},
+  { 0.354636762547562,  0.351933427534857,  0.346643193593808},
+  { 0.213680467209818,  0.208764154253828,  0.185992646424045},
+  { 0.094452764555327,  0.087423796528460,  0.078299527458197},
+  { 0.129722100892800,  0.126512402478568,  0.121503396241859},
+  { 0.236712791137010,  0.233931621210715,  0.222236168254197},
+  {-0.020735133497873, -0.020241604203896, -0.018707677741929},
+  {-0.073279787762454, -0.073091939150411, -0.068554941014884},
+  {-0.102740171078351, -0.099605437423063, -0.094746265045717}
+}

BIN
examples/PBR_Materials/helmet/DamagedHelmet.bin


BIN
examples/PBR_Materials/helmet/DamagedHelmet.glb


+ 0 - 204
examples/PBR_Materials/helmet/DamagedHelmet.gltf

@@ -1,204 +0,0 @@
-{
-    "accessors" : [
-        {
-            "bufferView" : 0,
-            "componentType" : 5123,
-            "count" : 46356,
-            "max" : [
-                14555
-            ],
-            "min" : [
-                0
-            ],
-            "type" : "SCALAR"
-        },
-        {
-            "bufferView" : 1,
-            "componentType" : 5126,
-            "count" : 14556,
-            "max" : [
-                0.9424954056739807,
-                0.8128451108932495,
-                0.900973916053772
-            ],
-            "min" : [
-                -0.9474585652351379,
-                -1.18715500831604,
-                -0.9009949564933777
-            ],
-            "type" : "VEC3"
-        },
-        {
-            "bufferView" : 2,
-            "componentType" : 5126,
-            "count" : 14556,
-            "max" : [
-                1.0,
-                1.0,
-                1.0
-            ],
-            "min" : [
-                -1.0,
-                -1.0,
-                -1.0
-            ],
-            "type" : "VEC3"
-        },
-        {
-            "bufferView" : 3,
-            "componentType" : 5126,
-            "count" : 14556,
-            "max" : [
-                0.9999759793281555,
-                1.998665988445282
-            ],
-            "min" : [
-                0.002448640065267682,
-                1.0005531199858524
-            ],
-            "type" : "VEC2"
-        }
-    ],
-    "asset" : {
-        "generator" : "Khronos Blender glTF 2.0 exporter",
-        "version" : "2.0"
-    },
-    "bufferViews" : [
-        {
-            "buffer" : 0,
-            "byteLength" : 92712,
-            "byteOffset" : 0,
-            "target" : 34963
-        },
-        {
-            "buffer" : 0,
-            "byteLength" : 174672,
-            "byteOffset" : 92712,
-            "target" : 34962
-        },
-        {
-            "buffer" : 0,
-            "byteLength" : 174672,
-            "byteOffset" : 267384,
-            "target" : 34962
-        },
-        {
-            "buffer" : 0,
-            "byteLength" : 116448,
-            "byteOffset" : 442056,
-            "target" : 34962
-        }
-    ],
-    "buffers" : [
-        {
-            "byteLength" : 558504,
-            "uri" : "DamagedHelmet.bin"
-        }
-    ],
-    "images" : [
-        {
-            "uri" : "Default_albedo.jpg"
-        },
-        {
-            "uri" : "Default_metalRoughness.jpg"
-        },
-        {
-            "uri" : "Default_emissive.jpg"
-        },
-        {
-            "uri" : "Default_AO.jpg"
-        },
-        {
-            "uri" : "Default_normal.jpg"
-        }
-    ],
-    "materials" : [
-        {
-            "emissiveFactor" : [
-                1.0,
-                1.0,
-                1.0
-            ],
-            "emissiveTexture" : {
-                "index" : 2
-            },
-            "name" : "Material_MR",
-            "normalTexture" : {
-                "index" : 4
-            },
-            "occlusionTexture" : {
-                "index" : 3
-            },
-            "pbrMetallicRoughness" : {
-                "baseColorTexture" : {
-                    "index" : 0
-                },
-                "metallicRoughnessTexture" : {
-                    "index" : 1
-                }
-            }
-        }
-    ],
-    "meshes" : [
-        {
-            "name" : "mesh_helmet_LP_13930damagedHelmet",
-            "primitives" : [
-                {
-                    "attributes" : {
-                        "NORMAL" : 2,
-                        "POSITION" : 1,
-                        "TEXCOORD_0" : 3
-                    },
-                    "indices" : 0,
-                    "material" : 0
-                }
-            ]
-        }
-    ],
-    "nodes" : [
-        {
-            "mesh" : 0,
-            "name" : "node_damagedHelmet_-6514",
-            "rotation" : [
-                0.7071068286895752,
-                0.0,
-                -0.0,
-                0.7071068286895752
-            ]
-        }
-    ],
-    "samplers" : [
-        {}
-    ],
-    "scene" : 0,
-    "scenes" : [
-        {
-            "name" : "Scene",
-            "nodes" : [
-                0
-            ]
-        }
-    ],
-    "textures" : [
-        {
-            "sampler" : 0,
-            "source" : 0
-        },
-        {
-            "sampler" : 0,
-            "source" : 1
-        },
-        {
-            "sampler" : 0,
-            "source" : 2
-        },
-        {
-            "sampler" : 0,
-            "source" : 3
-        },
-        {
-            "sampler" : 0,
-            "source" : 4
-        }
-    ]
-}

BIN
examples/PBR_Materials/helmet/Default_AO.jpg


BIN
examples/PBR_Materials/helmet/Default_albedo.jpg


BIN
examples/PBR_Materials/helmet/Default_emissive.jpg


BIN
examples/PBR_Materials/helmet/Default_metalRoughness.jpg


BIN
examples/PBR_Materials/helmet/Default_normal.jpg


+ 39 - 98
examples/PBR_Materials/main.lua

@@ -1,107 +1,48 @@
-local glsl = {}
-local lightPosition = {}
-local headsetPosition = {}
-local controller = nil
-
 function lovr.load()
-  model = lovr.graphics.newModel('helmet/DamagedHelmet.gltf')
-  shader = lovr.graphics.newShader(unpack(glsl.pbr))
-  lovr.graphics.setBackgroundColor(.18, .18, .20)
-  lightPosition = { 75, 60, 20 }
-end
+  model = lovr.graphics.newModel('helmet/DamagedHelmet.glb')
+
+  shader = lovr.graphics.newShader('standard', {
+    flags = {
+      normalTexture = false,
+      indirectLighting = true,
+      occlusion = true,
+      emissive = true,
+      skipTonemap = false
+    }
+  })
+
+  skybox = lovr.graphics.newTexture({
+    left = 'env/nx.png',
+    right = 'env/px.png',
+    top = 'env/py.png',
+    bottom = 'env/ny.png',
+    back = 'env/pz.png',
+    front = 'env/nz.png'
+  }, { linear = true })
+
+  environmentMap = lovr.graphics.newTexture(256, 256, { type = 'cube' })
+  for mipmap = 1, environmentMap:getMipmapCount() do
+    for face, dir in ipairs({ 'px', 'nx', 'py', 'ny', 'pz', 'nz' }) do
+      local filename = ('env/m%d_%s.png'):format(mipmap - 1, dir)
+      local image = lovr.data.newTextureData(filename, false)
+      environmentMap:replacePixels(image, 0, 0, face, mipmap)
+    end
+  end
 
-function lovr.update(dt)
-  controller = lovr.headset.getControllers()[1]
-  if controller then lightPosition = { controller:getPosition() } end
-  headsetPosition = { lovr.headset.getPosition() }
+  shader:send('lovrLightDirection', { -1, -1, -1 })
+  shader:send('lovrLightColor', { .9, .9, .8, 1.0 })
+  shader:send('lovrExposure', 2)
+  shader:send('lovrSphericalHarmonics', require('env/sphericalHarmonics'))
+  shader:send('lovrEnvironmentMap', environmentMap)
 
-  shader:send('lightPosition', lightPosition)
-  shader:send('headsetPosition', headsetPosition)
+  lovr.graphics.setBackgroundColor(.18, .18, .20)
+  lovr.graphics.setCullingEnabled(true)
+  lovr.graphics.setBlendMode()
 end
 
 function lovr.draw()
+  lovr.graphics.skybox(skybox)
   lovr.graphics.setShader(shader)
-  model:draw(0, 1.6, -1.5, .4, lovr.timer.getTime() * .12 + .1)
+  model:draw(0, 1.5, -3, 1, lovr.timer.getTime() * .15 - 1)
   lovr.graphics.setShader()
-
-  if controller then
-    local x, y, z = unpack(lightPosition)
-    lovr.graphics.setColor(1, 1, 1)
-    lovr.graphics.sphere(x, y, z, .01)
-  end
 end
-
-glsl.pbr = {
-[[
-out vec3 vNormal;
-out vec3 vVertex;
-
-vec4 position(mat4 projection, mat4 transform, vec4 vertex) {
-  vNormal = mat3(lovrModel) * lovrNormal;
-  vVertex = vec3(lovrModel * vertex);
-  return projection * lovrView * vec4(vVertex, 1.0);
-}
-]],
-
-[[
-#define PI 3.141592653
-
-in vec3 vNormal;
-in vec3 vVertex;
-
-uniform vec3 headsetPosition;
-uniform vec3 lightPosition;
-
-float D_GGX(float NoH, float roughness) {
-  float alpha = roughness * roughness;
-  float alpha2 = alpha * alpha;
-  float denom = (NoH * NoH) * (alpha2 - 1.) + 1.;
-  return alpha2 / (PI * denom * denom);
-}
-
-float G_SmithGGXCorrelated(float NoV, float NoL, float roughness) {
-  float alpha = roughness * roughness;
-  float alpha2 = alpha * alpha;
-  float GGXV = NoL * sqrt(alpha2 + (1. - alpha2) * (NoV * NoV));
-  float GGXL = NoV * sqrt(alpha2 + (1. - alpha2) * (NoL * NoL));
-  return .5 / max(GGXV + GGXL, 1e-5);
-}
-
-vec3 F_Schlick(vec3 F0, float LoH) {
-  return F0 + (vec3(1.) - F0) * pow(1. - LoH, 5.);
-}
-
-vec4 color(vec4 graphicsColor, sampler2D image, vec2 uv) {
-  vec3 baseColor = texture(lovrDiffuseTexture, uv).rgb;
-  vec3 emissive = texture(lovrEmissiveTexture, uv).rgb;
-  float metalness = texture(lovrMetalnessTexture, uv).b * lovrMetalness;
-  float roughness = max(texture(lovrRoughnessTexture, uv).g * lovrRoughness, .05);
-  float occlusion = texture(lovrOcclusionTexture, uv).r;
-  vec3 F0 = mix(vec3(.04), baseColor, metalness);
-
-  vec3 N = normalize(vNormal);
-  vec3 V = normalize(headsetPosition - vVertex);
-  vec3 L = normalize(lightPosition - vVertex);
-  vec3 H = normalize(V + L);
-
-  float NoV = abs(dot(N, V)) + 1e-5;
-  float NoL = clamp(dot(N, L), 0., 1.);
-  float NoH = clamp(dot(N, H), 0., 1.);
-  float LoH = clamp(dot(L, H), 0., 1.);
-
-  float D = D_GGX(NoH, roughness);
-  float G = G_SmithGGXCorrelated(NoV, NoL, roughness);
-  vec3 F = F_Schlick(F0, LoH);
-
-  vec3 specular = vec3(D * G * F);
-  vec3 diffuse = (vec3(1.) - F) * (1. - metalness) * baseColor;
-  vec3 color = (diffuse + specular) * NoL * occlusion + emissive;
-
-]] ..
-(lovr.getOS() == 'Web' and '  color = pow(color, vec3(.4545));\n' or '') ..
-[[
-
-  return vec4(vec3(color), 1.);
-}
-]]
-}

+ 5 - 5
examples/Physics/main.lua

@@ -1,5 +1,3 @@
-shader = require 'shader'
-
 function lovr.load()
   world = lovr.physics.newWorld()
   world:setLinearDamping(.01)
@@ -20,6 +18,9 @@ function lovr.load()
   controllerBoxes = {}
 
   lovr.timer.step() -- Reset the timer before the first update
+
+  shader = lovr.graphics.newShader('standard')
+  shader:send('lovrExposure', 2)
 end
 
 function lovr.update(dt)
@@ -27,14 +28,13 @@ function lovr.update(dt)
   world:update(dt)
 
   -- Place boxes on controllers
-  for i, controller in ipairs(lovr.headset.getControllers()) do
+  for i, hand in ipairs(lovr.headset.getHands()) do
     if not controllerBoxes[i] then
       controllerBoxes[i] = world:newBoxCollider(0, 0, 0, .25)
       controllerBoxes[i]:setKinematic(true)
       controllerBoxes[i]:setMass(10)
     end
-    controllerBoxes[i]:setPosition(controller:getPosition())
-    controllerBoxes[i]:setOrientation(controller:getOrientation())
+    controllerBoxes[i]:setPose(lovr.headset.getPose(hand))
   end
 end
 

+ 0 - 44
examples/Physics/shader.lua

@@ -1,44 +0,0 @@
-return lovr.graphics.newShader([[
-
-// All of these are in view-space.
-out vec3 lightDirection; // A vector from the vertex to the light
-out vec3 normalDirection;
-out vec3 vertexPosition;
-
-vec3 lightPosition = vec3(0, 10, 3);
-
-vec4 position(mat4 projection, mat4 transform, vec4 vertex) {
-  vec4 vVertex = transform * vec4(lovrPosition, 1.);
-  vec4 vLight = lovrView * vec4(lightPosition, 1.);
-
-  lightDirection = normalize(vec3(vLight - vVertex));
-  normalDirection = normalize(lovrNormalMatrix * lovrNormal);
-  vertexPosition = vVertex.xyz;
-
-  return projection * transform * vertex;
-}
-]], [[
-in vec3 lightDirection;
-in vec3 normalDirection;
-in vec3 vertexPosition;
-
-vec3 cAmbient = vec3(.25);
-vec3 cDiffuse = vec3(1);
-vec3 cSpecular = vec3(.35);
-
-vec4 color(vec4 graphicsColor, sampler2D image, vec2 uv) {
-  float diffuse = max(dot(normalDirection, lightDirection), 0.);
-  float specular = 0.;
-
-  if (diffuse > 0.) {
-    vec3 r = reflect(lightDirection, normalDirection);
-    vec3 viewDirection = normalize(-vertexPosition);
-
-    float specularAngle = max(dot(r, viewDirection), 0.);
-    specular = pow(specularAngle, 5.);
-  }
-
-  vec3 cFinal = pow(clamp(vec3(diffuse) * cDiffuse + vec3(specular) * cSpecular, cAmbient, vec3(1.)), vec3(.4545));
-  return vec4(cFinal, 1.) * graphicsColor * texture(image, uv);
-}
-]])

+ 4 - 6
examples/Spectator_Camera/main.lua

@@ -3,10 +3,8 @@ function lovr.load()
 
   -- Precompute camera transform (could also be attached to a controller)
   local x, y, z = -5, 5, 5
-  camera = lovr.math.mat4()
-  camera:translate(x, y, z)
-  camera:rotate(lovr.math.lookAt(x, y, z, 0, 0, 0))
-  view = lovr.math.mat4(camera):invert()
+  camera = lovr.math.newMat4():translate(x, y, z)--:lookAt(vec3(x, y, z), vec3(0, 0, 0))
+  view = lovr.math.newMat4(camera):invert()
 end
 
 local renderScene
@@ -49,8 +47,8 @@ renderScene = function(isCamera)
   end
 
   -- Always draw the controllers
-  for i, controller in ipairs(lovr.headset.getControllers()) do
-    local x, y, z, angle, ax, ay, az = controller:getPose()
+  for i, hand in ipairs(lovr.headset.getHands()) do
+    local x, y, z, angle, ax, ay, az = lovr.headset.getPose(hand)
     lovr.graphics.cube('fill', x, y, z, .06, angle, ax, ay, az)
   end
 end