Skip to content

Conversation

@yaRnMcDonuts
Copy link
Member

@yaRnMcDonuts yaRnMcDonuts commented Dec 19, 2020

I added a small amount of code to the Unshaded.j3md and Unshaded.frag files to allow for desaturating the material's output color based on a float value, specifically for use in GUIs.

Nearly all our GUI libraries use the Unshaded matdef for elements that are attached to the GUI node, and any custom gui elements will typically start from extending Unshaded if they need to do something in the shader, so adding this to Unshaded would alow all of our existent gui libraries to have desaturation functionality.
This should also not break any existing code, as nothing happens with this code unless the float value for desaturation gets defined for the material.

Following up on this thread https://hub.jmonkeyengine.org/t/how-to-desaturate-gui-element/43963

added a few lines of code for desaturating final color output based on a float value
added float variable "DesaturationValue" and corresponding define "DESATURATION" to support desaturation of the final output color in Unshaded.frag
fixed alpha value that was previously being set to 0.0 by mistake
added ifdef around variable declaration
@riccardobl
Copy link
Member

riccardobl commented Dec 20, 2020

Instead of hard coding gray, i would prefer this to take the color from the material params

Actually, I was missing the point here. I read the code again, this can be merged.

@stephengold stephengold merged commit 9b40114 into jMonkeyEngine:master Dec 21, 2020
@stephengold stephengold added this to the Future Release milestone Dec 21, 2020
@stephengold stephengold modified the milestones: Future Release, v3.4.0 Feb 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants