Help with Canvases and Shaders

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
BruceTheGoose
Citizen
Posts: 76
Joined: Sat Sep 20, 2014 2:54 pm

Help with Canvases and Shaders

Post by BruceTheGoose »

Code: Select all

Intro = {}
Intro.Alpha = 0
Intro.Appeared = true

function Intro:Load()
  Logo = love.graphics.newImage("Resources/Gfx/LoveLogo.png")
  iCanvas = love.graphics.newCanvas()
  local str = love.filesystem.read("Resources/Shaders/CRT-Simple.frag")
  scanline = love.graphics.newShader(str)
  scanline:send('inputSize',{Game.Width,Game.Height})
  scanline:send('textureSize', {Game.Width, Game.Height})
end

function Intro:Update(dt)
  if self.Appeared then
    if self.Alpha < 254 then
      self.Alpha = self.Alpha + 70 * dt
    end
    if self.Alpha >= 254 then
      self.Alpha = 255
      self.Appeared = false
    end
  end
  if not self.Appeared then
    self.Alpha = self.Alpha - 120 * dt
    if self.Alpha < 1 then
      if Game:getState() == "Intro" then
        Game:setState("Menu")
      end
    end
  end
end

function Intro:Draw()
  love.graphics.setCanvas(iCanvas)
  love.graphics.setColor(255,255,255,self.Alpha)
  love.graphics.draw(Logo,Game.Width/2-Logo:getWidth()/2*0.5,Game.Height/2-Logo:getHeight()/2*0.5,0,0.5,0.5)
  love.graphics.setColor(255,255,255,255)
  love.graphics.setCanvas()
  love.graphics.setShader(scanline)
  love.graphics.draw(iCanvas)
  love.graphics.setShader()
end

I'm using the CRT shader from Mari0 and I was guided by http://love2d.org/forums/viewtopic.php? ... &start=230 to set up the shader. However, The alpha of the Logo does not change. I'm assuming that either the canvas or the shader are to blame for this. Help is appreciated.
"I don't know."
jjmafiae
Party member
Posts: 1331
Joined: Tue Jul 24, 2012 8:22 am

Re: Help with Canvases and Shaders

Post by jjmafiae »

have you tried debugging the code with print("") ?
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 9 guests