Browse Source

Blur uses clampler;

bjorn 2 years ago
parent
commit
71c390f175
1 changed files with 5 additions and 0 deletions
  1. 5 0
      examples/Effects/Blur/main.lua

+ 5 - 0
examples/Effects/Blur/main.lua

@@ -75,6 +75,10 @@ function lovr.load()
       lovr.graphics.newTexture(width, height, layers, { mipmaps = false }),
       lovr.graphics.newTexture(width, height, layers, { mipmaps = false }),
       lovr.graphics.newTexture(width, height, layers, { mipmaps = false })
       lovr.graphics.newTexture(width, height, layers, { mipmaps = false })
     }
     }
+
+    -- Make a clamping sampler (clampler, get it?) to prevent blurred
+    -- pixels from wrapping around the edges
+    clampler = lovr.graphics.newSampler({ wrap = 'clamp' })
   end
   end
 end
 end
 
 
@@ -98,6 +102,7 @@ end
 -- draws one texture onto another with the blur shader
 -- draws one texture onto another with the blur shader
 local function fullScreenDraw(source, destination, blurSize)
 local function fullScreenDraw(source, destination, blurSize)
   local pass = lovr.graphics.getPass('render', { destination, depth = false, samples = 1 })
   local pass = lovr.graphics.getPass('render', { destination, depth = false, samples = 1 })
+  pass:setSampler(clampler)
   pass:setShader(screenShader)
   pass:setShader(screenShader)
   pass:send('sourceTexture', source)
   pass:send('sourceTexture', source)
   pass:send('direction', blurSize)
   pass:send('direction', blurSize)