jMonkeyEngine / jMonkeyEngine/jmonkeyengine
ShaderNodes: ColorToGrey has a wrong implementation
- Dominant language
- Java
- Stars
- 4.3k
- Forks
- 1.2k
- Avg merge
- 4d 7h
- Merged PRs (30d)
- 14
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with jme3-core/src/main/resources/Common/MatDefs/ShaderNodes/Basic/colorToGrey.frag, especially lines 15-21, and review linked pull request #1572 before making changes. Compare the current conversion with the referenced luminosity shader; done means ColorToGrey produces correct luminance for both grayscale and non-grayscale RGB inputs.
Written by the indexing model from the issue text.
Assessment
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 30/100