mortie / swaylock-effects

Swaylock, with fancy effects
MIT License
713 stars 46 forks source link

Add a vignette effect #6

Closed asmigala closed 5 years ago

asmigala commented 5 years ago

Adds a simple vignette effect (darkens the borders of the image).

There are two parameters, base and factor, both are in the range 0-1, base specifies how dark is the darkest part of the image and factor specifies how much brighter is the brightest part, so e.g. 0.2:0.6 will cause the borders to be 0.2 times darker than the original image, while the center will be 0.8 times darker.

Not sure about the names of the parameters.

Can also be used as a simple darken effect if the factor is specified as 0.

mortie commented 5 years ago

This is pretty neat. However, there's a couple things I'd like to change:

I mean, being able to produce images like this by choosing unintended values is really cool, but maybe not the intended use of this effect: fancy small

asmigala commented 5 years ago

Sorry about the spaces, will fix.

When it comes to the normalization, the effect you shown is really not intended, but not sure how to fix it a usable way - your suggestion would give the same result for 0.1:0.2 and 0.2:0.4, which are very different as it's currently implemented.

Would you be ok with simply clamping the resulting vignette_factor to a value between 0 and 1? We could also clamp each of the parameters separately, e.g. make sure base is in the 0..1 range and factor is in (1-base)..1 range. That would probably give a nicer result (no hard edges).

mortie commented 5 years ago

I see what you mean. Yeah, just clamping base to 0..1 and factor to (1-base)..1 is probably the best solution, both for the visual reasons you cite and because it wouldn't slow down the tight inner loop.