just a few refactors and simplified the short version to be optimal

This commit is contained in:
Tim Anema 2014-12-13 23:41:57 -05:00
parent 41058d5d5b
commit 6ae929fbeb
2 changed files with 3 additions and 14 deletions

View File

@ -18,11 +18,7 @@ function love.load()
glow = love.graphics.newImage("examples/gfx/machine2_glow.png") glow = love.graphics.newImage("examples/gfx/machine2_glow.png")
-- create light world -- create light world
lightWorld = LightWorld({ lightWorld = LightWorld({ambient = {55,55,55}})
ambient = {55,55,55},
refractionStrength = 32.0,
reflectionVisibility = 0.75,
})
-- create light -- create light
lightMouse = lightWorld:newLight(0, 0, 255, 127, 63, 300) lightMouse = lightWorld:newLight(0, 0, 255, 127, 63, 300)
@ -43,10 +39,6 @@ function love.load()
imageTest:setNormalMap(image_normal) imageTest:setNormalMap(image_normal)
imageTest:setGlowMap(glow) imageTest:setGlowMap(glow)
imageTest:setOffset(12, -10) imageTest:setOffset(12, -10)
-- create body object
objectTest = lightWorld:newRefraction(normal, 64, 64, 128, 128)
objectTest:setReflection(true)
end end
function love.keypressed(k) function love.keypressed(k)

View File

@ -76,7 +76,6 @@ function light_world:refreshScreenSize(w, h)
self.glowMap = love.graphics.newCanvas(w, h) self.glowMap = love.graphics.newCanvas(w, h)
self.glowMap2 = love.graphics.newCanvas(w, h) self.glowMap2 = love.graphics.newCanvas(w, h)
self.refractionMap = love.graphics.newCanvas(w, h) self.refractionMap = love.graphics.newCanvas(w, h)
self.refractionMap2 = love.graphics.newCanvas(w, h)
self.reflectionMap = love.graphics.newCanvas(w, h) self.reflectionMap = love.graphics.newCanvas(w, h)
self.reflectionMap2 = love.graphics.newCanvas(w, h) self.reflectionMap2 = love.graphics.newCanvas(w, h)
@ -220,8 +219,7 @@ function light_world:drawRefraction(l,t,w,h,s)
end end
end) end)
util.drawCanvasToCanvas(self.render_buffer, self.refractionMap2) self.refractionShader:send("backBuffer", self.render_buffer)
self.refractionShader:send("backBuffer", self.refractionMap2)
self.refractionShader:send("refractionStrength", self.refractionStrength) self.refractionShader:send("refractionStrength", self.refractionStrength)
util.drawCanvasToCanvas(self.refractionMap, self.render_buffer, {shader = self.refractionShader}) util.drawCanvasToCanvas(self.refractionMap, self.render_buffer, {shader = self.refractionShader})
end end
@ -238,8 +236,7 @@ function light_world:drawReflection(l,t,w,h,s)
end end
end) end)
util.drawCanvasToCanvas(self.render_buffer, self.reflectionMap2) self.reflectionShader:send("backBuffer", self.render_buffer)
self.reflectionShader:send("backBuffer", self.reflectionMap2)
self.reflectionShader:send("reflectionStrength", self.reflectionStrength) self.reflectionShader:send("reflectionStrength", self.reflectionStrength)
self.reflectionShader:send("reflectionVisibility", self.reflectionVisibility) self.reflectionShader:send("reflectionVisibility", self.reflectionVisibility)
util.drawCanvasToCanvas(self.reflectionMap, self.render_buffer, {shader = self.reflectionShader}) util.drawCanvasToCanvas(self.reflectionMap, self.render_buffer, {shader = self.reflectionShader})