diff --git a/jme3-core/src/main/resources/Common/MatDefs/Misc/Unshaded.frag b/jme3-core/src/main/resources/Common/MatDefs/Misc/Unshaded.frag index e615d8f1e3..0846d22df8 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Misc/Unshaded.frag +++ b/jme3-core/src/main/resources/Common/MatDefs/Misc/Unshaded.frag @@ -12,6 +12,10 @@ uniform vec4 m_Color; uniform sampler2D m_ColorMap; uniform sampler2D m_LightMap; +#ifdef DESATURATION + uniform float m_DesaturationValue; +#endif + varying vec2 texCoord1; varying vec2 texCoord2; @@ -45,6 +49,11 @@ void main(){ discard; } #endif + + #ifdef DESATURATION + vec3 gray = vec3(dot(vec3(0.2126,0.7152,0.0722), color.rgb)); + color.rgb = vec3(mix(color.rgb, gray, m_DesaturationValue)); + #endif gl_FragColor = color; -} \ No newline at end of file +} diff --git a/jme3-core/src/main/resources/Common/MatDefs/Misc/Unshaded.j3md b/jme3-core/src/main/resources/Common/MatDefs/Misc/Unshaded.j3md index 30e626f022..07f72d771c 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Misc/Unshaded.j3md +++ b/jme3-core/src/main/resources/Common/MatDefs/Misc/Unshaded.j3md @@ -59,6 +59,9 @@ MaterialDef Unshaded { Float ShadowMapSize Boolean BackfaceShadows: true + + // 1.0 indicates 100% desaturation + Float DesaturationValue } Technique { @@ -82,7 +85,8 @@ MaterialDef Unshaded { NUM_BONES : NumberOfBones DISCARD_ALPHA : AlphaDiscardThreshold NUM_MORPH_TARGETS: NumberOfMorphTargets - NUM_TARGETS_BUFFERS: NumberOfTargetsBuffers + NUM_TARGETS_BUFFERS: NumberOfTargetsBuffers + DESATURATION : DesaturationValue } }