Browse Source

Update a few more references/examples;

bjorn 1 year ago
parent
commit
dab68650f8

+ 6 - 5
api/init.lua

@@ -9966,6 +9966,7 @@ return {
           description = "The three different types of `Pass` objects.  Each Pass has a single type, which determines the type of work it does and which functions can be called on it.",
           key = "PassType",
           module = "lovr.graphics",
+          deprecated = true,
           related = {
             "lovr.graphics.getPass",
             "lovr.graphics.submit",
@@ -10311,9 +10312,9 @@ return {
           description = "Returns the global background color.  The textures in a render pass will be cleared to this color at the beginning of the pass if no other clear option is specified.  Additionally, the headset and window will be cleared to this color before rendering.",
           key = "lovr.graphics.getBackgroundColor",
           module = "lovr.graphics",
-          notes = "Setting the background color in `lovr.draw` will apply on the following frame, since the default pass is cleared before `lovr.draw` is called.\n\nInternally, this color is applied to the default pass objects when retrieving one of them using `lovr.headset.getPass` or `lovr.graphics.getPass`.  Both are called automatically by the default `lovr.run` implementation.\n\nUsing the background color to clear the display is expected to be more efficient than manually clearing after a render pass begins, especially on mobile GPUs.",
+          notes = "Setting the background color in `lovr.draw` will apply on the following frame, since the default pass is cleared before `lovr.draw` is called.\n\nInternally, this color is applied to the default pass objects when retrieving one of them using `lovr.headset.getPass` or `lovr.graphics.getWindowPass`.  Both are called automatically by the default `lovr.run` implementation.\n\nUsing the background color to clear the display is expected to be more efficient than manually clearing after a render pass begins, especially on mobile GPUs.",
           related = {
-            "lovr.graphics.getPass",
+            "lovr.graphics.newPass",
             "Pass:setClear",
             "Texture:clear",
             "Pass:fill"
@@ -12925,9 +12926,9 @@ return {
           description = "Changes the global background color.  The textures in a render pass will be cleared to this color at the beginning of the pass if no other clear option is specified.  Additionally, the headset and window will be cleared to this color before rendering.",
           key = "lovr.graphics.setBackgroundColor",
           module = "lovr.graphics",
-          notes = "Setting the background color in `lovr.draw` will apply on the following frame, since the default pass is cleared before `lovr.draw` is called.\n\nInternally, this color is applied to the default pass objects when retrieving one of them using `lovr.headset.getPass` or `lovr.graphics.getPass`.  Both are called automatically by the default `lovr.run` implementation.\n\nUsing the background color to clear the display is expected to be more efficient than manually clearing after a render pass begins, especially on mobile GPUs.",
+          notes = "Setting the background color in `lovr.draw` will apply on the following frame, since the default pass is cleared before `lovr.draw` is called.\n\nInternally, this color is applied to the default pass objects when retrieving one of them using `lovr.headset.getPass` or `lovr.graphics.getWindowPass`.  Both are called automatically by the default `lovr.run` implementation.\n\nUsing the background color to clear the display is expected to be more efficient than manually clearing after a render pass begins, especially on mobile GPUs.",
           related = {
-            "lovr.graphics.getPass",
+            "lovr.graphics.newPass",
             "Pass:setClear",
             "Texture:clear",
             "Pass:fill"
@@ -24544,7 +24545,7 @@ return {
           module = "lovr.headset",
           notes = "The same Pass will be returned until `lovr.headset.submit` is called.\n\nThe first time this function is called during a frame, the views of the Pass will be initialized with the headset view poses and view angles.\n\nThe pass will be cleared to the background color, which can be changed using `lovr.graphics.setBackgroundColor`.\n\nThe pass will have a depth buffer.  If `t.headset.stencil` was set to a truthy value in `lovr.conf`, the depth buffer will use the `d32fs8` format, otherwise `d32f` will be used.\n\nIf `t.headset.antialias` was set to a truthy value in `lovr.conf`, the pass will be multisampled.",
           related = {
-            "lovr.graphics.getPass",
+            "lovr.graphics.newPass",
             "lovr.graphics.getWindowPass",
             "lovr.conf"
           },

+ 1 - 0
api/lovr/graphics/PassType.lua

@@ -1,4 +1,5 @@
 return {
+  deprecated = true,
   summary = 'Different types of Passes.',
   description = [[
     The three different types of `Pass` objects.  Each Pass has a single type, which determines the

+ 3 - 3
api/lovr/graphics/getBackgroundColor.lua

@@ -36,14 +36,14 @@ return {
     pass is cleared before `lovr.draw` is called.
 
     Internally, this color is applied to the default pass objects when retrieving one of them using
-    `lovr.headset.getPass` or `lovr.graphics.getPass`.  Both are called automatically by the default
-    `lovr.run` implementation.
+    `lovr.headset.getPass` or `lovr.graphics.getWindowPass`.  Both are called automatically by the
+    default `lovr.run` implementation.
 
     Using the background color to clear the display is expected to be more efficient than manually
     clearing after a render pass begins, especially on mobile GPUs.
   ]],
   related = {
-    'lovr.graphics.getPass',
+    'lovr.graphics.newPass',
     'Pass:setClear',
     'Texture:clear',
     'Pass:fill'

+ 3 - 3
api/lovr/graphics/setBackgroundColor.lua

@@ -55,14 +55,14 @@ return {
     pass is cleared before `lovr.draw` is called.
 
     Internally, this color is applied to the default pass objects when retrieving one of them using
-    `lovr.headset.getPass` or `lovr.graphics.getPass`.  Both are called automatically by the default
-    `lovr.run` implementation.
+    `lovr.headset.getPass` or `lovr.graphics.getWindowPass`.  Both are called automatically by the
+    default `lovr.run` implementation.
 
     Using the background color to clear the display is expected to be more efficient than manually
     clearing after a render pass begins, especially on mobile GPUs.
   ]],
   related = {
-    'lovr.graphics.getPass',
+    'lovr.graphics.newPass',
     'Pass:setClear',
     'Texture:clear',
     'Pass:fill'

+ 1 - 1
api/lovr/headset/getPass.lua

@@ -31,7 +31,7 @@ return {
     multisampled.
   ]],
   related = {
-    'lovr.graphics.getPass',
+    'lovr.graphics.newPass',
     'lovr.graphics.getWindowPass',
     'lovr.conf'
   }

+ 17 - 18
examples/Lighting/Shadows/main.lua

@@ -14,6 +14,7 @@ local debug_show_shadow_map = false -- Enable to view shadow map in overlap
 local shader, render_texture
 local shadow_map_texture, shadow_map_sampler
 local light_space_matrix
+local shadow_map_pass, lighting_pass
 
 local function render_scene(pass)
   local t = lovr.timer.getTime()
@@ -107,15 +108,6 @@ local function lighting_shader()
 end
 
 local function render_shadow_map(draw)
-  local shadow_map_pass
-  if debug_render_from_light then
-    shadow_map_pass = lovr.graphics.getPass('render', { shadow_map_texture, samples = 1 })
-  else
-    shadow_map_pass = lovr.graphics.getPass('render', {
-      depth = { texture = shadow_map_texture, clear = light_orthographic and 1 or 0 }, samples = 1
-    })
-  end
-
   local near_plane = 2
   local projection
   if light_orthographic then
@@ -130,6 +122,7 @@ local function render_shadow_map(draw)
 
   light_space_matrix = mat4(projection):mul(view)
 
+  shadow_map_pass:reset()
   shadow_map_pass:setProjection(1, projection)
   shadow_map_pass:setViewPose(1, view, true)
   if light_orthographic then
@@ -143,20 +136,20 @@ local function render_shadow_map(draw)
   end
 
   draw(shadow_map_pass)
-
-  return shadow_map_pass
 end
 
 local function render_lighting_pass(draw)
-  local lighting_pass = lovr.graphics.getPass('render', { render_texture, samples = 1 })
+  lighting_pass:reset()
 
-  local t = lovr.timer.getTime()
+  local t
   if lovr.headset then
+    t = lovr.headset.getTime()
     for i = 1, lovr.headset.getViewCount() do
       lighting_pass:setViewPose(i, lovr.headset.getViewPose(i))
       lighting_pass:setProjection(i, lovr.headset.getViewAngles(i))
     end
   else
+    t = lovr.timer.getTime()
     lighting_pass:setViewPose(1, 0, 3 - math.sin(t * 0.1), 4, -math.pi / 8, 1, 0, 0)
   end
 
@@ -171,8 +164,6 @@ local function render_lighting_pass(draw)
 
   lighting_pass:setColor(1, 1, 1, 1)
   lighting_pass:sphere(light_pos, 0.1)
-
-  return lighting_pass
 end
 
 local function debug_passes(pass)
@@ -213,6 +204,15 @@ function lovr.load(args)
     local width, height = lovr.system.getWindowDimensions()
     render_texture = lovr.graphics.newTexture(width, height, 1, { mipmaps = false })
   end
+
+  if debug_render_from_light then
+    shadow_map_pass = lovr.graphics.newPass({ shadow_map_texture, samples = 1 })
+  else
+    shadow_map_pass = lovr.graphics.newPass({ depth = shadow_map_texture, samples = 1 })
+    shadow_map_pass:setClear({ depth = light_orthographic and 1 or 0 })
+  end
+
+  lighting_pass = lovr.graphics.newPass(render_texture)
 end
 
 function lovr.update(dt)
@@ -222,9 +222,8 @@ function lovr.update(dt)
 end
 
 function lovr.draw(pass)
-  local shadow_map_pass = render_shadow_map(render_scene)
-  local lighting_pass = render_lighting_pass(render_scene)
-
+  render_shadow_map(render_scene)
+  render_lighting_pass(render_scene)
   debug_passes(pass)
 
   return lovr.graphics.submit({ shadow_map_pass, lighting_pass, pass })

+ 2 - 1
tests/render-to-depth-texture.lua

@@ -1,4 +1,5 @@
 function lovr.load()
   t = lovr.graphics.newTexture(100, 100, { format = 'd32f' })
-  p = lovr.graphics.getPass({ depth = t })
+  p = lovr.graphics.newPass({ depth = t })
+  lovr.graphics.submit(p)
 end