LÖVE 11.0 released!

General discussion about LÖVE, Lua, game development, puns, and unicorns.
User avatar
SiENcE
Party member
Posts: 792
Joined: Thu Jul 24, 2008 2:25 pm
Location: Berlin/Germany
Contact:

Re: LÖVE 11.0 released!

Post by SiENcE »

zorg wrote: Mon Apr 09, 2018 3:58 pmPaused at the very beginning == Stopped then, basically
Sure, but how do i know if a source was stopped or paused? Or do I have to remember that now? Before i had only to ask the source.
User avatar
zorg
Party member
Posts: 3436
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: LÖVE 11.0 released!

Post by zorg »

SiENcE wrote: Mon Apr 09, 2018 8:48 pm
zorg wrote: Mon Apr 09, 2018 3:58 pmPaused at the very beginning == Stopped then, basically
Sure, but how do i know if a source was stopped or paused? Or do I have to remember that now? Before i had only to ask the source.
The point is that when playback is suspended at the very beginning, the paused and stopped "states" are basically equivalent. pause is always halt playback, stop is always halt playback and rewind, and rewind is always seek(0).
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Iori Branford
Prole
Posts: 36
Joined: Wed Apr 13, 2016 3:53 pm

Re: LÖVE 11.0 released!

Post by Iori Branford »

So I found an answer on color clamping.
https://bitbucket.org/rude/love/issues/ ... error-if-a

Indeed the behavior my project relies on was against spec, and in 11.0 requires a pixel shader (or one of the floating point pixel formats but no idea how widely supported they are).
User avatar
shru
Prole
Posts: 26
Joined: Mon Sep 28, 2015 3:56 am
Location: Hyperborea
Contact:

Re: LÖVE 11.0 released!

Post by shru »

Iori Branford wrote: Mon Apr 09, 2018 9:58 pm Indeed the behavior my project relies on was against spec, and in 11.0 requires a pixel shader (or one of the floating point pixel formats but no idea how widely supported they are).
I was also able to recreate the effect by drawing a given sprite additional time(s) after calling `love.graphics.setBlendMode('add')`. I don't know a lot about shaders or alternate pixel formats, so I don't have any conception of whether this is more or less computationally expensive than either of those approaches.
itchtwittergithub
User avatar
pgimeno
Party member
Posts: 3544
Joined: Sun Oct 18, 2015 2:58 pm

Re: LÖVE 11.0 released!

Post by pgimeno »

shru wrote: Tue Apr 10, 2018 7:18 am I was also able to recreate the effect by drawing a given sprite additional time(s) after calling `love.graphics.setBlendMode('add')`. I don't know a lot about shaders or alternate pixel formats, so I don't have any conception of whether this is more or less computationally expensive than either of those approaches.
Shaders are running all the time, therefore using a shader should be computationally cheaper than drawing the sprite multiple times.

This is an approach you can try:

Code: Select all

local shader = love.graphics.newShader[[
  // Based on the default shader code at https://love2d.org/wiki/love.graphics.newShader
  extern number colour[4];
  vec4 effect(vec4 ignored, Image texture, vec2 texture_coords, vec2 screen_coords)
  {
    vec4 texturecolor = Texel(texture, texture_coords);
    return texturecolor * (vec4(colour[0], colour[1], colour[2], colour[3])*(1.0/255.0));
  }
]]
love.graphics.setShader(shader)

function mySetColour(r, g, b, a) -- in this example it's global; you may want to put it inside a module or object.
  if g == nil then assert(type(r) == "table"); g = r[2]; b = r[3]; a = r[4]; r = r[1] end
  if a == nil then a = 255 end
  assert(type(r) == "number" and type(g) == "number" and type(b) == "number" and type(a) == "number")
  shader:send('colour', r, g, b, a)
end

-- example usage:

local img = love.graphics.newImage('image1.jpg')

function love.draw()
  mySetColour(511, 255, 255) -- draw redder than normal
  love.graphics.draw(img)
end
If you want 0-1 range, remove the *(1.0/255.0) part from the shader and change a = 255 to a = 1 in mySetColour.
User avatar
pixelicidio
Prole
Posts: 5
Joined: Sat Mar 17, 2018 2:47 pm
Contact:

Re: LÖVE 11.0 released!

Post by pixelicidio »

For the new COLOR FROMAT change the fun thing about lua is that you can replece the setColor function for the whole project only once like this:

Code: Select all

--love version >11 fix colors
if api.getVersion() >=  11 then
  local oldSetColor = love.graphics.setColor
  love.graphics.setColor = function (r, g, b, a)     
    if type(r)=="table" then
        g = r[2] / 255
        b = r[3] / 255
        a = (r[4] or 255) / 255
        r = r[1] / 255
    else
      r = r / 255
      g = g / 255
      b = b / 255
      a = (a or 255) / 255
    end
    oldSetColor(r,g,b,a)
  end
end
Then do the same for other functions involving colors.
User avatar
shru
Prole
Posts: 26
Joined: Mon Sep 28, 2015 3:56 am
Location: Hyperborea
Contact:

Re: LÖVE 11.0 released!

Post by shru »

pgimeno wrote: Tue Apr 10, 2018 2:33 pm Shaders are running all the time, therefore using a shader should be computationally cheaper than drawing the sprite multiple times.

This is an approach you can try:

-- snip --
Just wanted to take the time to thank you for the example code.
itchtwittergithub
User avatar
D0NM
Party member
Posts: 250
Joined: Mon Feb 08, 2016 10:35 am
Location: Zabuyaki
Contact:

Re: LÖVE 11.0 released!

Post by D0NM »

Thank you, pixelicidio!

You just have to think about something like that... and it is ready ))
Our LÖVE Gamedev blog Zabuyaki (an open source retro beat 'em up game). Twitter: @Zabuyaki.
:joker: LÖVE & Lua Video Lessons in Russian / Видео уроки по LÖVE и Lua :joker:
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: LÖVE 11.0 released!

Post by raidho36 »

Note that this function is just a compatibility layer to spare you the work. You probably want to properly convert your setColor functions some time in the future.
User avatar
pgimeno
Party member
Posts: 3544
Joined: Sun Oct 18, 2015 2:58 pm

Re: LÖVE 11.0 released!

Post by pgimeno »

Also don't forget getColor.
Post Reply

Who is online

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