made the normal shading reflect the shadow calculations a bit better and isolated the examples to one directory
@ -36,53 +36,53 @@ function love.load()
|
|||||||
love.graphics.setDefaultFilter("nearest", "nearest")
|
love.graphics.setDefaultFilter("nearest", "nearest")
|
||||||
|
|
||||||
-- load image font
|
-- load image font
|
||||||
font = love.graphics.newImageFont("gfx/font.png", " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,!?-+/():;%&`'*#=[]\"")
|
font = love.graphics.newImageFont("examples/gfx/font.png", " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,!?-+/():;%&`'*#=[]\"")
|
||||||
love.graphics.setFont(font)
|
love.graphics.setFont(font)
|
||||||
|
|
||||||
-- set background
|
-- set background
|
||||||
quadScreen = love.graphics.newQuad(0, 0, love.window.getWidth() + 32, love.window.getHeight() + 24, 32, 24)
|
quadScreen = love.graphics.newQuad(0, 0, love.window.getWidth() + 32, love.window.getHeight() + 24, 32, 24)
|
||||||
imgFloor = love.graphics.newImage("gfx/floor.png")
|
imgFloor = love.graphics.newImage("examples/gfx/floor.png")
|
||||||
imgFloor:setWrap("repeat", "repeat")
|
imgFloor:setWrap("repeat", "repeat")
|
||||||
|
|
||||||
-- load image examples
|
-- load image examples
|
||||||
circle = love.graphics.newImage("gfx/circle.png")
|
circle = love.graphics.newImage("examples/gfx/circle.png")
|
||||||
circle_normal = love.graphics.newImage("gfx/circle_normal.png")
|
circle_normal = love.graphics.newImage("examples/gfx/circle_normal.png")
|
||||||
cone = love.graphics.newImage("gfx/cone.png")
|
cone = love.graphics.newImage("examples/gfx/cone.png")
|
||||||
cone_large = love.graphics.newImage("gfx/cone_large.png")
|
cone_large = love.graphics.newImage("examples/gfx/cone_large.png")
|
||||||
cone_large_normal = love.graphics.newImage("gfx/cone_large_normal.png")
|
cone_large_normal = love.graphics.newImage("examples/gfx/cone_large_normal.png")
|
||||||
cone_normal = love.graphics.newImage("gfx/cone_normal.png")
|
cone_normal = love.graphics.newImage("examples/gfx/cone_normal.png")
|
||||||
chest = love.graphics.newImage("gfx/chest.png")
|
chest = love.graphics.newImage("examples/gfx/chest.png")
|
||||||
chest_normal = love.graphics.newImage("gfx/chest_normal.png")
|
chest_normal = love.graphics.newImage("examples/gfx/chest_normal.png")
|
||||||
machine = love.graphics.newImage("gfx/machine.png")
|
machine = love.graphics.newImage("examples/gfx/machine.png")
|
||||||
machine_normal = love.graphics.newImage("gfx/machine_normal.png")
|
machine_normal = love.graphics.newImage("examples/gfx/machine_normal.png")
|
||||||
machine_glow = love.graphics.newImage("gfx/machine_glow.png")
|
machine_glow = love.graphics.newImage("examples/gfx/machine_glow.png")
|
||||||
machine2 = love.graphics.newImage("gfx/machine2.png")
|
machine2 = love.graphics.newImage("examples/gfx/machine2.png")
|
||||||
machine2_normal = love.graphics.newImage("gfx/machine2_normal.png")
|
machine2_normal = love.graphics.newImage("examples/gfx/machine2_normal.png")
|
||||||
machine2_glow = love.graphics.newImage("gfx/machine2_glow.png")
|
machine2_glow = love.graphics.newImage("examples/gfx/machine2_glow.png")
|
||||||
blopp = love.graphics.newImage("gfx/blopp.png")
|
blopp = love.graphics.newImage("examples/gfx/blopp.png")
|
||||||
tile = love.graphics.newImage("gfx/tile.png")
|
tile = love.graphics.newImage("examples/gfx/tile.png")
|
||||||
tile_normal = love.graphics.newImage("gfx/tile_normal.png")
|
tile_normal = love.graphics.newImage("examples/gfx/tile_normal.png")
|
||||||
tile_glow = love.graphics.newImage("gfx/tile_glow.png")
|
tile_glow = love.graphics.newImage("examples/gfx/tile_glow.png")
|
||||||
refraction_normal = love.graphics.newImage("gfx/refraction_normal.png")
|
refraction_normal = love.graphics.newImage("examples/gfx/refraction_normal.png")
|
||||||
water = love.graphics.newImage("gfx/water.png")
|
water = love.graphics.newImage("examples/gfx/water.png")
|
||||||
led = love.graphics.newImage("gfx/led.png")
|
led = love.graphics.newImage("examples/gfx/led.png")
|
||||||
led2 = love.graphics.newImage("gfx/led2.png")
|
led2 = love.graphics.newImage("examples/gfx/led2.png")
|
||||||
led3 = love.graphics.newImage("gfx/led3.png")
|
led3 = love.graphics.newImage("examples/gfx/led3.png")
|
||||||
led_normal = love.graphics.newImage("gfx/led_normal.png")
|
led_normal = love.graphics.newImage("examples/gfx/led_normal.png")
|
||||||
led_glow = love.graphics.newImage("gfx/led_glow.png")
|
led_glow = love.graphics.newImage("examples/gfx/led_glow.png")
|
||||||
led_glow2 = love.graphics.newImage("gfx/led_glow2.png")
|
led_glow2 = love.graphics.newImage("examples/gfx/led_glow2.png")
|
||||||
led_glow3 = love.graphics.newImage("gfx/led_glow3.png")
|
led_glow3 = love.graphics.newImage("examples/gfx/led_glow3.png")
|
||||||
ape = love.graphics.newImage("gfx/ape.png")
|
ape = love.graphics.newImage("examples/gfx/ape.png")
|
||||||
ape_normal = love.graphics.newImage("gfx/ape_normal.png")
|
ape_normal = love.graphics.newImage("examples/gfx/ape_normal.png")
|
||||||
ape_glow = love.graphics.newImage("gfx/ape_glow.png")
|
ape_glow = love.graphics.newImage("examples/gfx/ape_glow.png")
|
||||||
imgLight = love.graphics.newImage("gfx/light.png")
|
imgLight = love.graphics.newImage("examples/gfx/light.png")
|
||||||
|
|
||||||
-- materials
|
-- materials
|
||||||
material = {}
|
material = {}
|
||||||
|
|
||||||
local files = love.filesystem.getDirectoryItems("gfx/sphere")
|
local files = love.filesystem.getDirectoryItems("examples/gfx/sphere")
|
||||||
for i, file in ipairs(files) do
|
for i, file in ipairs(files) do
|
||||||
material[i] = love.graphics.newImage("gfx/sphere/" .. file)
|
material[i] = love.graphics.newImage("examples/gfx/sphere/" .. file)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- light world
|
-- light world
|
||||||
@ -134,7 +134,7 @@ function love.update(dt)
|
|||||||
|
|
||||||
mx, my = (love.mouse.getX() - offsetX)/scale, (love.mouse.getY() - offsetY)/scale
|
mx, my = (love.mouse.getX() - offsetX)/scale, (love.mouse.getY() - offsetY)/scale
|
||||||
|
|
||||||
mouseLight:setPosition(mx, my, 1 + (math.sin(lightDirection) + 1.0) * 64.0)
|
mouseLight:setPosition(mx, my, 1 + (math.sin(lightDirection) + 1.0))
|
||||||
|
|
||||||
lightDirection = lightDirection + dt
|
lightDirection = lightDirection + dt
|
||||||
colorAberration = math.max(0.0, colorAberration - dt * 10.0)
|
colorAberration = math.max(0.0, colorAberration - dt * 10.0)
|
||||||
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 87 KiB After Width: | Height: | Size: 87 KiB |
Before Width: | Height: | Size: 57 KiB After Width: | Height: | Size: 57 KiB |
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 967 B After Width: | Height: | Size: 967 B |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1019 B After Width: | Height: | Size: 1019 B |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 981 B After Width: | Height: | Size: 981 B |
Before Width: | Height: | Size: 193 B After Width: | Height: | Size: 193 B |
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 990 B After Width: | Height: | Size: 990 B |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 127 KiB After Width: | Height: | Size: 127 KiB |
Before Width: | Height: | Size: 116 KiB After Width: | Height: | Size: 116 KiB |
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 44 KiB |
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 33 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 48 KiB |
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 42 KiB |
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 51 KiB After Width: | Height: | Size: 51 KiB |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 1018 B After Width: | Height: | Size: 1018 B |
Before Width: | Height: | Size: 1012 B After Width: | Height: | Size: 1012 B |
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 KiB |
@ -6,8 +6,8 @@ function love.load()
|
|||||||
y = 0
|
y = 0
|
||||||
scale = 1
|
scale = 1
|
||||||
-- load images
|
-- load images
|
||||||
image = love.graphics.newImage("gfx/rock.png")
|
image = love.graphics.newImage("examples/gfx/rock.png")
|
||||||
image_normal = love.graphics.newImage("gfx/rock_n.png")
|
image_normal = love.graphics.newImage("examples/gfx/rock_n.png")
|
||||||
|
|
||||||
-- create light world
|
-- create light world
|
||||||
lightWorld = LightWorld({
|
lightWorld = LightWorld({
|
||||||
|
@ -8,9 +8,9 @@ function love.load()
|
|||||||
scale = 1
|
scale = 1
|
||||||
colorAberration = 0.0
|
colorAberration = 0.0
|
||||||
-- load images
|
-- load images
|
||||||
image = love.graphics.newImage("gfx/machine2.png")
|
image = love.graphics.newImage("examples/gfx/machine2.png")
|
||||||
quadScreen = love.graphics.newQuad(0, 0, love.window.getWidth() + 32, love.window.getHeight() + 24, 32, 24)
|
quadScreen = love.graphics.newQuad(0, 0, love.window.getWidth() + 32, love.window.getHeight() + 24, 32, 24)
|
||||||
imgFloor = love.graphics.newImage("gfx/floor.png")
|
imgFloor = love.graphics.newImage("examples/gfx/floor.png")
|
||||||
imgFloor:setWrap("repeat", "repeat")
|
imgFloor:setWrap("repeat", "repeat")
|
||||||
|
|
||||||
post_shader = PostShader()
|
post_shader = PostShader()
|
||||||
|
@ -9,10 +9,10 @@ function love.load()
|
|||||||
scale = 1
|
scale = 1
|
||||||
colorAberration = 0.0
|
colorAberration = 0.0
|
||||||
-- load images
|
-- load images
|
||||||
image = love.graphics.newImage("gfx/machine2.png")
|
image = love.graphics.newImage("examples/gfx/machine2.png")
|
||||||
image_normal = love.graphics.newImage("gfx/cone_normal.png")
|
image_normal = love.graphics.newImage("examples/gfx/cone_normal.png")
|
||||||
normal = love.graphics.newImage("gfx/refraction_normal.png")
|
normal = love.graphics.newImage("examples/gfx/refraction_normal.png")
|
||||||
glow = love.graphics.newImage("gfx/machine2_glow.png")
|
glow = love.graphics.newImage("examples/gfx/machine2_glow.png")
|
||||||
|
|
||||||
-- create light world
|
-- create light world
|
||||||
lightWorld = LightWorld({
|
lightWorld = LightWorld({
|
||||||
|
@ -142,7 +142,7 @@ function light:drawShadow(l,t,w,h,s,bodies, canvas)
|
|||||||
self.shadow:clear()
|
self.shadow:clear()
|
||||||
util.drawto(self.shadow, l, t, s, function()
|
util.drawto(self.shadow, l, t, s, function()
|
||||||
|
|
||||||
self.shader:send("lightPosition", {(self.x + l/s) * s, (h/s - (self.y + t/s)) * s, self.z/255.0})
|
self.shader:send("lightPosition", {(self.x + l/s) * s, (h/s - (self.y + t/s)) * s, (self.z * 10)/255.0})
|
||||||
self.shader:send("lightRange", self.range*s)
|
self.shader:send("lightRange", self.range*s)
|
||||||
self.shader:send("lightColor", {self.red / 255.0, self.green / 255.0, self.blue / 255.0})
|
self.shader:send("lightColor", {self.red / 255.0, self.green / 255.0, self.blue / 255.0})
|
||||||
self.shader:send("lightSmooth", self.smooth)
|
self.shader:send("lightSmooth", self.smooth)
|
||||||
@ -198,7 +198,7 @@ end
|
|||||||
function light:drawNormalShading(l,t,w,h,s, normalMap, canvas)
|
function light:drawNormalShading(l,t,w,h,s, normalMap, canvas)
|
||||||
if self.visible and self:inRange(l,t,w,h,s) then
|
if self.visible and self:inRange(l,t,w,h,s) then
|
||||||
self.normalShader:send('lightColor', {self.red / 255.0, self.green / 255.0, self.blue / 255.0})
|
self.normalShader:send('lightColor', {self.red / 255.0, self.green / 255.0, self.blue / 255.0})
|
||||||
self.normalShader:send("lightPosition", {(self.x + l/s) * s, (h/s - (self.y + t/s)) * s, self.z / 255.0})
|
self.normalShader:send("lightPosition", {(self.x + l/s) * s, (h/s - (self.y + t/s)) * s, (self.z * 10) / 255.0})
|
||||||
self.normalShader:send('lightRange',{self.range})
|
self.normalShader:send('lightRange',{self.range})
|
||||||
self.normalShader:send("lightSmooth", self.smooth)
|
self.normalShader:send("lightSmooth", self.smooth)
|
||||||
self.normalShader:send("lightAngle", math.pi - self.angle / 2.0)
|
self.normalShader:send("lightAngle", math.pi - self.angle / 2.0)
|
||||||
|
25
main.lua
@ -20,23 +20,26 @@ function love.load()
|
|||||||
exf.bigfont = love.graphics.newFont(love._vera_ttf, 24)
|
exf.bigfont = love.graphics.newFont(love._vera_ttf, 24)
|
||||||
exf.list.font = exf.smallfont
|
exf.list.font = exf.smallfont
|
||||||
|
|
||||||
exf.bigball = love.graphics.newImage("gfx/love-big-ball.png")
|
exf.bigball = love.graphics.newImage("examples/gfx/love-big-ball.png")
|
||||||
|
|
||||||
-- Find available demos.
|
-- Find available demos.
|
||||||
local files = love.filesystem.getDirectoryItems("examples")
|
local files = love.filesystem.getDirectoryItems("examples")
|
||||||
local n = 0
|
local n = 0
|
||||||
|
|
||||||
for i, v in ipairs(files) do
|
for i, v in ipairs(files) do
|
||||||
n = n + 1
|
is_file = love.filesystem.isFile("examples/".. v )
|
||||||
table.insert(exf.available, v);
|
if is_file then
|
||||||
local file = love.filesystem.newFile(v, love.file_read)
|
n = n + 1
|
||||||
file:open("r")
|
table.insert(exf.available, v);
|
||||||
local contents = love.filesystem.read("examples/" .. v, 100)
|
local file = love.filesystem.newFile(v, love.file_read)
|
||||||
local s, e, c = string.find(contents, "Example: ([%a%p ]-)[\r\n]")
|
file:open("r")
|
||||||
file:close(file)
|
local contents = love.filesystem.read("examples/" .. v, 100)
|
||||||
if not c then c = "Untitled" end
|
local s, e, c = string.find(contents, "Example: ([%a%p ]-)[\r\n]")
|
||||||
local title = exf.getn(n) .. " " .. c .. " (" .. v .. ")"
|
file:close(file)
|
||||||
exf.list:add(title, v)
|
if not c then c = "Untitled" end
|
||||||
|
local title = exf.getn(n) .. " " .. c .. " (" .. v .. ")"
|
||||||
|
exf.list:add(title, v)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
exf.list:done()
|
exf.list:done()
|
||||||
|