Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(love 11.0) Use normalized colors; fix broken sketch and filmgrain #58

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ moonshine.effects.desaturate

Name | Type | Default
-----|------|--------
tint | color / table of numbers | {255,255,255}
tint | color / table of numbers | {1,1,1}
strength | number between 0 and 1 | 0.5


Expand All @@ -312,7 +312,7 @@ DMG ships with 7 palettes:
7. `pocket`

Custom palettes must be in the format `{{R,G,B}, {R,G,B}, {R,G,B}, {R,G,B}}`,
where `R`, `G`, and `B` are numbers between `0` and `255`.
where `R`, `G`, and `B` are numbers between `0` and `1`.


<a name="effect-fastgaussianblur"></a>
Expand Down
9 changes: 5 additions & 4 deletions desaturate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ return function(moonshine)

setters.tint = function(c)
assert(type(c) == "table" and #c == 3, "Invalid value for `tint'")
assert(c[1] <= 1, "Colors should be normalized in [0,1]")
shader:send("tint", {
(tonumber(c[1]) or 0) / 255,
(tonumber(c[2]) or 0) / 255,
(tonumber(c[3]) or 0) / 255,
(tonumber(c[1]) or 0),
(tonumber(c[2]) or 0),
(tonumber(c[3]) or 0),
1
})
end
Expand All @@ -41,7 +42,7 @@ return function(moonshine)
shader:send("strength", math.max(0, math.min(1, tonumber(v) or 0)))
end

local defaults = {tint = {255,255,255}, strength = 0.5}
local defaults = {tint = {1,1,1}, strength = 0.5}

return moonshine.Effect{
name = "desaturate",
Expand Down
2 changes: 1 addition & 1 deletion filmgrain.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ PERFORMANCE OF THIS SOFTWARE.
return function(moonshine)
local noisetex = love.image.newImageData(256,256)
noisetex:mapPixel(function()
local l = love.math.random() * 255
local l = love.math.random()
return l,l,l,l
end)
noisetex = love.graphics.newImage(noisetex)
Expand Down
7 changes: 4 additions & 3 deletions scanlines.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,11 @@ return function(moonshine)
end
setters.color = function(c)
assert(type(c) == "table" and #c == 3, "Invalid value for `color'")
assert(c[1] <= 1, "Colors should be normalized in [0,1]")
shader:send("color", {
(tonumber(c[1]) or defaults.color[0]) / 255,
(tonumber(c[2]) or defaults.color[1]) / 255,
(tonumber(c[3]) or defaults.color[2]) / 255
(tonumber(c[1]) or defaults.color[1]),
(tonumber(c[2]) or defaults.color[2]),
(tonumber(c[3]) or defaults.color[3])
})
end

Expand Down
2 changes: 1 addition & 1 deletion sketch.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ SOFTWARE.
return function(moonshine)
local noisetex = love.image.newImageData(256,256)
noisetex:mapPixel(function()
return love.math.random() * 255,love.math.random() * 255, 0, 0
return love.math.random(),love.math.random(), 0, 0
end)
noisetex = love.graphics.newImage(noisetex)
noisetex:setWrap ("repeat", "repeat")
Expand Down
7 changes: 4 additions & 3 deletions vignette.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ return function(moonshine)
end
setters.color = function(c)
assert(type(c) == "table" and #c == 3, "Invalid value for `color'")
assert(c[1] <= 1, "Colors should be normalized in [0,1]")
shader:send("color", {
(tonumber(c[1]) or 0) / 255,
(tonumber(c[2]) or 0) / 255,
(tonumber(c[3]) or 0) / 255,
(tonumber(c[1]) or 0),
(tonumber(c[2]) or 0),
(tonumber(c[3]) or 0),
1
})
end
Expand Down