On PCs it has the desired effect. On Android devices it varies. For example, on Samsung Galaxy Note 5 the effect is much reduced. Enabling gamma-correct mode and/or high-DPI mode don't help. And my old Moto X (XT1060) did something in between: almost completely dark but not quite, as I could still make out brightly-colored objects. (It also couldn't reach 60fps, but that's a separate issue.) I don't have a screenshot at the moment.
Does anyone have an idea what's going on? What part of my shader code varies by Android device? Color format? Texel format? smoothstep?
Code: Select all
StealthMap.DarknessRadius = 480
StealthMap.DarknessShader = love.graphics.newShader([[
extern number radius;
extern vec2 center;
vec4 effect(vec4 color, Image texture, vec2 tc, vec2 sc)
{
number d = length(center - sc) / radius;
number v = smoothstep(0.0, 1.0, 1.0 - d);
return color * Texel(texture, tc) * v;
}
]])
function StealthMap:endMove()
local player = self.map.objects[
tonumber(self.map.properties.playerid)]
if player and player.body then
local x, y = player.body:getWorldCenter()
x = x - levity.camera.x
y = y - levity.camera.y
x = x * levity.camera.scale
y = y * levity.camera.scale
self.shader:send("radius",
self.DarknessRadius * levity.camera.scale)
self.shader:send("center", { x, y })
end
end
function StealthMap:beginDraw()
love.graphics.setShader(self.DarknessShader)
end
function StealthMap:endDraw()
love.graphics.setShader()
end