Open aphadeon opened 9 years ago
Tone/Tint
The "gray" value is best suited for a shader-based solution as that's a desaturation slider from 0.0 to 1.0. The type of "grayscaling" needs investigating (lightness, luminosity, average); my suspicions are that it is an ( R + G + B ) / 3.0 averaging.
in vec3 input; // Incoming colour
uniform float gray; // Greying value, 0.0 to 1.0
vec3 Greying() {
float average = ( input.r + input.g + input.b ) / 3.0;
return mix( input.rgb, vec3( average, average, average ), gray );
}
The RGB values can be done via multi-pass blending, however if shaders are going to be used for the "gray" value then it makes more sense to do this in shader-space.
in vec3 input; // Incoming colour
uniform vec4 tint; // Tinting value, RGB + Grey
out vec3 colour; // Output colour
vec3 Greying() {
float average = ( input.r + input.g + input.b ) / 3.0;
return mix( input.rgb, vec3( average, average, average ), tint.z );
}
vec3 Tinting( vec3 colour ) {
return colour + tint.rgb; // Tint is signed, clamping done in software
}
colour = Tinting( Greying() ); // Colour = tint + mix( input, greyscale, grey )
However, along with the shader solution I'd be tempted to create a second path for when the "gray" value == 0 that goes through add/subtract RGB tinting via hardware blending, rather than a shader, as there would most likely be performance gains here at the expense of an extra blend operation.
I couldn't find any information on character tinting, is this not a feature? I thought it was for some reason.
Hue
This can be done with offline texture generation or with shaders. Texture generation can get messy with memory if too many different hues are used. There would be "hitches" each time a hue is changed.
Shaders is the better option I bet and there is a stackoverflow solution that shows a GLSL solution; http://stackoverflow.com/questions/9234724/how-to-change-hue-of-a-texture-with-glsl
Almost forgot to list this one. The Color class is implemented, but it still has to be implemented for Drawable. Likewise, Tone has to be implemented for Drawable and Viewport. Hue shifting also has to be implemented for Bitmaps.