function love.draw()
cam:attach()
-- set the x, y position of the camera here
lightWorld.setTranslation(cameraX, cameraY)
lightWorld.update()
love.graphics.setColor(255, 255, 255)
map:draw()
lightWorld.drawShadow()
love.graphics.setColor(63, 255, 127)
love.graphics.line(100, 100, 400, 250)
lightWorld.drawShine()
cam:detach()
end
@Snuux: löve is perfect for learning the pixel shader basics. At first, just try to program some color filters (like color to b/w or sephia). Than a bloom filter is a nice experience because you must combine different shaders and use different techniques. And at least you should try a few calculations with normal maps (but this is more necessary in 3D programming). The best way of learning for me was experimenting with other scripts.
Found that the problem was with hump's translation. Probably not even a problem, just me misunderstanding. Anyways, this is a function that takes a hump camera and gets the reverse translation that the light engine needs. Works great for me.
function getLightTranslation(c)
local tx,ty = love.graphics.getWidth()/(2*c.scale), love.graphics.getHeight()/(2*c.scale)
tx = tx-c.x
ty = ty-c.y
return -tx,-ty
end
How would one go about using the Engine to do also LoS?
Ie not only draw shadows etc but also track what isnt "seen" by the light? Else must one use another program or engine to achieve this ?
ArchAngel075 wrote:How would one go about using the Engine to do also LoS?
Ie not only draw shadows etc but also track what isnt "seen" by the light? Else must one use another program or engine to achieve this ?
If you draw the shadow on top of everything and have it be completely black, it will block out everything "not seen".
function love.load()
-- set the angle of the light-cone to 45° (default: Pi * 2)
light.setAngle(3.14 / 4.0)
-- set the direction of the light-cone (default: 0)
light.setDirection(3.14)
end
Last edited by PriorBlue on Sun Mar 16, 2014 9:10 pm, edited 1 time in total.
(Movable) refraction's and reflection's are added now. You can use them as glass or even water. (Press "0" to include a refraction box)
At the moment the effect is included as postshader, so it's only working when you write the entire scene in a canvas and set it before you draw the refraction/reflection channel (or use my postshader system ).
function love.load()
-- set the global refraction strength to 16 (default: 8)
lightWorld.setRefractionStrength(16.0)
-- set the global reflection strength to 32 (default: 16)
lightWorld.setReflectionStrength(32)
-- set the global reflection visibility to 0.5 (default: 1.0)
lightWorld.setReflectionVisibility(0.5)
-- create a refraction from a normal map
refraction = lightWorld.newRefraction(imgNormal, x, y)
-- create a refraction from a height map and choose the strength (default: 1.0)
refraction = lightWorld.newRefractionHeightMap(imgHeightMap, x, y, strength)
-- move the normal map texture within the boundary
refraction.setTileOffset(x, y)
end
function love.draw()
-- set your canvas
love.graphics.setCanvas(myCanvas)
-- draw scene objects
-- draw the reflection
lightWorld.drawReflection()
-- draw the refraction
lightWorld.drawRefraction()
-- draw Canvas
love.graphics.setCanvas()
love.graphics.draw(myCanvas)
end
I added functionality to the glow color channels.
Dynamic glow:
Chromatic aberration effect:
How to use the new glow:
color on diffuse image = Glow Color (+brightness)
red-channel = start brightness
green-channel = end brightness
blue-channel = delay
Examples:
Last edited by PriorBlue on Wed Mar 19, 2014 10:14 pm, edited 2 times in total.
Love all the new work, but can you make the refraction/reflection shader still ?
In it's current state it just lookes like water, to make it look like glass it needs to be fixed, can you do that ?
LoveDebug- A library that will help you debug your game with an on-screen fully interactive lua console, you can even do code hotswapping