Skip to content

ShaderNodes: ColorToGrey has a wrong implementation #1284

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

Open
MeFisto94 opened this issue Feb 8, 2020 · 1 comment · May be fixed by #1572
Open

ShaderNodes: ColorToGrey has a wrong implementation #1284

MeFisto94 opened this issue Feb 8, 2020 · 1 comment · May be fixed by #1572
Labels
bug Something that is supposed to work, but doesn't. More severe than a "defect".

Comments

@MeFisto94
Copy link
Member

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 take r, 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.

@MeFisto94 MeFisto94 added the bug Something that is supposed to work, but doesn't. More severe than a "defect". label Feb 8, 2020
@stephengold
Copy link
Member

Sounds reasonable.

This was referenced Jun 10, 2021
@stephengold stephengold added this to the Future Release milestone Oct 24, 2021
@stephengold stephengold linked a pull request Oct 24, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that is supposed to work, but doesn't. More severe than a "defect".
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants