You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It should extract the luminance of a color (or in other words: convert RGB to Greyscale).
I think the way it has been done only works when r == g == b and then dividing by 3 again (because currently grey can be everything between 0 and 3. So it would only work when only one channel is used).
Also, when r == g == b and we'd do (r + g+ b) / 3, we could also take r, as simple as that.
So we are talking about this:
https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-core/src/main/resources/Common/MatDefs/ShaderNodes/Basic/colorToGrey.frag
It should extract the luminance of a color (or in other words: convert RGB to Greyscale).
I think the way it has been done only works when r == g == b and then dividing by 3 again (because currently grey can be everything between 0 and 3. So it would only work when only one channel is used).
Also, when r == g == b and we'd do
(r + g+ b) / 3
, we could also taker
, as simple as that.So: For images already being Greyscale in RGB, we can just take one component.
For Images not being Greyscale, we need a more complicated code like https://github.com/flixel-gdx/flixel-gdx/blob/master/flixel-core/src/org/flixel/data/shaders/blend/luminosity.glsl
Luminance is only Lines 15-21 and we can add a proper RGB->HSL conversion as well.
The license is BSD.
Tagging @neph1 as he contributed the initial ColorToGrey implementation.
The text was updated successfully, but these errors were encountered: