For some context, I made a proof of concept for a flashlight effect on clickteam fusion 2.5 and this effects uses a effect for invert colors and a subtract effect on the layer
On the image is better to see
The current layer I'm on have 2 images, the room dark mode and with effect to invert colors, and also a flashlight mask.
and on a layer above without any effect I have the room with all lights
so I tried replicate this effect but the final result don't look nothing like the original on fusion
here the code I used to try make this work:
Code: Select all
function love.load()
dbginterface = require 'src.Components.Modules.Game.Interface.DebugInterface'
roomoff = love.graphics.newImage("assets/images/game/test/room_off.png")
roomlight = love.graphics.newImage("assets/images/game/test/room_light.png")
flashlight = love.graphics.newImage("assets/images/game/night8/flashlight.png")
light = love.graphics.newImage("assets/images/game/night8/lantern_light.png")
shd_perspective = love.graphics.newShader("assets/shaders/Projection.glsl")
shd_invert = love.graphics.newShader("assets/shaders/InvertShader.glsl")
tuneConfig = {
latitudeVar = 26.6,
longitudeVar = 40,
fovVar = 0.263000
}
shd_perspective:send("latitudeVar", tuneConfig.latitudeVar)
shd_perspective:send("longitudeVar", tuneConfig.longitudeVar)
shd_perspective:send("fovVar", tuneConfig.fovVar)
flash = {
x = 0,
y = 0
}
gameCam = camera.new(0, nil)
gameCam.factorX = 2.8
gameCam.factorY = 25
cnv_mainCanvas = love.graphics.newCanvas(love.graphics.getWidth(), love.graphics.getHeight(), {
format = "rgba8",
readable = true,
})
cnv_invertedRoom = love.graphics.newCanvas(love.graphics.getWidth(), love.graphics.getHeight(), {
format = "rgba8",
readable = true,
})
cnv_flash = love.graphics.newCanvas(love.graphics.getWidth(), love.graphics.getHeight(), {
format = "rgba8",
readable = true,
})
love.graphics.setBackgroundColor(0, 0, 0, 0)
end
function love.draw()
cnv_mainCanvas:renderTo(function()
gameCam:attach()
love.graphics.draw(roomlight, 0, 0)
gameCam:detach()
end)
cnv_invertedRoom:renderTo(function()
gameCam:attach()
love.graphics.setShader(shd_invert)
love.graphics.draw(roomoff, 0, 0)
love.graphics.setShader()
gameCam:detach()
end)
cnv_flash:renderTo(function()
love.graphics.draw(cnv_invertedRoom, 0, 0)
love.graphics.draw(flashlight, flash.x, flash.y, 0, 1.2, 1.1, flashlight:getWidth() / 2, flashlight:getHeight() / 2)
end)
love.graphics.setShader(shd_perspective)
love.graphics.draw(cnv_mainCanvas, 0, 0)
love.graphics.setBlendMode("subtract")
love.graphics.draw(cnv_flash, 0, 0)
love.graphics.setBlendMode("alpha")
love.graphics.setShader()
end