I want to create a shader that will modify the global opacity of a scene, regardless of whether textures are used.
Im not sure how to determine whether textures are present. I found a similar question here but there are no satisfying answers. For now I've settled for checking for the presence of texture coords greater than 0, but I expect this might create some artifacts in the upper left corners of things (although I haven't noticed any yet).
Here's the shader I'm using. Can this be improved? Is there some value passed in from Love that can help determine whether a texture is present? If not, would it be possible to add something like this?
I don't think you need that "if", if I recall correctly the texture should be white with full opacity (1,1,1,1) if no texture is set, so you should not encounter any issue
(Also, can't you use [wiki]love.graphics.setColor[/wiki]? Do you need a shader, maybe to change opacity a great number of times without affecting performance too much?)
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
In 0.8.0, removing the "if" (treating everything as textured) cause untextured graphic primitives not to display at all. I wonder if this has changed in a later version. I'm using 0.8.0 on my Debian laptop because the libc in the repos is behind where it needs to be for Love trunk, but I may update soon. For now I'm trying to keep my game compatible with both 0.8.0 and 0.9.x, since I'll be deploying on Android.
Nixola wrote:can't you use love.graphics.setColor?
I can't really see a clean way to do it. I'm rendering one scene within another scene (showing part of the level on the pre-level screen) as part of a scene transtion, and it kind of zooms and fades in when you start the level. So I think it really needs to be "global" opacity for that scene.
I think you can safely update to 0.9: LÖVE provides up to date .deb, .rpm and source for Linux distros and binaries for Mac and Win; also, LÖVE on Android/iOS (which is still experimental) is up to date as well, using either 0.9.1 or 0.9.2 (can't remember now, but I think it's the latter). I checked on my Windows 7 x64 machine and I can't get the primitives to draw either on 0.8.0, but it should work on the latest LÖVE version.
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
The problem is liblove wants libc6 >= 2.15, but under this version of Debian the repos have libc6 2.13. So far I'm too lazy to build libc, but I may try to build Love against 2.13. I'll test your suggestion on Android though.
You could try downloading version 2.19 from here? It's a package for a newer debian version, but it might work anyway
If you're lazy: x86_64, x86 packages
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
In 0.8.0, removing the "if" (treating everything as textured) cause untextured graphic primitives not to display at all. I wonder if this has changed in a later version.
It has – in 0.9 and newer, everything is textured (primitive shapes use a 1x1 white texture across their whole shape), so it will work as you want in that case.
Here's pixel shader code that will work (in 0.9+) for textured and untextured cases, and when SpriteBatches with per-sprite colors are used (which wouldn't work if you just used setColor with no shader.)
time thief wrote:
The problem is liblove wants libc6 >= 2.15, but under this version of Debian the repos have libc6 2.13.
The deb was built on ubuntu, so that's probably why it has that dependency, as far as I know there's nothing that would prevent you from compiling love.
slime wrote:in 0.9 and newer, everything is textured
Ahh, that's good, thanks for clearing that up.
bartbes wrote:as far as I know there's nothing that would prevent you from compiling love.
I might do that at some point (probably only if I want to make a pull request or something though). For now I'm just upgrading this laptop from Debian 7 to 8 and keeping my fingers crossed.
The .deb I got you should be from Debian 8, so you should be able to upgrade and everything should be fine; even if LÖVE doesn't update, its .deb should now work
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics