LÖVE 11.0 released!

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

Re: LÖVE 11.0 released!

Post by SiENcE » Mon Apr 09, 2018 8:48 pm

zorg wrote:
Mon Apr 09, 2018 3:58 pm
Paused 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: 2379
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: LÖVE 11.0 released!

Post by zorg » Mon Apr 09, 2018 9:07 pm

SiENcE wrote:
Mon Apr 09, 2018 8:48 pm
zorg wrote:
Mon Apr 09, 2018 3:58 pm
Paused 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: 26
Joined: Wed Apr 13, 2016 3:53 pm

Re: LÖVE 11.0 released!

Post by Iori Branford » Mon Apr 09, 2018 9:58 pm

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: 20
Joined: Mon Sep 28, 2015 3:56 am
Location: Hyperborea
Contact:

Re: LÖVE 11.0 released!

Post by shru » Tue Apr 10, 2018 7:18 am

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: 1267
Joined: Sun Oct 18, 2015 2:58 pm

Re: LÖVE 11.0 released!

Post by pgimeno » Tue Apr 10, 2018 2:33 pm

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.
Thrust II Reloaded - GifLoad for Löve - GSpöt GUI - My NotABug.org repositories
The Microsoft Github repositories I had have been closed after the acquisition announcement and will be removed in the near future.

User avatar
pixelicidio
Prole
Posts: 5
Joined: Sat Mar 17, 2018 2:47 pm
Contact:

Re: LÖVE 11.0 released!

Post by pixelicidio » Wed Apr 11, 2018 5:02 pm

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: 20
Joined: Mon Sep 28, 2015 3:56 am
Location: Hyperborea
Contact:

Re: LÖVE 11.0 released!

Post by shru » Wed Apr 11, 2018 10:46 pm

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: 194
Joined: Mon Feb 08, 2016 10:35 am
Location: Zabuyaki
Contact:

Re: LÖVE 11.0 released!

Post by D0NM » Thu Apr 12, 2018 6:10 am

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). Follow @Zabuyaki.
Twitter @FaMeSoft / GP32 Free Platformer: SUPER PLUSHA
:joker: LÖVE & Lua Video Lessons in Russian / Видео уроки по LÖVE и Lua :joker:

User avatar
raidho36
Party member
Posts: 1685
Joined: Mon Jun 17, 2013 12:00 pm

Re: LÖVE 11.0 released!

Post by raidho36 » Thu Apr 12, 2018 8:51 am

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: 1267
Joined: Sun Oct 18, 2015 2:58 pm

Re: LÖVE 11.0 released!

Post by pgimeno » Thu Apr 12, 2018 10:59 am

Also don't forget getColor.
Thrust II Reloaded - GifLoad for Löve - GSpöt GUI - My NotABug.org repositories
The Microsoft Github repositories I had have been closed after the acquisition announcement and will be removed in the near future.

Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests